Directory Organization
Let's look at different aspects of directory management in vsfs.
We'll cover the following...
In vsfs (as in many file systems), directories have a simple organization; a directory basically just contains a list of (entry name, inode number) pairs. For each file or directory in a given directory, there is a string and a number in the data block(s) of the directory. For each string, there may also be a length (assuming variable-sized names).
For example, assume a directory dir
(inode number 5) has three files in it (foo
, bar
, and foobar_is_a_pretty_longname
), with inode numbers 12, 13, and 24 respectively. The on-disk data for dir
might look like:
inum |
reclen |
strlen |
name |
---|---|---|---|
5 | 12 | 2 | . |
2 | 12 | 3 | .. |
12 | 12 | 4 | foo |
13 | 12 | 4 | bar |
24 | 36 | 28 | foobar_is_a_pretty_longname |
In this example, each entry has an inode number, record length (the total bytes for the name plus any leftover space), string length (the actual length of the name), and finally the name of the entry. Note that each directory ...