CS FundamentalsHardGATE CS (PYQ pattern)

A Unix-like file system has 1 KB blocks, 4-byte pointers, and inodes with 10 direct pointers and one single-indirect pointer. Every directory fits in one block and all inodes are stored separately on disk. The root inode is in memory; nothing else is cached. A program opens /usr/lib/data.bin (exactly 100 blocks long) and reads the whole file sequentially. How many disk-block reads are needed for the path lookup plus reading the whole file (no read-ahead)?

  1. A. 106
  2. B. 108
  3. C. 110
  4. D. 107

Correct answer: D. 107

Path lookup: root directory block (1), inode of usr (1) + its directory block (1), inode of lib (1) + its directory block (1), inode of data.bin (1) = 6 reads. The file needs 100 data blocks plus 1 single-indirect block (blocks 10 to 99 are reached through it) = 101. Total 107.

More Operating Systems questions

Exams that ask this topic