pub struct BlockFs { /* private fields */ }Expand description
BlockFS filesystem
Implementations§
Source§impl BlockFs
impl BlockFs
pub fn new(block_count: u32, inode_count: u32) -> Self
pub fn format(block_count: u32, inode_count: u32) -> Result<Self, KernelError>
Sourcepub fn open_existing(
backend: Arc<Mutex<dyn DiskBackend>>,
) -> Result<Self, KernelError>
pub fn open_existing( backend: Arc<Mutex<dyn DiskBackend>>, ) -> Result<Self, KernelError>
Open an existing BlockFS from a disk backend.
Reads the superblock, validates the magic number, and loads the bitmap, inode table, and all data blocks into memory. The disk backend remains attached for subsequent sync operations.
Sourcepub fn set_disk_backend(
&self,
backend: Arc<Mutex<dyn DiskBackend>>,
load: bool,
) -> Result<(), KernelError>
pub fn set_disk_backend( &self, backend: Arc<Mutex<dyn DiskBackend>>, load: bool, ) -> Result<(), KernelError>
Attach a disk backend for persistent storage.
When a disk backend is attached, sync() will write all dirty blocks
to the device. Without a backend, BlockFS operates as a pure RAM
filesystem.
If load is true, existing data is read from the disk into memory.
Sourcepub fn detach_disk_backend(&self)
pub fn detach_disk_backend(&self)
Detach the disk backend. Outstanding dirty blocks will NOT be flushed;
call sync() first if persistence is needed.
Sourcepub fn dirty_block_count(&self) -> usize
pub fn dirty_block_count(&self) -> usize
Get the number of dirty blocks pending sync.