Struct VfsManager

Source
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

Source

pub fn new() -> Self

Create a new VFS manager instance with a dummy root

Source

pub fn new_with_root(root_fs: Arc<dyn FileSystemOperations>) -> Self

Create a new VFS manager instance with a specified root filesystem

Source

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.

Source

pub fn unmount(&self, mount_point_str: &str) -> Result<(), FileSystemError>

Unmount a mount point at the specified path

This will remove the mount point from the mount tree and clean up any associated resources.

§Arguments
  • mount_point_str - The path of the mount point to unmount.
§Errors

Returns an error if the mount point is not valid or if the unmount operation fails.

Source

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.

Source

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 bind
  • source_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.

Source

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

Source

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, write
  • O_CREAT, etc.).
§Errors

Returns an error if the path does not exist, is not a file, or if the filesystem cannot be resolved.

Source

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.

Source

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.

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.

Source

pub fn remove(&self, path: &str) -> Result<(), FileSystemError>

Remove a file at the specified path

This will remove the file from the filesystem and update the mount tree.

§Arguments
  • path - The path of the file to remove.
§Errors

Returns an error if the path does not exist, is not a file, or if the filesystem cannot be resolved.

Source

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.

Source

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.

Source

pub fn set_cwd(&self, path: &str) -> Result<(), FileSystemError>

Set current working directory

This will change the current working directory to the specified path.

§Arguments
  • path - The path to set as the current working directory.
§Errors

Returns an error if the path does not exist, is not a directory, or if the filesystem cannot be resolved.

Source

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.

Source

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.

Source

pub fn resolve_path(&self, path: &str) -> Result<Arc<VfsEntry>, FileSystemError>

Source

pub fn resolve_path_with_options( &self, path: &str, options: &PathResolutionOptions, ) -> Result<Arc<VfsEntry>, FileSystemError>

Resolve a path with specified options

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 to
  • target_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.

Source

fn split_parent_child( &self, path: &str, ) -> Result<(String, String), FileSystemError>

Split a path into parent directory and filename

Auto Trait Implementations§

§

impl !Freeze for VfsManager

§

impl !RefUnwindSafe for VfsManager

§

impl Send for VfsManager

§

impl Sync for VfsManager

§

impl Unpin for VfsManager

§

impl !UnwindSafe for VfsManager

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.