Module disk_layout

Module disk_layout 

Source
Expand description

on-disk layout of the file system’s metadata structures.

This module defines the on-disk layout of the file system’s core metadata structures. These types represent raw disk-resident data such as the superblock, block/inode allocation bitmaps, and inode table. Each struct in this module is tightly packed and designed to match the exact binary layout used by the file system when persisting and loading from disk.

This module defines MetaData trait, and support MetaData::load method, allowing them to be generically loaded from a logical block address (LBA).

§Examples of accessing metadata.

use crate::ffs::disk_layout::{MetaData, BlockBitmap};

let block_bitmap = BlockBitmap::load(ffs, lba)?; // read BlockPointsTo<BlockBitMap> from lba.
{ // READ
    let guard = block_bitmap.read(); // reading metadata does not requires transaction.
    assert!(guard.is_allocated(0));
}
{ // WRITE
    let tx = ffs.open_transaction(); // Open a new transaction. Only a single transaction can be existed.
    let mut guard = block_bitmap.write(&tx); // writing metadata requires transaction.
    guard.try_allocate(1);
    guard.submit(); // Submit the modified change to the transaction.
}

Structs§

BlockBitmap
Represents the on-disk block allocation bitmap for the file system.
DirectoryBlock
Represents a block that contains multiple directory entries.
DirectoryBlockEntry
Represent a single directory entry within a directory block.
IndirectBlock
Represents an indirect block in the filesystem.
Inode
Represent a single inode within a inode array.
InodeArray
Represents a fixed-size array of inodes loaded from a block.
InodeBitmap
Represents the on-disk inode allocation bitmap for the file system.
JournalSb
Represents the on-disk metadata for the journal superblock.
JournalTxBegin
Represents a journal transaction header used to track modified blocks.
JournalTxEnd
Represents a journal transaction is ended.
SuperBlock
On-disk representation of the superblock of the Fast File System (FFS).