diff options
author | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:34:54 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:34:54 +0000 |
commit | b4d7be064fef3e483324d66af851466e2badfc32 (patch) | |
tree | eeed9b1ac17439e4b13cfa4e40c54429b03a725d /sys/compat | |
parent | 9ef9a018392248ab5f911960b69a3af51ad14c4a (diff) | |
download | FreeBSD-src-b4d7be064fef3e483324d66af851466e2badfc32.zip FreeBSD-src-b4d7be064fef3e483324d66af851466e2badfc32.tar.gz |
MFC r283399:
Implement dup3() system call.
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_file.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 19104a4..224beacf 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1600,3 +1600,22 @@ linux_pipe2(struct thread *td, struct linux_pipe2_args *args) /* XXX: Close descriptors on error. */ return (copyout(fildes, args->pipefds, sizeof(fildes))); } + +int +linux_dup3(struct thread *td, struct linux_dup3_args *args) +{ + int cmd; + intptr_t newfd; + + if (args->oldfd == args->newfd) + return (EINVAL); + if ((args->flags & ~LINUX_O_CLOEXEC) != 0) + return (EINVAL); + if (args->flags & LINUX_O_CLOEXEC) + cmd = F_DUP2FD_CLOEXEC; + else + cmd = F_DUP2FD; + + newfd = args->newfd; + return (kern_fcntl(td, args->oldfd, cmd, newfd)); +} |