vserver 1.9.3
[linux-2.6.git] / arch / x86_64 / ia32 / sys_ia32.c
index c0b196e..267a4a8 100644 (file)
@@ -61,7 +61,6 @@
 #include <linux/ptrace.h>
 #include <linux/highuid.h>
 #include <linux/vmalloc.h>
-#include <linux/vs_cvirt.h>
 #include <asm/mman.h>
 #include <asm/types.h>
 #include <asm/uaccess.h>
@@ -886,7 +885,7 @@ sys32_sysctl(struct sysctl_ia32 __user *args32)
        oldvalp = (void *) A(a32.oldval);
        newvalp = (void *) A(a32.newval);
 
-       if ((oldvalp && get_user(oldlen, (int *) A(a32.oldlenp)))
+       if ((oldvalp && get_user(oldlen, (int __user *)compat_ptr(a32.oldlenp)))
            || !access_ok(VERIFY_WRITE, namep, 0)
            || !access_ok(VERIFY_WRITE, oldvalp, 0)
            || !access_ok(VERIFY_WRITE, newvalp, 0))
@@ -898,7 +897,7 @@ sys32_sysctl(struct sysctl_ia32 __user *args32)
        unlock_kernel();
        set_fs(old_fs);
 
-       if (oldvalp && put_user (oldlen, (int *) A(a32.oldlenp)))
+       if (oldvalp && put_user (oldlen, (int __user *)compat_ptr(a32.oldlenp)))
                return -EFAULT;
 
        return ret;
@@ -1128,7 +1127,7 @@ long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
 } 
 
 asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
-                            compat_uptr_t __user *envp, struct pt_regs regs)
+                            compat_uptr_t __user *envp, struct pt_regs *regs)
 {
        long error;
        char * filename;
@@ -1137,21 +1136,47 @@ asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
        error = PTR_ERR(filename);
        if (IS_ERR(filename))
                return error;
-       error = compat_do_execve(filename, argv, envp, &regs);
+       error = compat_do_execve(filename, argv, envp, regs);
        if (error == 0)
                current->ptrace &= ~PT_DTRACE;
        putname(filename);
        return error;
 }
 
-asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp, struct pt_regs regs)
+asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
+                           struct pt_regs *regs)
 {
-       void __user *parent_tid = (void __user *)regs.rdx;
-       void __user *child_tid = (void __user *)regs.rdi; 
+       void __user *parent_tid = (void __user *)regs->rdx;
+       void __user *child_tid = (void __user *)regs->rdi;
        if (!newsp)
-               newsp = regs.rsp;
-        return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0, 
-                   parent_tid, child_tid);
+               newsp = regs->rsp;
+        return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
+}
+
+asmlinkage long sys32_waitid(int which, compat_pid_t pid,
+                            siginfo_t32 __user *uinfo, int options,
+                            struct compat_rusage __user *uru)
+{
+       siginfo_t info;
+       struct rusage ru;
+       long ret;
+       mm_segment_t old_fs = get_fs();
+
+       info.si_signo = 0;
+       set_fs (KERNEL_DS);
+       ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
+                        uru ? &ru : NULL);
+       set_fs (old_fs);
+
+       if (ret < 0 || info.si_signo == 0)
+               return ret;
+
+       if (uru && (ret = put_compat_rusage(&ru, uru)))
+               return ret;
+
+       BUG_ON(info.si_code & __SI_MASK);
+       info.si_code |= __SI_CHLD;
+       return ia32_copy_siginfo_to_user(uinfo, &info);
 }
 
 /*
@@ -1265,7 +1290,7 @@ asmlinkage long sys32_open(const char __user * filename, int flags, int mode)
                if (fd >= 0) {
                        struct file *f = filp_open(tmp, flags, mode);
                        error = PTR_ERR(f);
-                       if (unlikely(IS_ERR(f))) {
+                       if (IS_ERR(f)) {
                                put_unused_fd(fd); 
                                fd = error;
                        } else
@@ -1291,28 +1316,20 @@ sys_timer_create(clockid_t which_clock,
 long
 sys32_timer_create(u32 clock, struct sigevent32 __user *se32, timer_t __user *timer_id)
 {
-       struct sigevent se;
-       mm_segment_t oldfs;
-       long err;
-
+       struct sigevent __user *p = NULL;
        if (se32) { 
+               struct sigevent se;
+               p = compat_alloc_user_space(sizeof(struct sigevent));
                memset(&se, 0, sizeof(struct sigevent)); 
                if (get_user(se.sigev_value.sival_int,  &se32->sigev_value) ||
                    __get_user(se.sigev_signo, &se32->sigev_signo) ||
                    __get_user(se.sigev_notify, &se32->sigev_notify) ||
                    __copy_from_user(&se._sigev_un._pad, &se32->payload, 
-                                    sizeof(se32->payload)))
+                                    sizeof(se32->payload)) ||
+                   copy_to_user(p, &se, sizeof(se)))
                        return -EFAULT;
        } 
-       if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
-               return -EFAULT;
-
-       oldfs = get_fs();
-       set_fs(KERNEL_DS);
-       err = sys_timer_create(clock, se32 ? &se : NULL, timer_id);
-       set_fs(oldfs); 
-       
-       return err; 
+       return sys_timer_create(clock, p, timer_id);
 } 
 
 long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, 
@@ -1348,6 +1365,12 @@ long sys32_quotactl(void)
        return -ENOSYS;
 } 
 
+long sys32_lookup_dcookie(u32 addr_low, u32 addr_high,
+                         char __user * buf, size_t len)
+{
+       return sys_lookup_dcookie(((u64)addr_high << 32) | addr_low, buf, len);
+}
+
 cond_syscall(sys32_ipc)
 
 static int __init ia32_init (void)