File System Implementation in Operating System

Prerequisite – File Systems in Operating Systems
A file is a collection of related information. The file system resides on secondary storage and provides efficient and convenient access to the disk by allowing data to be stored, located, and retrieved.

File system organized in many layers :

Advantages :



  1. Duplication of code is minimized.
  2. Each file system can have its own logical file system.

Disadvantages :
If we access many files at same time then it results in low performance.

We can implement file system by using two types data structures :

    1. On-disk Structures –
    Generally they contain information about total number of disk blocks, free disk blocks, location of them and etc. Below given are different on-disk structures :
    1. Boot Control Block –
      It is usually the first block of volume and it contains information needed to boot an operating system.In UNIX it is called boot block and in NTFS it is called as partition boot sector.
    2. Volume Control Block –
      It has information about a particular partition ex:- free block count, block size and block pointers etc.In UNIX it is called super block and in NTFS it is stored in master file table.
    3. Directory Structure –
      They store file names and associated inode numbers.In UNIX, includes file names and associated file names and in NTFS, it is stored in master file table.
    4. Per-File FCB –
      It contains details about files and it has a unique identifier number to allow association with directory entry. In NTFS it is stored in master file table.

    2. In-Memory Structure :
    They are maintained in main-memory and these are helpful for file system management for caching. Several in-memory structures given below :

    1. Mount Table –
      It contains information about each mounted volume.
    2. Directory-Structure cache –
      This cache holds the directory information of recently accessed directories.
    3. System wide open-file table –
      It contains the copy of FCB of each open file.
    4. Per-process open-file table –
      It contains information opened by that particular process and it maps with appropriate system wide open-file.

    Directory Implementation :

    1. Linear List –
      It maintains a linear list of filenames with pointers to the data blocks.It is time-consuming also.To create a new file, we must first search the directory to be sure that no existing file has the same name then we add a file at end of the directory.To delete a file, we search the directory for the named file and release the space.To reuse the directory entry either we can mark the entry as unused or we can attach it to a list of free directories.
    2. Hash Table –
      The hash table takes a value computed from the file name and returns a pointer to the file. It decreases the directory search time. The insertion and deletion process of files is easy. The major difficulty is hash tables are its generally fixed size and hash tables are dependent on hash function on that size.

    Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.


    Check out this Author's contributed articles.

    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :