pub trait DiskBackend: Send + Sync {
// Required methods
fn read_block(
&self,
block_num: u64,
buf: &mut [u8],
) -> Result<(), KernelError>;
fn write_block(
&self,
block_num: u64,
data: &[u8],
) -> Result<(), KernelError>;
fn block_count(&self) -> u64;
fn is_read_only(&self) -> bool;
}Expand description
Trait for a block-level disk backend that BlockFS can sync to.
Operates on BlockFS-sized blocks (4KB). Implementations are responsible for translating to the underlying device’s sector size (typically 512 bytes).
Required Methods§
Sourcefn read_block(&self, block_num: u64, buf: &mut [u8]) -> Result<(), KernelError>
fn read_block(&self, block_num: u64, buf: &mut [u8]) -> Result<(), KernelError>
Read a single 4KB block from the disk.
block_num is the 0-based BlockFS block index.
buf must be at least BLOCK_SIZE (4096) bytes.
Sourcefn write_block(&self, block_num: u64, data: &[u8]) -> Result<(), KernelError>
fn write_block(&self, block_num: u64, data: &[u8]) -> Result<(), KernelError>
Write a single 4KB block to the disk.
block_num is the 0-based BlockFS block index.
data must be at least BLOCK_SIZE (4096) bytes.
Sourcefn block_count(&self) -> u64
fn block_count(&self) -> u64
Total capacity in BlockFS-sized blocks (4KB each).
Sourcefn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Whether the device is read-only.