Skip to content

VFS POSIX Subsystem

Mohamed Anwar edited this page Apr 19, 2018 · 1 revision

VFS provides a subsystem for file operations defined in POSIX standard. Any filesystem may subscribe some or all of its handlers to use POSIX handlers or provide its own implementation. The following interfaces are currently supported:

int     posix_file_open(struct file *file);
int     posix_file_close(struct file *file);
ssize_t posix_file_read(struct file *file, void *buf, size_t size);
ssize_t posix_file_write(struct file *file, void *buf, size_t size);
ssize_t posix_file_readdir(struct file *file, struct dirent *dirent);
int     posix_file_ioctl(struct file *file, int request, void *argp);
off_t   posix_file_lseek(struct file *file, off_t offset, int whence);

An example of a filesystem that uses POSIX subsystem may be found in kernel/fs/tmpfs/tmpfs.c

...
#include <fs/posix.h>
...
struct fs tmpfs = {
    ...
    .fops = {
        ...
        .read  = posix_file_read,
        .write = posix_file_write,
        ...
    },
};

Clone this wiki locally