Detecting the last directory entry in an ISO9660 filesystem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Twicetimes
Posts: 13
Joined: Sun May 29, 2016 10:53 am

Detecting the last directory entry in an ISO9660 filesystem

Post by Twicetimes »

Based on all the ISO9660 documentation I've found, I'm operating under the following assumptions:

1) Directory entries cannot be larger than 255 bytes
2) Directory entries always end in the same logical block as the one in which they started

To detect when you've hit the last entry for a directory, it seems to be a case of checking that the first byte following the end of the previous entry has a value of zero (the 'Length of Directory entry' field).

Due to assumption #2 above however, it seems to me that if you're less than 255 bytes from the end of the current block, there might just be zero-padding to the end of this block, and then more directory entries in the next block. However, I haven't found that confirmed in so many words anywhere. Is this how it works? Is there a scenario where checking the start of the next logical block would be reading unrelated data?
Twicetimes
Posts: 13
Joined: Sun May 29, 2016 10:53 am

Re: Detecting the last directory entry in an ISO9660 filesys

Post by Twicetimes »

Finally realised what the answer to this is. The first directory entry describes itself, so I can look at the data length field and divide by the logical block size to know how many blocks are used for all the directory's entries combined.
Post Reply