Expand description
Virtual File System (VFS) module.
This module provides a flexible Virtual File System implementation that supports per-task isolated filesystems, containerization, and bind mount functionality.
§Architecture Overview
The VFS architecture has evolved to support containerization, process isolation, and advanced mount operations including bind mounts:
§VfsManager Distribution
- Per-Task VfsManager: Each task can have its own isolated
VfsManager
instance stored asOption<Arc<VfsManager>>
in the task structure - Shared Filesystems: Multiple VfsManager instances can share underlying filesystem objects while maintaining independent mount points
- Bind Mounts: Support for mounting directories from one location to another, including cross-VFS bind mounting for container orchestration
§Key Components
VfsManager
: Main VFS management structure supporting both isolation and sharingFileSystemDriverManager
: Global singleton for filesystem driver registrationVirtualFileSystem
: Trait combining filesystem and file operation interfacesMountPoint
: Associates filesystem instances with mount pathsMountTree
: Hierarchical mount tree structure supporting bind mounts
§Bind Mount Functionality
The VFS provides comprehensive bind mount support for flexible directory mapping:
§Basic Bind Mounts
let mut vfs = VfsManager::new();
// Mount a directory at another location
vfs.bind_mount("/source/dir", "/target/dir", false)?;
§Read-Only Bind Mounts
// Create read-only bind mount for security
vfs.bind_mount("/source/dir", "/readonly/dir", true)?;
§Cross-VFS Bind Mounts
// Share directories between isolated VFS instances
let host_vfs = Arc::new(vfs_manager);
container_vfs.bind_mount_from(&host_vfs, "/host/data", "/container/data", false)?;
§Thread-Safe Access
Bind mount operations are thread-safe and can be called from system call context:
// Use shared reference method for system calls
vfs_arc.bind_mount_shared_ref("/source", "/target", false)?;
§Usage Patterns
§Container Isolation with Bind Mounts
// Create isolated VfsManager for container
let mut container_vfs = VfsManager::new();
container_vfs.mount(fs_id, "/");
// Bind mount host resources into container
let host_vfs = Arc::new(host_vfs_manager);
container_vfs.bind_mount_from(&host_vfs, "/host/shared", "/shared", true)?;
// Assign to task
task.vfs = Some(Arc::new(container_vfs));
§Shared Filesystem Access
The VFS supports two distinct patterns for sharing filesystem resources:
§VFS Sharing via Arc
// Share entire VfsManager instance including mount points
let shared_vfs = Arc::new(original_vfs);
let task_vfs = Arc::clone(&shared_vfs);
// All mount operations affect the shared mount tree
shared_vfs.mount(tmpfs_id, "/tmp")?; // Visible to all references
// Useful for:
// - Fork-like behavior where child inherits parent's full filesystem view
// - Thread-like sharing where all threads see the same mount points
// - System-wide mount operations
The design enables flexible deployment scenarios from simple shared filesystems to complete filesystem isolation with selective resource sharing for containerized applications through bind mounts.
Modules§
- drivers
- helper
- mount_
tree - Mount Tree Implementation
- params
- Filesystem Parameter System
- syscall
- tmpfs
- TmpFS - Temporary File System (RAM-only)
Structs§
- Device
File Info - Information about device files in the filesystem
- Directory
- Structure representing a directory
- Directory
Entry - Structure representing a directory entry
- File
- File
Metadata - File
Permission - File
System Driver Manager - Global filesystem driver manager singleton
- File
System Error - Generic
File System - Template for a basic block device-based file system implementation
- VfsManager
- VFS manager for per-task or shared filesystem management.
Enums§
- File
System Error Kind - File
System Type - Enum defining the type of file system
- File
Type - Manager
Ref - Seek
From
Constants§
Statics§
Traits§
- File
Handle - Trait for file handlers
- File
Operations - Trait defining file operations
- File
System - Trait defining basic file system operations
- File
System Driver - Trait for file system drivers
- Virtual
File System - Trait combining the complete VFS interface
Functions§
- get_
fs_ driver_ manager - Global filesystem driver manager singleton
Type Aliases§
- File
System Ref - Result
- Result type for file system operations