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/i386/linux | |
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/i386/linux')
-rw-r--r-- | sys/i386/linux/linux_machdep.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index ded3b17..7f727ac 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -813,29 +813,19 @@ int linux_pipe(struct thread *td, struct linux_pipe_args *args) { int error; - int reg_edx; + int fildes[2]; #ifdef DEBUG if (ldebug(pipe)) printf(ARGS(pipe, "*")); #endif - reg_edx = td->td_retval[1]; - error = pipe(td, 0); - if (error) { - td->td_retval[1] = reg_edx; - return (error); - } - - error = copyout(td->td_retval, args->pipefds, 2*sizeof(int)); - if (error) { - td->td_retval[1] = reg_edx; + error = kern_pipe(td, fildes); + if (error) return (error); - } - td->td_retval[1] = reg_edx; - td->td_retval[0] = 0; - return (0); + /* XXX: Close descriptors on error. */ + return (copyout(fildes, args->pipefds, sizeof fildes)); } int |