File Systems in Operating System: Structure, Attributes, Types
โก Smart Summary
File system in an operating system organizes, stores, and retrieves data on secondary storage such as magnetic disks, optical disks, and tapes, defining file structure, attributes, access methods, and allocation so programs manage information reliably.

What is File System?
A file is a collection of correlated information which is recorded on secondary or non-volatile storage like magnetic disks, optical disks, and tapes. It is a method of data collection that is used as a medium for giving input and receiving output from that program.
In general, a file is a sequence of bits, bytes, or records whose meaning is defined by the file creator and user. Every file has a logical location where it is placed for storage and retrieval.
Objective of File Management System
Here are the main objectives of the file management system:
- It provides I/O support for a variety of storage device types.
- It minimizes the chances of lost or destroyed data.
- It helps the OS standardize I/O interface routines for user processes.
- It provides I/O support for multiple users in a multiuser system environment.
Properties of a File System
Here are the important properties of a file system:
- Files are stored on disk or other storage and do not disappear when a user logs off.
- Files have names and are associated with access permissions that permit controlled sharing.
- Files can be arranged in more complex structures to reflect the relationship between them.
File Structure
A file structure needs a predefined format in such a way that an operating system understands it. It has an exclusively defined structure, which is based on its type.
Three types of file structure in OS are:
- A text file: It is a series of characters that is organized into lines.
- An object file: It is a series of bytes that is organized into blocks.
- A source file: It is a series of functions and processes.
Reading Suggestion:- What is Operating System? Explain Types of OS, Features and Examples.
File Attributes
A file has a name and data. Moreover, it also stores meta information like file creation date and time, current size, and last modified date. All this information is called the attributes of a file system.
Here are some important file attributes used in OS:
- Name: It is the only information stored in a human-readable form.
- Identifier: Every file is identified by a unique tag number within a file system known as an identifier.
- Location: It points to the file location on the device.
- Type: This attribute is required for systems that support various types of files.
- Size: This attribute is used to display the current file size.
- Protection: This attribute assigns and controls the access rights of reading, writing, and executing the file.
- Time, date, and security: It is used for protection, security, and monitoring.
File Type
File type refers to the ability of the operating system to differentiate various types of files like text files, binary files, and source files. Operating systems like MS-DOS and UNIX have the following types of files:
Character Special File
It is a hardware file that reads or writes data character by character, like a mouse, printer, and more.
Ordinary Files
- These types of files store user information.
- They may be text, executable programs, or databases.
- They allow the user to perform operations like add, delete, and modify.
Directory Files
- A directory contains files and other related information about those files. It is basically a folder to hold and organize multiple files.
Special Files
- These files are also called device files. They represent physical devices like printers, disks, networks, and flash drives.
Functions of File
- Create a file, find space on the disk, and make an entry in the directory.
- Write to a file, which requires positioning within the file.
- Read from a file, which involves positioning within the file.
- Delete a directory entry and regain disk space.
- Reposition: move the read/write position.
Commonly Used Terms in File Systems
Field
This element stores a single value, which can be static or variable length.
Database
A collection of related data is called a database. Relationships among elements of data are explicit.
Files
A file is a collection of similar records that is treated as a single entity.
Record
A record type is a complex data type that allows the programmer to create a new data type with the desired column structure. It groups one or more columns to form a new data type. These columns have their own names and data type.
File Access Methods
File access is a process that determines the way files are accessed and read into memory. Generally, a single access method is always supported by operating systems, though some operating systems also support multiple access methods.
Three file access methods are:
- Sequential access
- Direct random access
- Index sequential access
Sequential Access
In this type of file access method, records are accessed in a certain pre-defined sequence. In the sequential access method, information stored in the file is also processed one by one. Most compilers access files using this access method.
Random Access
The random access method is also called direct random access. This method allows accessing the record directly. Each record has its own address, which can be directly accessed for reading and writing.
Index Sequential Access
This type of access method is based on simple sequential access. In this access method, an index is built for every file, with a direct pointer to different memory blocks. In this method, the index is searched sequentially, and its pointer can access the file directly. Multiple levels of indexing can be used to offer greater efficiency in access. It also reduces the time needed to access a single record.
Space Allocation
In the operating system, files are always allocated disk spaces. Three types of space allocation methods are:
- Linked Allocation
- Indexed Allocation
- Contiguous Allocation
Contiguous Allocation
In this method:
- Every file uses a contiguous address space on memory.
- Here, the OS assigns disk addresses in linear order.
- In the contiguous allocation method, external fragmentation is the biggest issue.
Linked Allocation
In this method:
- Every file includes a list of links.
- The directory contains a link or pointer in the first block of a file.
- With this method, there is no external fragmentation.
- This file allocation method is used for sequential access files.
- This method is not ideal for a direct access file.
Indexed Allocation
In this method:
- The directory comprises the addresses of index blocks of the specific files.
- An index block is created, having all the pointers for specific files.
- All files should have individual index blocks to store the addresses for disk space.
File Directories
A single directory may or may not contain multiple files. It can also have sub-directories inside the main directory. Information about files is maintained by directories. In Windows OS, they are called folders.
Single Level Directory
Following is the information which is maintained in a directory:
- Name: The name which is displayed to the user.
- Type: Type of the directory.
- Position: Current next-read/write pointers.
- Location: Location on the device where the file header is stored.
- Size: Number of bytes, blocks, and words in the file.
- Protection: Access control on read/write/execute/delete.
- Usage: Time of creation, access, and modification.
File Types- name, extension
| File Type | Usual extension | Function |
| Executable | exe, com, bin or none | ready-to-run machine-language program |
| Object | obj, o | compiled, machine language, not linked |
| Source code | c, p, pas, 177, asm, a | source code in various languages |
| Batch | bat, sh | series of commands to be executed |
| Text | txt, doc | textual data documents |
| Word processor | doc, docs, tex, rrf, etc. | various word-processor formats |
| Library | lib, h | libraries of routines |
| Archive | arc, zip, tar | related files grouped into one file, sometimes compressed |

