operating-systems file-management
Definition
File Types
Operating systems distinguish between different types of files to determine how they should be handled, interpreted, and executed.
1. Regular Files
Contain user data or program code.
- ASCII Files: Consist of lines of text. They are portable and can be edited with any text editor.
- Binary Files: Contain arbitrary sequences of bits. These include:
- Data Files: Specific to an application.
- Executables: Programs that the OS can run.
Executable Format
The OS must be able to interpret the internal structure of an executable. A typical format (e.g., ELF in Linux or PE in Windows) includes:
- Magic Number: A specific bit pattern at the very beginning used to identify the file type to the kernel.
- Header: Contains metadata (e.g., file size, entry point).
- Text Segment: The machine code instructions.
- Data Segment: Initialised variables.
- Symbol Table: Information used for debugging and dynamic linking.
Directories
Special system files used to maintain the structure of the file system. They map file names to the corresponding file identifiers or metadata (see File Directory).
Special Files
Used to represent IO devices as if they were files.
- Character Special Files: Represent devices that manage data as a stream of characters (e.g., terminals, serial ports).
- Block Special Files: Represent devices that handle data in fixed-size blocks (e.g., hard disks).