What is Directory Structure in Operating System?

Mahesh Sharma
3 min readAug 23, 2021

--

A directory container is used to store files and folders. It organizes files and folders in a hierarchical fashion.

There are many logical structures for directory. These are listed below.

Directory single-level -
A single-level directory is the simplest type of directory. All files are located in one directory, making it simple to understand and support.

  1. The single-level directory has some limitations. However, this is not true when there are more files or users. All files must share the same directory. If two users call each other to test the dataset, then the unique-name rule is violated.

Advantages:

  • It is easy to implement because it is only one directory.
  • Searches will be faster if files are smaller.
  • In such a directory structure, file operations like search, deletion, and updating are simple.

Disadvantages:

  • Name collisions can occur because two files cannot have the same name.
  • If the directory is large, searching will take too much time.
  • This does not allow you to group files of the same type together.

2. Directory with two levels
As we’ve seen, confusion can often result from a single-level directory. This problem can be solved by creating a separate directory for each user.

Each user is given a user directory (UFD) in the two-level directory structure. Although the UFDs have similar structures, each one lists only files belonging to a single user. The master directory is searched whenever a new user ID=s logs in. Each entry points to the user’s UFD.

Advantages:

  • We can give full path like /User-name/directory-name/.
  • Different users can share the same directory and file name.
  • Thanks to user-grouping and path name, searching for files becomes easier.

Dis-advantages:

  • Users are not permitted to share files with others.
  • It is not easy to scale, however, because two files of the exact same type can’t be combined in one user.

3. Tree-structured directory
After we have established that a directory of two levels is a tree of height 2 and a directory of two levels, it makes sense to expand the directory structure to any height.
This generalization allows users to create their own subdirectories and organize files according to them.

  1. The most common directory structure in os is the tree structure. Each file in the tree has its root directory.

Advantages -

  • It is possible to give the full path name, which is very general.
  • It is very scalable and the likelihood of name collisions is low.
  • It is easy to search, as we can use both absolute and relative paths.

Disadvantages:

  • Each file may not be compatible with the hierarchical model. Files can be saved to multiple directories.
  • We cannot share files.
  • This is because it can be inefficient as accessing files may take place under multiple directories.

4. Directory of cyclic graphs -

Acyclic graphs allow you to share files and subdirectories. Two directories could contain the same file or subdirectory. This is a natural extension of the tree-structured directory.

  1. This is useful when two programmers work on a single project and need to access files. Because they are working together on a joint project, the files associated with them are kept in a separate subdirectory. This allows them to access files from other projects as well as files belonging to other programmers. It is important that the common subdirectories be shared. We use Acyclic directories.
  2. It is important to remember that a shared file is not the exact same as a copy file. If a programmer makes changes in a subdirectory, it will reflect in both.

Advantages:

  • Files can be shared.
  • Different paths make it easy to search.

Disadvantages:

  • The files are shared via linking.
  • If the link is soft link, then delete the file and leave behind a pointer.
  • If a hard link is used, we must delete all references associated with the file.

5. General graph directory structure -
A general graph directory structure allows cycles where multiple directories can be created from one parent directory.
This type of directory structure has one problem: it is difficult to determine the total space or size taken up by files and directories.

Advantages:

  • It allows for cycles.
  • It’s more flexible than other directories structures.

Disadvantages:

It is more expensive than other options.

It requires garbage collection.

--

--

Mahesh Sharma
Mahesh Sharma

Written by Mahesh Sharma

Mahesh Sharma – Digital Marketing Expert | 10+ Years | SEO, PPC, Social Media & Content Strategist | Boosting Brand Visibility & ROI with Data-Driven Marketing.

No responses yet