Basic Concepts of Files and File Systems
The file system is one of the most important pieces of system software in an operating system: it manages and stores data. This chapter builds the basic vocabulary of files and file systems, so that everything that follows — directory structures, allocation methods, access control, and concrete implementations — has a solid foundation to stand on.
What Is a File
A file is a named collection of related information that a user stores on secondary storage; it is the basic unit of data management. Files have four defining characteristics:
- Persistence: a file is kept on persistent storage, so its data outlives the program that wrote it
- Naming: every file has a unique name, which is how a user identifies and reaches it
- Structure: the inside of a file has some structure — text, binary, a database format, and so on
- Independence: files are independent of one another, so changing one file does not disturb another
File Categories
Judged by different criteria, files fall into different kinds:
By Content
- Text file: holds readable character data, such as source code or a configuration file
- Binary file: holds machine-executable code or data, such as an executable program or an image file
- Database file: stores structured data, such as the table files of a database
By Purpose
- Program file: contains executable program code
- Data file: stores the data a program needs while it runs
- Configuration file: stores configuration information for the system or for a program
- Temporary file: holds data created while a program is running and discarded afterwards
What Is a File System
A file system is the system software in an operating system responsible for storing, organizing, naming, protecting, and persisting files. It is the interface between users and storage devices, and it gives everyone the same uniform way of getting at data.
Functions of a File System
The file system provides four core functions:
1. Storage Space Management
- Allocate and reclaim storage space
- Manage the free space
- Deal with fragmentation
2. File Organization and Naming
- Provide a naming mechanism for files
- Organize files into a hierarchy
- Manage file metadata
3. File Access Control
- Provide read and write interfaces for files
- Enforce access permissions on files
- Keep files secure
4. Data Persistence
- Guarantee that data is stored durably
- Provide backup and recovery functions
- Keep data consistent when the system crashes
The Layered Structure of File Systems
Modern file systems are usually designed in layers, each one hiding the details of the layer below it:
What Each Layer Does
- User program layer: applications reach their files through the file operation API
- File system interface layer: provides the standard file operations, such as
open,read,write, andclose - File system implementation layer: implements the actual behaviour, including directory management and space allocation
- Device driver layer: takes care of talking to the concrete storage hardware
- Storage device layer: the physical storage medium itself, such as a hard disk or an SSD
1. User Friendliness
- Offer simple, easy-to-use interfaces for file operations
- Support intuitive ways of naming and organizing files
- Provide a rich set of file operations
2. Performance Optimization
- Use storage space efficiently
- Access files quickly
- Optimize I/O operations
3. Reliability
- Keep data consistent and intact
- Recover from failures
- Back up and protect data
4. Security
- Control access permissions
- Protect data with encryption
- Prevent unauthorized access
5. Scalability
- Support large storage capacities
- Adapt to different application needs
- Support many kinds of file
Early File Systems
- Simple file systems: supported only basic file storage and access
- Flat structure: every file sat at the same level, with no notion of a directory
Modern File Systems
- Hierarchical structure: support for multi-level directories and subdirectories
- Advanced features: permission control, journaling, compression, and so on
- Network file systems: support for remote file access and sharing
Future Trends
- Distributed file systems: file storage and access spread across a network
- Cloud storage integration: seamless integration with cloud storage services
- Intelligent file systems: file management and optimization driven by AI
| Term | Abbreviation | Explanation |
|---|---|---|
| File | - | A named collection of data stored on secondary storage |
| File System | FS | The software mechanism that manages files |
| File Attribute | - | The metadata describing a file |
| File Operation | - | Any operation performed on a file |
| File Type | - | The classification of a file |
| File Structure | - | The logical organization of the contents of a file |
| Sequential File | - | A file whose records are arranged in order |
| Indexed File | - | A file that carries an index |
| Indexed Sequential File | - | A file that combines sequential order with an index |
| Direct File | - | A file whose records can be accessed directly |
| Directory | - | The indexing structure that groups files |
| Directory Entry | - | One entry inside a directory |
| Path | - | The identifier of a file’s location |
| Absolute Path | - | A path that starts at the root directory |
| Relative Path | - | A path that starts at the current directory |
| File Name | - | The name of a file |
| File Extension | - | The suffix of a file name |
| Mount | - | Attaching a file system into the directory tree |
| Unmount | - | Detaching a file system from the directory tree |
| Virtual File System | VFS | A uniform interface over all file systems |
| File Descriptor | FD | The identifier of an opened file |
| File Control Block | FCB | The metadata structure of a file |
| Index Node | inode | The UNIX metadata structure of a file |
