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

DiskBackend

Trait DiskBackend 

Source
pub trait DiskBackend: Send + Sync {
    // Required methods
    fn read_block(
        &self,
        block_num: u64,
        buf: &mut [u8],
    ) -> Result<(), KernelError>;
    fn write_block(
        &self,
        block_num: u64,
        data: &[u8],
    ) -> Result<(), KernelError>;
    fn block_count(&self) -> u64;
    fn is_read_only(&self) -> bool;
}
Expand description

Trait for a block-level disk backend that BlockFS can sync to.

Operates on BlockFS-sized blocks (4KB). Implementations are responsible for translating to the underlying device’s sector size (typically 512 bytes).

Required Methods§

Source

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

Read a single 4KB block from the disk.

block_num is the 0-based BlockFS block index. buf must be at least BLOCK_SIZE (4096) bytes.

Source

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

Write a single 4KB block to the disk.

block_num is the 0-based BlockFS block index. data must be at least BLOCK_SIZE (4096) bytes.

Source

fn block_count(&self) -> u64

Total capacity in BlockFS-sized blocks (4KB each).

Source

fn is_read_only(&self) -> bool

Whether the device is read-only.

Implementors§