Im currently reading the book

  • "How Linux Works" by Brian Ward

and on chapter 4.5 it is said

A directory inode contains a list of filenames and corresponding links to other inodes.

This implies that a directory's inode is structurally different than a normal file inode.

I have found this question and the top (and only) answer there implies this is isn't corrent (it agrees with Brian Ward but the answer is highly downvoted), so I want to know what is correct.

If the answer I'm looking for is filesystem specific, I would be interested to know the answer for ext2/3/4.


Fundamentally they are the same, see:

It's just the data blocks which are different. I'd recommend that you download an old enough version of the Linux kernel (e.g. 2.0) and study the ext2 filesystem source code which will give you a full understanding.

  • im not sure i understand, from what ive read, the translation between filename and the inode number is stored in the directory's file data and not in its inode. am I correct? – amos-baron Nov 25 '20 at 8:58
  • 1
    In Unix-style filesystems, the fundamental identifier of a file is not its name, but its inode number. The same file can be referred to by multiple names, from different directories on the same filesystem. This is how hard linking works. The directory's file data contains the name->inode number mappings of the directory's contents. The directory's own name is stored in the file data of its parent directory. – telcoM Nov 25 '20 at 10:38

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.