A directory is an object that contains the names of file system objects. The file system allows users to organize files and other file system objects through the use of directories. The structure created by the placement of names in directories can take a number of forms: Single-level tree, Two-level tree, multi-level tree or cyclic graph.
The simplest directory structure is the single-level directory. All files are contained in the same directory, which is easy to support and understand. A single-level directory has significant limitations when the number of files increases or when the system has more than one user. Since all the files are in the same directory, they must have unique names.
In the two-level directory structure, each user has its own user file directory (UFD). Each UFD has a similar structure but lists only the files of a single user. When a user job starts or a user logs in, the system’s master file directory (MFD) is searched. The MFD is indexed by user name or account number, and each entry points to the UFD for that user.
When a user refers to a particular file, only his own UFD is searched. Different users may have files with the same name, as long as all the file names within each UFD are unique.
To create a file for a user, the operating system searches only that user’s UFD to ascertain whether another file of that name exists. To delete a file, the operating system confines its search to the local UFD; thus, it cannot accidentally delete another user’s file that has the same name.
A tree structure is A more powerful and flexible approach to organize files and directories in hierarchical. There is a master directory, which has under it a number of user directories. Each of these user directories may have sub-directories and files as entries. This is true at any level: That is, at any level, a directory may consist of entries for subdirectories and/or entries for files.
An acyclic graph allows directories to have shared subdirectories and files. The same file or subdirectory may be in two different directories. An acyclic graph is a natural generalization of the tree-structured directory scheme.
A shared file (or directory) is not the same as two copies of the file. With two copies, each programmer can view the copy rather than the original, but if one programmer changes the file, the changes will not appear in the other’s copy.
Shared files and subdirectories can be implemented in several ways. A common way is to create a new directory entry called a link. A link is a pointer to another file or subdirectory.
General Graph Directory:-
When we add links to an existing tree-structured directory, the tree structure is destroyed, resulting in a simple graph structure.