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::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§

FileStat
OpenFlags
Strat9 ABI open flags passed via SYS_OPEN.

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.