Directory Structure
What is a 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
Operations in Directory Structure in OS:
We can make the use of the multiple types of file systems that are present on the different operating systems,
Now in order to organize the directory in a optimal way the user must know and should be able to apply the different operations like insert, delete, search, list the entries in the directory. As can be observed below we will understand the different operations that can be performed on the Directory in Operating Structure:
1. Creating: In the directory structure , we can always create new files which can be then inserted to the directory. This also means that we can create new directory to store the files following the rule of giving the directory unique name.
2. Searching: With the search operation, we can search a directory for the required file or even for another directory. We can also perform the search operation in order to list all the files with the same name.
3. Deleting: In the directory if there resides a file That is no longer needed by the user,or even if the files or in some case directories are empty then those files or directories can be deleted. We can also delete the directory which was once required but now no more needed by the user. Also, when a directory is empty it is always resembled by dot and dotdot.
4. List a directory: We can retrieve the list of all the files whihc are present in the directory by the list operation. This also means that the contents of the directory entry, for each file in a list can also be recovered. We usually need to have all the files in the directory opened which needs to be recovered. Once the files are listed then those opened files needs to be closed to free up the internal tablespace.
5. Renaming: We always name the files(based on the content it represents or its uses) present in the directory to quickly access and organize each files in the directory. Now with the help of the rename operation we can rename it in case, if the content inside or the use of the file get changed. We also need to note here that when we rename the file or directory, it also changes its position inside the directory.
6. Link: Whenever we want to link two files so that when the files appear in more than one directory based on the needs or requirements of the user we can simply do so by creating a link between the file and the name specified by the path where the file is to appear. This way the file can be allowed to appear in more than one directory.
7. Unlink: Now if the file is unlinked with respect to the users need we see that by the unlink operation the directory entry is removed and the file is now linked only to one directory. This also means that if a file appears in multiple directories, then only the link is removed.