Changeset 368ee04 in mainline for uspace/app/getterm/getterm.c
- Timestamp:
- 2017-04-05T18:10:39Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93ad8166
- Parents:
- 39f892a9 (diff), 2166728 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/getterm/getterm.c
r39f892a9 r368ee04 36 36 37 37 #include <sys/types.h> 38 #include <fcntl.h>39 38 #include <unistd.h> 40 39 #include <stdio.h> … … 43 42 #include <errno.h> 44 43 #include <loc.h> 44 #include <vfs/vfs.h> 45 45 #include "version.h" 46 46 #include "welcome.h" … … 58 58 } 59 59 60 static void reopen(FILE **stream, int fd, const char *path, int flags,61 const char * mode)60 static void reopen(FILE **stream, int fd, const char *path, int mode, 61 const char *fmode) 62 62 { 63 63 if (fclose(*stream)) … … 66 66 *stream = NULL; 67 67 68 int oldfd = open(path, flags);68 int oldfd = vfs_lookup_open(path, WALK_REGULAR, mode); 69 69 if (oldfd < 0) 70 70 return; 71 71 72 72 if (oldfd != fd) { 73 if ( dup2(oldfd, fd) != fd)73 if (vfs_clone(oldfd, fd, false) != fd) 74 74 return; 75 75 76 if ( close(oldfd))76 if (vfs_put(oldfd)) 77 77 return; 78 78 } 79 79 80 *stream = fdopen(fd, mode);80 *stream = fdopen(fd, fmode); 81 81 } 82 82 … … 141 141 snprintf(term_node, LOC_NAME_MAXLEN, "%s/%s", locfs, term); 142 142 143 reopen(&stdin, 0, term_node, O_RDONLY, "r");144 reopen(&stdout, 1, term_node, O_WRONLY, "w");145 reopen(&stderr, 2, term_node, O_WRONLY, "w");143 reopen(&stdin, 0, term_node, MODE_READ, "r"); 144 reopen(&stdout, 1, term_node, MODE_WRITE, "w"); 145 reopen(&stderr, 2, term_node, MODE_WRITE, "w"); 146 146 147 147 if (stdin == NULL)
Note:
See TracChangeset
for help on using the changeset viewer.