1

I am doing some experimentation with the internals of the ext4 file system, when I stumbled upon this issue while trying to implement reading a file by path.

The root directory i-node, number 2 as per the Kernel documentation's special i-node table, is easily found in the i-node table per the pointers in the block group descriptors and superblock.

As far as I understand it, the process of looking up a file by path is

  1. Find the root directory i-node
  2. Traverse it's directory entries until we find the name of the sub-directory we're looking for
  3. Take the i-node number the directory entry we have found points to
  4. go to (2.), repeat until we have found the file.
  5. Read the file by parsing the extent tree

Is this correct?

If so, how are the struct ext4_dir_entrys stored/referenced from the i-node? I assume i_node.i_block[] has something to do with that, but I am not entirely clear on how to read the directory entries from there. Are they stored in the i-node? Or does the array contain pointers?

Flo
  • 153
  • 1
  • 1
  • 7
  • Are you looking for this? https://www.kernel.org/doc/html/latest/filesystems/ext4/dynamic.html#hash-tree-directories – root Feb 16 '21 at 00:04

0 Answers0