================ Start Lecture #17 ================

4.2: Directories

Unit of organization.

4.2.1: Hierarchical directory systems

Possibilities

These are not as wildly different as they sound.

4.2.2: Path Names

You can specify the location of a file in the file hierarchy by using either an absolute versus or a Relative path to the file

Homework: 1, 8.

4.2.3: Directory operations

  1. Create: Produces an ``empty'' directory. Normally the directory created actually contains . and .., so is not really empty

  2. Delete: Requires the directory to be empty (i.e., to just contain . and ..). Commands are normally written that will first empty the directory (except for . and ..) and then delete it. These commands make use of file and directory delete system calls.

  3. Opendir: Same as for files (creates a ``handle'')

  4. Closedir: Same as for files

  5. Readdir: In the old days (of unix) one could read directories as files so there was no special readdir (or opendir/closedir). It was believed that the uniform treatment would make programming (or at least system understanding) easier as there was less to learn.

    However, experience has taught that this was not a good idea since the structure of directories then becomes exposed. Early unix had a simple structure (and there was only one). Modern systems have more sophisticated structures and more importantly they are not fixed across implementations.

  6. Rename: As with files

  7. Link: Add a second name for a file; discussed below.

  8. Unlink: Remove a directory entry. This is how a file is deleted. But if there are many links and just one is unlinked, the file remains. Discussed in more detail below.

4.3: File System Implementation

4.3.1; Implementing Files

Contiguous allocation

Homework: 7.

Linked allocation

FAT (file allocation table)

Inodes

4.3.2; Implementing Directories

Recall that a directory is a mapping that converts file (or subdirectory) names to the files (or subdirectories) themselves.

Trivial File System (CP/M)

MS-DOS and Windows (FAT)

Unix

Homework: 11