asmlinkage long sys32_waitid(int which, compat_pid_t pid, compat_siginfo_t __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 ? (struct rusage __user *) &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 copy_siginfo_to_user32(uinfo, &info); }
asmlinkage long compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options, struct compat_rusage __user *ru) { if (!ru) { return sys_wait4(pid, stat_addr, options, NULL); } else { struct rusage r; int ret; unsigned int status; mm_segment_t old_fs = get_fs(); set_fs (KERNEL_DS); ret = sys_wait4(pid, (stat_addr ? (unsigned int __user *) &status : NULL), options, (struct rusage __user *) &r); set_fs (old_fs); if (ret > 0) { if (put_compat_rusage(&r, ru)) return -EFAULT; if (stat_addr && put_user(status, stat_addr)) return -EFAULT; } return ret; } }
COMPAT_SYSCALL_DEFINE5(waitid, int, which, compat_pid_t, pid, struct compat_siginfo __user *, uinfo, int, options, struct compat_rusage __user *, uru) { siginfo_t info; struct rusage ru; long ret; mm_segment_t old_fs = get_fs(); memset(&info, 0, sizeof(info)); set_fs(KERNEL_DS); ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options, uru ? (struct rusage __user *)&ru : NULL); set_fs(old_fs); if ((ret < 0) || (info.si_signo == 0)) return ret; if (uru) { /* sys_waitid() overwrites everything in ru */ if (COMPAT_USE_64BIT_TIME) ret = copy_to_user(uru, &ru, sizeof(ru)); else ret = put_compat_rusage(&ru, uru); if (ret) return -EFAULT; } BUG_ON(info.si_code & __SI_MASK); info.si_code |= __SI_CHLD; return copy_siginfo_to_user32(uinfo, &info); }
COMPAT_SYSCALL_DEFINE4(wait4, compat_pid_t, pid, compat_uint_t __user *, stat_addr, int, options, struct compat_rusage __user *, ru) { if (!ru) { return sys_wait4(pid, stat_addr, options, NULL); } else { struct rusage r; int ret; unsigned int status; mm_segment_t old_fs = get_fs(); set_fs (KERNEL_DS); ret = sys_wait4(pid, (stat_addr ? (unsigned int __force_user *) &status : NULL), options, (struct rusage __force_user *) &r); set_fs (old_fs); if (ret > 0) { if (put_compat_rusage(&r, ru)) return -EFAULT; if (stat_addr && put_user(status, stat_addr)) return -EFAULT; } return ret; } }
asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru) { struct rusage r; int ret; mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); ret = sys_getrusage(who, (struct rusage __user *) &r); set_fs(old_fs); if (ret) return ret; if (put_compat_rusage(&r, ru)) return -EFAULT; return 0; }
asmlinkage long sysn32_waitid(int which, compat_pid_t pid, siginfo_t __user *uinfo, int options, struct compat_rusage __user *uru) { struct rusage ru; long ret; mm_segment_t old_fs = get_fs(); set_fs (KERNEL_DS); ret = sys_waitid(which, pid, uinfo, options, uru ? (struct rusage __user *) &ru : NULL); set_fs (old_fs); if (ret < 0 || uinfo->si_signo == 0) return ret; if (uru) ret = put_compat_rusage(&ru, uru); return ret; }