Skip to content
Mohamed Anwar edited this page Apr 19, 2018 · 2 revisions

Virtual Filesystem (VFS)

Virtual Filesystem in Aquila is based on UNIX concept of single filesystem tree.

inode

inode is the main object in VFS it is a representation of any file in a filesystem (regular, directory, symbolic link, etc...). VFS generic inode is defined in kernel/include/fs/vfs.h as follows

struct inode {
    vino_t      id;     /* Unique Identifier */
    char        *name;  /* inode name (if present in a directory) */
    size_t      size;   /* inode size */
    uint32_t    type;   /* inode type */
    struct fs   *fs;    /* pointer to fs used for operations on inode */

    dev_t       dev;    /* device storing inode */
    dev_t       rdev;   /* device pointed to by inode */

    void        *p;     /* fs handler private data */

    uint32_t    uid;    /* User ID */
    uint32_t    gid;    /* Group ID */
    uint32_t    mask;   /* File access mask */

    ssize_t     ref;    /* Number of processes referencing this node */
    queue_t     *read_queue;  /* Optional read_queue for blocking I/O */
    queue_t     *write_queue; /* Optional write_queue for blocking I/O */
};

inodes are unique and only one copy is permitted for each file in use (with the references count kept in ref member of the structure). To facilitate uniqueness, each filesystem handler must ensure that any open request to the same file must return the same inode, for that the fs handler may either use itbl or provide its own implementation.

vnode

Unlike inodes, vnodes are stripped down versions used during lookup and other various parts. vnodes may not be unique, they serve only as a pointer to an inode. Its implementation looks like

struct vnode {
    struct inode *super;  /* super node containing inode reference */
    vino_t       id;     /* unique underlying inode identifier */
    uint32_t     type;   /* inode type */
    uint32_t     mask;   /* inode access mask */
    uint32_t     uid;    /* user ID */
    uint32_t     gid;    /* group ID */
};

Clone this wiki locally