[parisc-linux-cvs] linux-2.5 tausq

Randolph Chung Randolph Chung <randolph@tausq.org>
Mon, 14 Jul 2003 22:42:23 -0700


> port compat syscalls for readahead and sendfile over to 2.5; fix some
> compile problems

since i can't link the kernel on 64-bit, this hasn't really been tested.
please review:

Index: arch/parisc/kernel/sys_parisc.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/parisc/kernel/sys_parisc.c,v
retrieving revision 1.11
diff -u -p -r1.11 sys_parisc.c
--- arch/parisc/kernel/sys_parisc.c	18 Mar 2003 08:15:27 -0000	1.11
+++ arch/parisc/kernel/sys_parisc.c	15 Jul 2003 05:34:21 -0000
@@ -185,6 +185,7 @@ extern asmlinkage ssize_t sys_pread64(un
 					size_t count, loff_t pos);
 extern asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char *buf,
 					size_t count, loff_t pos);
+extern asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count);
 
 asmlinkage ssize_t parisc_pread64(unsigned int fd, char *buf, size_t count,
 					unsigned int high, unsigned int low)
@@ -198,6 +199,11 @@ asmlinkage ssize_t parisc_pwrite64(unsig
 	return sys_pwrite64(fd, buf, count, (loff_t)high << 32 | low);
 }
 
+asmlinkage ssize_t parisc_readahead(int fd, unsigned int high, unsigned int low,
+		                    size_t count)
+{
+	return sys_readahead(fd, (loff_t)high << 32 | low, count);
+}
 
 /*
  * FIXME, please remove this crap as soon as possible
Index: arch/parisc/kernel/sys_parisc32.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/parisc/kernel/sys_parisc32.c,v
retrieving revision 1.33
diff -u -p -r1.33 sys_parisc32.c
--- arch/parisc/kernel/sys_parisc32.c	17 Jun 2003 15:23:48 -0000	1.33
+++ arch/parisc/kernel/sys_parisc32.c	15 Jul 2003 05:34:21 -0000
@@ -46,6 +46,7 @@
 #include <linux/namei.h>
 #include <linux/vfs.h>
 #include <linux/ptrace.h>
+#include <linux/swap.h>
 
 #include <asm/types.h>
 #include <asm/uaccess.h>
@@ -372,18 +373,16 @@ put_compat_timeval(struct compat_timeval
 	return copy_to_user(u, &t32, sizeof t32);
 }
 
-static int
-get_compat_timeval(struct compat_timeval *u, struct timeval *t)
+static inline long get_ts32(struct timespec *o, struct compat_timeval *i)
 {
-	int err;
-	struct compat_timeval t32;
+	long usec;
 
-	if ((err = copy_from_user(&t32, u, sizeof t32)) == 0)
-	{
-	    t->tv_sec = t32.tv_sec;
-	    t->tv_usec = t32.tv_usec;
-	}
-	return err;
+	if (__get_user(o->tv_sec, &i->tv_sec))
+		return -EFAULT;
+	if (__get_user(usec, &i->tv_usec))
+		return -EFAULT;
+	o->tv_nsec = usec * 1000;
+	return 0;
 }
 
 asmlinkage long sys32_time(compat_time_t *tloc)
@@ -417,23 +416,22 @@ sys32_gettimeofday(struct compat_timeval
     return 0;
 }
 
-asmlinkage int
-sys32_settimeofday(struct compat_timespec *tv, struct timezone *tz)
+asmlinkage 
+int sys32_settimeofday(struct compat_timeval *tv, struct timezone *tz)
 {
-    struct timeval ktv;
-    struct timezone ktz;
-    extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz);
+	struct timespec kts;
+	struct timezone ktz;
 
-    if (tv) {
-	    if (get_compat_timeval(tv, &ktv))
-		    return -EFAULT;
-    }
-    if (tz) {
-	    if (copy_from_user(&ktz, tz, sizeof(ktz)))
-		    return -EFAULT;
-    }
+ 	if (tv) {
+		if (get_ts32(&kts, tv))
+			return -EFAULT;
+	}
+	if (tz) {
+		if (copy_from_user(&ktz, tz, sizeof(ktz)))
+			return -EFAULT;
+	}
 
-    return do_sys_settimeofday(tv ? &ktv : NULL, tz ? &ktz : NULL);
+	return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
 }
 
 int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf)
@@ -1086,6 +1084,27 @@ asmlinkage long sys32_msgrcv(int msqid,
 
 	kfree(mb);
 	return err;
+}
+
+
+extern asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
+asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, s32 count)
+{
+        mm_segment_t old_fs = get_fs();
+        int ret;
+        off_t of;
+
+        if (offset && get_user(of, offset))
+                return -EFAULT;
+
+        set_fs(KERNEL_DS);
+        ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count);
+        set_fs(old_fs);
+
+        if (offset && put_user(of, offset))
+                return -EFAULT;
+
+        return ret;
 }
 
 /* EXPORT/UNEXPORT */
Index: arch/parisc/kernel/syscall.S
===================================================================
RCS file: /var/cvs/linux-2.5/arch/parisc/kernel/syscall.S,v
retrieving revision 1.31
diff -u -p -r1.31 syscall.S
--- arch/parisc/kernel/syscall.S	5 May 2003 17:05:48 -0000	1.31
+++ arch/parisc/kernel/syscall.S	15 Jul 2003 05:34:21 -0000
@@ -483,7 +483,7 @@ sys_call_table:
 	ENTRY_SAME(madvise)
 	ENTRY_SAME(clone_wrapper)	/* 120 */
 	ENTRY_SAME(setdomainname)
-	ENTRY_SAME(sendfile)
+	ENTRY_DIFF(sendfile)
 	/* struct sockaddr... */
 	ENTRY_SAME(recvfrom)
 	/* struct timex contains longs */
@@ -592,7 +592,7 @@ sys_call_table:
 	ENTRY_SAME(ni_syscall)
 	ENTRY_SAME(ni_syscall)		/* 205 */
 	ENTRY_SAME(gettid)             
-	ENTRY_SAME(readahead)          
+	ENTRY_OURS(readahead)          
 	ENTRY_SAME(ni_syscall)		/* tkill */
 
 	ENTRY_SAME(sendfile64)