A directory is a container that is used to contain folders and file. It organises files and folders into hierarchical manner.
There are several logical structures of directory, these are given as below.
- Single-level directory –
Single level directory is simplest disectory structure.In it all files are contained in same directory which make it easy to support and understand.
A single level directory has a significant limitation, however, 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 the unique name . if two users call there dataset test, then the unique name rule violated.
- Since it is a single directory, so its implementation is very easy.
- If files are smaller in size, searching will faster.
- The operations like file creation, searching, deletion, updating are very easy in such a directory structure.
- There may chance of name collision because two files can not have the same name.
- Searching will become time taking if directory will large.
- In this can not group the same type of files together.
- Two-level directory –
As we have seen, a single level directory often leads to confusion of files names among different users. the solution to this problem is to create a separate directory for each user.
In the two-level directory structure, each user has there own user files directory (UFD). The UFDs has similar structures, but each lists only the files of a single user. system’s master file directory (MFD) is searches whenever a new user id=s logged in. The MFD is indexed by username or account number, and each entry points to the UFD for that user.
- We can give full path like /User-name/directory-name/.
- Diffrent users can have same directory as well as file name.
- Searching of files become more easy due to path name and user-grouping.
- A user is not allowed to share files with other users.
- Still it not very scalable, two files of the same type cannot be grouped together in the same user.
- Tree-structured directory –
Once we have seen a two-level directory as a tree of height 2, the natural generalization is to extend the directory structure to a tree of arbitrary height.
This generalization allows the user to create there own subdirectories and to organise on their files accordingly.
A tree structure is the most common directory structure. The tree has a root directory, and every file in the system have a unique path.
- Very generalize, since full path name can be given.
- Very scalable, the probability of name collision is less.
- Searching becomes very easy, we can use both absolute path as well as relative.
- Every file does not fit into the hierarchical model, files may be saved into multiple directories.
- We can not share files.
- It is inefficient, because accessing a file may go under multiple directories.
- Acyclic graph directory –
An acyclic graph is a graph with no cycle and allows to share subdirectories and files. The same file or subdirectories may be in two different directories. It is a natural generalization of the tree-structured directory.
It is used in the situation like when two programmers are working on a joint project and they need to access files. The associated files are stored in a subdirectory, separated them from other projects and files of other programmers since they are working on a joint project so they want to the subdirectories into there own directories. The common subdirectories should be shared. So here we use Acyclic directories.
It is the point to note that shared file is not the same as copy file if any programmer makes some changes in the subdirectory it will reflect in both subdirectories.
- We can share files.
- Searching is easy due to different-different paths.
- We share the files via linking, in case of deleting it may create the problem,
- If the link is softlink then after deleting the file we left with a dangling pointer.
- In case of hardlink, to delete a file we have to delete all the reference associated with it.
- General graph directory structure –
In general graph directory structure, cycles are allowed within a directory structure where multiple directories can be derived from more than one parent directory.
The main problem with this kind of directory structure is to calculate total size or space that have been taken by the files and directories.
- It allows cycles.
- It is more flexible than other directories structure.
- It is more costly than others.
- It needs garbage collection.
- Operating System | File Directory | Path Name
- Operating System | Buddy System - Memory allocation technique
- Operating System | Requirements of memory management system
- Operating System | Introduction of Operating System - Set 1
- Operating System | Semaphores in operating system
- Operating System | Starvation and Aging in Operating Systems
- Operating System | Kernel I/O Subsystem (I/O System)
- Operating System | Unix File System
- Operating System | Introduction of System Call
- Operating System | Types of Operating Systems
- Operating System | Paging
- Operating System | Segmentation
- Operating System | Microkernel
- Functions of Operating System
- Operating System | Multithreading
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.