pub trait BlockDevice {
// Required methods
fn read_blocks(&mut self, lba: u64, buf: &mut [u8]) -> Result<(), FsError>;
fn write_blocks(&mut self, lba: u64, buf: &[u8]) -> Result<(), FsError>;
fn block_size(&self) -> usize;
fn num_blocks(&self) -> u64;
fn flush(&mut self) -> Result<(), FsError>;
}
Expand description
Block device abstraction used by the filesystem layer.
Implementors provide sector-based access to a storage medium.
Required Methods§
Sourcefn read_blocks(&mut self, lba: u64, buf: &mut [u8]) -> Result<(), FsError>
fn read_blocks(&mut self, lba: u64, buf: &mut [u8]) -> Result<(), FsError>
Read blocks starting at lba
into buf
.
Sourcefn write_blocks(&mut self, lba: u64, buf: &[u8]) -> Result<(), FsError>
fn write_blocks(&mut self, lba: u64, buf: &[u8]) -> Result<(), FsError>
Write blocks starting at lba
from buf
.
Implementations may leave this unimplemented if the device is read-only.
Sourcefn block_size(&self) -> usize
fn block_size(&self) -> usize
Return the logical block size in bytes.
Sourcefn num_blocks(&self) -> u64
fn num_blocks(&self) -> u64
Return the total number of addressable blocks.