pub struct FilesystemMut<D: BlockDevice + 'static> { /* private fields */ }Expand description
Mutable mounted filesystem shell backed by a real block device.
The mounted view owns the device and keeps a read-only parser view pointed
at that same device through a small block cache. Mounted mutations commit
through the block-device/cache layer only. Unsupported native transaction
shapes return Error::Unsupported instead of falling back to a hidden
capacity-sized image allocation.
Implementations§
§impl<D: BlockDevice + 'static> FilesystemMut<D>
impl<D: BlockDevice + 'static> FilesystemMut<D>
pub fn refresh(&mut self) -> Result<()>
pub fn refresh(&mut self) -> Result<()>
Reparses visible filesystem state from the owned block device. Write methods call this after durable commits so subsequent reads observe exactly what a remount would observe, without keeping a resident metadata-block image.
pub fn as_filesystem(&self) -> &Filesystem<'static>
pub fn as_filesystem(&self) -> &Filesystem<'static>
Returns the mounted read-only metadata view.
This is useful for metadata-only inspection such as stat, read_dir,
attrs, global state, and directory usage. For file payload reads through
a mutable mount, prefer FilesystemMut::read_file or file handles:
CTZ data blocks intentionally stay on the owned block device and are
fetched through the view’s small read cache instead of being copied into
a resident metadata snapshot.
pub fn info(&self) -> &FsInfo
pub fn limits(&self) -> FilesystemLimits
pub fn directory_usage(&self, path: &str) -> Result<DirectoryUsage>
pub fn used_blocks(&self) -> Result<Vec<bool>>
pub fn read_dir(&self, path: &str) -> Result<Vec<DirEntry>>
pub fn read_dir_with<F>(&self, path: &str, visitor: F) -> Result<()>
pub fn open_dir<'fs>(&'fs self, path: &str) -> Result<DirHandle<'fs, 'static>>
pub fn read_file(&self, path: &str) -> Result<Vec<u8>>
pub fn read_attr(&self, path: &str, attr_type: u8) -> Result<Vec<u8>>
pub fn read_attr_into( &self, path: &str, attr_type: u8, out: &mut [u8], ) -> Result<usize>
pub fn walk(&self, path: &str) -> Result<Vec<WalkEntry>>
pub fn walk_with<F>(&self, path: &str, visitor: F) -> Result<()>
pub fn create_file(&mut self, path: &str, data: &[u8]) -> Result<()>
pub fn create_file(&mut self, path: &str, data: &[u8]) -> Result<()>
Creates a file through native mounted transactions only.
The mounted API must not silently materialize the whole block device in
RAM. If a path shape is not covered by the native writer yet, callers get
Unsupported instead of a hidden block_size * block_count allocation.
pub fn write_file(&mut self, path: &str, data: &[u8]) -> Result<()>
pub fn write_file(&mut self, path: &str, data: &[u8]) -> Result<()>
Creates or replaces a file with the provided bytes through native paths.
pub fn append_file(&mut self, path: &str, data: &[u8]) -> Result<()>
pub fn rename_file(&mut self, from: &str, to: &str) -> Result<()>
pub fn rename_file(&mut self, from: &str, to: &str) -> Result<()>
Renames a file by copying visible bytes to the new path and removing the old path.
This is not yet littlefs’s atomic rename transaction. It is a deliberate mounted-API milestone that gives users same-content rename semantics on top of already C-verified create/delete operations. Power-loss tests will force this into a true atomic metadata operation later.
pub fn rename_dir(&mut self, from: &str, to: &str) -> Result<()>
pub fn remove_file(&mut self, path: &str) -> Result<()>
pub fn set_attr(&mut self, path: &str, attr_type: u8, data: &[u8]) -> Result<()>
pub fn remove_attr(&mut self, path: &str, attr_type: u8) -> Result<()>
pub fn create_dir(&mut self, path: &str) -> Result<()>
pub fn remove_dir(&mut self, path: &str) -> Result<()>
pub fn create_file_writer<'fs>( &'fs mut self, path: &str, ) -> Result<FileWriter<'fs, D>>
pub fn open_file<'fs>( &'fs mut self, path: &str, options: FileOptions, ) -> Result<FileHandle<'fs, D>>
pub fn sync(&mut self) -> Result<()>
pub fn set_block_cycles(&mut self, block_cycles: Option<u32>)
pub fn set_block_cycles(&mut self, block_cycles: Option<u32>)
Configures the mounted metadata relocation threshold.
littlefs treats block_cycles as a wear-leveling hint: once a metadata
pair has been compacted enough times, the pair should move to freshly
allocated blocks and its parent should be updated to point at the new
pair. None disables this mounted-writer relocation policy. The default
mirrors the C fixture (128), while tests can lower the value to force
relocation without hundreds of commits.