diff options
author | dchagin <dchagin@FreeBSD.org> | 2011-01-28 18:47:07 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2011-01-28 18:47:07 +0000 |
commit | 051ceeb5f3c8cf51e869949c05b1bba132d25804 (patch) | |
tree | 481deadfab18548058f8b5da6648a71e1f2eb473 /sys/compat/linux | |
parent | cc6bdf663542811773e9cfd95af15b63ef575c5f (diff) | |
download | FreeBSD-src-051ceeb5f3c8cf51e869949c05b1bba132d25804.zip FreeBSD-src-051ceeb5f3c8cf51e869949c05b1bba132d25804.tar.gz |
Implement a variation of the linux_common_wait() which should
be used by linuxolator itself.
Move linux_wait4() to MD path as it requires native struct
rusage translation to struct l_rusage on linux32/amd64.
MFC after: 1 Month.
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 86 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.h | 5 |
2 files changed, 28 insertions, 63 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index de2b91a..7aa01c1 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -847,35 +847,17 @@ linux_futimesat(struct thread *td, struct linux_futimesat_args *args) } #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ -#define __WCLONE 0x80000000 - int -linux_waitpid(struct thread *td, struct linux_waitpid_args *args) +linux_common_wait(struct thread *td, int pid, int *status, + int options, struct rusage *ru) { - int error, options, tmpstat; - -#ifdef DEBUG - if (ldebug(waitpid)) - printf(ARGS(waitpid, "%d, %p, %d"), - args->pid, (void *)args->status, args->options); -#endif - /* - * this is necessary because the test in kern_wait doesn't work - * because we mess with the options here - */ - if (args->options & ~(WUNTRACED | WNOHANG | WCONTINUED | __WCLONE)) - return (EINVAL); + int error, tmpstat; - options = (args->options & (WNOHANG | WUNTRACED)); - /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ - if (args->options & __WCLONE) - options |= WLINUXCLONE; - - error = kern_wait(td, args->pid, &tmpstat, options, NULL); + error = kern_wait(td, pid, &tmpstat, options, ru); if (error) - return error; + return (error); - if (args->status) { + if (status) { tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | @@ -883,60 +865,38 @@ linux_waitpid(struct thread *td, struct linux_waitpid_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, status, sizeof(int)); } - return (0); + return (error); } int -linux_wait4(struct thread *td, struct linux_wait4_args *args) +linux_waitpid(struct thread *td, struct linux_waitpid_args *args) { - int error, options, tmpstat; - struct rusage ru, *rup; - struct proc *p; - + int options; + #ifdef DEBUG - if (ldebug(wait4)) - printf(ARGS(wait4, "%d, %p, %d, %p"), - args->pid, (void *)args->status, args->options, - (void *)args->rusage); + if (ldebug(waitpid)) + printf(ARGS(waitpid, "%d, %p, %d"), + args->pid, (void *)args->status, args->options); #endif - + /* + * this is necessary because the test in kern_wait doesn't work + * because we mess with the options here + */ + if (args->options & ~(WUNTRACED | WNOHANG | WCONTINUED | __WCLONE)) + return (EINVAL); + options = (args->options & (WNOHANG | WUNTRACED)); /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ if (args->options & __WCLONE) options |= WLINUXCLONE; - if (args->rusage != NULL) - rup = &ru; - else - rup = NULL; - error = kern_wait(td, args->pid, &tmpstat, options, rup); - if (error) - return error; - - p = td->td_proc; - PROC_LOCK(p); - sigqueue_delete(&p->p_sigqueue, SIGCHLD); - PROC_UNLOCK(p); - - if (args->status) { - tmpstat &= 0xffff; - if (WIFSIGNALED(tmpstat)) - tmpstat = (tmpstat & 0xffffff80) | - BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); - else if (WIFSTOPPED(tmpstat)) - tmpstat = (tmpstat & 0xffff00ff) | - (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); - error = copyout(&tmpstat, args->status, sizeof(int)); - } - if (args->rusage != NULL && error == 0) - error = copyout(&ru, args->rusage, sizeof(ru)); - - return (error); + return (linux_common_wait(td, args->pid, args->status, options, NULL)); } + int linux_mknod(struct thread *td, struct linux_mknod_args *args) { diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index 5d4afc2..c7ac5ac 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -67,4 +67,9 @@ extern const char *linux_platform; extern int stclohz; +#define __WCLONE 0x80000000 + +int linux_common_wait(struct thread *td, int pid, int *status, + int options, struct rusage *ru); + #endif /* _LINUX_MISC_H_ */ |