VFS
include/fs/vfs.h View source View on GitHubflags on file creation
Structs
Section titled “Structs”vfs_stat
Section titled “vfs_stat” struct vfs_stat (8 fields) source
vfs_dirent
Section titled “vfs_dirent” struct vfs_dirent (4 fields) source
vfs_ops
Section titled “vfs_ops” struct vfs_ops (23 fields) source
read data from file
write data to file
create file with given name
make node - special devices
create symbolic link
mount filesystem at mountpoint
enum err (*readdir)(struct vfs_node *node, struct vfs_dirent *out, uint64_t index) read directory entry at index
enum err (*rename)(struct vfs_node *old_parent, const char *old_name, struct vfs_node *new_parent, const char *new_name) rename/move file or directory
read symlink into target buffer
create hard link to target
update access times, unix time
enum err (*finddir)(struct vfs_node *node, const char *name, struct vfs_dirent *out) find node by name
vfs_mount
Section titled “vfs_mount” struct vfs_mount (6 fields) source
vfs_node
Section titled “vfs_node” struct vfs_node (14 fields) source
vfs_node_flags
Section titled “vfs_node_flags” enum vfs_node_flags : uint32_t (15 variants) source
clang-format off
VFS_NODE_NONE = 0x0000 No flags
VFS_NODE_MOUNTPOINT = 0x0001 This node is a mountpoint
VFS_NODE_SYMLINK = 0x0002 This node is a symlink
VFS_NODE_DEVICE = 0x0008 This node represents a device (char/block)
VFS_NODE_PIPE = 0x0010 Pipe or FIFO
VFS_NODE_SOCKET = 0x0020 Unix domain socket
VFS_NODE_SYNC = 0x0030 VFS_NODE_TEMPORARY = 0x0040 Temporary/in-memory (e.g., tmpfs)
VFS_NODE_NOATIME = 0x0080 Access time updates disabled
VFS_NODE_APPENDONLY = 0x0100 Only allows appending
VFS_NODE_IMMUTABLE = 0x0200 Cannot be modified
VFS_NODE_NOFOLLOW = 0x0400 Symlink should not be followed
VFS_NODE_IN_USE = 0x0800 Open count > 0 (used internally)
VFS_NODE_DIRSYNC = 0x1000 vfs_open_opts
Section titled “vfs_open_opts” enum vfs_open_opts : uint32_t (12 variants) source
VFS_OPEN_READ = 0x01 Open for reading
VFS_OPEN_WRITE = 0x02 Open for writing
VFS_OPEN_RDWR = VFS_OPEN_READ | VFS_OPEN_WRITE VFS_OPEN_APPEND = 0x04 Writes go to end of file
VFS_OPEN_CREAT = 0x08 Create if it doesn’t exist
VFS_OPEN_TRUNC = 0x10 Truncate to 0 size if it exists
VFS_OPEN_EXCL = 0x20 Fail if file exists (with CREAT)
VFS_OPEN_DIR = 0x40 Must be a directory
VFS_OPEN_SYMLINK_NOFOLLOW = 0x80 Don’t follow final symlink
VFS_OPEN_NONBLOCK = 0x100 Non-blocking I/O (device nodes/pipes)
VFS_OPEN_SYNC = 0x200 Synchronous writes
VFS_OPEN_NOATIME = 0x400 Don’t update access time
Functions
Section titled “Functions”vfs_node_print
Section titled “vfs_node_print”vfs_mount
Section titled “vfs_mount”vfs_unmount
Section titled “vfs_unmount”vfs_finddir
Section titled “vfs_finddir”vfs_clear_mounts
Section titled “vfs_clear_mounts”void vfs_clear_mounts(void) source Macros
Section titled “Macros”VFS_NAME_MAX
Section titled “VFS_NAME_MAX”#define VFS_NAME_MAX 256 source this because of ext2
VFS_MODE_FILE
Section titled “VFS_MODE_FILE”#define VFS_MODE_FILE 0x8000U source mode stuff
1000 << 12
VFS_MODE_DIR
Section titled “VFS_MODE_DIR”#define VFS_MODE_DIR 0x4000U source 0100 << 12
VFS_MODE_SYMLINK
Section titled “VFS_MODE_SYMLINK”#define VFS_MODE_SYMLINK 0xA000U source 1010 << 12
VFS_MODE_CHARDEV
Section titled “VFS_MODE_CHARDEV”#define VFS_MODE_CHARDEV 0x2000U source 0010 << 12
VFS_MODE_BLOCKDEV
Section titled “VFS_MODE_BLOCKDEV”#define VFS_MODE_BLOCKDEV 0x6000U source 0110 << 12
VFS_MODE_PIPE
Section titled “VFS_MODE_PIPE”#define VFS_MODE_PIPE 0x1000U source 0001 << 12
VFS_MODE_SOCKET
Section titled “VFS_MODE_SOCKET”#define VFS_MODE_SOCKET 0xC000U source 1100 << 12
VFS_MODE_O_READ
Section titled “VFS_MODE_O_READ”#define VFS_MODE_O_READ 0x0100U source 0400 (bit 8)VFS_MODE_O_WRITE
Section titled “VFS_MODE_O_WRITE”#define VFS_MODE_O_WRITE 0x0080U source 0200 (bit 7)VFS_MODE_O_EXEC
Section titled “VFS_MODE_O_EXEC”#define VFS_MODE_O_EXEC 0x0040U source 0100 (bit 6)VFS_MODE_G_READ
Section titled “VFS_MODE_G_READ”#define VFS_MODE_G_READ 0x0020U source 0040 (bit 5)VFS_MODE_G_WRITE
Section titled “VFS_MODE_G_WRITE”#define VFS_MODE_G_WRITE 0x0010U source 0020 (bit 4)VFS_MODE_G_EXEC
Section titled “VFS_MODE_G_EXEC”#define VFS_MODE_G_EXEC 0x0008U source 0010 (bit 3)VFS_MODE_R_READ
Section titled “VFS_MODE_R_READ”#define VFS_MODE_R_READ 0x0004U source 0004 (bit 2)VFS_MODE_R_WRITE
Section titled “VFS_MODE_R_WRITE”#define VFS_MODE_R_WRITE 0x0002U source 0002 (bit 1)VFS_MODE_R_EXEC
Section titled “VFS_MODE_R_EXEC”#define VFS_MODE_R_EXEC 0x0001U source 0001 (bit 0)VFS_MODE_READ
Section titled “VFS_MODE_READ”#define VFS_MODE_READ (VFS_MODE_O_READ | VFS_MODE_G_READ | VFS_MODE_R_READ) source VFS_MODE_WRITE
Section titled “VFS_MODE_WRITE”#define VFS_MODE_WRITE (VFS_MODE_O_WRITE | VFS_MODE_G_WRITE | VFS_MODE_R_WRITE) source VFS_MODE_EXEC
Section titled “VFS_MODE_EXEC”#define VFS_MODE_EXEC (VFS_MODE_O_EXEC | VFS_MODE_G_EXEC | VFS_MODE_R_EXEC) source VFS_MODE_TYPE_MASK
Section titled “VFS_MODE_TYPE_MASK”#define VFS_MODE_TYPE_MASK 0xF000U source