Operating System - File System
Operating System - File System
File
A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical disks. In general, a file is a sequence of bits, bytes,
lines or records whose meaning is defined by the files creator and user.
File Structure
A File Structure should be according to a required format that the operating system can
understand.
File Type
File type refers to the ability of the operating system to distinguish different types of file such as
text files source files and binary files etc. Many operating systems support many types of files.
Operating system like MS-DOS and UNIX have the following types of files −
Ordinary files
These files contain list of file names and other information related to these files.
Special files
These files represent physical device like disks, terminals, printers, networks, tape drive
etc.
Block special files − data is handled in blocks as in the case of disks and tapes.
Sequential access
Direct/Random access
Sequential access
A sequential access is that in which the records are accessed in some sequence, i.e., the
information in the file is processed in order, one record after the other. This access method is the
most primitive one. Example: Compilers usually access files in this fashion.
Direct/Random access
The records need not be in any sequence within the file and they need not be in adjacent
locations on the storage medium.
An index is created for each file which contains pointers to various blocks.
Index is searched sequentially and its pointer is used to access the file directly.
Space Allocation
Files are allocated disk spaces by operating system. Operating systems deploy following three
main ways to allocate disk space to files.
Contiguous Allocation
Linked Allocation
Indexed Allocation
Contiguous Allocation
Linked Allocation
Indexed Allocation
Each file has its own index block which stores the addresses of disk space occupied by
the file.