FabricFs

Struct FabricFs 

Source
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

Source

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.

Source

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.

Source

pub fn create(&mut self, path: &str) -> Result<FileHandle>

Create a file at the given path and return a writable handle.

Source

pub fn open(&mut self, path: &str, flags: OpenFlags) -> Result<FileHandle>

Open a file at the given path with the specified flags.

Source

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.

Source

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.

Source

pub fn seek(&mut self, handle: &mut FileHandle, pos: SeekFrom) -> Result<u64>

Seek to a position in an open file.

Source

pub fn close(&mut self, _handle: FileHandle) -> Result<()>

Close an open file handle.

Source

pub fn remove(&mut self, path: &str) -> Result<()>

Remove a file at the given path.

Source

pub fn readdir(&mut self, path: &str) -> Result<Vec<DirEntry>>

List entries in the directory at the given path.

Source

pub fn stat(&mut self, path: &str) -> Result<FileStat>

Get file metadata for the given path.

Source

pub fn mkdir(&mut self, path: &str) -> Result<()>

Create a directory at the given path.

Source

pub fn sync(&mut self) -> Result<()>

Flush all dirty metadata and data to block storage.

Source

pub fn unmount(self) -> Result<Vec<BlockLease>>

Sync and release all leases.

Source

pub fn set_stripe_threshold(&mut self, threshold: u64)

Set the stripe threshold in bytes.

Source

pub fn set_stripe_size(&mut self, size: u32)

Set the stripe size in blocks.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.