Explain directory structure with various level of directory
Directory can be defined as the listing of the related files on the disk. The directory may store some or the entire file attributes.
To get the benefit of different file systems on the different operating systems, A hard disk can be divided into the number of partitions of different sizes. The partitions are also called volumes or mini disks.
Each partition must have at least one directory in which, all the files of the partition can be listed. A directory entry is maintained for each file in the directory, which stores all the information related to that file.
A directory can be viewed as a file, which contains the Meta data of the bunch of files.
Every Directory supports a number of common operations on the file:
⦁ File Creation
⦁ Search for the file
⦁ File deletion
⦁ Renaming the file
⦁ Traversing Files
⦁ Listing of files
Single Level Directory
The simplest method is to have one big list of all the files on the disk. The entire
system will contain only one
directory, which is supposed to
mention all the files
present in the file system. The directory contains one entry per the file system.
each file present on
This type of directories can be used for a simple system.
Advantages
⦁ Implementation is very simple.
⦁ If the sizes of the files are very small then the searching becomes faster.
⦁ File creation, searching, deletion is very simple since directory.
Disadvantages
we have only one
⦁ We cannot have two files with the same name.
⦁ The directory may be very big therefore searching for a file may take so much time.
⦁ Protection cannot be implemented for multiple users.
⦁ There are no ways to group same kind of files.
⦁ Choosing the unique name for every file is a bit complex and limits the number of files in the system because most of the Operating System limits the number of characters used to construct the file name.
Two Level Directory
In two level directory systems, we can create a separate directory for each user. There is one master directory, which contains separate directories dedicated to each user. For each user, there is a different directory present
at the second level, containing group of user's file. The system doesn't let a user to enter in the other user's directory without permission.
Characteristics of two level directory system
⦁ Each files has a path name as /User-name/directory-name/
⦁ Different users can have the same file name.
⦁ Searching becomes more efficient as only one user's list needs to be traversed.
⦁ The same kind of files cannot be grouped into a single directory for a particular user.
Every Operating System maintains a variable as PWD, which contains the present
directory, name (present user name) so that the searching can be done appropriately.
Tree Structured Directory
In Tree structured directory system, any directory entry can either be a file or sub
directory. Tree structured directory system overcomes the drawbacks of two level directory system. The similar kind of files can now be grouped in one directory.
Each user has its own directory and it cannot enter in the other user's directory. However, the user has the permission to read the root's data but he cannot write or modify this. Only administrator of the system has the complete access of root directory.
Searching is more efficient in this directory structure. The concept of current working
directory is used. A file can absolute.
be accessed by two types of path, either relative or
Absolute path is the path of the file with respect to the root directory of the system
while relative path is the path with respect to the current working directory of the system. In tree structured directory systems, the user is given the privilege to create the files as well as directories.