Changeset 6122cb6a in rtems
- Timestamp:
- 12/10/13 01:35:29 (10 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 663ffd0e
- Parents:
- 9da8740
- Location:
- cpukit/libcsupport
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libcsupport/include/rtems/libio_.h
r9da8740 r6122cb6a 41 41 42 42 #define RTEMS_FILESYSTEM_SYMLOOP_MAX 32 43 44 /* 45 * Not defined in newlib so provide here. Users should use dup2 and 46 * not this non-portable fcntl command. Provided here to allow the 47 * RTEMS implementation to work. 48 */ 49 #define F_DUP2FD 20 43 50 44 51 /* -
cpukit/libcsupport/src/dup2.c
r9da8740 r6122cb6a 55 55 */ 56 56 57 return fcntl( fildes, F_DUP FD, fildes2 );57 return fcntl( fildes, F_DUP2FD, fildes2 ); 58 58 } -
cpukit/libcsupport/src/fcntl.c
r9da8740 r6122cb6a 25 25 #include <rtems/libio_.h> 26 26 27 static int duplicate_iop( rtems_libio_t *iop , int fd2)27 static int duplicate_iop( rtems_libio_t *iop ) 28 28 { 29 29 int rv = 0; 30 30 31 /*32 * FIXME: We ignore the start value fd2 for the file descriptor search. This33 * is not POSIX conform.34 */35 31 rtems_libio_t *diop = rtems_libio_allocate(); 36 32 … … 63 59 } 64 60 61 static int duplicate2_iop( rtems_libio_t *iop, int fd2 ) 62 { 63 rtems_libio_t *iop2; 64 int rv = 0; 65 66 rtems_libio_check_fd( fd2 ); 67 iop2 = rtems_libio_iop( fd2 ); 68 69 if (iop != iop2) 70 { 71 int oflag; 72 73 if ((iop2->flags & LIBIO_FLAGS_OPEN) != 0) { 74 rv = (*iop2->pathinfo.handlers->close_h)( iop2 ); 75 } 76 77 if (rv == 0) { 78 oflag = rtems_libio_to_fcntl_flags( iop->flags ); 79 oflag &= ~O_CREAT; 80 iop2->flags |= rtems_libio_fcntl_flags( oflag ); 81 82 rtems_filesystem_instance_lock( &iop->pathinfo ); 83 rtems_filesystem_location_clone( &iop2->pathinfo, &iop->pathinfo ); 84 rtems_filesystem_instance_unlock( &iop->pathinfo ); 85 86 /* 87 * XXX: We call the open handler here to have a proper open and close 88 * pair. 89 * 90 * FIXME: What to do with the path? 91 */ 92 rv = (*iop2->pathinfo.handlers->open_h)( iop2, NULL, oflag, 0 ); 93 if ( rv == 0 ) { 94 rv = fd2; 95 } 96 } 97 } 98 99 return rv; 100 } 101 65 102 static int vfcntl( 66 103 int fd, … … 89 126 switch ( cmd ) { 90 127 case F_DUPFD: /* dup */ 128 ret = duplicate_iop( iop ); 129 break; 130 131 case F_DUP2FD: /* dup2 */ 91 132 fd2 = va_arg( ap, int ); 92 ret = duplicate _iop( iop, fd2 );133 ret = duplicate2_iop( iop, fd2 ); 93 134 break; 94 135
Note: See TracChangeset
for help on using the changeset viewer.