⚠️ 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: 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§

Source

fn read_block( &mut self, block_num: u64, buf: &mut [u8], ) -> Result<(), KernelError>

Read a block (512 bytes) at the given sector number.

Source

fn write_block( &mut self, block_num: u64, data: &[u8], ) -> Result<(), KernelError>

Write a block (512 bytes) at the given sector number.

Source

fn capacity_sectors(&self) -> u64

Get the device capacity in sectors.

Source

fn is_read_only(&self) -> bool

Check if the device is read-only.

Provided Methods§

Source

fn block_size(&self) -> usize

Get the block size in bytes.

Implementors§