3

Does a directory inode use a plain array storing ( filename, inode ) pairs, or some kind of associative array { filename: inode }to speed up file lookup, or any other optimizations on a plain array?

Take ext2/3/4 as example if you think the question is too broad or filesystem-specific.

This question is specifically focused on the internal representation of directory inodes.

3

1 Answer 1

-1

As we know, everything is a file in Linux even the directories. Also every file has an inode.

That said, a directory's inode has a map of it's contents (files and subdirectories) into blocks (a block is part of a inode structure), it can be described with the following image:

enter image description here

1
  • 2
    First of all, a directory’s inode does no such thing.  A directory’s inode points to the directory’s data blocks, which contain the inode numbers and filenames of the files that are “in” the directory.  Secondly, the OP clearly knows that a directory associates inode numbers with filenames — the question says so.  (The OP probably already knows everything you said.)  But your image illustrates the association at only a conceptual level.  The question is: how do the ext2/3/4 filesystems do this?  Your illustration might have been relatively accurate twenty years ago; it’s not very useful now. Nov 23, 2016 at 3:22

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.