pub trait BlockDevice {
// Required methods
fn read_blocks(
&self,
lba: u64,
count: u32,
buf: &mut [u8],
) -> Result<usize, KernelError>;
fn write_blocks(
&self,
lba: u64,
count: u32,
buf: &[u8],
) -> Result<usize, KernelError>;
fn block_size(&self) -> u32;
fn total_blocks(&self) -> u64;
}Expand description
Trait for block-level I/O on a storage device
Required Methods§
Sourcefn read_blocks(
&self,
lba: u64,
count: u32,
buf: &mut [u8],
) -> Result<usize, KernelError>
fn read_blocks( &self, lba: u64, count: u32, buf: &mut [u8], ) -> Result<usize, KernelError>
Read count blocks starting at logical block address lba into buf.
Returns the number of bytes actually read.
Sourcefn write_blocks(
&self,
lba: u64,
count: u32,
buf: &[u8],
) -> Result<usize, KernelError>
fn write_blocks( &self, lba: u64, count: u32, buf: &[u8], ) -> Result<usize, KernelError>
Write count blocks starting at logical block address lba from buf.
Returns the number of bytes actually written.
Sourcefn block_size(&self) -> u32
fn block_size(&self) -> u32
Get the block (sector) size in bytes
Sourcefn total_blocks(&self) -> u64
fn total_blocks(&self) -> u64
Get the total number of blocks on the device