GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Compute inode maximum file capacity

3 questions solved the same way, newest first. Back to Operating Systems

How these are solved

Compute indirect-block fanout from block bytes/address bytes, sum direct plus each supplied indirection contribution, and multiply data-block count by block size. Direct counts, pointer widths and maximum indirection differ.

2 marks · NAT
Report issue

Maximum inode-addressed file size

File Systems

Question 42, GATE 2019: An inode has 12 direct pointers, one single-indirect pointer, and one double-indirect pointer. Blocks are 4 kB and each disk-block address is 32 bits. Find the maximum file-data size in GB, rounded to one decimal place; retain the official key's alternative unit ranges.
Tap to enlarge
Answer & solution

Official answer: 3.7 to 3.8 OR 4.0 to 4.1

Our answer: 4.0 under consistent binary units; alternate range retained

1. A block pointer occupies 32/8=4 bytes. Under the usual binary convention, one block is B=4096 bytes, so an indirect block stores 4096/4=1024 addresses.
2. Direct pointers address 12 data blocks. The single-indirect pointer addresses one metadata block containing 1024 data-block pointers, so it contributes 1024 data blocks.
3. The double-indirect pointer reaches a first-level metadata block containing 1024 pointers to second-level indirect blocks. Each second-level block addresses another 1024 data blocks. Its contribution is 1024²=1,048,576 data blocks.
4. Total file-data capacity is (12+1024+1,048,576)×4096=4,299,210,752 bytes. Metadata blocks are not part of the file's data size and must not be added to this total.
5. In binary GiB, divide by 230 to obtain 4.003952... GiB, rounding to 4.0. This is the conventional intended calculation even though the question prints GB.
6. Units matter. Taking kB as 1000 gives (12+1000+1000²)×4000=4,004,048,000 bytes: 4.0 decimal GB, or 3.7 GiB after rounding. Taking binary blocks but decimal GB instead gives 4.3, not an accepted supplied range. Preserve the official disjoint intervals 3.7–3.8 OR 4.0–4.1 rather than concealing this unit ambiguity.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Maximum file size with double indirection

File Systems

Question 41, GATE 2012: A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, 1 indirect
        block address and 1 doubly indirect block address. The size of each disk block is 128 Bytes and the
        size of each disk block address is 8 Bytes. The maximum possible file size in this file system is
        (A) 3 KBytes
        (B) 35 KBytes
        (C) 280 KBytes
        (D) dependent on the size of the disk
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Each indirect block holds 128/8=16 addresses. The descriptor therefore reaches 8+16+16²=280 data blocks. Their payload is 280×128=35, 840 bytes=35 KiB (the option calls these KBytes). Indirection blocks are metadata and do not count as file payload. The 300 GByte disk is more than large enough. Hence B.

Check: The eight direct pointers cover 1024 bytes, the single-indirect pointer covers 16×128=2048 bytes, and double indirection covers 256×128=32768 bytes. Their sum is 35840 bytes. Multiplying 280 by KiB instead of by 128 bytes produces the 280-KByte distractor.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Exact inode addressing capacity

File Systems

Question 49, GATE 2004: A Unix-style inode has 10 direct pointers and one each single-, double- and triple-indirect pointer. Blocks are 1 Kbyte, block addresses are 32 bits, and integers are 48 bits. What is the maximum file size? Use 1 Kbyte=1024 bytes; alternatives are powers of two, not exact inode totals.
Options:
(A) 2^24 bytes
(B) 2^32 bytes
(C) 2^34 bytes
(D) 2^48 bytes
Question 49, GATE 2004: A Unix-style inode has 10 direct pointers and one each single-, double- and triple-indirect pointer. Blocks are 1 Kbyte, block addresses are 32 bits, and integers are 48 bits. What is the maximum file size? Use 1 Kbyte=1024 bytes; alternatives are powers of two, not exact inode totals.
Options:
(A) 2^24 bytes
(B) 2^32 bytes
(C) 2^34 bytes
(D) 2^48 bytes
Tap to enlarge
Your answer
Answer & solution

Answer: 17,247,250,432 bytes; C only as a power-of-two approximation (no official key was published)

1. A1KiB indirect block holds 1024/4=256 addresses. The inode can reference 10+256+256²+256³=16,843,018 data blocks, totaling 17,247,250,432 bytes.

2. The32-bit block-address space and 48-bit integer bound are both larger and do not constrain this total. The dominant triple-indirect contribution alone is 256³×1024=234 bytes, option C, but the exact maximum includes direct, single-indirect and double-indirect blocks and exceeds 234 by 67,381,248 bytes.

3. Thus no offered power-of-two option is exactly the stated maximum; C is the usual scale approximation, not an exact equality.

4. Teaching check: Indirect blocks contain addresses, so divide 1024 bytes by four bytes per address before exponentiating. The triple-indirect branch contributes 256³ data blocks; it does not replace the smaller branches. Distinguish exact capacity from the dominant-power approximation offered by the choices.

Original paper, page 7