Directories

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:

Store all this data in the directory entry (like MS-DOS)

---directories contain all information about a file except the actual bytes:
filenamesizeownertypedateprotectiondisk blocks...
Letter to granny4567bobtext1998-Jan-01rw-r-----...
Picture of the dog50324bobimage/jpg1998-Mar-29rw-r--r--...
ws20002MBbobexecutable1974-Dec-23r-xr-xr-x...

advantage: faster listing all the detail about all files in a directory. Perhaps faster access to files

Encapsule in an inode (like UNIX)

---directory entries refer to inodes:
filenameinode number
Letter to granny45
Picture of the dog13
ws200010

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).)

Locating a file's inode in a directory tree

For example, "/home/users/bob/documents/paper_one.tex"
  1. First find the root inode "/". Check that it is a directory. Search the directory for "home".
  2. Take the inode for "home". Check that it is a directory. Search the directory for "users".
  3. Take the inode for "users". Check that it is a directory. Search the directory for "bob".
  4. Take the inode for "bob". Check that it is a directory. Search the directory for "documents".
  5. Take the inode for "documents". Check that it is a directory. Search the directory for "paper_one.tex".
  6. Return its inode.


last updated 25 March 1998