My question deals with the relationship between the read and execute bits on a directory. I'm going to give my assumptions, first, all according to my current knowledge, then ask my question in bold in the context of those assumptions. Please feel free to correct any incorrect assumptions:
- Files and directories both are stored using inodes.
- Files and directories both have permissions (let's just focus on the rwx bits, forgetting the sticky, setuid, setguid (unless they're relevant)).
- The contents of a directory's inode's data blocks store a mapping of file names to inode numbers.
- Read permission on a directory allows a user to obtain a list of the names of all files in that directory.
- The user must know a file's inode number in order to access its contents. UPDATE: The meaning of the original statement here doesn't reflect what I meant to express. What I meant is more along the lines of: The user doesn't need to know a file's inode number, but the user must have permission to get an inode for a given filename in order to get the contents of the file.
- Execute permission on a directory allows a user to "use" that directory, and I understand that specifically to mean obtaining the directory's inode number (I would like confirmation of my understanding of this). This will allow the user to do things like cd into that directory, which is the prototypical example given of what a user needs the execute permission for.
Given that a user must be able to obtain the "contents" of a directory (really the contents of the directory's inode's data blocks) in order to gain access to the directory listing, and that the user must know the directory's inode number to gain access to its contents, why is it that a user can still obtain a directory listing while not having execute permission on the directory? It seems that obtaining a listing of the contents of a directory D requires temporarily looking up its inode number in order to read the contents of the inode's data blocks. Furthermore, it would seem necessary that read permission would imply execute permission on a directory.