1

From Tanenbaum's Modern Operating Systems, when trying to access a file in a ext2 file system in Linux, and then reaching the parent directory of the file,

If the file is present, the system extracts the i-node number and uses it as an index into the i-node table (on disk) to locate the corresponding i-node and bring it into memory. The i-node is put in the i-node table, a kernel data structure that holds all the i-nodes for currently open files and directories.

Are there two different inode tables mentioned?

  1. Is the first inode table stored somewhere in the disk? Where is it stored? See the layout of a disk, a partition, and a file system below from the same book.

    Is it a mapping from the inode numbers to the inode addresses?

  2. Is the second inode table stored in the main memory?

    Is it a mapping from what to the inodes?

enter image description here

enter image description here

1

The text you quoted is, arguably, sloppily worded.  The master, authoritative inodes for a filesystem are stored in the filesystem.  So, for a filesystem that’s on a disk (in a disk partition), the inodes are on the disk.  But, for efficiency, the kernel stores (caches) local copies of active inodes in memory.

  1. To repeat, yes, “the first inode table” is stored on the disk (assuming that the filesystem is disk-resident).  So what are you asking?  The two figures you copied into your question both show areas labeled “I-nodes”.  Those are where the inodes are.  The specifics are different in different filesystem types.

    • Is it a mapping from the inode numbers to the inode addresses?
      No; the inodes are stored in an array (or, in some filesystems, in several arrays), so the inode address can be computed by a formula that looks something like

      inode address = (base address of inode array) + (inode number) × (sizeof inode)

    As I hope you already know, an inode contains the metadata for a file, and it points to the data blocks for the file.

  2. Yes, “the second inode table” is stored in memory.  It’s not a mapping to the inodes; it’s a copy of selected inodes (with, perhaps, some additional metadata concerning the state of the inode in the system).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.