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
- Find the root directory i-node
- Traverse it's directory entries until we find the name of the sub-directory we're looking for
- Take the i-node number the directory entry we have found points to
- go to (2.), repeat until we have found the file.
- Read the file by parsing the extent tree
Is this correct?
If so, how are the struct ext4_dir_entry
s 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?