AgentD / squashfs-tools-ng

A new set of tools and libraries for working with SquashFS images
Other
194 stars 30 forks source link

Directory entry count question #39

Closed 0xPhoeniX closed 4 years ago

0xPhoeniX commented 4 years ago

Hey, I have a small clarification question.

Can you please explain or point in the documentation about why the directory entry count is calculated in the following way: src

Thanks in advance!

AgentD commented 4 years ago

Hi!

A directory header is always followed by at least 1 entry. The entry counter in the directory header is stored off-by-one to make it impossible to encode 0. Writing a header and then no data after it simply makes no sense. For empty directories, the inode would indicate a size of 0, eliminating the requirement to write a header in the first place.

There is no "official" documentation. I found most of this out through a combination of source code browsing and trial/error.

I tried to document the format myself: https://github.com/AgentD/squashfs-tools-ng/blob/master/doc/format.txt

and I also contributed most of this back to an earlier documentation attempt that helped me a lot in the beginning: https://dr-emann.github.io/squashfs/

0xPhoeniX commented 4 years ago

Thanks a lot! That is the same conclusion that I started to come to after couple of hours staring at the code, data and docs :-)

It would be really helpful if you can add that note to the both of the docs!

Great work!

AgentD commented 4 years ago

I added a clarification to the text file in commit 69c0f77.