Preface
- Why FAT12?
- Who This Book Is For
- What You Will Build
- What You Will Learn
- A Note on Style
- How to Read This Book
- About the Author
- Feedback
Prerequisites
- Operating System
- C Compiler and Dependencies
- Editor and Hex Editor
- Getting the Code (Optional)
Part I: Reading
Chapter 1: Hello, Disk!
- What Is FAT12?
- Creating a Virtual Disk
- Sectors and LBA
- A Tale of Four Regions
- Project Layout
- A Portable Foundation: The BlockDevice
- Reading Sector 0
- Tracing the Translation
- Production Notes
- What Is Next
Chapter 2: The Blueprint (BPB)
- Boot Sector Structure
- Mapping Bytes to Structs
- The FAT12 Library
- The Info Command
- Debugging
- Production Notes
- What Is Next
Chapter 3: The Root Directory
- What Is the Root Directory?
- Loading the Root Directory
- Formatting an 8.3 Name
- Decoding Timestamps
- The ls Command
- Updating the Header
- Building
- Verification: Create Real Files
- Debugging with a Hexdump
- Production Notes
- What Is Next
Chapter 4: Reading Files
- What the FAT Actually Is
- Where the FAT Lives
- Data Region Geometry
- Reading a FAT Entry
- Loading the FAT
- Reading a Cluster Chain
- File API
- The cat Command
- Updating the Header
- Building
- Verification: Create a Real File
- Hexdump Verification
- Multi-Cluster File
- Production Notes
- FAT Family: FAT16 and FAT32
- What Is Next
Part II: Writing
Chapter 5: Full Path Walking
- Subdirectories in FAT12
- Reading a Subdirectory from a Cluster Chain
- Splitting a Path into Tokens
- Finding an Entry by Name
- The Centerpiece:
fat12_resolve_path - Wiring into
fat12_opendir - Wiring into
fat12_open - Updating the CLI Commands
- Verification: Nested Directories
- Production Notes
- The FAT Family: FAT32 Root Cluster
- What Is Next
Chapter 6: Writing Files
- The Write Path
- Writing FAT Entries
- Finding Free Clusters
- Allocating a Chain
- Writing Data Clusters
- Syncing the FAT
- Loading the Parent Directory
- Finding a Free Slot
- Formatting 8.3 Names
- Creating a Directory Entry
- Updating the File Struct
- Splitting a Path into Parent and Name
- Adding Write Mode to fat12_open
- Adding fat12_write
- Updating fat12_close
- Updating the Header
- The Write CLI Command
- Verification
- Production Notes
- Append Mode
- FAT Family: Writing Across FAT Variants
- What Is Next
Chapter 7: Creating Directories
- What We Need to Do
- What Are
.and..? - The
fat12_mkdirFunction - Helper: Creating Directory Contents
- Updating the Header
- The
mkdirCLI Command - Verification
- Production Notes
- FAT Family: Directories Across FAT Variants
- What Is Next
Chapter 8: Deleting
- Production Notes
- FAT Family: Deleting Across FAT Variants
- What Is Next
Chapter 9: Renaming and Moving
- The Two Cases
- The
fat12_moveFunction - The
update_dotdotHelper - Updating the Header
- The
mvCLI Command - Verification
- Production Notes
- FAT Family: Rename and Move Across FAT Variants
- What Is Next
Part III: Advanced
Chapter 10: Formatting
- What We Are Building
- What We Need to Do
compute_sectors_per_fatformat_boot_sectorformat_fatsformat_root_dir- Updating the Header
- The
formatCLI Command - Verification
- Production Notes
- FAT Family: Formatting Across FAT Variants
- What Is Next
Chapter 11: Into the Kernel
- What Changes, What Does Not
- The Freestanding Environment
- lib.c — Heap, Memory, and String Functions
- ATA PIO Block Device
- The Kernel Entry Point
- Linking at 1 MB
- kernel_main — Boot-Time Operations
- Building
- Running in QEMU
- Debugging Tips
- Production Notes
- FAT Family: Multiplatform Payoff
- What Is Next
Conclusion
- The Architecture
- What Is Next
- Thank You