summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authorantoine <antoine@FreeBSD.org>2008-03-08 22:02:21 +0000
committerantoine <antoine@FreeBSD.org>2008-03-08 22:02:21 +0000
commit514f31f40ed28fea8fdc190c743417debb0d03b3 (patch)
treea5c6d546b6b95056f3d9779f9c1afae2cec004f6 /sys/kern/kern_descrip.c
parent587a314ce88f943ab58c211714655de88ddbdd25 (diff)
downloadFreeBSD-src-514f31f40ed28fea8fdc190c743417debb0d03b3.zip
FreeBSD-src-514f31f40ed28fea8fdc190c743417debb0d03b3.tar.gz
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
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 7025587..5174c15 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -397,6 +397,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) {
@@ -633,7 +638,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,
OpenPOWER on IntegriCloud