Add llseek() support -- needed to support things like partition scanning.
diff --git a/include/unistd.h b/include/unistd.h
index 5b05213..37f3ab2 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -74,6 +74,7 @@
#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 bdaa583..3ec4ad2 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 @@
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 5b05213..37f3ab2 100644
--- a/klibc/include/unistd.h
+++ b/klibc/include/unistd.h
@@ -74,6 +74,7 @@
#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 0000000..fdffc16
--- /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 0000000..fdffc16
--- /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
+