Ignore:
File:
1 edited

Legend:

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

    r8d2dd7f2 rf77c1c9  
    3131#include <stdlib.h>
    3232#include <stddef.h>
     33#include <str_error.h>
    3334#include <str.h>
    3435#include <vfs/vfs.h>
     
    7273        rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY, NULL);
    7374        if (rc != EOK) {
    74                 TPRINTF("rc=%d\n", rc);
     75                TPRINTF("rc=%s\n", str_error_name(rc));
    7576                return "vfs_link_path() failed";
    7677        }
    7778        TPRINTF("Created directory %s\n", TEST_DIRECTORY);
    7879       
    79         int fd0 = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE,
    80             MODE_READ | MODE_WRITE);
    81         if (fd0 < 0)
     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)
    8284                return "vfs_lookup_open() failed";
    8385        TPRINTF("Created file %s (fd=%d)\n", TEST_FILE, fd0);
    8486       
    8587        size_t size = sizeof(text);
    86         ssize_t cnt = vfs_write(fd0, &pos, text, size);
    87         if (cnt < 0)
     88        size_t cnt;
     89        rc  = vfs_write(fd0, &pos, text, size, &cnt);
     90        if (rc != EOK)
    8891                return "write() failed";
    8992        TPRINTF("Written %zd bytes\n", cnt);
     
    9396        char buf[BUF_SIZE];
    9497        TPRINTF("read..\n");
    95         while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) {
    96                 TPRINTF("read returns %zd\n", cnt);
    97                 if (cnt < 0)
     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)
    98101                        return "read() failed";
    99102               
    100                 int _cnt = (int) cnt;
    101                 if (_cnt != cnt) {
     103                int icnt = (int) cnt;
     104                if ((size_t) icnt != cnt) {
    102105                        /* Count overflow, just to be sure. */
    103106                        TPRINTF("Read %zd bytes\n", cnt);
    104107                } else {
    105                         TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, _cnt, buf);
     108                        TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, icnt, buf);
    106109                }
    107110        }
Note: See TracChangeset for help on using the changeset viewer.