The file system is a mechanism for storing and retrieving file contents, including data and programs. It is always present in secondary storage, designed to hold large amounts of permanent data. This tutorial focuses mainly on accessing file storage on the most common secondary storage medium, the disk.
Disks are ideal for storing files due to their large secondary storage capacity and ability to maintain a file system. They have two characteristics which make them a suitable medium for storing various files:
- A disk can be rewritten in place; it is possible to read a chunk from the disk, modify it, and write it back there in the same place.
- A disk can access directly any given block of data it contains. Hence, it is easy to access any file in sequence or at random, and switching from one single file to another requires only moving the read-write heads and waiting for the disk to rotate to that specific location.
Basic File System Structure
The primary file system requires generic commands for the appropriate device driver, mainly for reading and writing physical blocks on the disk. Each physical block can be identified by its numeric disk address, such as drive 1, cylinder 62, track 2, sector 14, etc.
A file system uses various on-disk and in-memory configurations and structures, which vary depending on the operating system and file system. However, they all follow certain basic principles.
- A boot control block usually contains the information the system requires for booting an operating system from that volume. When the disks do not have any operating system, this block can be treated as empty. This is typically the first chunk of a volume. In UFS, this is termed the boot block; in NTFS, it is the partition boot sector.
- A volume control block holds volume or partition details, such as the number of blocks in the partition, the size of the blocks or chunks, free-block count, and free-block pointers. In UFS, it is termed superblock; in NTFS, it is stored in the master file table.
- A directory structure per file system is required for organizing the files. In UFS, it held the file names and associated 'inode' numbers. In NTFS, it gets stored in the master file table.
- The FCB contains many details regarding any file, which include file permissions, ownership, the size of the file, and the location of data blocks. In UFS, it is called the inode. In NTFS, this information gets stored within the master file table that uses a relational database (RDBM) structure, using a row per file.