⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

BlockDevice

Trait BlockDevice 

Source
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§

Source

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.

Source

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.

Source

fn block_size(&self) -> u32

Get the block (sector) size in bytes

Source

fn total_blocks(&self) -> u64

Get the total number of blocks on the device

Implementors§