[parisc-linux-cvs] Large file work

Matthew Wilcox willy@ldl.fc.hp.com
Thu, 29 Mar 2001 15:00:52 -0700


This patch will probably make glibc work for files >2GB.  I don't have
time to recompile glibc against these headers though, so I'm just going
to post this patch to the list.  If anyone's brave, they need to copy
the new <asm/unistd.h> to somewhere where glibc will pick it up (either
with --with-headers= or by copying it to /usr/include/asm/unistd.h
before booting.)

Index: arch/parisc/kernel/sys_parisc32.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/sys_parisc32.c,v
retrieving revision 1.3
diff -u -p -r1.3 sys_parisc32.c
--- sys_parisc32.c	2001/03/25 23:29:35	1.3
+++ sys_parisc32.c	2001/03/29 21:41:33
@@ -1,8 +1,9 @@
 /*
  * sys_parisc32.c: Conversion between 32bit and 64bit native syscalls.
  *
- * Copyright (C) 2000 Hewlett Packard Company
+ * Copyright (C) 2000-2001 Hewlett Packard Company
  * Copyright (C) 2000 John Marvin
+ * Copyright (C) 2001 Matthew Wilcox
  *
  * These routines maintain argument size conversion between 32bit and 64bit
  * environment. Based heavily on sys_ia32.c and sys_sparc32.c.
@@ -2695,4 +2696,34 @@ asmlinkage long sys32_shmctl(int shmid, 
 	}
 
 	return err;
+}
+
+/* LFS */
+
+asmlinkage long sys32_truncate64(const char * path, unsigned int high, unsigned int low)
+{
+	return sys_truncate(path, (loff_t)high << 32 | low);
+}
+
+asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned int high, unsigned int low)
+{
+	return sys_ftruncate(fd, (loff_t)high << 32 | low);
+}
+
+asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+		case F_GETLK64:
+			cmd = F_GETLK;
+			break;
+		case F_SETLK64:
+			cmd = F_SETLK;
+			break;
+		case F_SETLKW64:
+			cmd = F_SETLKW;
+			break;
+		default:
+			break;
+	}
+	sys_fcntl(fd, cmd, arg);
 }
Index: arch/parisc/kernel/syscall.S
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/syscall.S,v
retrieving revision 1.59
diff -u -p -r1.59 syscall.S
--- syscall.S	2001/03/05 03:20:40	1.59
+++ syscall.S	2001/03/29 21:41:33
@@ -430,7 +430,7 @@ sys_call_table:
 	ENTRY_SAME(recv)
 	ENTRY_DIFF(statfs)
 	ENTRY_DIFF(fstatfs)		/* 100 */
-	ENTRY_SAME(ni_syscall)
+	ENTRY_SAME(stat64)
 	/* don't think hppa glibc even provides an entry pt for this
 	 * so disable for now */
 	ENTRY_UHOH(socketcall)
@@ -445,7 +445,7 @@ sys_call_table:
 	ENTRY_SAME(pwrite)
 	ENTRY_SAME(getcwd)		/* 110 */
 	ENTRY_SAME(vhangup)
-	ENTRY_SAME(ni_syscall)
+	ENTRY_SAME(fstat64)
 	ENTRY_SAME(vfork_wrapper)
 	/* struct rusage contains longs... */
 	ENTRY_DIFF(wait4)
@@ -552,10 +552,14 @@ sys_call_table:
 	ENTRY_SAME(shmat_wrapper)
 	ENTRY_SAME(shmdt)
 	ENTRY_SAME(shmget)
-	/***************/
 	ENTRY_DIFF(shmctl)		/* 195 */
 	ENTRY_SAME(ni_syscall)		/* streams1 */
 	ENTRY_SAME(ni_syscall)		/* streams2 */
+	ENTRY_SAME(lstat64)
+	ENTRY_DIFF(truncate64)
+	ENTRY_DIFF(ftruncate64)	/* 200 */
+	ENTRY_SAME(getdents64)
+	ENTRY_DIFF(fcntl64)
 
 .end
 
