pub trait BlockDevice: Send + Sync {
// Required methods
fn read_block(
&mut self,
block_num: u64,
buf: &mut [u8],
) -> Result<(), KernelError>;
fn write_block(
&mut self,
block_num: u64,
data: &[u8],
) -> Result<(), KernelError>;
fn capacity_sectors(&self) -> u64;
fn is_read_only(&self) -> bool;
// Provided method
fn block_size(&self) -> usize { ... }
}Expand description
Block device trait for generic block I/O operations.
Required Methods§
Sourcefn read_block(
&mut self,
block_num: u64,
buf: &mut [u8],
) -> Result<(), KernelError>
fn read_block( &mut self, block_num: u64, buf: &mut [u8], ) -> Result<(), KernelError>
Read a block (512 bytes) at the given sector number.
Sourcefn write_block(
&mut self,
block_num: u64,
data: &[u8],
) -> Result<(), KernelError>
fn write_block( &mut self, block_num: u64, data: &[u8], ) -> Result<(), KernelError>
Write a block (512 bytes) at the given sector number.
Sourcefn capacity_sectors(&self) -> u64
fn capacity_sectors(&self) -> u64
Get the device capacity in sectors.
Sourcefn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Check if the device is read-only.
Provided Methods§
Sourcefn block_size(&self) -> usize
fn block_size(&self) -> usize
Get the block size in bytes.