THINK FIRST·CODE LATER

← All labs

Inode calculator: file sizes and disk reads

Problem

Input: block size (bytes), pointer size (bytes), number of direct pointers; then byte offsets until the end of input. The inode also has one single, one double and one triple indirect pointer.

Print:

Pointers per block: 1024
Blocks reachable: direct 12, single 1024, double 1048576, triple 1073741824
Max file size: 4.00 TiB (4402345721856 bytes)

(the size with two decimals in the largest unit B/KiB/MiB/GiB/TiB/PiB where the value is ≥ 1). Then for each offset: offset 49152: block 12, single indirect, 2 disk reads — the number of disk reads to fetch the data block assuming the inode is in memory (direct 1, single 2, double 3, triple 4; singular 1 disk read) — or offset X: beyond maximum file size.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.