What is File System?
The File System is a method or data structure that helps in storing the data or files in the system so that it can be fetched easily when required. The files can be stored without the File System but it would be very difficult to fetch the correct file when required.
The File System stores all the information or properties about a file logically which helps in fetching the required data efficiently.
What is a File?
A collection of related information and data under a single name is called a File. There may be different types of files that store different types of information. All the information stored in a system is stored in a file. Examples of different types of files are Text Files, Program Files, etc.
File Attributes
The information about a particular file is called File Attributes. It is also called the properties of a File.
There are various attributes of a file like
- Name - It is the name of the file according to the stored data for identification.
- Extension - It denotes the type of data stored in a file. Like
.txtextension is used for Text Files. - Size - It is the size of that file.
- Location - It shows the location of the file where it is stored in the system.
- Date - It shows when the last changes were done in the file.
- Protection - It shows who has permission to access a particular file.
File Directories
The File Directory is itself a file that contains information about the files. The File directory is the collection of files. It contains a lot of information about the files like name, type, location, protection, etc.
Different types of operations can be performed on a File Directory.
- Create a File
- Search a File
- Delete a File
- Rename a File
There are various types of File Directories.
- Single Level Directory
- Two Level Directory
- Tree-Structured Directory
Allocation of Files
Files are allocated or stored in disks in different ways. The different methods of File Allocation are explained below.
Contiguous Allocation - In the Contiguous Allocation method, the blocks of files are stored in a contiguous manner in the disk. This means by knowing about the starting block's location of the file and the location of any other block of the file can be predicted because they all are allocated contiguously.
Advantages of Contiguous Allocation.
- This is simple to implement.
- The retrieval of any block is easy.
Disadvantages of Contiguous Allocation.
- External Fragmentation occurs.
- The size of the file should be known before allocation.
Linked List Allocation - In the Linked List Allocation method, it is not necessary to store the blocks of files in a contiguous manner. The first block stores the pointer to the second block and the second block to the third and similarly thereafter. It is not necessary to predefine the size of a file in this method. It also removes external fragmentation as blocks can be stored at random positions.
Advantages of Linked List Allocation.
- It removes external fragmentation.
- The File Size can be increased anytime.
Disadvantages of Linked List Allocation.
- The blocks of files can be accessed only in a sequential manner.
- Internal Fragmentation Occurs.
Indexed File Allocation - In this method, the addresses of all blocks of a file are stored in a separate block. All the blocks of a file are accessed using the data stored in the index block. It also removes the problem of external fragmentation as blocks can be stored at non-contiguous positions. Any block can be accessed directly in this method, unlike Linked List Allocation.
Advantages of Indexed Allocation.
- It removes external fragmentation.
- Data can be accessed directly.
Disadvantages of Indexed Allocation.
- There can be multilevel indexing which makes it a little complex.