Skip to content
DeepForgeby svx
All problems
EasyData Structuresds-165

Inode Block Pointers Capacity

Problem

Compute the maximum file size addressable by an inode.

Each inode has num_direct direct block pointers and block_size is the size of one disk block. The single, double, and triple indirect pointers each index a full block of pointers_per_block addresses. The capacity is block_size * (num_direct + p + p^2 + p^3).

Return the total number of addressable bytes.

Hint

Indirect levels multiply: one indirect pointer addresses p blocks, two address p^2, three address p^3.

Test cases

case 1
in: [1024,10,4]
expected: 96256
case 2
in: [512,0,2]
expected: 7168
case 3
in: [4096,1,1]
expected: 16384
case 4
in: [4096,12,1024]
expected: 4402345721856
Starter codePython
def inode_capacity(block_size, num_direct, pointers_per_block):
    # Your code here
    pass

4 test cases · run your code against them in the editor