A directory refers to a container that stores and organizes files and folders in a system.
There are several ways to structure a directory. However, tree-structured directories are the most common.
The directory is structured in the form of a tree. It also has a root directory, and every file in the system has a unique path.
A directory within a tree-structured directory may contain files or subdirectories. Special system calls are used to create or remove directories.
One bit in each directory entry is used to identify the entry as either a file (represented by ‘0’) or a directory (represented by ‘1’).
Each user has their own directory and cannot access the directory of another user. All users can read data from the root directory. However, they cannot write to or modify the root directory. This privilege is reserved for the system administrator who has complete access to the root directory.
We can access a file using two types of paths. These are:
The absolute path is the path to the file with respect to the root directory.
The relative path is the path to the file with respect to the current working directory.
Consider the above directory tree. Let’s assume that the current working directory is: root/home/Desktop
.
To access the file under the directory labeled Edpresso, we can use the following paths:
Relative path: Edpresso
Absolute path: root/home/Desktop/Edpresso
A tree-structured directory is very general because every file can be accessed using its absolute path.
It is also very scalable since we can easily create or remove directories and subdirectories. This also reduces the probability of name collisions within a directory.
Tree-structured directories also allow for easier searching, as we can use both the absolute or relative paths for a file.
Tree-structured directories do not allow file sharing between users.
They are also inefficient in the sense that accessing a file may force you to go under multiple directories.
Advantages | Disadvantages |
General | Inefficient |
Scalable | No file sharing |
Easy to Seacrh | File duplication in multiple directories |