[parisc-linux-cvs] more long long fun

Matthew Wilcox matthew@wil.cx
Wed, 11 Apr 2001 16:40:25 +0100


 * Include prototypes for sys_truncate, sys_ftruncate & sys_fcntl
   for 32-bit emulation (removes warnings)
 * Fix pread/pwrite

Index: arch/parisc/kernel/sys_parisc32.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/sys_parisc32.c,v
retrieving revision 1.4
diff -u -p -r1.4 sys_parisc32.c
--- sys_parisc32.c	2001/04/10 20:05:24	1.4
+++ sys_parisc32.c	2001/04/11 15:16:00
@@ -2700,6 +2700,12 @@ asmlinkage long sys32_shmctl(int shmid, 
 
 /* LFS */
 
+extern asmlinkage long sys_truncate(const char *, loff_t);
+extern asmlinkage long sys_ftruncate(const char *, loff_t);
+extern asmlinkage long sys_fcntl(unsigned int, unsigned int, unsigned long);
+extern asmlinkage ssize_t sys_pread(unsigned int, char *, size_t, loff_t);
+extern asmlinkage ssize_t sys_pwrite(unsigned int, char *, size_t, loff_t);
+
 asmlinkage long sys32_truncate64(const char * path, unsigned int high, unsigned int low)
 {
 	return sys_truncate(path, (loff_t)high << 32 | low);
@@ -2725,5 +2731,17 @@ asmlinkage long sys32_fcntl64(unsigned i
 		default:
 			break;
 	}
-	sys_fcntl(fd, cmd, arg);
+	return sys_fcntl(fd, cmd, arg);
 }
+
+asmlinkage int sys32_pread(int fd, void *buf, size_t count, unsigned int high, unsigned int low)
+{
+	return sys_pread(fd, buf, count, (loff_t)high << 32 | low);
+}
+
+asmlinkage int sys32_pwrite(int fd, void *buf, size_t count, unsigned int high, unsigned int low)
+{
+       return sys_pwrite(fd, buf, count, (loff_t)high << 32 | low);
+}
+
+
Index: fs/read_write.c
===================================================================
RCS file: /home/cvs/parisc/linux/fs/read_write.c,v
retrieving revision 1.6
diff -u -p -r1.6 read_write.c
--- read_write.c	2000/11/10 21:43:50	1.6
+++ read_write.c	2001/04/11 15:16:07
@@ -315,8 +315,8 @@ bad_file:
    lseek back to original location.  They fail just like lseek does on
    non-seekable files.  */
 
-asmlinkage ssize_t sys_pread(unsigned int fd, char * buf,
-			     size_t count, loff_t pos)
+static inline
+ssize_t do_pread(unsigned int fd, char * buf, size_t count, loff_t pos)
 {
 	ssize_t ret;
 	struct file * file;
@@ -346,8 +346,8 @@ bad_file:
 	return ret;
 }
 
-asmlinkage ssize_t sys_pwrite(unsigned int fd, const char * buf,
-			      size_t count, loff_t pos)
+static inline
+ssize_t do_pwrite(unsigned int fd, const char * buf, size_t count, loff_t pos)
 {
 	ssize_t ret;
 	struct file * file;
@@ -377,3 +377,35 @@ out:
 bad_file:
 	return ret;
 }
+
+#if BITS_PER_LONG == 32
+#ifdef __BIG_ENDIAN
+#define LOFF_T(high, low) unsigned int high, unsigned int low
+#else
+#define LOFF_T(high, low) unsigned int low, unsigned int high
+#endif
+
+asmlinkage
+ssize_t sys_pread(unsigned int fd, char *buf, size_t count, LOFF_T(high, low))
+{
+	return do_pread(fd, buf, count, (loff_t)high << 32 | low);
+}
+
+ssize_t sys_pwrite(unsigned int fd, char *buf, size_t count, LOFF_T(high, low))
+{
+	return do_pwrite(fd, buf, count, (loff_t)high << 32 | low);
+}
+
+
+#else /* BITS_PER_LONG != 32 */
+asmlinkage
+ssize_t sys_pread(unsigned int fd, char *buf, size_t count, loff_t pos)
+{
+	return do_pread(fd, buf, count, pos);
+}
+
+ssize_t sys_pwrite(unsigned int fd, char *buf, size_t count, loff_t pos)
+{
+	return do_pwrite(fd, buf, count, pos);
+}
+#endif

-- 
Revolutions do not require corporate support.