Changeset 132ab5d1 in mainline for uspace/app/bdsh/cmds/modules/cat/cat.c
- Timestamp:
- 2018-01-30T03:20:45Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5a6cc679
- Parents:
- 8bfb163 (diff), 6a5d05b (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
-
uspace/app/bdsh/cmds/modules/cat/cat.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
r8bfb163 r132ab5d1 180 180 off64_t head, off64_t tail, bool tail_first) 181 181 { 182 int fd, bytes = 0, count = 0, reads = 0; 182 int fd, count = 0, reads = 0; 183 size_t bytes; 183 184 char *buff = NULL; 184 int i;185 size_t i; 185 186 size_t offset = 0, copied_bytes = 0; 186 187 off64_t file_size = 0, length = 0; 187 188 aoff64_t pos = 0; 189 int rc; 188 190 189 191 bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0); … … 193 195 /* Allow storing the whole UTF-8 character. */ 194 196 blen = STR_BOUNDS(1); 195 } else 196 fd = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ); 197 } else { 198 int rc = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ, &fd); 199 if (rc != EOK) { 200 fd = -1; 201 } 202 } 197 203 198 204 if (fd < 0) { … … 250 256 } 251 257 252 bytes = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read); 258 rc = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read, 259 &bytes); 253 260 copied_bytes = 0; 254 261 255 if ( bytes > 0) {262 if (rc == EOK && bytes > 0) { 256 263 buff[bytes] = '\0'; 257 264 offset = 0; … … 284 291 if (reading_stdin) 285 292 fflush(stdout); 286 } while ( bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));293 } while (rc == EOK && bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE)); 287 294 288 295 vfs_put(fd); 289 if ( bytes == -1) {296 if (rc != EOK) { 290 297 printf("Error reading %s\n", fname); 291 298 free(buff); … … 321 328 console_rows = 0; 322 329 should_quit = false; 330 dash_represents_stdin = false; 323 331 console = console_init(stdin, stdout); 324 332 number = false; … … 331 339 332 340 for (c = 0, optreset = 1, optind = 0, opt_ind = 0; c != -1;) { 333 c = getopt_long(argc, argv, "xhvmH:t:b:s :n", long_options, &opt_ind);341 c = getopt_long(argc, argv, "xhvmH:t:b:sn", long_options, &opt_ind); 334 342 switch (c) { 335 343 case 'h':
Note:
See TracChangeset
for help on using the changeset viewer.
