Directories are special files. They are special in that instead of actually storing data, they store references to other files.
There are two main philosophical approaches to representing the references to files within a directory:
---directories contain all information about a file except the actual bytes:
filename | size | owner | type | date | protection | disk blocks | ... |
---|---|---|---|---|---|---|---|
Letter to granny | 4567 | bob | text | 1998-Jan-01 | rw-r----- | ... | |
Picture of the dog | 50324 | bob | image/jpg | 1998-Mar-29 | rw-r--r-- | ... | |
ws2000 | 2MB | bob | executable | 1974-Dec-23 | r-xr-xr-x | ... |
advantage: faster listing all the detail about all files in a directory. Perhaps faster access to files
---directory entries refer to inodes:
filename | inode number |
---|---|
Letter to granny | 45 |
Picture of the dog | 13 |
ws2000 | 10 |
advantage: directories are smaller (faster), one file may be in several directories (several hard links to the one file).
(generally, directories may be regarded as special cases of files (structure understood and maintained by the filesystem, may not be directly modified by filesystem clients).)