Question

The index node (inode) of a Unix-like file system has 12 direct, one single-indirect and one double-indirect pointers. The disk block size is 4 kB4\text{ kB}, and the disk block address is 3232-bits long. The maximum possible file size is (rounded off to 1 decimal place) _________ GB.

Official answer and solution
Accepted answers
3.7 to 3.8, or 4 to 4.1
From
Official GATE 2019 answer key
Note on this question

Official answer key accepted both 3.7 to 3.8 and 4.0 to 4.1. The calculation yields ~4.0 GB in binary GiB units (4.004 GB) or ~3.7 GiB if 4 GB is converted to binary gigabytes.

Solution

Compute the total number of blocks addressable via direct, single-indirect, and double-indirect pointers in the inode, then convert to GB.

We are given:

  • Disk block size = 4 kB=4096 bytes=212 bytes4\text{ kB} = 4096\text{ bytes} = 2^{12}\text{ bytes}
  • Disk block address = 32 bits=4 bytes32\text{ bits} = 4\text{ bytes}

The number of block pointers that fit in a single disk block is:

Pointers per block=4096 bytes4 bytes/pointer=1024=210 pointers\text{Pointers per block} = \frac{4096\text{ bytes}}{4\text{ bytes/pointer}} = 1024 = 2^{10}\text{ pointers}

The total number of data blocks addressable by the inode is:

  • Direct pointers (1212): 12 blocks12\text{ blocks}
  • Single-indirect pointer (11): 210=1024 blocks2^{10} = 1024\text{ blocks}
  • Double-indirect pointer (11): 210×210=220=1048576 blocks2^{10} \times 2^{10} = 2^{20} = 1048576\text{ blocks}

Total blocks:

Nblocks=12+1024+1048576=1049612 blocksN_{\text{blocks}} = 12 + 1024 + 1048576 = 1049612\text{ blocks}

Total maximum file size in bytes:

Size=1049612×4096 bytes=4,299,210,752 bytes\text{Size} = 1049612 \times 4096\text{ bytes} = 4,299,210,752\text{ bytes}

In binary gigabytes (1 GiB=230 bytes1\text{ GiB} = 2^{30}\text{ bytes}):

Size=1049612×212230=1049612218≈4.003955 GB≈4.0 GB\text{Size} = \frac{1049612 \times 2^{12}}{2^{30}} = \frac{1049612}{2^{18}} \approx 4.003955\text{ GB} \approx 4.0\text{ GB}

In decimal gigabytes (1 GB=109 bytes1\text{ GB} = 10^9\text{ bytes}), or converting 4 GB4\text{ GB} to GiB (4×109/230≈3.725 GiB4 \times 10^9 / 2^{30} \approx 3.725\text{ GiB}), the GATE answer key officially accepted both 3.7 to 3.8 and 4.0 to 4.1.

Final answer

3.7 to 3.8

Common trap

Forgetting that indirect blocks contain block addresses (4 bytes each) rather than direct data.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2019 Computer Science and Information Technology (CS)
Question
52 of 65, printed as CS Q.42
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.