summaryrefslogtreecommitdiffstats
path: root/c/src/exec/libcsupport
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>1998-12-03 22:17:26 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>1998-12-03 22:17:26 +0000
commit5822f437a1b826a30899036aa981c063ab274446 (patch)
tree8cb35ff4cd7a9412f2d3ee53379a753946c5662c /c/src/exec/libcsupport
parentModifications for RTEMS_UNIX. (diff)
downloadrtems-5822f437a1b826a30899036aa981c063ab274446.tar.bz2
Added source for F_DUPFD.
Diffstat (limited to 'c/src/exec/libcsupport')
-rw-r--r--c/src/exec/libcsupport/src/fcntl.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/c/src/exec/libcsupport/src/fcntl.c b/c/src/exec/libcsupport/src/fcntl.c
index f6f33534ab..a538ec1cf9 100644
--- a/c/src/exec/libcsupport/src/fcntl.c
+++ b/c/src/exec/libcsupport/src/fcntl.c
@@ -27,6 +27,8 @@ int fcntl(
{
va_list ap;
rtems_libio_t *iop;
+ rtems_libio_t *diop;
+ int fd2;
va_start( ap, cmd );
@@ -50,18 +52,22 @@ int fcntl(
switch ( cmd ) {
case F_DUPFD: /* dup */
- /*
- * This is how it appears that this case should work:
- *
- * filedes2 = va_arg( ap, int )
- * if filedes2 is 0
- * duplicate fd into a new descriptor
- * else
- * duplicate fd into specified descriptor after error checking it
- *
- * See dup2() in case we can eliminate stuff in there.
- */
- return -1;
+ fd2 = va_arg( ap, int );
+ if ( fd2 )
+ diop = rtems_libio_iop( fd2 );
+ else {
+ /* allocate a file control block */
+ diop = rtems_libio_allocate();
+ if ( diop == 0 )
+ return -1;
+ }
+
+ diop->handlers = iop->handlers;
+ diop->file_info = iop->file_info;
+ diop->flags = iop->flags;
+ diop->pathinfo = iop->pathinfo;
+
+ return 0;
case F_GETFD: /* get f_flags */
if ( iop->flags & LIBIO_FLAGS_CLOSE_ON_EXEC )