Free Files and disks lessonsFiles and disks · Stage 0 · Files · Step 3
Inodes
See how a Unix file's record holds direct and indirect pointers, and work out the largest file it can describe. About 14 minutes.
With 4 KB blocks and 4-byte pointers, how many data blocks can a single-indirect block reach?
- A1,024
- B12
- C4,096
Show the answer
1,024. 4096 ÷ 4 = 1024 pointers fit in one block.
Largest file size
An inode has directCount direct pointers, then single, double and triple indirect pointers, of which only the first indirectLevels are used (0 to 3: for 0 none, for 1 only single, for 2 single and double, and for 3 all three). Blocks are blockBytes bytes and pointers are pointerBytes bytes. Return the largest file size in bytes: the total number of addressable data blocks times blockBytes.
blockBytes = 4096, pointerBytes = 4, directCount = 12, indirectLevels = 3 → 4402345721856
512 ≤ blockBytes ≤ 65536 powers of two · pointerBytes a power of two, at most 8 · 0 ≤ directCount ≤ 16 · 0 ≤ indirectLevels ≤ 3
Solve it in your browserFree account, no card. Python, C++, Java or JavaScript, with hints if you get stuck, and your progress is saved.
Sign up free to solve