Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 368ee04 in mainline for uspace/app/tester/vfs/vfs1.c


Ignore:
Timestamp:
2017-04-05T18:10:39Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
93ad8166
Parents:
39f892a9 (diff), 2166728 (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.
Message:

Merge from lp:~jakub/helenos/vfs-2.5-cherrypick

This merge cherry-picks some of the changesets from Jiri Zarevucky's:

lp:~zarevucky-jiri/helenos/vfs-2.5

and then continues independently, yet sometime in a similar vein.

Roughly speaking, Jiri's branch is merged entirely up to its revision
1926 and then cherry-picked on and off until its revision 1965. Among
these changes are:

  • relativization of the API,
  • client-side roots,
  • server-side mounts,
  • inbox for passing arbitrary files from parent to child,
  • some streamlining and cleanup.

Additional changes include:

  • addressing issues introduced by the above changes,
  • client-side I/O cursors (file positions),
  • all HelenOS file system APIs begin with the vfs_ prefix and can be used after including vfs/vfs.h,
  • removal of some POSIX-ish headers and definitions,
  • additional cleanup.
File:
1 edited

Legend:

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

    r39f892a9 r368ee04  
    3333#include <vfs/vfs.h>
    3434#include <unistd.h>
    35 #include <fcntl.h>
    3635#include <dirent.h>
    3736#include <loc.h>
    3837#include <sys/types.h>
    39 #include <sys/stat.h>
    4038#include "../tester.h"
    4139
     
    7068const char *test_vfs1(void)
    7169{
    72         if (mkdir(TEST_DIRECTORY, 0) != 0) {
    73                 TPRINTF("rc=%d\n", errno);
    74                 return "mkdir() failed";
     70        aoff64_t pos = 0;
     71        int rc;
     72
     73        rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY, NULL);
     74        if (rc != EOK) {
     75                TPRINTF("rc=%d\n", rc);
     76                return "vfs_link_path() failed";
    7577        }
    7678        TPRINTF("Created directory %s\n", TEST_DIRECTORY);
    7779       
    78         int fd0 = open(TEST_FILE, O_CREAT);
     80        int fd0 = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE,
     81            MODE_READ | MODE_WRITE);
    7982        if (fd0 < 0)
    80                 return "open() failed";
     83                return "vfs_lookup_open() failed";
    8184        TPRINTF("Created file %s (fd=%d)\n", TEST_FILE, fd0);
    8285       
    8386        size_t size = sizeof(text);
    84         ssize_t cnt = write(fd0, text, size);
     87        ssize_t cnt = vfs_write(fd0, &pos, text, size);
    8588        if (cnt < 0)
    8689                return "write() failed";
    8790        TPRINTF("Written %zd bytes\n", cnt);
    88        
    89         if (lseek(fd0, 0, SEEK_SET) != 0)
    90                 return "lseek() failed";
    91         TPRINTF("Sought to position 0\n");
     91
     92        pos = 0;
    9293       
    9394        char buf[BUF_SIZE];
    9495        TPRINTF("read..\n");
    95         while ((cnt = read(fd0, buf, BUF_SIZE))) {
     96        while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) {
    9697                TPRINTF("read returns %zd\n", cnt);
    9798                if (cnt < 0)
     
    107108        }
    108109       
    109         close(fd0);
     110        vfs_put(fd0);
    110111       
    111112        const char *rv = read_root();
     
    113114                return rv;
    114115       
    115         if (rename(TEST_FILE, TEST_FILE2) != 0)
    116                 return "rename() failed";
     116        if (vfs_rename_path(TEST_FILE, TEST_FILE2) != EOK)
     117                return "vfs_rename_path() failed";
    117118        TPRINTF("Renamed %s to %s\n", TEST_FILE, TEST_FILE2);
    118119       
    119         if (unlink(TEST_FILE2) != 0)
    120                 return "unlink() failed";
     120        if (vfs_unlink_path(TEST_FILE2) != EOK)
     121                return "vfs_unlink_path() failed";
    121122        TPRINTF("Unlinked %s\n", TEST_FILE2);
    122123       
    123         if (rmdir(TEST_DIRECTORY) != 0)
    124                 return "rmdir() failed";
     124        if (vfs_unlink_path(TEST_DIRECTORY) != EOK)
     125                return "vfs_unlink_path() failed";
    125126        TPRINTF("Removed directory %s\n", TEST_DIRECTORY);
    126127       
Note: See TracChangeset for help on using the changeset viewer.