Solution (source code)

= Solution

A traditional UNIX-like <file system> identifies a <computer file> by an <inode number>. Its <inode> records <file metadata>, such as byte length, ownership and permissions, and contains direct <file data block> addresses plus <indirect block pointers>. A <file-system directory> maps a name to the <inode number>; the filename need not be stored inside the <inode>.

In the familiar direct/single/double/triple scheme, a single <indirect block pointer> reaches a block of data-block addresses, a double <indirect block pointer> reaches blocks of those addresses, and a triple <indirect block pointer> adds one more level. If there are $d$ direct pointers, one pointer of each indirect level, block size $B$ bytes and pointer width $h$ bytes, put $q=\lfloor B/h\rfloor$. The index structure can name
$$
K=d+q+q^2+q^3
$$
data blocks, giving
$$
\boxed{L_{\rm index}=B(d+q+q^2+q^3).}
$$
The actual maximum is the minimum of this structural bound, the representable <file offset>/length bound, the addressable data-block space, and the capacity left on the device after allocating metadata and index blocks. For an unsigned $\ell$-bit byte-length field, its bound is $2^\ell-1$ bytes. An empty <computer file> is permitted and needs no data blocks in this scheme. Exact numerical limits cannot be given without the <inode> layout and field widths; different UNIX-like implementations choose different layouts, and some use extent trees rather than this traditional scheme.