In this tutorial, we will know how operating system handles file systems.
A file is a grouping of linked data, we save it on secondary storage. A collection of logically connected elements is referred to as a file. A file is the smallest allocation of logical secondary storage from the user’s perspective.
What is a File Directory :
A file directory is a collection of files. The directory includes attributes, location, and ownership information about the files. The operating system is in charge of a lot of this data, especially when it comes to storage. The directory is a file in and of itself, accessible using a variety of file management techniques.
Operations Performed on Directory :
- We can search for a file
- It is possible to create a file
- We may delete a file
- We can list a directory
- Rename operation on a file
- We may traverse the file system.
Types of File Directories in File Systems :
Single level directory – here for all users we maintain a single directory.
Two level directory – in this case, for each users operating system maintains separate directories .
Tree-structured directory – The directory is basically organized into a tree structure. Searching is quick and easy, and grouping is also possible.
File Allocation Methods :
1. Continuous Allocation in File Systems
At the moment of file creation, we assign a single continuous set of blocks to the file. As a result, this is a variable-size part pre-allocation approach. Each file only requires a single entry in the file allocation table, which shows the file’s starting block and length.
2. Linked Allocation in File Systems
The allocation is done on a block-by-block basis. A pointer to the next block in the chain is included in each block. The file table only requires a single entry for each file, indicating the file’s beginning block and length. We can extend the chain by adding any free block. The blocks don’t have to be consecutive. If a free disc block is available then increasing the file size is always possible.
3. Indexed Allocation in File Systems
In this scenario, each file has its own one-level index in the file allocation table: Each block assigned to the file has its own entry in the index. We can use either fixed-size blocks or variable-size blocks for allocation. This file allocation strategy allows for both sequential and direct access to the file, making it the most popular.