40#include <kernel/file.h>
41#include <kernel/types.h>
42#include <uapi/fcntl.h>
46#include <utils/compiler.h>
47#include <utils/stringify.h>
99error_t
vfs_mount(
const char *path,
const char *fs_type,
struct block_device *);
110error_t
vfs_mount_root(
const char *fs_type,
struct block_device *);
255 vfs_t *(*new)(
struct block_device *);
267#define DECLARE_FILESYSTEM(fs_name, fs_new) \
268 SECTION(".data.vfs.filesystems") \
270 static vfs_fs_t fs_name##_fs_declaration = { \
271 .name = stringify(fs_name), \
error_t vfs_remove(const char *path)
Remove the file located at the given path.
Definition: vfs.c:245
struct file * vfs_open(const char *path, int oflags)
Open the file located at the given path.
Definition: vfs.c:296
error_t vfs_mount(const char *path, const char *fs_type, struct block_device *)
Mount a filesystem of the given type at a given path.
Definition: vfs.c:79
error_t vfs_unmount(const char *path)
Unmount the filesystem present at the given path.
Definition: vfs.c:109
vnode_t * vfs_create(const char *path, vnode_type type)
Create a new file at the given path.
Definition: vfs.c:207
vnode_t * vfs_find_by_path(const char *path)
Retreive the vnode corresponding to a path.
Definition: vfs.c:128
error_t vfs_mount_root(const char *fs_type, struct block_device *)
Mount a filesystem at the root of the VFS.
Definition: vfs.c:70
vnode_t * vfs_vnode_acquire(vnode_t *, bool *)
Increment the refcount of a vnode.
Definition: vfs.c:306
vnode_type
The different existing types of vnodes.
Definition: vfs.h:164
vnode_t * vfs_vnode_release(vnode_t *)
Decrease the refcount of a vnode.
Definition: vfs.c:325
@ VNODE_SOCKET
Socket file.
Definition: vfs.h:171
@ VNODE_SYMLINK
Symbolic link.
Definition: vfs.h:170
@ VNODE_FIFO
FIFO.
Definition: vfs.h:165
@ VNODE_BLOCKDEVICE
Block device.
Definition: vfs.h:168
@ VNODE_FILE
Regular file.
Definition: vfs.h:169
@ VNODE_CHARDEVICE
Character device.
Definition: vfs.h:166
@ VNODE_DIRECTORY
Regular directory.
Definition: vfs.h:167
#define IS_ERR(_x)
Check if an integer can be interpreted as an error.
Definition: error.h:83
static bool vfs_exist(const char *path)
Definition: vfs.h:239
Opened file description.
Definition: file.h:29
A single path component.
Definition: path.h:107
Intrusive doubly-linked list node.
Definition: linked_list.h:27
Spinlock.
Definition: spinlock.h:29
Represents a file system format.
Definition: vfs.h:253
const char *const name
Name of the filesystem.
Definition: vfs.h:254
Vector Table for operations on a filesystems.
Definition: vfs.h:65
represents a single virtual filesystem
Definition: vfs.h:78
struct block_device * blkdev
Block device the filesystem resides on.
Definition: vfs.h:83
vnode_t * node
vnode on which this FS is mounted
Definition: vfs.h:81
vfs_ops_t * operations
vfs_operations
Definition: vfs.h:80
void * pdata
Private FS dependent data.
Definition: vfs.h:82
Vector table for operations performed on a single virtual node.
Definition: vfs.h:177
void(* release)(vnode_t *node)
Called by the VFS driver before deleting a vnode (optional).
Definition: vfs.h:198
error_t(* remove)(vnode_t *node, const char *child)
Remove a child from a directory.
Definition: vfs.h:189
represents a single virtual node
Definition: vfs.h:205
vfs_t * fs
Filesystem to which this node belong.
Definition: vfs.h:206
vnode_ops_t * operations
vnode_operations
Definition: vfs.h:209
u16 refcount
Number of references hold to that node.
Definition: vfs.h:208
void * pdata
Private node data.
Definition: vfs.h:210
vfs_t * mounted_here
Potential filesystem mounted over this node.
Definition: vfs.h:211
struct stat stat
File statistics.
Definition: vfs.h:212
vnode_type type
Type of the node.
Definition: vfs.h:207
spinlock_t lock
Must be held when accessing the node's data.
Definition: vfs.h:213