Operating Systems7h estimated

File Systems & I/O

Difficulty
Importance

The problem

Data needs to survive after a program exits and a machine restarts, which memory (RAM) cannot do — file systems give a persistent, hierarchical way to name, store, and retrieve data on durable storage, and I/O is the disciplined interface every program uses to reach it.

Why now

Trees already gave the hierarchical structure a file system's directories use; virtual memory already showed how the OS mediates access to a resource through an abstraction layer. File I/O is that same mediation pattern, applied to durable storage instead of RAM.

Mental model

A file system is a tree (directories containing files and more directories) laid on top of a flat block device, with a lookup table mapping paths to physical disk locations. I/O is always mediated by the OS — a program never touches the disk directly, it asks the kernel via a system call, which is what makes permissions, caching, and safety enforceable in one place.

Requires

Unlocks

Used in

Projects

  • Write a program that opens, writes, and reads back a file, then inspect its raw bytes on disk to confirm what was actually stored
  • Measure and compare the time cost of many small writes versus one large buffered write to the same file

Examples

  • A file path like /home/user/notes.txt is a walk down the file system tree from root to leaf
  • Buffered writes batch many small writes into fewer, larger disk operations because each I/O operation has fixed overhead

Resources

Mastery checklist