File System Internals Workshop
Retrieval Prompts
- 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? - What is an inode, and what does it not contain?
- How does a directory resolve
foo.txtto an inode number? - Sketch the ext-style on-disk layout (superblock, bitmaps, inode table, data blocks) from memory.
- Explain why
forkshares an open-file entry but twoopencalls 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)vsopen(path)twice- FAT vs ext-style vs log-structured
Common Mistake Check
Identify the error in each statement:
- "
rm foodeletes the data immediately." - "
mv a bin the same directory moves the file's inode." - "
cp a bduplicates the inode." - "An ext4 file with a single extent still requires an indirect block for 1 MiB of data."
- "When two processes open the same file independently, writes through one move the read offset of the other."
- "
close(fd)releases the inode unconditionally." - "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:
touch /tmp/aecho hello > /tmp/aln /tmp/a /tmp/bmv /tmp/a /home/me/a(across directories, same FS)rm /tmp/a- Extending a 100 MiB file by 4 KiB (extent-based ext4).
mkdir /tmp/drmdir /tmp/don 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:
- LBA that holds inode 5000.
- LBA read to satisfy the user read.
- 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