Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/vfs/vfs1.c

    rf77c1c9 r8d2dd7f2  
    3131#include <stdlib.h>
    3232#include <stddef.h>
    33 #include <str_error.h>
    3433#include <str.h>
    3534#include <vfs/vfs.h>
     
    7372        rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY, NULL);
    7473        if (rc != EOK) {
    75                 TPRINTF("rc=%s\n", str_error_name(rc));
     74                TPRINTF("rc=%d\n", rc);
    7675                return "vfs_link_path() failed";
    7776        }
    7877        TPRINTF("Created directory %s\n", TEST_DIRECTORY);
    7978       
    80         int fd0;
    81         rc = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE,
    82             MODE_READ | MODE_WRITE, &fd0);
    83         if (rc != EOK)
     79        int fd0 = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE,
     80            MODE_READ | MODE_WRITE);
     81        if (fd0 < 0)
    8482                return "vfs_lookup_open() failed";
    8583        TPRINTF("Created file %s (fd=%d)\n", TEST_FILE, fd0);
    8684       
    8785        size_t size = sizeof(text);
    88         size_t cnt;
    89         rc  = vfs_write(fd0, &pos, text, size, &cnt);
    90         if (rc != EOK)
     86        ssize_t cnt = vfs_write(fd0, &pos, text, size);
     87        if (cnt < 0)
    9188                return "write() failed";
    9289        TPRINTF("Written %zd bytes\n", cnt);
     
    9693        char buf[BUF_SIZE];
    9794        TPRINTF("read..\n");
    98         while ((rc = vfs_read(fd0, &pos, buf, BUF_SIZE, &cnt))) {
    99                 TPRINTF("read returns rc = %s, cnt = %zu\n", str_error_name(rc), cnt);
    100                 if (rc != EOK)
     95        while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) {
     96                TPRINTF("read returns %zd\n", cnt);
     97                if (cnt < 0)
    10198                        return "read() failed";
    10299               
    103                 int icnt = (int) cnt;
    104                 if ((size_t) icnt != cnt) {
     100                int _cnt = (int) cnt;
     101                if (_cnt != cnt) {
    105102                        /* Count overflow, just to be sure. */
    106103                        TPRINTF("Read %zd bytes\n", cnt);
    107104                } else {
    108                         TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, icnt, buf);
     105                        TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, _cnt, buf);
    109106                }
    110107        }
Note: See TracChangeset for help on using the changeset viewer.