summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2016-01-09 15:34:54 +0000
committerdchagin <dchagin@FreeBSD.org>2016-01-09 15:34:54 +0000
commitb4d7be064fef3e483324d66af851466e2badfc32 (patch)
treeeeed9b1ac17439e4b13cfa4e40c54429b03a725d
parent9ef9a018392248ab5f911960b69a3af51ad14c4a (diff)
downloadFreeBSD-src-b4d7be064fef3e483324d66af851466e2badfc32.zip
FreeBSD-src-b4d7be064fef3e483324d66af851466e2badfc32.tar.gz
MFC r283399:
Implement dup3() system call.
-rw-r--r--sys/amd64/linux32/linux32_dummy.c1
-rw-r--r--sys/amd64/linux32/syscalls.master3
-rw-r--r--sys/compat/linux/linux_file.c19
-rw-r--r--sys/i386/linux/linux_dummy.c1
-rw-r--r--sys/i386/linux/syscalls.master3
5 files changed, 23 insertions, 4 deletions
diff --git a/sys/amd64/linux32/linux32_dummy.c b/sys/amd64/linux32/linux32_dummy.c
index 07a2d1a..bcf28ea 100644
--- a/sys/amd64/linux32/linux32_dummy.c
+++ b/sys/amd64/linux32/linux32_dummy.c
@@ -123,7 +123,6 @@ DUMMY(timerfd_gettime);
DUMMY(signalfd4);
DUMMY(eventfd2);
DUMMY(epoll_create1);
-DUMMY(dup3);
DUMMY(inotify_init1);
/* linux 2.6.30: */
DUMMY(preadv);
diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master
index ab82637..53fd315 100644
--- a/sys/amd64/linux32/syscalls.master
+++ b/sys/amd64/linux32/syscalls.master
@@ -539,7 +539,8 @@
327 AUE_NULL STD { int linux_signalfd4(void); }
328 AUE_NULL STD { int linux_eventfd2(void); }
329 AUE_NULL STD { int linux_epoll_create1(void); }
-330 AUE_NULL STD { int linux_dup3(void); }
+330 AUE_NULL STD { int linux_dup3(l_int oldfd, \
+ l_int newfd, l_int flags); }
331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
332 AUE_NULL STD { int linux_inotify_init1(void); }
; linux 2.6.30:
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));
+}
diff --git a/sys/i386/linux/linux_dummy.c b/sys/i386/linux/linux_dummy.c
index 13436a3..3758556 100644
--- a/sys/i386/linux/linux_dummy.c
+++ b/sys/i386/linux/linux_dummy.c
@@ -119,7 +119,6 @@ DUMMY(timerfd_gettime);
DUMMY(signalfd4);
DUMMY(eventfd2);
DUMMY(epoll_create1);
-DUMMY(dup3);
DUMMY(inotify_init1);
/* linux 2.6.30: */
DUMMY(preadv);
diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master
index a8fa08d..b7eb462 100644
--- a/sys/i386/linux/syscalls.master
+++ b/sys/i386/linux/syscalls.master
@@ -547,7 +547,8 @@
327 AUE_NULL STD { int linux_signalfd4(void); }
328 AUE_NULL STD { int linux_eventfd2(void); }
329 AUE_NULL STD { int linux_epoll_create1(void); }
-330 AUE_NULL STD { int linux_dup3(void); }
+330 AUE_NULL STD { int linux_dup3(l_int oldfd, \
+ l_int newfd, l_int flags); }
331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
332 AUE_NULL STD { int linux_inotify_init1(void); }
; linux 2.6.30:
OpenPOWER on IntegriCloud