Changeset bb9ec2d in mainline for uspace/lib/c/generic/io/io.c
- Timestamp:
- 2017-03-07T20:47:35Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a737667e
- Parents:
- e796dc8
- git-author:
- Jiri Zarevucky <zarevucky.jiri@…> (2017-03-07 20:47:35)
- git-committer:
- Jakub Jermar <jakub@…> (2017-03-07 20:47:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/io.c
re796dc8 rbb9ec2d 45 45 #include <vfs/vfs.h> 46 46 #include <vfs/vfs_sess.h> 47 #include <vfs/inbox.h> 47 48 #include <ipc/loc.h> 48 49 #include <adt/list.h> … … 101 102 static LIST_INITIALIZE(files); 102 103 103 void __stdio_init(int filc) 104 { 105 if (filc > 0) { 106 stdin = fdopen(0, "r"); 104 void __stdio_init(void) 105 { 106 /* The first three standard file descriptors are assigned for compatibility. 107 * This will probably be removed later. 108 */ 109 110 int infd = inbox_get("stdin"); 111 if (infd >= 0) { 112 int stdinfd = vfs_clone(infd, false); 113 assert(stdinfd == 0); 114 _vfs_open(stdinfd, MODE_READ); 115 stdin = fdopen(stdinfd, "r"); 107 116 } else { 108 117 stdin = &stdin_null; … … 110 119 } 111 120 112 if (filc > 1) { 113 stdout = fdopen(1, "w"); 121 int outfd = inbox_get("stdout"); 122 if (outfd >= 0) { 123 int stdoutfd = vfs_clone(outfd, false); 124 assert(stdoutfd <= 1); 125 while (stdoutfd < 1) { 126 stdoutfd = vfs_clone(outfd, false); 127 } 128 _vfs_open(stdoutfd, MODE_APPEND); 129 stdout = fdopen(stdoutfd, "a"); 114 130 } else { 115 131 stdout = &stdout_kio; … … 117 133 } 118 134 119 if (filc > 2) { 120 stderr = fdopen(2, "w"); 135 int errfd = inbox_get("stderr"); 136 if (errfd >= 0) { 137 int stderrfd = vfs_clone(errfd, false); 138 assert(stderrfd <= 2); 139 while (stderrfd < 2) { 140 stderrfd = vfs_clone(errfd, false); 141 } 142 _vfs_open(stderrfd, MODE_APPEND); 143 stderr = fdopen(stderrfd, "a"); 121 144 } else { 122 145 stderr = &stderr_kio;
Note:
See TracChangeset
for help on using the changeset viewer.