Expand description
Block-based persistent filesystem (BlockFS)
A simple ext2-like filesystem with:
- Superblock with metadata
- Inode table for file/directory metadata
- Block allocation bitmap
- Data blocks for file content
Structs§
- Block
Bitmap - Block allocation bitmap
- BlockFs
- BlockFS filesystem
- Block
FsInner - Internal BlockFS state
- Block
FsNode - BlockFS node implementation
- Disk
DirEntry - On-disk directory entry (ext2-style variable-length record)
- Disk
Inode - On-disk inode structure
- Superblock
- Superblock structure
- Virtio
Block Backend - Adapter that wraps the global virtio-blk device as a
DiskBackend.
Constants§
- BLOCKFS_
MAGIC - Magic number for BlockFS
- BLOCK_
SIZE - Block size (4KB)
- DIRECT_
BLOCKS - Number of direct block pointers in a DiskInode
- DIRECT_
MAX_ BLOCKS - Maximum file size addressable via direct blocks only: 12 * 4KB = 48KB
- DIR_
ENTRY_ HEADER_ SIZE - Size of the fixed header in a DiskDirEntry (inode + rec_len + name_len + file_type)
- DOUBLE_
INDIRECT_ MAX_ BLOCKS - Maximum file size addressable via direct + single + double indirect: 12 + 1024 + 1024*1024 = 1_049_612 blocks = ~4GB
- MAX_
FILENAME_ LEN - Maximum filename length
- PTRS_
PER_ BLOCK - Number of block pointers that fit in one indirect block (4096 / 4 = 1024)
- SINGLE_
INDIRECT_ MAX_ BLOCKS - Maximum file size addressable via direct + single indirect: 12 + 1024 = 1036 blocks = ~4MB
Traits§
- Disk
Backend - Trait for a block-level disk backend that BlockFS can sync to.
Functions§
- attach_
virtio_ backend - Try to attach the virtio-blk device as a disk backend for the given
BlockFS instance. Returns
trueif a device was found and attached. - init
- Initialize BlockFS