Index: fs/open.c
===================================================================
RCS file: /home/cvs/parisc/linux/fs/open.c,v
retrieving revision 1.6
diff -u -p -r1.6 open.c
--- open.c	2000/11/10 21:43:50	1.6
+++ open.c	2001/03/29 21:41:33
@@ -186,6 +186,27 @@ asmlinkage long sys_ftruncate(unsigned i
 
 /* LFS versions of truncate are only needed on 32 bit machines */
 #if BITS_PER_LONG == 32
+#ifdef __hppa__
+/*
+ * The fuckwits who did this assumed they knew the ABI on every single
+ * 32-bit processor supported by Linux.  Surprisingly THEY WERE WRONG.
+ * Never Never Never Never prototype a syscall to take a `long long' as an
+ * argument, because You Will Lose.  And it's too late to fix it, because
+ * the glibc morons are using this stupid macro which passes either the
+ * high or low half of the word first, depending on your endianness.
+ * So the simple obvious C below cannot be used on other architectures.
+ * Bunch of fucking losers.
+ */
+asmlinkage long sys_truncate64(const char * path, unsigned int high, unsigned int low)
+{
+	return do_sys_truncate(path, (loff_t)high << 32 | low);
+}
+
+asmlinkage long sys_ftruncate64(unsigned int fd, unsigned int high, unsigned int low)
+{
+	return do_sys_ftruncate(fd, (loff_t)high << 32 | low);
+}
+#else
 asmlinkage long sys_truncate64(const char * path, loff_t length)
 {
 	return do_sys_truncate(path, length);
@@ -195,6 +216,7 @@ asmlinkage long sys_ftruncate64(unsigned
 {
 	return do_sys_ftruncate(fd, length);
 }
+#endif
 #endif
 
 #if !(defined(__alpha__) || defined(__ia64__))
Index: include/asm-parisc/unistd.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/asm-parisc/unistd.h,v
retrieving revision 1.20
diff -u -p -r1.20 unistd.h
--- unistd.h	2001/03/07 18:12:47	1.20
+++ unistd.h	2001/03/29 21:41:34
@@ -576,7 +576,7 @@
 #define __NR_symlink             (__NR_Linux + 83)
 #define __NR_lstat               (__NR_Linux + 84)
 #define __NR_readlink            (__NR_Linux + 85)
-#define __NR_uselib              (__NR_Linux + 86)
+/* #define __NR_uselib              (__NR_Linux + 86) */
 #define __NR_swapon              (__NR_Linux + 87)
 #define __NR_reboot              (__NR_Linux + 88)
 #define __NR_mmap2             (__NR_Linux + 89)
@@ -591,8 +591,8 @@
 #define __NR_recv                (__NR_Linux + 98)
 #define __NR_statfs              (__NR_Linux + 99)
 #define __NR_fstatfs            (__NR_Linux + 100)
-/* #define __NR_ioperm             (__NR_Linux + 101) */
-#define __NR_socketcall         (__NR_Linux + 102)
+#define __NR_stat64           (__NR_Linux + 101)
+/* #define __NR_socketcall         (__NR_Linux + 102) */
 #define __NR_syslog             (__NR_Linux + 103)
 #define __NR_setitimer          (__NR_Linux + 104)
 #define __NR_getitimer          (__NR_Linux + 105)
@@ -602,7 +602,7 @@
 #define __NR_pwrite             (__NR_Linux + 109)
 #define __NR_getcwd             (__NR_Linux + 110)
 #define __NR_vhangup            (__NR_Linux + 111)
-/* #define __NR_idle               (__NR_Linux + 112) */
+#define __NR_fstat64            (__NR_Linux + 112)
 #define __NR_vfork              (__NR_Linux + 113)
 #define __NR_wait4              (__NR_Linux + 114)
 #define __NR_swapoff            (__NR_Linux + 115)
@@ -690,7 +690,13 @@
 #define __NR_getpmsg            (__NR_Linux + 196)      /* some people actually want streams */
 #define __NR_putpmsg            (__NR_Linux + 197)      /* some people actually want streams */
 
-#define __NR_Linux_syscalls     197
+#define __NR_lstat64            (__NR_Linux + 198)
+#define __NR_truncate64            (__NR_Linux + 199)
+#define __NR_ftruncate64            (__NR_Linux + 200)
+#define __NR_getdents64            (__NR_Linux + 201)
+#define __NR_fcntl64            (__NR_Linux + 202)
+
+#define __NR_Linux_syscalls     202
 
 #define HPUX_GATEWAY_ADDR       0xC0000004
 #define LINUX_GATEWAY_ADDR      0x100