Commit d121ff24 authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Linus Torvalds

[PATCH] Consolidate compat_sys_waitid

This patch does:
	- consolidate the three implementations of compat_sys_waitid
	  (some were called sys32_waitid).
	- adds sys_waitid syscall to ppc
	- adds sys_waitid and compat_sys_waitid syscalls to ppc64

I have left PARISC and MIPS to their own devices (by request).
Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5487472e
......@@ -494,7 +494,7 @@ ia32_syscall_table:
data8 compat_sys_mq_notify
data8 compat_sys_mq_getsetattr
data8 sys_ni_syscall /* reserved for kexec */
data8 sys32_waitid
data8 compat_sys_waitid
// guard against failures to increase IA32_NR_syscalls
.org ia32_syscall_table + 8*IA32_NR_syscalls
......@@ -2633,32 +2633,6 @@ long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
advice);
}
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);
}
#ifdef NOTYET /* UNTESTED FOR IA64 FROM HERE DOWN */
asmlinkage long sys32_setreuid(compat_uid_t ruid, compat_uid_t euid)
......
......@@ -1450,3 +1450,4 @@ _GLOBAL(sys_call_table)
.long sys_add_key
.long sys_request_key /* 270 */
.long sys_keyctl
.long sys_waitid
......@@ -939,6 +939,7 @@ _GLOBAL(sys_call_table32)
.llong .sys32_add_key
.llong .sys32_request_key
.llong .compat_sys_keyctl
.llong .compat_sys_waitid
.balign 8
_GLOBAL(sys_call_table)
......@@ -1214,3 +1215,4 @@ _GLOBAL(sys_call_table)
.llong .sys_add_key
.llong .sys_request_key /* 270 */
.llong .sys_keyctl
.llong .sys_waitid
......@@ -1121,34 +1121,3 @@ sys32_timer_create(u32 clock, struct sigevent32 __user *se32,
return err;
}
asmlinkage long compat_sys_waitid(u32 which, u32 pid,
struct compat_siginfo __user *uinfo,
u32 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) {
ret = put_compat_rusage(&ru, uru);
if (ret)
return ret;
}
BUG_ON(info.si_code & __SI_MASK);
info.si_code |= __SI_CHLD;
return copy_siginfo_to_user32(uinfo, &info);
}
......@@ -590,7 +590,7 @@ ia32_sys_call_table:
.quad compat_sys_mq_notify
.quad compat_sys_mq_getsetattr
.quad quiet_ni_syscall /* reserved for kexec */
.quad sys32_waitid
.quad compat_sys_waitid
.quad quiet_ni_syscall /* sys_altroot */
.quad sys_add_key
.quad sys_request_key
......
......@@ -955,32 +955,6 @@ asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
}
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 ? &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);
}
/*
* Some system calls that need sign extended arguments. This could be done by a generic wrapper.
*/
......
......@@ -276,8 +276,9 @@
#define __NR_add_key 269
#define __NR_request_key 270
#define __NR_keyctl 271
#define __NR_waitid 272
#define __NR_syscalls 272
#define __NR_syscalls 273
#define __NR(n) #n
......
......@@ -282,8 +282,9 @@
#define __NR_add_key 269
#define __NR_request_key 270
#define __NR_keyctl 271
#define __NR_waitid 272
#define __NR_syscalls 272
#define __NR_syscalls 273
#ifdef __KERNEL__
#define NR_syscalls __NR_syscalls
#endif
......
......@@ -83,6 +83,12 @@ struct compat_rusage {
extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
struct compat_siginfo;
extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
struct compat_siginfo __user *, int,
struct compat_rusage __user *);
struct compat_dirent {
u32 d_ino;
compat_off_t d_off;
......@@ -145,7 +151,6 @@ long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask,
unsigned long bitmap_size);
long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
unsigned long bitmap_size);
struct compat_siginfo;
int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
#endif /* CONFIG_COMPAT */
......
......@@ -23,6 +23,7 @@
#include <linux/security.h>
#include <asm/uaccess.h>
#include <asm/bug.h>
int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
{
......@@ -413,6 +414,36 @@ compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options,
}
}
asmlinkage long compat_sys_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) {
ret = put_compat_rusage(&ru, uru);
if (ret)
return ret;
}
BUG_ON(info.si_code & __SI_MASK);
info.si_code |= __SI_CHLD;
return copy_siginfo_to_user32(uinfo, &info);
}
static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
unsigned len, cpumask_t *new_mask)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment