Changeset 5973fd0 in mainline for uspace/app/tester/vfs/vfs1.c


Ignore:
Timestamp:
2008-01-18T23:45:16Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ae78b53
Parents:
62da45a
Message:

Finish implementation of readdir(). Functions from this family are implemented
via using file descriptors for directories. For example, readdir() is
implemented as read() from an open directory. Of course, FS implementations
must understand that they are asked to read a directory and behave accordingly.

File:
1 edited

Legend:

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

    r62da45a r5973fd0  
    11/*
    2  * Copyright (c) 2007 Jakub Jermar
     2 * Copyright (c) 2008 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    3535#include <unistd.h>
    3636#include <fcntl.h>
     37#include <dirent.h>
    3738#include "../tester.h"
    3839
     
    4142        if (mount("tmpfs", "/", "nulldev0") != EOK)
    4243                return "Mount failed.\n";
     44
     45
     46        DIR *dirp;
     47        struct dirent *dp;
     48
     49        dirp = opendir("/");
     50        if (!dirp)
     51                return "opendir() failed.";
     52        while ((dp = readdir(dirp)))
     53                printf("Discovered %s\n", dp->d_name);
     54        closedir(dirp);
     55
    4356        int fd1 = open("/dir1/file1", 0);
    4457        int fd2 = open("/dir2/file2", 0);
    4558
    4659        if (fd1 < 0)
    47                 return "Open failed.\n";
     60                return "open() failed.\n";
    4861        if (fd2 < 0)
    49                 return "Open failed.\n";
     62                return "open() failed.\n";
    5063
    5164        if (!quiet)
     
    5669        ssize_t cnt = read(fd1, buf, sizeof(buf));
    5770        if (cnt < 0)
    58                 return "Read failed.\n";
     71                return "read() failed.\n";
    5972
    6073        if (!quiet)
Note: See TracChangeset for help on using the changeset viewer.