Allegedly stands for “index node.”

We usually don’t care about all blocks in the File system, just the blocks for the currently opened files. Instead of spreading out the block numbers in a table (like FAT), can we group the block numbers of a single file together?

Inodes are data structures that contain file metadata and an array of 121 physical block numbers corresponding to the first 12 logical blocks in a file, plus some indirect pointers to other blocks for larger files. Inodes are only created for actual files. Each file has a unique inode number.

struct inode_st {
    attributes_t metadata;
    block_no_t blocks[12];
    block_no_t* single_ind;
    block_no_t** double_ind;
    block_no_t*** triple_ind;
}

The inode data structure contains:

  • Owner of the file
  • Access permissions
  • File size
  • Time of last change to file, last access to file, and last change to inode of the file.
  • An array containing the first 12 logical blocks
  • Singly, doubly, triply indirect pointer to more blocks

When we’re using inodes, Directory entries store the inode number for the file (instead of the file’s initial block like in FAT).

Disk layout

In the absence of FAT’s built-in way of knowing whether blocks are free or not, inodes require us to maintain a bitmap block.

Inodes are smaller than a block (literally just a C struct), so we can fit multiple inodes into a single block. We designate a certain block on the disk as a “inode block” that we always check. A file’s inode number would correspond to one of the inodes in this block.

Footnotes

  1. Why 12? Great question. I dunno. That’s just what they decided on. Fuck 12