pub trait FileSystemDriver: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn filesystem_type(&self) -> FileSystemType;
// Provided methods
fn create_from_block(
&self,
_block_device: Box<dyn BlockDevice>,
_block_size: usize,
) -> Result<Box<dyn VirtualFileSystem>> { ... }
fn create_from_memory(
&self,
_memory_area: &MemoryArea,
) -> Result<Box<dyn VirtualFileSystem>> { ... }
fn create(&self) -> Result<Box<dyn VirtualFileSystem>> { ... }
fn create_with_params(
&self,
params: &dyn FileSystemParams,
) -> Result<Box<dyn VirtualFileSystem>> { ... }
}
Expand description
Trait for file system drivers
This trait is used to create file systems from block devices or memory areas. It is not intended to be used directly by the VFS manager. Instead, the VFS manager will use the appropriate creation method based on the source.
Required Methods§
Sourcefn filesystem_type(&self) -> FileSystemType
fn filesystem_type(&self) -> FileSystemType
Get the type of the file system
Provided Methods§
Sourcefn create_from_block(
&self,
_block_device: Box<dyn BlockDevice>,
_block_size: usize,
) -> Result<Box<dyn VirtualFileSystem>>
fn create_from_block( &self, _block_device: Box<dyn BlockDevice>, _block_size: usize, ) -> Result<Box<dyn VirtualFileSystem>>
Create a file system from a block device
When implementing this method, ensure that the file system driver can handle block device-based creation. If the driver does not support this, return an appropriate error.
§Arguments
_block_device
- The block device to use for creating the file system_block_size
- The block size of the device
Sourcefn create_from_memory(
&self,
_memory_area: &MemoryArea,
) -> Result<Box<dyn VirtualFileSystem>>
fn create_from_memory( &self, _memory_area: &MemoryArea, ) -> Result<Box<dyn VirtualFileSystem>>
Create a file system from a memory area
When implementing this method, ensure that the file system driver can handle memory-based creation. If the driver does not support this, return an appropriate error.
§Notes
File system drivers must validate the provided MemoryArea to ensure it is valid. If the MemoryArea is invalid, the driver should return an appropriate error.
§Arguments
_memory_area
- The memory area to use for creating the file system
§Returns
Result<Box<dyn VirtualFileSystem>>
- The created file system
fn create(&self) -> Result<Box<dyn VirtualFileSystem>>
Sourcefn create_with_params(
&self,
params: &dyn FileSystemParams,
) -> Result<Box<dyn VirtualFileSystem>>
fn create_with_params( &self, params: &dyn FileSystemParams, ) -> Result<Box<dyn VirtualFileSystem>>
Create a file system with structured parameters
This method creates file systems using type-safe structured parameters that implement the FileSystemParams trait. This approach replaces the old BTreeMap<String, String> approach with better type safety.
§Arguments
params
- Structured parameter implementing FileSystemParams
§Returns
Result<Box<dyn VirtualFileSystem>>
- The created file system
§Note
This method uses dynamic dispatch for parameter handling to support future dynamic filesystem module loading while maintaining type safety.