Changeset 368ee04 in mainline for uspace/app/tester


Ignore:
Timestamp:
2017-04-05T18:10:39Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
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.
Location:
uspace/app/tester
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/hw/misc/virtchar1.c

    r39f892a9 r368ee04  
    4545#include <vfs/vfs.h>
    4646#include <vfs/vfs_sess.h>
    47 #include <sys/stat.h>
    48 #include <fcntl.h>
    4947#include "../../tester.h"
    5048
     
    5654{
    5755        TPRINTF("Opening `%s'...\n", path);
    58         int fd = open(path, O_RDONLY);
     56        int fd = vfs_lookup(path, WALK_REGULAR);
    5957        if (fd < 0) {
    6058                TPRINTF("   ...error: %s\n", str_error(errno));
     
    7169        async_sess_t *sess = vfs_fd_session(fd, INTERFACE_DDF);
    7270        if (!sess) {
    73                 close(fd);
     71                vfs_put(fd);
    7472                TPRINTF("   ...error: %s\n", str_error(errno));
    7573                return "Failed to get session to device";
     
    9290        TPRINTF(" Closing session and file descriptor\n");
    9391        async_hangup(sess);
    94         close(fd);
     92        vfs_put(fd);
    9593       
    9694        return NULL;
  • uspace/app/tester/mm/pager1.c

    r39f892a9 r368ee04  
    2828
    2929#include <stdio.h>
    30 #include <unistd.h>
    31 #include <fcntl.h>
     30#include <vfs/vfs.h>
    3231#include <stdlib.h>
    3332#include <malloc.h>
     
    4847        TPRINTF("Creating temporary file...\n");
    4948
    50         fd = open(TEST_FILE, O_CREAT);
     49        fd = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE,
     50            MODE_READ | MODE_WRITE);
    5151        if (fd < 0)
    5252                return NULL;
    53         (void) unlink(TEST_FILE);
    54         if (write(fd, text, sizeof(text)) != sizeof(text)) {
    55                 close(fd);
     53        (void) vfs_unlink_path(TEST_FILE);
     54
     55        if (vfs_write(fd, (aoff64_t []) {0}, text, sizeof(text)) < 0) {
     56                vfs_put(fd);
    5657                return NULL;
    5758        }
     
    6465
    6566        if (!vfs_pager_sess) {
    66                 close(fd);
     67                vfs_put(fd);
    6768                return NULL;
    6869        }
     
    7374            AS_AREA_READ | AS_AREA_CACHEABLE, vfs_pager_sess, fd, 0, 0);
    7475        if (result == AS_MAP_FAILED) {
    75                 close(fd);
     76                vfs_put(fd);
    7677                return NULL;
    7778        }
     
    101102
    102103        as_area_destroy(buffer);       
    103         close(fd);
     104        vfs_put(fd);
    104105       
    105106        return NULL;
  • 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.