pub struct TmpFS {
root: RwLock<Arc<TmpNode>>,
memory_limit: usize,
current_memory: Mutex<usize>,
next_file_id: Mutex<u64>,
name: String,
}
Expand description
TmpFS v2 - New memory-based filesystem implementation
This struct implements an in-memory filesystem for VFS v2.
It supports regular files, directories, and device nodes, with optional memory usage limits.
The internal structure is based on TmpNode
and uses locking for thread safety.
Fields§
§root: RwLock<Arc<TmpNode>>
Root directory node
memory_limit: usize
Memory limit (0 = unlimited)
current_memory: Mutex<usize>
Current memory usage
next_file_id: Mutex<u64>
Next file ID generator
name: String
Filesystem name
Implementations§
Source§impl TmpFS
impl TmpFS
Sourcepub fn new(memory_limit: usize) -> Arc<Self>
pub fn new(memory_limit: usize) -> Arc<Self>
Create a new TmpFS instance (two-phase initialization)
Sourcepub fn create_from_option_string(
option: Option<&str>,
) -> Arc<dyn FileSystemOperations>
pub fn create_from_option_string( option: Option<&str>, ) -> Arc<dyn FileSystemOperations>
VFS v2 driver registration API: create from option string Example option: “mem=1048576” etc.
Sourcefn generate_file_id(&self) -> u64
fn generate_file_id(&self) -> u64
Generate next unique file ID
Sourcefn check_memory_limit(
&self,
additional_bytes: usize,
) -> Result<(), FileSystemError>
fn check_memory_limit( &self, additional_bytes: usize, ) -> Result<(), FileSystemError>
Check memory limit
Sourcefn add_memory_usage(&self, bytes: usize)
fn add_memory_usage(&self, bytes: usize)
Add to memory usage
Sourcefn subtract_memory_usage(&self, bytes: usize)
fn subtract_memory_usage(&self, bytes: usize)
Subtract from memory usage
Trait Implementations§
Source§impl FileSystemOperations for TmpFS
impl FileSystemOperations for TmpFS
Source§fn create_hardlink(
&self,
link_parent: &Arc<dyn VfsNode>,
link_name: &String,
target_node: &Arc<dyn VfsNode>,
) -> Result<Arc<dyn VfsNode>, FileSystemError>
fn create_hardlink( &self, link_parent: &Arc<dyn VfsNode>, link_name: &String, target_node: &Arc<dyn VfsNode>, ) -> Result<Arc<dyn VfsNode>, FileSystemError>
Create a hard link to an existing file
This function creates a new directory entry (hard link) for an existing file. Both the link and the target must be in the same filesystem. The link count of the target file is incremented. Returns the target node (the same inode as the original file).