For most users, the file system is the most visible aspect of a general-purpose operating system.
The file systems are a method of abstraction. A file system simplifies access to the operating system resources. They mainly focus on the simplification of storage devices.
With file system abstractions, the operating system provides a uniform logical view of stored information.
File systems abstract away the complexity of the resources by providing simple interfaces. The main objective of a file system is to provide an abstract data type called a File to provide uniform access to storage devices. File systems also provide the same uniform access methods for other system resources thereby reducing the overall complexity of an operating system.
The physical properties of the storage device abstracted away with a logical storage unit, file, provided by the OS.
The level of sophistication of an operating system can potentially be measured by looking at how advanced its file systems are. The most sophisticated operating systems only provide a file system interface to access all the system resources. Thereby, the operating system API complexity is reduced which results in an increase in learnability and high developer experience.
As the file systems get more sophisticated, it allows the operating system to extend its feature set without introducing additional complexity.
File systems provide efficient and convenient access to the storage device by allowing data to be stored, located, and retrieved easily.
File System Design Problems
A file system poses two quite different design problems.
1 – How the file system should look to the user?
- The task involves defining the following aspects:
- Defining a file and its attributes
- Defining the operations allowed on a file.
- Defining a directory structure for organizing files.
2 – How to map logical fs level algorithms and data structures to the physical storage devices.
File Abstract Type
|File Field||Field Description|
|Name||Human readable file identifier.|
|Identifier||A unique number to identify the file internally.|
|Type||The way the file is processed changes depending on its type.|
|Location||Pointer to the storage medium|
|Size||The current file length|
|Protection||Access control information. Who can read-write-execute?|
|Timestamps||Last access, last modification, and formation timestamps.|
|User||The file owner.|
Basic File Operations
A file is an abstract data type.
1 – Forming a file
- Search empty space for the new file.
- Insert new file directory entry.
2 – Opening a file
Instead of using file names in all operations, the file opening concept increases the efficiency of the file system.
The handle obtained when opening a file will be used throughout the file lifetime, thereby most of the operations required to locate the file will not be required.
The use of a file handle rather than a file name removes the need for file name evaluation and access permission checks.
3 – Writing a file
The file system keeps track of the writes using a pointer called file offset. File offset advanced whenever a write occurs.
4 – Reading a file
The file system keeps track of the reads using a pointer called file offset. The file offset is advanced whenever a read occurs.
5 – Repositioning within a file
Reposition the file offset. Repositioning is known as seeking.
- It does not involve any actual IO.
6 – Deleting a file
- Search for the directory entry associated with the given file name.
- Release file resources.
- Mark the entry as free.
7 – Truncating a file
Truncation allows the change of the file length without change in other file attributes.
- File length can also be increased in addition to reducing the file length.
File System Modules
1 – File organization module
- File metadata
2 – Directory organization module
3 – Free Space Management
Keeps track of unallocated blocks.
- Slack Space Management
4 – Caching
Caches hold various frequently accessed file system structures, directory entries, and data blocks for efficiency.
5 -Volume management
- Boot control block per volume
- It is used by the system to boot an OS from a bootable volume.
- In UFS, it is called the boot block.
- Volume control block per volume
- Volume metadata.
- In UFS it is called the superblock.
 Operating System Concepts, Abraham Silberschatz 10th edition, File Systems