Implement dup3() system call.

Differential Revision:	https://reviews.freebsd.org/D1049
Reviewed by:	emaste
This commit is contained in:
Dmitry Chagin 2015-05-24 15:14:51 +00:00
parent 44e93b234f
commit 254a937ee5
5 changed files with 23 additions and 4 deletions

View File

@ -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);

View File

@ -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:

View File

@ -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));
}

View File

@ -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);

View File

@ -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: