Merge master.kernel.org:/pub/scm/linux/kernel/git/lethal/sh64-2.6
[pandora-kernel.git] / arch / mips / kernel / linux32.c
index 3f40c37..53f4171 100644 (file)
@@ -5,7 +5,6 @@
  * Written by Ulf Carlsson (ulfc@engr.sgi.com)
  * sys32_execve from ia64/ia32 code, Feb 2000, Kanoj Sarcar (kanoj@sgi.com)
  */
-#include <linux/config.h>
 #include <linux/compiler.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
@@ -78,6 +77,8 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
        memset(&tmp, 0, sizeof(tmp));
        tmp.st_dev = new_encode_dev(stat->dev);
        tmp.st_ino = stat->ino;
+       if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino)
+               return -EOVERFLOW;
        tmp.st_mode = stat->mode;
        tmp.st_nlink = stat->nlink;
        SET_UID(tmp.st_uid, stat->uid);
@@ -356,73 +357,13 @@ asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high,
 asmlinkage ssize_t sys32_pread(unsigned int fd, char __user * buf,
                               size_t count, u32 unused, u64 a4, u64 a5)
 {
-       ssize_t ret;
-       struct file * file;
-       ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
-       loff_t pos;
-
-       ret = -EBADF;
-       file = fget(fd);
-       if (!file)
-               goto bad_file;
-       if (!(file->f_mode & FMODE_READ))
-               goto out;
-       pos = merge_64(a4, a5);
-       ret = rw_verify_area(READ, file, &pos, count);
-       if (ret < 0)
-               goto out;
-       ret = -EINVAL;
-       if (!file->f_op || !(read = file->f_op->read))
-               goto out;
-       if (pos < 0)
-               goto out;
-       ret = -ESPIPE;
-       if (!(file->f_mode & FMODE_PREAD))
-               goto out;
-       ret = read(file, buf, count, &pos);
-       if (ret > 0)
-               dnotify_parent(file->f_dentry, DN_ACCESS);
-out:
-       fput(file);
-bad_file:
-       return ret;
+       return sys_pread64(fd, buf, count, merge_64(a4, a5));
 }
 
 asmlinkage ssize_t sys32_pwrite(unsigned int fd, const char __user * buf,
                                size_t count, u32 unused, u64 a4, u64 a5)
 {
-       ssize_t ret;
-       struct file * file;
-       ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
-       loff_t pos;
-
-       ret = -EBADF;
-       file = fget(fd);
-       if (!file)
-               goto bad_file;
-       if (!(file->f_mode & FMODE_WRITE))
-               goto out;
-       pos = merge_64(a4, a5);
-       ret = rw_verify_area(WRITE, file, &pos, count);
-       if (ret < 0)
-               goto out;
-       ret = -EINVAL;
-       if (!file->f_op || !(write = file->f_op->write))
-               goto out;
-       if (pos < 0)
-               goto out;
-
-       ret = -ESPIPE;
-       if (!(file->f_mode & FMODE_PWRITE))
-               goto out;
-
-       ret = write(file, buf, count, &pos);
-       if (ret > 0)
-               dnotify_parent(file->f_dentry, DN_MODIFY);
-out:
-       fput(file);
-bad_file:
-       return ret;
+       return sys_pwrite64(fd, buf, count, merge_64(a4, a5));
 }
 
 asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid,
@@ -1052,7 +993,7 @@ struct sysctl_args32
        unsigned int __unused[4];
 };
 
-#ifdef CONFIG_SYSCTL
+#ifdef CONFIG_SYSCTL_SYSCALL
 
 asmlinkage long sys32_sysctl(struct sysctl_args32 __user *args)
 {
@@ -1093,14 +1034,14 @@ asmlinkage long sys32_sysctl(struct sysctl_args32 __user *args)
        return error;
 }
 
-#endif /* CONFIG_SYSCTL */
+#endif /* CONFIG_SYSCTL_SYSCALL */
 
 asmlinkage long sys32_newuname(struct new_utsname __user * name)
 {
        int ret = 0;
 
        down_read(&uts_sem);
-       if (copy_to_user(name,&system_utsname,sizeof *name))
+       if (copy_to_user(name, utsname(), sizeof *name))
                ret = -EFAULT;
        up_read(&uts_sem);
 
@@ -1182,6 +1123,16 @@ asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,
        return sys_readahead(fd, merge_64(a2, a3), count);
 }
 
+asmlinkage long sys32_sync_file_range(int fd, int __pad,
+       unsigned long a2, unsigned long a3,
+       unsigned long a4, unsigned long a5,
+       int flags)
+{
+       return sys_sync_file_range(fd,
+                       merge_64(a2, a3), merge_64(a4, a5),
+                       flags);
+}
+
 /* Argument list sizes for sys_socketcall */
 #define AL(x) ((x) * sizeof(unsigned int))
 static unsigned char socketcall_nargs[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
@@ -1347,9 +1298,3 @@ _sys32_clone(nabi_no_regargs struct pt_regs regs)
        return do_fork(clone_flags, newsp, &regs, 0,
                       parent_tidptr, child_tidptr);
 }
-
-extern asmlinkage void sys_set_thread_area(u32 addr);
-asmlinkage void sys32_set_thread_area(u32 addr)
-{
-       sys_set_thread_area(AA(addr));
-}