Skip to main content

File System Internals Workshop

Retrieval Prompts

  1. State from memory the three layers reached by open: per-process FD table, system-wide open-file table, in-memory inode table. What is in each?
  2. What is an inode, and what does it not contain?
  3. How does a directory resolve foo.txt to an inode number?
  4. Sketch the ext-style on-disk layout (superblock, bitmaps, inode table, data blocks) from memory.
  5. Explain why fork shares an open-file entry but two open calls do not.

Compare and Distinguish

Separate these pairs clearly:

  • file name vs inode vs file descriptor
  • directory vs regular file at the on-disk level
  • hard link vs symbolic link
  • dup(fd) vs open(path) twice
  • FAT vs ext-style vs log-structured

Common Mistake Check

Identify the error in each statement:

  1. "rm foo deletes the data immediately."
  2. "mv a b in the same directory moves the file's inode."
  3. "cp a b duplicates the inode."
  4. "An ext4 file with a single extent still requires an indirect block for 1 MiB of data."
  5. "When two processes open the same file independently, writes through one move the read offset of the other."
  6. "close(fd) releases the inode unconditionally."
  7. "A directory's data blocks are only used for quick lookups and can be rebuilt from the inode."

Mini Application

For each operation, list every on-disk structure touched (bitmaps, inode table entries, data blocks, directory data blocks) in a likely order:

  1. touch /tmp/a
  2. echo hello > /tmp/a
  3. ln /tmp/a /tmp/b
  4. mv /tmp/a /home/me/a (across directories, same FS)
  5. rm /tmp/a
  6. Extending a 100 MiB file by 4 KiB (extent-based ext4).
  7. mkdir /tmp/d
  8. rmdir /tmp/d on an empty directory.

For each, answer: which structures must be persisted for the operation to survive a crash?

Layout Tracing

Given the ext-style layout below, resolve read(fd, buf, 4096) on inode 5000, offset 0, into a specific LBA:

 region         starting LBA     size
---------------------------------------
superblock 0 1
inode bitmap 1 1
data bitmap 2 1
inode table 3 128 (one inode per 256 B, 16 per block)
data blocks 131 rest

Inode 5000 has direct pointer blocks[0] = 10000. Compute:

  1. LBA that holds inode 5000.
  2. LBA read to satisfy the user read.
  3. How many block reads are required in total? (Assume cold cache.)

Evidence Check

This page is complete only if, given any of the drills above, you can:

  • enumerate every on-disk structure that changes
  • defend the order with a crash-consistency justification
  • translate an inode number and offset into a specific LBA