patch-2.4.19 linux-2.4.19/arch/mips64/kernel/linux32.c

Next file: linux-2.4.19/arch/mips64/kernel/mips64_ksyms.c
Previous file: linux-2.4.19/arch/mips64/kernel/irq_cpu.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.18/arch/mips64/kernel/linux32.c linux-2.4.19/arch/mips64/kernel/linux32.c
@@ -27,6 +27,7 @@
 #include <linux/personality.h>
 #include <linux/timex.h>
 #include <linux/dnotify.h>
+#include <linux/module.h>
 #include <net/sock.h>
 
 #include <asm/uaccess.h>
@@ -36,6 +37,13 @@
 
 #define A(__x) ((unsigned long)(__x))
 
+#ifdef __MIPSEB__
+#define merge_64(r1,r2)	((((r1) & 0xffffffffUL) << 32) + ((r2) & 0xffffffffUL))
+#endif
+#ifdef __MIPSEL__
+#define merge_64(r1,r2)	((((r2) & 0xffffffffUL) << 32) + ((r1) & 0xffffffffUL))
+#endif
+
 /*
  * Revalidate the inode. This is required for proper NFS attribute caching.
  */
@@ -887,9 +895,9 @@
 			          unsigned long offset_low, loff_t * result,
 			          unsigned int origin);
 
-extern asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high,
-			           unsigned int offset_low, loff_t * result,
-			           unsigned int origin)
+asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high,
+			    unsigned int offset_low, loff_t * result,
+			    unsigned int origin)
 {
 	return sys_llseek(fd, offset_high, offset_low, result, origin);
 }
@@ -1043,11 +1051,12 @@
    non-seekable files.  */
 
 asmlinkage ssize_t sys32_pread(unsigned int fd, char * buf,
-			       size_t count, u32 unused, loff_t pos)
+			       size_t count, u32 unused, u64 a4, u64 a5)
 {
 	ssize_t ret;
 	struct file * file;
 	ssize_t (*read)(struct file *, char *, size_t, loff_t *);
+	loff_t pos;
 
 	ret = -EBADF;
 	file = fget(fd);
@@ -1055,6 +1064,7 @@
 		goto bad_file;
 	if (!(file->f_mode & FMODE_READ))
 		goto out;
+	pos = merge_64(a4, a5);
 	ret = locks_verify_area(FLOCK_VERIFY_READ, file->f_dentry->d_inode,
 				file, pos, count);
 	if (ret)
@@ -1074,11 +1084,12 @@
 }
 
 asmlinkage ssize_t sys32_pwrite(unsigned int fd, const char * buf,
-			        size_t count, u32 unused, loff_t pos)
+			        size_t count, u32 unused, u64 a4, u64 a5)
 {
 	ssize_t ret;
 	struct file * file;
 	ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
+	loff_t pos;
 
 	ret = -EBADF;
 	file = fget(fd);
@@ -1086,6 +1097,7 @@
 		goto bad_file;
 	if (!(file->f_mode & FMODE_WRITE))
 		goto out;
+	pos = merge_64(a4, a5);
 	ret = locks_verify_area(FLOCK_VERIFY_WRITE, file->f_dentry->d_inode,
 				file, pos, count);
 	if (ret)
@@ -1112,7 +1124,6 @@
 static inline int
 get_fd_set32(unsigned long n, unsigned long *fdset, u32 *ufdset)
 {
-#ifdef __MIPSEB__
 	if (ufdset) {
 		unsigned long odd;
 
@@ -1139,9 +1150,6 @@
 		memset(fdset, 0, ((n + 1) & ~1)*sizeof(u32));
 	}
 	return 0;
-#else
-	<<Bomb - little endian support must define this>>
-#endif
 }
 
 static inline void
@@ -1600,7 +1608,9 @@
 	if (!p)
 		return -ENOMEM;
 	err = get_user (p->mtype, &up->mtype);
-	err |= __copy_from_user (p->mtext, &up->mtext, second);
+	if (err)
+		goto out;
+	err = __copy_from_user (p->mtext, &up->mtext, second);
 	if (err)
 		goto out;
 	old_fs = get_fs ();
@@ -2329,3 +2339,55 @@
 out:
 	return err;
 }
+
+asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count);
+
+asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,
+                                   size_t count)
+{
+	return sys_readahead(fd, merge_64(a2, a3), count);
+}
+
+#ifdef CONFIG_MODULES
+
+/* From sparc64 */
+
+struct kernel_sym32 {
+        u32 value;
+        char name[60];
+};
+
+extern asmlinkage int sys_get_kernel_syms(struct kernel_sym *table);
+
+asmlinkage int sys32_get_kernel_syms(struct kernel_sym32 *table)
+{
+        int len, i;
+        struct kernel_sym *tbl;
+        mm_segment_t old_fs;
+
+        len = sys_get_kernel_syms(NULL);
+        if (!table) return len;
+        tbl = kmalloc (len * sizeof (struct kernel_sym), GFP_KERNEL);
+        if (!tbl) return -ENOMEM;
+        old_fs = get_fs();
+        set_fs (KERNEL_DS);
+        sys_get_kernel_syms(tbl);
+        set_fs (old_fs);
+        for (i = 0; i < len; i++, table++) {
+                if (put_user (tbl[i].value, &table->value) ||
+                    copy_to_user (table->name, tbl[i].name, 60))
+                        break;
+        }
+        kfree (tbl);
+        return i;
+}
+
+#else
+
+asmlinkage long
+sys32_get_kernel_syms(struct kernel_sym *table)
+{
+	return -ENOSYS;
+}
+
+#endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)