Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2015 15:14:52 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283399 - in head/sys: amd64/linux32 compat/linux i386/linux
Message-ID:  <201505241514.t4OFEqs5045553@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun May 24 15:14:51 2015
New Revision: 283399
URL: https://svnweb.freebsd.org/changeset/base/283399

Log:
  Implement dup3() system call.
  
  Differential Revision:	https://reviews.freebsd.org/D1049
  Reviewed by:	emaste

Modified:
  head/sys/amd64/linux32/linux32_dummy.c
  head/sys/amd64/linux32/syscalls.master
  head/sys/compat/linux/linux_file.c
  head/sys/i386/linux/linux_dummy.c
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/linux32_dummy.c
==============================================================================
--- head/sys/amd64/linux32/linux32_dummy.c	Sun May 24 15:13:56 2015	(r283398)
+++ head/sys/amd64/linux32/linux32_dummy.c	Sun May 24 15:14:51 2015	(r283399)
@@ -122,7 +122,6 @@ DUMMY(timerfd_gettime);
 DUMMY(signalfd4);
 DUMMY(eventfd2);
 DUMMY(epoll_create1);
-DUMMY(dup3);
 DUMMY(inotify_init1);
 /* linux 2.6.30: */
 DUMMY(preadv);

Modified: head/sys/amd64/linux32/syscalls.master
==============================================================================
--- head/sys/amd64/linux32/syscalls.master	Sun May 24 15:13:56 2015	(r283398)
+++ head/sys/amd64/linux32/syscalls.master	Sun May 24 15:14:51 2015	(r283399)
@@ -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:

Modified: head/sys/compat/linux/linux_file.c
==============================================================================
--- head/sys/compat/linux/linux_file.c	Sun May 24 15:13:56 2015	(r283398)
+++ head/sys/compat/linux/linux_file.c	Sun May 24 15:14:51 2015	(r283399)
@@ -1608,3 +1608,22 @@ linux_pipe2(struct thread *td, struct li
 	/* 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));
+}

Modified: head/sys/i386/linux/linux_dummy.c
==============================================================================
--- head/sys/i386/linux/linux_dummy.c	Sun May 24 15:13:56 2015	(r283398)
+++ head/sys/i386/linux/linux_dummy.c	Sun May 24 15:14:51 2015	(r283399)
@@ -118,7 +118,6 @@ DUMMY(timerfd_gettime);
 DUMMY(signalfd4);
 DUMMY(eventfd2);
 DUMMY(epoll_create1);
-DUMMY(dup3);
 DUMMY(inotify_init1);
 /* linux 2.6.30: */
 DUMMY(preadv);

Modified: head/sys/i386/linux/syscalls.master
==============================================================================
--- head/sys/i386/linux/syscalls.master	Sun May 24 15:13:56 2015	(r283398)
+++ head/sys/i386/linux/syscalls.master	Sun May 24 15:14:51 2015	(r283399)
@@ -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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505241514.t4OFEqs5045553>