pub struct VfsManager {
pub id: VfsManagerId,
pub mount_tree: MountTree,
pub cwd: RwLock<Option<Arc<VfsEntry>>>,
pub mounted_filesystems: RwLock<Vec<Arc<dyn FileSystemOperations>>>,
}
Expand description
VFS Manager v2 - Enhanced VFS architecture implementation
This manager provides advanced VFS functionality with proper mount tree management, enhanced caching, and better support for containerization.
Fields§
§id: VfsManagerId
Unique identifier for this VfsManager instance
mount_tree: MountTree
Mount tree for hierarchical mount point management
cwd: RwLock<Option<Arc<VfsEntry>>>
Current working directory
mounted_filesystems: RwLock<Vec<Arc<dyn FileSystemOperations>>>
Strong references to all currently mounted filesystems
Implementations§
Source§impl VfsManager
impl VfsManager
Sourcepub fn new_with_root(root_fs: Arc<dyn FileSystemOperations>) -> Self
pub fn new_with_root(root_fs: Arc<dyn FileSystemOperations>) -> Self
Create a new VFS manager instance with a specified root filesystem
Sourcepub fn mount(
&self,
filesystem: Arc<dyn FileSystemOperations>,
mount_point_str: &str,
flags: u32,
) -> Result<(), FileSystemError>
pub fn mount( &self, filesystem: Arc<dyn FileSystemOperations>, mount_point_str: &str, flags: u32, ) -> Result<(), FileSystemError>
Mount a filesystem at the specified path
This will mount the given filesystem at the specified mount point. If the mount point is “/”, it will replace the root filesystem.
§Arguments
filesystem
- The filesystem to mount.mount_point_str
- The path where the filesystem should be mounted.flags
- Flags for the mount operation (e.g., read-only).
§Errors
Returns an error if the mount point is invalid, the filesystem cannot be mounted, or if the mount operation fails.
Sourcepub fn unmount(&self, mount_point_str: &str) -> Result<(), FileSystemError>
pub fn unmount(&self, mount_point_str: &str) -> Result<(), FileSystemError>
Sourcepub fn bind_mount(
&self,
source_path: &str,
target_path: &str,
) -> Result<(), FileSystemError>
pub fn bind_mount( &self, source_path: &str, target_path: &str, ) -> Result<(), FileSystemError>
Bind mount a directory from source_path to target_path
This will create a bind mount where the source directory is mounted at the target path.
§Arguments
source_path
- The path of the source directory to bind mount.target_path
- The path where the source directory should be mounted.
§Errors
Returns an error if the source is not a directory, the target is already a mount point, or if the source is not a valid directory.
Sourcepub fn bind_mount_from(
&self,
source_vfs: &Arc<VfsManager>,
source_path: &str,
target_path: &str,
) -> Result<(), FileSystemError>
pub fn bind_mount_from( &self, source_vfs: &Arc<VfsManager>, source_path: &str, target_path: &str, ) -> Result<(), FileSystemError>
Bind mount a directory from another VFS instance
This will create a bind mount where the source directory from another VFS is mounted at the target path in this VFS.
§Arguments
source_vfs
- The source VFS instance containing the directory to bindsource_path
- The path of the source directory in the source VFS.target_path
- The path where the source directory should be mounted in this VFS.
§Errors
Returns an error if the source path does not exist, the target is already a mount point, or if the source is not a valid directory.
Sourcefn bind_mount_entry(
&self,
source_entry: Arc<VfsEntry>,
source_mount_point: Arc<MountPoint>,
target_entry: Arc<VfsEntry>,
target_mount_point: Arc<MountPoint>,
) -> Result<(), FileSystemError>
fn bind_mount_entry( &self, source_entry: Arc<VfsEntry>, source_mount_point: Arc<MountPoint>, target_entry: Arc<VfsEntry>, target_mount_point: Arc<MountPoint>, ) -> Result<(), FileSystemError>
Create a bind mount from source_entry to target_entry
Sourcepub fn open(
&self,
path: &str,
flags: u32,
) -> Result<KernelObject, FileSystemError>
pub fn open( &self, path: &str, flags: u32, ) -> Result<KernelObject, FileSystemError>
Open a file at the specified path
This will resolve the path using the MountTreeV2 and open the file using the filesystem associated with the resolved VfsEntry.
§Arguments
path
- The path of the file to open.flags
- Flags for opening the file (e.g., read, writeO_CREAT
, etc.).
§Errors
Returns an error if the path does not exist, is not a file, or if the filesystem cannot be resolved.
Sourcepub fn create_file(
&self,
path: &str,
file_type: FileType,
) -> Result<(), FileSystemError>
pub fn create_file( &self, path: &str, file_type: FileType, ) -> Result<(), FileSystemError>
Create a file at the specified path
This will create a new file in the filesystem at the given path.
§Arguments
path
- The path where the file should be created.file_type
- The type of file to create (e.g., regular file, directory, etc.).
§Errors
Returns an error if the parent directory does not exist, the filesystem cannot be resolved, or if the file cannot be created.
Sourcepub fn create_dir(&self, path: &str) -> Result<(), FileSystemError>
pub fn create_dir(&self, path: &str) -> Result<(), FileSystemError>
Create a directory at the specified path
This will create a new directory in the filesystem at the given path.
§Arguments
path
- The path where the directory should be created.
§Errors
Returns an error if the parent directory does not exist, the filesystem cannot be resolved, or if the directory cannot be created.
Sourcepub fn create_symlink(
&self,
path: &str,
target_path: &str,
) -> Result<(), FileSystemError>
pub fn create_symlink( &self, path: &str, target_path: &str, ) -> Result<(), FileSystemError>
Create a symbolic link at the specified path
This will create a new symbolic link in the filesystem at the given path, pointing to the specified target path.
§Arguments
path
- The path where the symbolic link should be created.target_path
- The path that the symbolic link should point to.
§Errors
Returns an error if the parent directory does not exist, the filesystem cannot be resolved, or if the symbolic link cannot be created.
Sourcepub fn remove(&self, path: &str) -> Result<(), FileSystemError>
pub fn remove(&self, path: &str) -> Result<(), FileSystemError>
Sourcepub fn metadata(&self, path: &str) -> Result<FileMetadata, FileSystemError>
pub fn metadata(&self, path: &str) -> Result<FileMetadata, FileSystemError>
Get metadata for a file at the specified path
This will resolve the path using the MountTreeV2 and return the metadata for the file represented by the resolved VfsEntry.
§Arguments
path
- The path of the file to get metadata for.
§Errors
Returns an error if the path does not exist, is not a file, or if the filesystem cannot be resolved.
Sourcepub fn readdir(
&self,
path: &str,
) -> Result<Vec<DirectoryEntryInternal>, FileSystemError>
pub fn readdir( &self, path: &str, ) -> Result<Vec<DirectoryEntryInternal>, FileSystemError>
Read directory entries at the specified path
This will resolve the path using the MountTreeV2 and return a list of directory entries for the directory represented by the resolved VfsEntry.
§Arguments
path
- The path of the directory to read.
§Errors
Returns an error if the path does not exist, is not a directory, or if the filesystem cannot be resolved.
Sourcepub fn set_cwd(&self, path: &str) -> Result<(), FileSystemError>
pub fn set_cwd(&self, path: &str) -> Result<(), FileSystemError>
Sourcepub fn get_cwd(&self) -> Option<Arc<VfsEntry>>
pub fn get_cwd(&self) -> Option<Arc<VfsEntry>>
Get current working directory
This returns the current working directory as an Arc<VfsEntry>
.
If the current working directory is not set, it returns None
.
§Returns
An Option<Arc<VfsEntry>>
containing the current working directory entry,
or None
if the current working directory is not set.
Sourcepub fn create_device_file(
&self,
path: &str,
device_info: DeviceFileInfo,
) -> Result<(), FileSystemError>
pub fn create_device_file( &self, path: &str, device_info: DeviceFileInfo, ) -> Result<(), FileSystemError>
Create a device file
This will create a new device file in the filesystem at the given path.
§Arguments
path
- The path where the device file should be created.device_info
- Information about the device file to create (e.g., device type, major/minor numbers, etc.).
§Errors
Returns an error if the parent directory does not exist, the filesystem cannot be resolved, or if the device file cannot be created.
pub fn resolve_path(&self, path: &str) -> Result<Arc<VfsEntry>, FileSystemError>
Sourcepub fn resolve_path_with_options(
&self,
path: &str,
options: &PathResolutionOptions,
) -> Result<Arc<VfsEntry>, FileSystemError>
pub fn resolve_path_with_options( &self, path: &str, options: &PathResolutionOptions, ) -> Result<Arc<VfsEntry>, FileSystemError>
Resolve a path with specified options
Sourcepub fn create_hardlink(
&self,
source_path: &str,
target_path: &str,
) -> Result<(), FileSystemError>
pub fn create_hardlink( &self, source_path: &str, target_path: &str, ) -> Result<(), FileSystemError>
Create a hard link
This will create a hard link where the source file is linked to the target path. Both paths will refer to the same underlying file data.
§Arguments
source_path
- Path of the existing file to link totarget_path
- Path where the hard link should be created
§Errors
Returns an error if the source doesn’t exist, target already exists, filesystems don’t match, or hard links aren’t supported.
Sourcefn split_parent_child(
&self,
path: &str,
) -> Result<(String, String), FileSystemError>
fn split_parent_child( &self, path: &str, ) -> Result<(String, String), FileSystemError>
Split a path into parent directory and filename