Repository navigation
5 CodaFS Filesystem and Storage
Relevant source files
This section provides a high-level overview of the CadenzaOS storage stack, bridging raw hardware input/output up to the CodaFS filesystem and binary program loaders. CodaFS is designed as a direct, synchronous, block-aligned filesystem with no internal VFS or caching layers src/kernel/fs/coda_fs.zig12-13
As a parent page, this document outlines the macro architecture of the storage system. Detailed technical specifications are delegated to the following child pages:
Title: CodaFS Storage Stack Architecture

Sources: src/kernel/fs/coda_fs.zig:1-30, src/kernel/fs/coda_sm.zig:1-20, src/kernel/drivers/ata.zig:1-18, src/kernel/fs/ata_block_device.zig:1-15
CodaFS relies on a strict on-disk layout anchored by a primary Superblock located at configuration-defined LBA constants (conf.SB_LBA) src/kernel/fs/coda_fs.zig53-86 The superblock records structural invariants such as filesystem magic (CODA_MAGIC), block dimensions, space manager boundaries, and the physical extent of the root directory src/kernel/fs/coda_fs.zig56-63 It also embeds a SystemPolicy which influences telemetry thresholds and future AI-guided behavior src/kernel/fs/coda_fs.zig50-51
File metadata (FileMeta) and directory entries (DirEntry) describe objects on disk, tracking physical storage ranges per file without complex indirection layers src/kernel/fs/coda_file.zig19-64 Directory structures support lookup, addition, and renaming operations directly in-memory src/kernel/fs/coda_file.zig73-118 The CodaFs struct represents a mounted filesystem, holding the Superblock, SpaceManager, and a handle to the root directory src/kernel/fs/coda_fs.zig99-117
For comprehensive coverage of superblock validation, mkfs formatting, path resolution, and directory mutations, see the child page On-Disk Format and Operations.
Sources: src/kernel/fs/coda_fs.zig:53-86, src/kernel/fs/coda_fs.zig:50-51, src/kernel/fs/coda_file.zig:19-64, src/kernel/fs/coda_file.zig:73-118, src/kernel/fs/coda_fs.zig:99-117
The storage subsystem decouples filesystem logic from physical hardware via the generic BlockDevice interface src/kernel/fs/block_device.zig1-25 Hardware drivers like the ATA PIO driver (ata.zig) src/kernel/drivers/ata.zig1-18 are wrapped by partition adapters (ata_block_device.zig) to translate filesystem-relative blocks into absolute disk sectors src/kernel/fs/ata_block_device.zig31-61 Additionally, RAM-backed block devices (ramdisk.zig) provide write-through caching over memory and physical storage src/kernel/fs/ramdisk.zig5-18
Disk space allocation is managed by SpaceManager (coda_sm.zig), which maintains free-space extents (Extent) and persists allocator state via an on-disk header src/kernel/fs/coda_sm.zig37-61 The SpaceManager is initialized either freshly during mkfs or from disk during mountsrc/kernel/fs/coda_fs.zig138-142src/kernel/fs/coda_fs.zig173-178
Title: Block Device Hierarchy

Sources: src/kernel/fs/coda_fs.zig:78-83, src/kernel/fs/coda_sm.zig:37-61, src/kernel/fs/block_device.zig:1-25, src/kernel/fs/ata_block_device.zig:31-61, src/kernel/fs/ramdisk.zig:5-18, src/kernel/drivers/ata.zig:69-84, src/kernel/fs/coda_fs.zig:138-142, src/kernel/fs/coda_fs.zig:173-178
For complete details on first-fit extent allocation, RAM disk drivers, and ATA polling routines, see the child page Space Manager and Block Devices.
Sources: src/kernel/fs/coda_sm.zig:37-61, src/kernel/fs/block_device.zig:1-25, src/kernel/fs/ata_block_device.zig:31-61, src/kernel/fs/ramdisk.zig:5-18, src/kernel/drivers/ata.zig:1-18
Userland and system executables stored within CodaFS conform to the custom CDZP flat binary format. Every program image begins with a structured binary header containing magic values ('CDZP'), version metadata, image sizes, and entry point offsets.
Build-time tools (tools/pack.sh) bundle compiled binaries into storable disk images, while kernel loaders handle embedded application installation and spawn-time memory preparation.
For technical breakdowns of header validation rules, linker script integration, and process image loading, see the child page Binary Format and Program Loading.
Sources: src/kernel/fs/coda_fs.zig:1-30
- Overview
- Getting Started and Build System
- Kernel Configuration and Global State
- Project Governance and Contributing
- Boot and Early Kernel Initialization
- Bootloader Stages and Linking
- kmain Boot Sequence
- Splash Screen and Branding
- Interrupts, Scheduling, and Syscalls
- IDT, PIC, APIC and IRQ Stubs
- Scheduler and Task Lifecycle
- System Call Interface
- Demonstration Tasks
- CodaFS Filesystem and Storage
- On-Disk Format and Operations
- Space Manager and Block Devices
- Binary Format and Program Loading
- Shell, Terminal, and Display
- Shell Command Pipeline
- Terminal, Input Devices and Prompts
- Display: VGA, Framebuffer, Console and Serial