#[repr(C, packed(1))]pub struct BlockBitmap {
bits: [u64; 512],
}Expand description
Represents the on-disk block allocation bitmap for the file system.
Each bit in the BlockBitmap corresponds to a single block on disk.
A bit value of 1 indicates that the block is in use, while 0
means the block is free and available for allocation.
Fields§
§bits: [u64; 512]Implementations§
Source§impl BlockBitmap
impl BlockBitmap
Sourcepub fn is_allocated(&self, pos: usize) -> bool
pub fn is_allocated(&self, pos: usize) -> bool
Checks whether a block at the given position is allocated.
§Parameters
pos: The index of the block to check.
§Returns
trueif the block is currently marked as allocated (bit is 1).falseif the block is free (bit is 0).
This method is used to determine the allocation status of a block in the file system’s block bitmap.
Sourcepub fn try_allocate(&mut self, pos: usize) -> bool
pub fn try_allocate(&mut self, pos: usize) -> bool
Attempts to allocate a block at the given position.
§Parameters
pos: The index of the block to allocate.
§Returns
trueif the block was previously free and is now marked as allocated.falseif the block was already allocated (no change).
This method is used during block allocation to claim a free block. If the block is already allocated, it fails without modifying the bitmap.
Sourcepub fn deallocate(&mut self, pos: usize) -> bool
pub fn deallocate(&mut self, pos: usize) -> bool
deallocate a block at the given position.
§Parameters
pos: The index of the block to deallocate.
§Returns
trueif the block was previously free and is now marked as allocated.falseif the block was already allocated (no change).
This method is used during block allocation to claim a free block. If the block is already allocated, it fails without modifying the bitmap.