Directory

  • Used to provide a logical grouping of files
  • Used to keep track of files
directoryfile 1file 2file 3file 4Single-Leveldirectoryfile 1file 2Tree-Structuredfile 1directorydirectoryfile 1file 2file 1directoryDAGaliasdirectoryfile 1file 2file 1directoryGeneral Graphcycleallows cycle # Single-Level

The files exist in one high-level directory, under which all the files lie under that. This means that there are no duplicate file names as there is no way to distinguish between them.

Tree-Structure

This allows for recursive embedding of directories into another: resulting in the natural formation of a tree structure.

This means that now there are two ways to refer to a file:

Absolute Pathname

The pathname followed from the root of the tree to the final file.

root/Users/document.out

Relative Pathname

The pathname from the current working directory.

document.out from root/Users, and Users/document.out from root.

Directed Acyclic Graph

This allows sharing of files (without actually replicating the content). Thus, the file “appears” in multiple directories.

Implementations:

Hard Link

Limited to file only.

Unix implements this hard link, ln. Given two directories A and B, if B wants to share a file F stored in A,

  • A and B have separate pointers to point to F on disk

Low overhead

Only pointers are added in directory.

Deletion problems

What happens if the file is deleted?

Symbolic Link

Can be file or directory.

Unix also implements the symbolic link with ln -s. Given the same scenario,

  • B creates a link file G that contains the path name of F.
  • Access to G finds F and accesses it.

Simple deletion

Deletion from the original directory results in expected behaviour, as while G remains, it will not be able to access F.

Similarly, deletion of G in B does not affect F.

Larger overhead

Special link takes up actual disk space, as compared to the pointer.

General Graph

Allows for cycles within the file directory, allowing for creation of link to directory.

In Unix, a symbolic link is allowed to link to directory, allowing for creation of a general graph.

Hard to traverse

Infinite loop

Hard to delete

Difficult to determine when to remove file or directory.