Files Directories in Operating System
File Directories in OS
Group of files combined is known as directory. A directory contains all information about file, its attributes. The directory can be viewed as a symbol table that translates file names into their directory entries.Directory itself can be organized in many ways.
The organization must allow us to insert entries, to delete entries, to search for a named entry, and to list all the entries in the directory. In this section, we examine several schemes for defining the logical structure of the directory system.
Types of File Directories in OS
- Single Level Directory
- Two Level Directory
- Tree Structured Directory
Single Level Directory –All the files belong to a single directory
- Easy to implement
- Reduced Redundancy
- All files belong to one same directory
- User can’t have 2 files with same names
- User doesn’t have option to group files according to his/her needs.
Two Level Directories –
In this type of directory each user has its own directory.
In the two-level directory structure, each user has his own user file directory (UFD). The UFDs have similar structures, but each lists only the files of a single user. When a user job starts or a user logs in, the system’s master file directory (MFD) is searched. The MFD is indexed by user name or account number, and each entry points to the UFD for that user.
- Sharing Directory by users problem is solved
- More secure then 1 level directory
- Two users can have file with same name in their own directories.
- Grouping problem is still not solved, for example if user wants to create a directory group for all files that are movies or music., he cant do that
- No two files for a single user can have same names.
Due to two levels there is a path name for every file to locate that file.
Directory is maintained in the form of a tree. Searching is efficient and also there is grouping capability. We have absolute or relative path name for a file.
- Two files can have same names now, if they are in different sub directories.
- Grouping is also possible now