From f26fb38a13575b91333594e6c32316032286dc9c Mon Sep 17 00:00:00 2001 From: Antoine Brodin Date: Sun, 20 Apr 2008 19:32:46 +0000 Subject: MFC to RELENG_7: Introduce a new F_DUP2FD command to fcntl(2), for compatibility with Solaris and AIX. fcntl(fd, F_DUP2FD, arg) and dup2(fd, arg) are functionnaly equivalent. Document it. Add some regression tests (identical to the dup2(2) regression tests). PR: 120233 Submitted by: Jukka Ukkonen Approved by: rwaston (mentor) MFC after: 1 month --- sys/kern/kern_descrip.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/kern/kern_descrip.c') diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index eeabd117fbe80..2d71ce0faf61c 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -435,6 +435,11 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) error = do_dup(td, DUP_VARIABLE, fd, newmin, td->td_retval); break; + case F_DUP2FD: + tmp = arg; + error = do_dup(td, DUP_FIXED, fd, tmp, td->td_retval); + break; + case F_GETFD: FILEDESC_SLOCK(fdp); if ((fp = fdtofp(fd, fdp)) == NULL) { @@ -694,7 +699,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) } /* - * Common code for dup, dup2, and fcntl(F_DUPFD). + * Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD). */ static int do_dup(struct thread *td, enum dup_type type, int old, int new, -- cgit v1.2.3