FAT12

FAT12

Björn Götz
This is a sample of the book's content.Buy on Leanpub

Table of Contents

FAT12

  • Introduction
    • Why FAT12?
    • Why Not Just Generate It?
    • Who This Book Is For
    • What We Will Build
    • How This Book Is Structured
    • How to Read This Book
    • Not Production Code
    • About the Author
    • Feedback
  • Prerequisites
    • Operating System and CPU Architecture
    • Command-Line Tools
    • Kernel Tools (Chapter 12 and Appendixes)
    • Getting the Code (Optional)
  • Part I: Reading
  • Chapter 1: Hello, Disk!
    • Creating a Disk Image
    • Sectors and LBA
    • The Block Device
    • Debug Logging
    • The File Block Device
    • Putting the Block Device to Work
    • Tracing the Translation
    • What’s Next
  • Chapter 2: Mounting the Filesystem
    • Meet the Boot Sector
    • Reading the Boot Sector
    • Putting It All Together
    • Mounting in Action
    • What’s Next
  • Chapter 3: Listing the Root Directory
    • Locating the Root Directory
    • Peeking Inside the Root Directory
    • Anatomy of a Directory Entry
    • The 8.3 Name Format
    • The Attribute Byte
    • The Timestamp Fields
    • Reading the Root Directory
    • Filtering the Entries
    • Putting It All Together
    • The ls Command
    • What’s Next
  • Chapter 4: Reading Files
    • The Data Region
    • Carving Up the Data Region
    • Finding a File’s First Cluster
    • Resolving a Path
    • Putting It All Together
    • The cat Command
    • What’s Next
  • Chapter 5: Reading Multi-Cluster Files
    • When One Cluster Isn’t Enough
    • Chaining Clusters with the File Allocation Table
    • Decoding the 12-Bit Entries
    • Loading the FAT
    • Counting the Clusters
    • Reading a Cluster Chain
    • Putting It All Together
    • Finding the Missing B
    • What’s Next
  • Chapter 6: Full Path Walking
    • Subdirectories: Files in Disguise
    • The Path Walking Algorithm
    • Retrofitting Reads
    • Watching the Walk
    • What’s Next
  • Part II: Writing
  • Chapter 7: Deleting
    • Finding the Parent Directory
    • Making Sure a Directory Is (Almost) Empty
    • Freeing the Directory Entry
    • Our First Real Write
    • Putting It All Together
    • The rm Command
    • The Clusters We Left Behind
    • Freeing the Cluster Chain
    • Fixing the Leak
    • Watching the Clusters Go Free
    • What’s Next
  • Chapter 8: Moving (and Renaming)
    • Encoding the Name
    • Putting It All Together
    • The mv Command
    • Finding a Free Slot
    • A Directory Trapped Inside Itself
    • A New Home, an Old Address
    • Completing the Move
    • Watching Entries Move
    • What’s Next
  • Chapter 9: Creating Directories
    • Allocating a Cluster
    • Turning a Cluster into a Directory
    • Stamping the Moment of Creation
    • Putting It All Together
    • The mkdir Command
    • Watching a Directory Come to Life
    • What’s Next
  • Chapter 10: Writing Files
    • Creating an Empty File
    • Opening a File for Writing
    • Buffering the Write
    • Allocating a Cluster Chain
    • Committing on Close
    • The create Command
    • Watching the Bytes Land
    • What’s Next
  • Part III: Advanced
  • Chapter 11: Formatting
    • FAT Size or Cluster Count: Which Came First?
    • The Boot Sector
    • The FAT Region
    • The Root Directory
    • The Data Region
    • Putting It All Together
    • The format Command
    • Watching the Big Bang
    • What’s Next
  • Chapter 12: Running FAT12 Inside a Kernel
    • What It Takes to Boot a Kernel in QEMU
    • The Assembly Entry Point
    • Printing to the VGA Screen
    • Building kernel.elf
    • Hello, Kernel!
    • RAM as Our Block Device
    • A Test Run for FAT12
    • 404: libc Not Found
    • FAT12 at Work on Bare Metal
    • What’s Next
  • Conclusion
    • What’s Next
    • Thank You
  • Appendixes
  • Appendix A: Talking to a Real Disk
    • How to Talk to an ATA Drive
    • Talking to Ports from C
    • Issuing a Command
    • Opening the Drive: IDENTIFY Yourself
    • Reading
    • Writing
    • Completing the Block Device
    • Replacing the RAM Disk
    • Spinning Up the Drive
  • Appendix B: A First Look at Long Filename Support (LFN / VFAT)
    • Getting Our Hands on Some Fragments
    • An Impostor Among Directory Entries
    • Decoding the Fragments
    • Following the Sequence
    • Verifying the Checksum
    • From Debug Trace to Full LFN Support
  • Appendix C: The Boot Sector Fields We Skipped
    • Booting from FAT12
    • Which Disk? The Drive Number
    • Where Is the Volume? Hidden Sectors
    • Cylinders, Heads, and Sectors (CHS)
    • The Extended BPB’s Identification Fields
    • OEM Name (Original Equipment Manufacturer)
    • Media Descriptor
    • Back to Our Formatter
  • Appendix D: FAT12 vs. FAT16 vs. FAT32
    • From FAT12 to FAT16
    • From FAT16 to FAT32
    • Telling FAT12, FAT16, and FAT32 Apart
    • What About exFAT?
    • Further Reading
FAT12/Conclusion

Conclusion

https://leanpub.com/fat12

What’s Next

https://leanpub.com/fat12

Thank You

https://leanpub.com/fat12

Previous

Chapter 12: Running FAT12 Inside a Kernel

Up next

Appendixes

In this chapter

  • Conclusion
  • What’s Next
  • Thank You