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 userspaceRe-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::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.
- 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§
Functions§
- 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.
- fsync
- Sync file to storage.
- ftruncate
- Truncate an open fd.
- 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.
- open
- Open a file and return a file descriptor.
- 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.
- readlink
- Read the target of a symbolic link.
- rename
- Rename a file or directory (must be within the same mount).
- seek
- Seek within a file.
- stat_
path - stat by path (opens, stats, closes).
- symlink
- Create a symbolic link.
- 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_
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_
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_
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 - Syscall handler for stat (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.