diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-08-12 01:30:55 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-08-12 01:30:55 +0000 |
commit | 4122764ace9a7548677a28ae921a592727a6345a (patch) | |
tree | be6cb50fb0f46a052166e1ee051a63bdcf2998d1 | |
parent | ad6cb3fea7ce96aec76b3d147a43fb330a7ccf93 (diff) | |
download | klibc-4122764ace9a7548677a28ae921a592727a6345a.tar.gz |
Add llseek() support -- needed to support things like partition scanning.klibc-0.19
-rw-r--r-- | include/unistd.h | 1 | ||||
-rw-r--r-- | klibc/Makefile | 6 | ||||
-rw-r--r-- | klibc/include/unistd.h | 1 | ||||
-rw-r--r-- | klibc/llseek.c | 34 | ||||
-rw-r--r-- | llseek.c | 34 |
5 files changed, 73 insertions, 3 deletions
diff --git a/include/unistd.h b/include/unistd.h index 5b05213431feb..37f3ab288990e 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -74,6 +74,7 @@ __extern int open(const char *, int, ...); #endif __extern int close(int); __extern off_t lseek(int, off_t, int); +__extern loff_t llseek(int, loff_t, int); __extern int dup(int); __extern int dup2(int, int); __extern int fcntl(int, int, long); diff --git a/klibc/Makefile b/klibc/Makefile index bdaa58312da3a..3ec4ad25f167f 100644 --- a/klibc/Makefile +++ b/klibc/Makefile @@ -1,10 +1,10 @@ -ARCH = alpha +ARCH = i386 CROSS = CC = $(CROSS)gcc LD = $(CROSS)ld REQFLAGS = -nostdinc -iwithprefix include -I. \ -I./arch/$(ARCH)/include -I./include/bits$(BITSIZE) \ - -I./include -I./linux/include \ + -DBITSIZE=$(BITSIZE) -I./include -I./linux/include \ -Wall CFLAGS = $(OPTFLAGS) $(REQFLAGS) LDFLAGS = @@ -34,7 +34,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ strncmp.o strncpy.o strrchr.o strspn.o strsep.o strtok.o \ gethostname.o getdomainname.o getcwd.o seteuid.o setegid.o \ getenv.o setenv.o unsetenv.o getopt.o readdir.o \ - time.o fdatasync.o + time.o fdatasync.o llseek.o LIB = libc.a SOFLAGS = -fPIC diff --git a/klibc/include/unistd.h b/klibc/include/unistd.h index 5b05213431feb..37f3ab288990e 100644 --- a/klibc/include/unistd.h +++ b/klibc/include/unistd.h @@ -74,6 +74,7 @@ __extern int open(const char *, int, ...); #endif __extern int close(int); __extern off_t lseek(int, off_t, int); +__extern loff_t llseek(int, loff_t, int); __extern int dup(int); __extern int dup2(int, int); __extern int fcntl(int, int, long); diff --git a/klibc/llseek.c b/klibc/llseek.c new file mode 100644 index 0000000000000..fdffc16e2ce27 --- /dev/null +++ b/klibc/llseek.c @@ -0,0 +1,34 @@ +/* + * llseek.c + * + * On 32-bit platforms, we need llseek() as well as lseek() to be + * able to handle large disks + */ + +#include <unistd.h> +#include <sys/syscall.h> + +#if BITSIZE == 32 + +static inline _syscall5(int, _llseek, int, fd, unsigned long, hi, unsigned long, lo, loff_t *,res, int, whence); + +loff_t llseek(int fd, loff_t offset, int whence) +{ + loff_t result; + int rv; + + rv = _llseek(fd, (unsigned long)(offset >> 32), + (unsigned long)offset, &result, whence); + + return rv ? (loff_t)-1 : result; +} + +#else + +loff_t llseek(int fd, loff_t offset, int whence) +{ + return lseek(fd, offset, whence); +} + +#endif + diff --git a/llseek.c b/llseek.c new file mode 100644 index 0000000000000..fdffc16e2ce27 --- /dev/null +++ b/llseek.c @@ -0,0 +1,34 @@ +/* + * llseek.c + * + * On 32-bit platforms, we need llseek() as well as lseek() to be + * able to handle large disks + */ + +#include <unistd.h> +#include <sys/syscall.h> + +#if BITSIZE == 32 + +static inline _syscall5(int, _llseek, int, fd, unsigned long, hi, unsigned long, lo, loff_t *,res, int, whence); + +loff_t llseek(int fd, loff_t offset, int whence) +{ + loff_t result; + int rv; + + rv = _llseek(fd, (unsigned long)(offset >> 32), + (unsigned long)offset, &result, whence); + + return rv ? (loff_t)-1 : result; +} + +#else + +loff_t llseek(int fd, loff_t offset, int whence) +{ + return lseek(fd, offset, whence); +} + +#endif + |