Changeset 4d21cf8 in mainline


Ignore:
Timestamp:
2007-11-03T14:23:57Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
20614d0
Parents:
fa23560
Message:

VFS work.
Introduce the notion of VFS_PAIR which corresponds to a file system instance,
and VFS_TRIPLET, which corresponds to a file system node. Separate vfs_triplet_t
and vfs_node_t as the former one is the stateless counterpart of the latter.

Location:
uspace/srv/vfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    rfa23560 r4d21cf8  
    100100
    101101/**
    102  * Instances of this type represent a file system node (e.g. directory, file).
    103  * They are abstracted away from any file system implementation and contain just
    104  * enough bits to uniquely identify the object in its file system instance.
     102 * VFS_PAIR uniquely represents a file system instance.
     103 */
     104#define VFS_PAIR        \
     105        int fs_handle;  \
     106        int dev_handle;
     107
     108/**
     109 * VFS_TRIPLET uniquely identifies a file system node (e.g. directory, file) but
     110 * doesn't contain any state. For a stateful structure, see vfs_node_t.
    105111 *
    106112 * @note        fs_handle, dev_handle and index are meant to be returned in one
    107113 *              IPC reply.
    108114 */
     115#define VFS_TRIPLET     \
     116        VFS_PAIR;       \
     117        uint64_t index;
     118
    109119typedef struct {
    110         int fs_handle;          /**< Global file system ID. */
    111         int dev_handle;         /**< Global mount device devno. */
    112         uint64_t index;         /**< Index of the node on its file system. */
     120        VFS_PAIR;
     121} vfs_pair_t;
     122
     123typedef struct {
     124        VFS_TRIPLET;
     125} vfs_triplet_t;
     126
     127/**
     128 * Instances of this type represent an active, in-memory VFS node and any state
     129 * which may be associated with it.
     130 */
     131typedef struct {
     132        VFS_TRIPLET;            /**< Identity of the node. */
     133        atomic_t refcnt;        /**< Usage counter. */
    113134} vfs_node_t;
    114135
     
    129150extern link_t fs_head;          /**< List of registered file systems. */
    130151
    131 extern vfs_node_t rootfs;       /**< Root node of the root file system. */
     152extern vfs_triplet_t rootfs;    /**< Root node of the root file system. */
    132153
    133154#define MAX_PATH_LEN            (64 * 1024)
     
    151172extern int fs_name_to_handle(char *, bool);
    152173
    153 extern int vfs_lookup_internal(char *, size_t, vfs_node_t *, vfs_node_t *);
     174extern int vfs_lookup_internal(char *, size_t, vfs_triplet_t *, vfs_pair_t *);
    154175
    155176#define MAX_OPEN_FILES  128     
  • uspace/srv/vfs/vfs_lookup.c

    rfa23560 r4d21cf8  
    6262 * @return              EOK on success or an error code from errno.h.
    6363 */
    64 int vfs_lookup_internal(char *path, size_t len, vfs_node_t *result,
    65     vfs_node_t *altroot)
     64int vfs_lookup_internal(char *path, size_t len, vfs_triplet_t *result,
     65    vfs_pair_t *altroot)
    6666{
    67         vfs_node_t *root;
     67        vfs_pair_t *root;
    6868
    6969        if (!len)
     
    7373                root = altroot;
    7474        else
    75                 root = &rootfs;
     75                root = (vfs_pair_t *) &rootfs;
    7676
    7777        if (!root->fs_handle)
  • uspace/srv/vfs/vfs_mount.c

    rfa23560 r4d21cf8  
    4747
    4848atomic_t rootfs_futex = FUTEX_INITIALIZER;
    49 vfs_node_t rootfs = { 0 };
    50 
    51 static int lookup_root(int fs_handle, int dev_handle, vfs_node_t *root)
     49vfs_triplet_t rootfs = {
     50        .fs_handle = 0,
     51        .dev_handle = 0,
     52        .index = 0,
     53};
     54
     55static int lookup_root(int fs_handle, int dev_handle, vfs_triplet_t *root)
    5256{
    53         vfs_node_t altroot = {
     57        vfs_pair_t altroot = {
    5458                .fs_handle = fs_handle,
    5559                .dev_handle = dev_handle,
    56                 /*
    57                  * At this point, we don't know what is the index of the root
    58                  * node. Finally, that's what this function is about.
    59                  */
    6060        };
    6161
     
    139139         */
    140140        int rc;
    141         vfs_node_t mounted_root;
     141        vfs_triplet_t mounted_root;
    142142        rc = lookup_root(fs_handle, dev_handle, &mounted_root);
    143143        if (rc != EOK) {
     
    150150         * Finally, we need to resolve the path to the mountpoint.
    151151         */
    152         vfs_node_t mp;
     152        vfs_triplet_t mp;
    153153        futex_down(&rootfs_futex);
    154154        if (rootfs.fs_handle) {
Note: See TracChangeset for help on using the changeset viewer.