Skip to main content

Module vfs

Module vfs 

Source
Expand description

Virtual File System (VFS) - Plan 9-inspired namespace.

The VFS provides:

  • Scheme abstraction: Pluggable backends (IPC, kernel, devices)
  • Mount table: Map path prefixes to schemes
  • File descriptors: Per-process FD tables
  • Path resolution: Navigate the namespace hierarchy

§Architecture

User syscall (open "/net/tcp/0")
     ↓
VFS::open() : path resolution
     ↓
MountTable::resolve() → ("/net" → IpcScheme, "tcp/0")
     ↓
IpcScheme::open("tcp/0") → IPC message to network stack
     ↓
OpenFile created with scheme reference + file_id
     ↓
FD allocated in process FD table
     ↓
Returns FD to userspace

Re-exports§

pub use blkdev_scheme::BlkDevScheme;
pub use fd::FileDescriptorTable;
pub use fd::STDERR;
pub use fd::STDIN;
pub use fd::STDOUT;
pub use file::OpenFile;
pub use mount::list_mounts;
pub use mount::mount;
pub use mount::resolve;
pub use mount::unmount;
pub use mount::Namespace;
pub use pipe::PipeScheme;
pub use procfs::ProcScheme;
pub use ramfs_scheme::RamfsScheme;
pub use scheme::DirEntry;
pub use scheme::DynScheme;
pub use scheme::FileFlags;
pub use scheme::IpcScheme;
pub use scheme::KernelScheme;
pub use scheme::Scheme;
pub use scheme_router::get_initfs_file_bytes;
pub use scheme_router::init_builtin_schemes;
pub use scheme_router::list_schemes;
pub use scheme_router::mount_scheme;
pub use scheme_router::register_initfs_file;
pub use scheme_router::register_scheme;

Modules§

blkdev_scheme
Block-device scheme : exposes raw disk devices under /dev.
console_scheme
fd
File Descriptor Table (per-process).
file
Open file state.
input_scheme
Input scheme : exposes raw keyboard and mouse events to userspace.
ipcfs
mount
Mount table and path resolution.
pipe
Kernel pipe implementation.
procfs
Procfs - process filesystem (similar to Linux & BSD /proc)
pty_scheme
Pseudo-terminal (PTY) scheme.
ramfs_scheme
In-kernel RAM filesystem : mounts on / to provide a writable root.
scheme
Scheme abstraction : backends for VFS operations.
scheme_router
Scheme Router (SR) - central registry for all schemes.

Structs§

FileStat
File status information (returned by SYS_FSTAT, SYS_STAT, SYS_FSTATAT).
OpenFlags
File open flags for SYS_OPEN and SYS_OPENAT.

Constants§

AT_FDCWD
Base directory for *at() syscalls: use the process CWD.
F_OK 🔒
POSIX access mode flags
R_OK 🔒
W_OK 🔒
X_OK 🔒

Statics§

PIPE_SCHEME 🔒

Functions§

build_pci_inventory_text 🔒
Performs the build pci inventory text operation.
check_access_permissions 🔒
Check file permissions against the access mode.
chmod
Change permission bits on a path.
close
Close a file descriptor.
create_background_stdin
Create a background stdin: a pipe read-end whose write end is immediately closed. Any read() on the returned file will return 0 (EOF) at once, preventing processes launched in the background from blocking on stdin or spinning on EBADF.
create_file
Create an empty regular file.
dup
Duplicate a file descriptor (POSIX dup).
dup2
Duplicate a file descriptor to a specific number (POSIX dup2).
fchmod
Change permission bits on an open fd.
fsize
Get file size.
fstat
fstat on an open file descriptor.
fstat_at
Stat a file relative to a directory FD.
fsync
Sync file to storage.
ftruncate
Truncate an open fd.
get_pipe_scheme 🔒
Returns pipe scheme.
getdents
Read directory entries from an open directory fd.
init
Initialize the VFS with default mounts.
link
Create a hard link (must be within the same mount).
lseek
POSIX lseek on a file descriptor.
mkdir
Create a directory.
normalize_path 🔒
Collapse ., .. and duplicate / in an absolute path.
open
Open a file and return a file descriptor.
open_at
Open a file relative to a directory FD.
open_resolved 🔒
Open a file with an already-resolved path (avoids double mount::resolve).
pipe
Create a pipe, returning (read_fd, write_fd).
read
Read from a file descriptor.
read_all
Read all remaining bytes from a file descriptor.
read_user_path 🔒
Read a NUL-terminated or length-bounded path from user space.
readlink
Read the target of a symbolic link.
rename
Rename a file or directory (must be within the same mount).
resolve_and_check_path_for_current_task
Resolve path against the current task CWD and enforce silo path policy.
resolve_for_syscall 🔒
Resolve a userspace path to an absolute path and enforce silo policy.
resolve_path 🔒
Resolve path relative to the current working directory when it is not absolute. Returns the normalized absolute path.
seek
Seek within a file.
stat_path
stat by path (opens, stats, closes).
symlink
Create a symbolic link.
sys_access
SYS_ACCESS (413): Check file access permissions without opening a FD.
sys_chdir
SYS_CHDIR (440): Change current working directory.
sys_chmod
SYS_CHMOD (452): Change file mode bits.
sys_close
Syscall handler for closing a file.
sys_dup
Syscall handler for dup.
sys_dup2
Syscall handler for dup2.
sys_faccessat
SYS_FACCESSAT (468): Check file access relative to a directory FD.
sys_fchdir
SYS_FCHDIR (441): Change cwd using an open file descriptor.
sys_fchmod
SYS_FCHMOD (453): Change file mode bits on open fd.
sys_fstat
Syscall handler for fstat.
sys_fstatat
SYS_FSTATAT (463): Stat a file relative to a directory FD.
sys_ftruncate
SYS_FTRUNCATE (455): Truncate open fd to given length.
sys_getcwd
SYS_GETCWD (442): Write the current working directory into a user buffer.
sys_getdents
Syscall handler for getdents.
sys_ioctl
SYS_IOCTL (443): I/O control : stub.
sys_link
SYS_LINK (449): Create a hard link.
sys_lseek
Syscall handler for lseek.
sys_mkdir
SYS_MKDIR (447): Create a directory.
sys_open
Syscall handler for opening a file.
sys_openat
SYS_OPENAT (462): Open a file relative to a directory FD.
sys_pipe
Syscall handler for pipe.
sys_pread
SYS_PREAD (456): Read at offset without changing fd position.
sys_pwrite
SYS_PWRITE (457): Write at offset without changing fd position.
sys_read
Syscall handler for reading from a file.
sys_readlink
SYS_READLINK (451): Read a symbolic link.
sys_rename
SYS_RENAME (448): Rename a file or directory.
sys_rmdir
SYS_RMDIR (446): Remove an empty directory.
sys_stat
SYS_STAT (409): Get file status by path.
sys_symlink
SYS_SYMLINK (450): Create a symbolic link.
sys_truncate
SYS_TRUNCATE (454): Truncate file to given length.
sys_umask
SYS_UMASK (444): Set file creation mask; return the old mask.
sys_unlink
SYS_UNLINK (445): Remove a file.
sys_write
Syscall handler for writing to a file.
tell
Get current offset in a file.
truncate
Truncate a file by path.
unlink
Remove a file or directory.
write
Write to a file descriptor.