diff options
author | John Baldwin <jhb@FreeBSD.org> | 2004-03-17 20:00:00 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2004-03-17 20:00:00 +0000 |
commit | b7e23e826c650173f9175c42f1b03cd80fdb0a93 (patch) | |
tree | e960ffc0a863b368d852fa094d1f4ccb757fe3c7 /sys/compat/linux/linux_misc.c | |
parent | cb8c2e1cd289a58a84b0fb4b9703c8847e507a73 (diff) | |
download | src-b7e23e826c650173f9175c42f1b03cd80fdb0a93.tar.gz src-b7e23e826c650173f9175c42f1b03cd80fdb0a93.zip |
- Replace wait1() with a kern_wait() function that accepts the pid,
options, status pointer and rusage pointer as arguments. It is up to
the caller to copyout the status and rusage to userland if needed. This
lets us axe the 'compat' argument and hide all that functionality in
owait(), by the way. This also cleans up some locking in kern_wait()
since it no longer has to drop locks around copyout() since all the
copyout()'s are deferred.
- Convert owait(), wait4(), and the various ABI compat wait() syscalls to
use kern_wait() rather than wait1() or wait4(). This removes a bit
more stackgap usage.
Tested on: i386
Compiled on: i386, alpha, amd64
Notes
Notes:
svn path=/head/; revision=127140
Diffstat (limited to 'sys/compat/linux/linux_misc.c')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 9e38f91f1f94..8a81dec689ed 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -795,13 +795,7 @@ linux_utime(struct thread *td, struct linux_utime_args *args) int linux_waitpid(struct thread *td, struct linux_waitpid_args *args) { - struct wait_args /* { - int pid; - int *status; - int options; - struct rusage *rusage; - } */ tmp; - int error, tmpstat; + int error, options, tmpstat; #ifdef DEBUG if (ldebug(waitpid)) @@ -809,20 +803,16 @@ linux_waitpid(struct thread *td, struct linux_waitpid_args *args) args->pid, (void *)args->status, args->options); #endif - tmp.pid = args->pid; - tmp.status = args->status; - tmp.options = (args->options & (WNOHANG | WUNTRACED)); + options = (args->options & (WNOHANG | WUNTRACED)); /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ if (args->options & __WCLONE) - tmp.options |= WLINUXCLONE; - tmp.rusage = NULL; + options |= WLINUXCLONE; - if ((error = wait4(td, &tmp)) != 0) + error = kern_wait(td, args->pid, &tmpstat, options, NULL); + if (error) return error; if (args->status) { - if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) - return error; tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | @@ -840,13 +830,8 @@ linux_waitpid(struct thread *td, struct linux_waitpid_args *args) int linux_wait4(struct thread *td, struct linux_wait4_args *args) { - struct wait_args /* { - int pid; - int *status; - int options; - struct rusage *rusage; - } */ tmp; - int error, tmpstat; + int error, options, tmpstat; + struct rusage ru; struct proc *p; #ifdef DEBUG @@ -856,15 +841,13 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args) (void *)args->rusage); #endif - tmp.pid = args->pid; - tmp.status = args->status; - tmp.options = (args->options & (WNOHANG | WUNTRACED)); + options = (args->options & (WNOHANG | WUNTRACED)); /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ if (args->options & __WCLONE) - tmp.options |= WLINUXCLONE; - tmp.rusage = (struct rusage *)args->rusage; + options |= WLINUXCLONE; - if ((error = wait4(td, &tmp)) != 0) + error = kern_wait(td, args->pid, &tmpstat, options, &ru); + if (error) return error; p = td->td_proc; @@ -873,8 +856,6 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args) PROC_UNLOCK(p); if (args->status) { - if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) - return error; tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | @@ -882,10 +863,12 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args) else if (WIFSTOPPED(tmpstat)) tmpstat = (tmpstat & 0xffff00ff) | (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); - return copyout(&tmpstat, args->status, sizeof(int)); + error = copyout(&tmpstat, args->status, sizeof(int)); } + if (args->rusage != NULL && error == 0) + error = copyout(&ru, args->rusage, sizeof(ru)); - return 0; + return (error); } int |