diff options
author | ed <ed@FreeBSD.org> | 2008-11-11 14:55:59 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-11-11 14:55:59 +0000 |
commit | 8d12469978678c211dcedcae430fb7091bd504b6 (patch) | |
tree | ecda9024889970adebb651c82cfc5ec015d4a7e5 /sys/amd64 | |
parent | 5b802b524bc0cd8e922224203f9cbeb05b7e8308 (diff) | |
download | FreeBSD-src-8d12469978678c211dcedcae430fb7091bd504b6.zip FreeBSD-src-8d12469978678c211dcedcae430fb7091bd504b6.tar.gz |
Several cleanups related to pipe(2).
- Use `fildes[2]' instead of `*fildes' to make more clear that pipe(2)
fills an array with two descriptors.
- Remove EFAULT from the manual page. Because of the current calling
convention, pipe(2) raises a segmentation fault when an invalid
address is passed.
- Introduce kern_pipe() to make it easier for binary emulations to
implement pipe(2).
- Make Linux binary emulation use kern_pipe(), which means we don't have
to recover td_retval after calling the FreeBSD system call.
Approved by: rdivacky
Discussed on: arch
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/linux32/linux32_machdep.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index aecf869..fcf01c8 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -977,33 +977,20 @@ linux_iopl(struct thread *td, struct linux_iopl_args *args) int linux_pipe(struct thread *td, struct linux_pipe_args *args) { - int pip[2]; int error; - register_t reg_rdx; + int fildes[2]; #ifdef DEBUG if (ldebug(pipe)) printf(ARGS(pipe, "*")); #endif - reg_rdx = td->td_retval[1]; - error = pipe(td, 0); - if (error) { - td->td_retval[1] = reg_rdx; - return (error); - } - - pip[0] = td->td_retval[0]; - pip[1] = td->td_retval[1]; - error = copyout(pip, args->pipefds, 2 * sizeof(int)); - if (error) { - td->td_retval[1] = reg_rdx; + error = kern_pipe(td, fildes); + if (error) return (error); - } - td->td_retval[1] = reg_rdx; - td->td_retval[0] = 0; - return (0); + /* XXX: Close descriptors on error. */ + return (copyout(fildes, args->pipefds, sizeof fildes)); } int |