diff options
author | dchagin <dchagin@FreeBSD.org> | 2015-05-24 15:14:51 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2015-05-24 15:14:51 +0000 |
commit | 1ec9e6445a8bfb768e9d0188d614f1e24b4b031a (patch) | |
tree | f123c78146fbb773f42ed0dd057f101553dd1cf5 /sys/compat/linux/linux_file.c | |
parent | 0922240f49d8df56826ff90fba61d7cbb746f6b7 (diff) | |
download | FreeBSD-src-1ec9e6445a8bfb768e9d0188d614f1e24b4b031a.zip FreeBSD-src-1ec9e6445a8bfb768e9d0188d614f1e24b4b031a.tar.gz |
Implement dup3() system call.
Differential Revision: https://reviews.freebsd.org/D1049
Reviewed by: emaste
Diffstat (limited to 'sys/compat/linux/linux_file.c')
-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 78a65d0..1fb9f82 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1608,3 +1608,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)); +} |