Changes in uspace/lib/posix/fcntl.c [f00af83:4cf8ca6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/fcntl.c
rf00af83 r4cf8ca6 52 52 int posix_fcntl(int fd, int cmd, ...) 53 53 { 54 int rc; 54 55 int flags; 55 56 56 57 switch (cmd) { 57 58 case F_DUPFD: 58 case F_DUPFD_CLOEXEC: 59 /* VFS currently does not provide the functionality to duplicate 60 * opened file descriptor. */ 61 // FIXME: implement this once dup() is available 62 errno = ENOTSUP; 63 return -1; 59 case F_DUPFD_CLOEXEC: /* FD_CLOEXEC is not supported. */ 60 /* VFS does not provide means to express constraints on the new 61 * file descriptor so the third argument is ignored. */ 62 63 /* Retrieve node triplet corresponding to the file descriptor. */ 64 /* Empty statement after label. */; 65 fdi_node_t node; 66 rc = fd_node(fd, &node); 67 if (rc != EOK) { 68 errno = -rc; 69 return -1; 70 } 71 72 /* Reopen the node so the fresh file descriptor is generated. */ 73 int newfd = open_node(&node, 0); 74 if (newfd < 0) { 75 errno = -newfd; 76 return -1; 77 } 78 79 /* Associate the newly generated descriptor to the file description 80 * of the old file descriptor. Just reopened node will be automatically 81 * closed. */ 82 rc = dup2(fd, newfd); 83 if (rc != EOK) { 84 errno = -rc; 85 return -1; 86 } 87 88 return newfd; 64 89 case F_GETFD: 65 90 /* FD_CLOEXEC is not supported. There are no other flags. */
Note:
See TracChangeset
for help on using the changeset viewer.