File System
File System
• Advantages:
• Since it is a single directory, so its implementation is very easy.
• If the files are smaller in size, searching will become faster.
• The operations like file creation, searching, deletion, updating are very easy in
such a directory structure.
• Disadvantages:
• There may chance of name collision because two files can have the same name.
• Searching will become time taking if the directory is large.
• This can not group the same type of files together.
Two - Level Directory Structure
• 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 their own user files directory
(UFD).
• The UFDs have similar structures, but each lists only the files of a single user.
• System’s master file directory (MFD) is searched whenever a new user id is correct.
• The MFD is indexed by username or account number, and each entry points to the
UFD for that user.
Two - Level Directory Structure
Advantages:
• The main advantage is there can be more than two files with same name, and
would be very helpful if there are multiple users.
• A security would be there which would prevent user to access other user’s
files.
• Searching of the files becomes very easy as only one user's list needs to be
traversed.
Disadvantages:
• As there is advantage of security, there is also disadvantage that the user
cannot share the file with the other users.
• Unlike the advantage users can create their own files, users don’t have the
ability to create subdirectories.
Tree – Structured Directory
• Tree directory structure of operating system is most commonly used in personal
computers.
• User can create files and subdirectories too, which was a disadvantage in the
Two-level directory structures.
• This directory structure resembles a real tree upside down, where the root
directory is at the peak. This root contains all the directories for each user.
• The users can create subdirectories and even store files in their directory.
• A user do not have access to the root directory data and cannot modify it. And,
even in this directory the user do not have access to other user’s directories.
Advantages:
• This directory structure allows subdirectories inside a directory.
• The searching is easier, because in this, we can use both types of paths, which
are the absolute path and relative path.
• File sorting of important and unimportant becomes easier.
• This directory is more scalable than the other two directory structures
explained.
Tree – Structured Directory
• Disadvantages:
• As the user isn’t allowed to access other user’s directory, this prevents the file
sharing among users.
• It is not efficient because, as the user has the capability to make
subdirectories, if the number of subdirectories increase the searching may
become complicated.
• Users cannot modify the root directory data.
• If files do not fit in one, they might have to be fit into other directories.
Acyclic – Graph Directory
• Acyclic directories are a generalization of the Tree directory structure.
• Acyclic directories allow files to have multiple parent directories; this means that
multiple users can access the same file from different paths.
• If any user makes a change, it would be reflected to all the users.
• However, it is important to note that the shared file is not a copy of the same file
in two different directories.
Acyclic – Graph Directory
• It is designed in a way that multiple directories point to a particular directory or
file with the help of links or aliases.
• Link is a pointer to another file or subdirectory.
• There are two types of links : Hard link and soft link
Hard Link :
• A hard link acts as a copy (mirrored) of the selected file. It accesses the data
available in the original file.
• If the earlier selected file is deleted, the hard link to the file will still contain
the data of that file.
Soft Link :
• A soft link (also known as Symbolic link) acts as a pointer or a reference to the
file name. It does not access the data available in the original file.
• If the earlier file is deleted, the soft link will be pointing to a file that does not
exist anymore.
• Thus acyclic directories allow file sharing and make it easier to search for files.
Acyclic – Graph Directory
The deletion of files is complicated in acyclic directories. There are two ways in
which a file can be deleted:
1. Delete the file when any user deletes the file.
• This may lead to dangling pointers.
• The situation may become worse if the deleted space is reallocated to
some new file, and the dangling pointers may now point to an arbitrary
location in the new files.
2. Delete the link to the file.
• This mechanism needs some way of storing the list of links to the file. This
list may become extremely large, so a better method is to keep a count of
the links to the file.
• Whenever a link is deleted, the count is decremented, and when a new link
is created, the count is incremented.
• The file can be deleted when the count becomes zero.
Acyclic – Graph Directory
Advantages :
• The sharing of files is possible.
• Because of different-different paths, searching is easy.
Disadvantages:
• If the files are shared through linking, there may be a problem in the case of
deleting.
• If we are using soft link, then in this case, if the file is deleted then there is
only a dangling pointer which is left.
• If we are using hard link, in this case, when we delete a file, then we also
have to remove all the reference connected with it.