Ignore:
Timestamp:
2017-12-04T18:44:24Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bde5c04
Parents:
40feeac
Message:

vfs_read/write() should return error code separately from number of bytes transferred.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r40feeac r8e3498b  
    180180    off64_t head, off64_t tail, bool tail_first)
    181181{
    182         int fd, bytes = 0, count = 0, reads = 0;
     182        int fd, count = 0, reads = 0;
     183        size_t bytes;
    183184        char *buff = NULL;
    184         int i;
     185        size_t i;
    185186        size_t offset = 0, copied_bytes = 0;
    186187        off64_t file_size = 0, length = 0;
    187188        aoff64_t pos = 0;
     189        int rc;
    188190
    189191        bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0);
     
    250252                }
    251253               
    252                 bytes = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read);
     254                rc = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read,
     255                    &bytes);
    253256                copied_bytes = 0;
    254257
    255                 if (bytes > 0) {
     258                if (rc == EOK && bytes > 0) {
    256259                        buff[bytes] = '\0';
    257260                        offset = 0;
     
    284287                if (reading_stdin)
    285288                        fflush(stdout);
    286         } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
     289        } while (rc == EOK && bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
    287290
    288291        vfs_put(fd);
    289         if (bytes == -1) {
     292        if (rc != EOK) {
    290293                printf("Error reading %s\n", fname);
    291294                free(buff);
Note: See TracChangeset for help on using the changeset viewer.