Struct TmpFS

Source
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

Source

pub fn new(memory_limit: usize) -> Arc<Self>

Create a new TmpFS instance (two-phase initialization)

Source

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.

Source

fn generate_file_id(&self) -> u64

Generate next unique file ID

Source

fn check_memory_limit( &self, additional_bytes: usize, ) -> Result<(), FileSystemError>

Check memory limit

Source

fn add_memory_usage(&self, bytes: usize)

Add to memory usage

Source

fn subtract_memory_usage(&self, bytes: usize)

Subtract from memory usage

Trait Implementations§

Source§

impl FileSystemOperations for TmpFS

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).

Source§

fn lookup( &self, parent_node: &Arc<dyn VfsNode>, name: &String, ) -> Result<Arc<dyn VfsNode>, FileSystemError>

Look up a child node by name within a parent directory Read more
Source§

fn open( &self, node: &Arc<dyn VfsNode>, _flags: u32, ) -> Result<Arc<dyn FileObject>, FileSystemError>

Open a file represented by a VfsNode Read more
Source§

fn create( &self, parent_node: &Arc<dyn VfsNode>, name: &String, file_type: FileType, _mode: u32, ) -> Result<Arc<dyn VfsNode>, FileSystemError>

Create a new file in the specified directory
Source§

fn remove( &self, parent_node: &Arc<dyn VfsNode>, name: &String, ) -> Result<(), FileSystemError>

Remove a file from the specified directory
Source§

fn readdir( &self, node: &Arc<dyn VfsNode>, ) -> Result<Vec<DirectoryEntryInternal>, FileSystemError>

Read directory entries from a directory node
Source§

fn root_node(&self) -> Arc<dyn VfsNode>

Get the root VfsNode for this filesystem
Source§

fn name(&self) -> &str

Get filesystem name
Source§

fn is_read_only(&self) -> bool

Check if filesystem is read-only

Auto Trait Implementations§

§

impl !Freeze for TmpFS

§

impl !RefUnwindSafe for TmpFS

§

impl Send for TmpFS

§

impl Sync for TmpFS

§

impl Unpin for TmpFS

§

impl !UnwindSafe for TmpFS

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.