OS File System
OS File System – A file is basically a name of collection of related information that is recorded on secondary storage such as magnetic tapes, magnetic disks and optical disks. Usually, a file is a classification of bits, bytes, lines or records whose meaning is defined by the files creator and user.
File-Structure
It is a structure, that is according to a requisite format that operating system can understand.
- A file has a defined structure according to its type.
- A text-file is a sequence of characters ordered into lines.
- A source-file is an arranged sequence of procedures and functions.
An object file is basically a sequence of bytes ordered into blocks that are understandable by the machine. When OS states different file structures, it also holds the code to support these file structure. MS-DOS, UNIX support least number of file structure.
File Type
It is refers to the capacity of the operating system to differentiate different types of file such as source files, text files and binary files etc. Several operating systems support several types of files. Operating system like UNIX and MS-DOS has the following types of files:
Ordinary files
- These are the files that hold user information.
- These might have databases, text or executable program.
The user can apply several operations on such files like modify, add, delete or even remove the entire file.
Directory files
These files have list of file names and other information associated to these files.
Special files
These files signify physical device like terminals, disks, printers, tape drive, networks, etc. There are two types of files.
- Character-special files: Data is controlled character by character as in case of printers or terminals.
- Block-special files: Data is controlled in blocks as in the case of tapes and disks.
File Access Mechanisms
It refers to the method in which the records of a file might be accessed.
There are following several ways to access files:
- Sequential access
- Direct/Random access.
- Indexed sequential access
Sequential Access
In this the records are retrieved in some sequence i.e. the information in the file is managed in order, one record after the other. This access scheme is the most primitive one. For example compilers normally access files in this fashion.
Direct/Random access
- Random access file organization offers, direct access to the records.
- Individually record has its own address on the file by the help of which it can be directly
accessed for reading or writing purpose. - The records must not be in any sequence with-in the file and they must not be in
contiguous locations on the storage medium.
Indexed Sequential Access
- This scheme is built up on base of sequential access.
- An index is generated for every file which contains pointers to various blocks.
- Index is searched consecutively and its pointer is used to access the file directly.
Space Allocation
Files are allotted disk spaces by operating system. Operating systems deploy these three
key means to allocate disk space to files.
- Contiguous Allocation
- Linked Allocation
- Indexed Allocation
Contiguous Allocation
· Each file reside in a contiguous address space on disk.
· Allotted disk address is in linear order.
· Easy to implement.
· External-fragmentation is a main problem with this type of allocation technique.
Linked Allocation
· Each file brings a list of links to disk blocks.
· Directory holds link/pointer to first block of a file.
· No external-fragmentation
· Effectively used in sequential access file.
· Inefficient in case of direct access file.
Indexed Allocation
· Delivers solutions to problems of adjacent and linked allocation.
· A index-block is generated having all pointers to files.
- Separately file has its own index block which stores the addresses of disk space engaged bythe file.
- Directory has the addresses of index blocks of files