pub struct FabricFs { /* private fields */ }Expand description
Distributed filesystem backed by leased block storage.
Stores metadata (inodes, directory entries) and data on one or more
BlockLeases. Files larger than stripe_threshold are striped
round-robin across all leases.
Implementations§
Source§impl FabricFs
impl FabricFs
Sourcepub fn format(leases: Vec<BlockLease>) -> Result<Self>
pub fn format(leases: Vec<BlockLease>) -> Result<Self>
Format leases with a fresh filesystem and return a mounted instance.
Writes a superblock to block 0, initializes the free bitmap and inode table, and creates the root directory inode.
Sourcepub fn mount(leases: Vec<BlockLease>) -> Result<Self>
pub fn mount(leases: Vec<BlockLease>) -> Result<Self>
Mount an existing filesystem from leases.
Reads the superblock, validates the magic and version, and populates the inode and directory caches for the root directory.
Sourcepub fn create(&mut self, path: &str) -> Result<FileHandle>
pub fn create(&mut self, path: &str) -> Result<FileHandle>
Create a file at the given path and return a writable handle.
Sourcepub fn open(&mut self, path: &str, flags: OpenFlags) -> Result<FileHandle>
pub fn open(&mut self, path: &str, flags: OpenFlags) -> Result<FileHandle>
Open a file at the given path with the specified flags.
Sourcepub fn read(&self, handle: &FileHandle, buf: &mut [u8]) -> Result<usize>
pub fn read(&self, handle: &FileHandle, buf: &mut [u8]) -> Result<usize>
Read from an open file handle into buf.
Returns the number of bytes read. Returns 0 at EOF.
Sourcepub fn write(&mut self, handle: &mut FileHandle, data: &[u8]) -> Result<usize>
pub fn write(&mut self, handle: &mut FileHandle, data: &[u8]) -> Result<usize>
Write data to an open file handle.
Returns the number of bytes written.
Sourcepub fn seek(&mut self, handle: &mut FileHandle, pos: SeekFrom) -> Result<u64>
pub fn seek(&mut self, handle: &mut FileHandle, pos: SeekFrom) -> Result<u64>
Seek to a position in an open file.
Sourcepub fn close(&mut self, _handle: FileHandle) -> Result<()>
pub fn close(&mut self, _handle: FileHandle) -> Result<()>
Close an open file handle.
Sourcepub fn readdir(&mut self, path: &str) -> Result<Vec<DirEntry>>
pub fn readdir(&mut self, path: &str) -> Result<Vec<DirEntry>>
List entries in the directory at the given path.
Sourcepub fn unmount(self) -> Result<Vec<BlockLease>>
pub fn unmount(self) -> Result<Vec<BlockLease>>
Sync and release all leases.
Sourcepub fn set_stripe_threshold(&mut self, threshold: u64)
pub fn set_stripe_threshold(&mut self, threshold: u64)
Set the stripe threshold in bytes.
Sourcepub fn set_stripe_size(&mut self, size: u32)
pub fn set_stripe_size(&mut self, size: u32)
Set the stripe size in blocks.