File System in Operating System
What is File System in Operating System
A file is a collection of related information that is recorded on secondary storage. Or file is a collection of logically related entities. From user’s perspective a file is the smallest allotment of logical secondary storage. A file is a collection of correlated information which is recorded on secondary or non-volatile storage like magnetic disks, optical disks, and tapes.
File system is the part of the operating system which is responsible for file management. It provides a mechanism to store the data and access to the file contents including data and programs. Some Operating systems treats everything as a file for example Ubuntu. A file has various kinds of structure. Some of them can be;
- Simple Record Structure with lines of fixed or variable lengths.
- Complex Structures like formatted document or reloadable load files.
- No Definite Structure like sequence of words and bytes etc.
Attributes of a File
Following are some of the attributes of a file;
- Name: It is the only information which is in human-readable form.
- Identifier: The file is identified by a unique tag(number) within file system.
- Type: It is needed for systems that support different types of files.
- Location: Pointer to file location on device.
- Size The current size of the file.
- Protection This controls and assigns the power of reading, writing, executing.
- Time, date, and user identification This is the data for protection, security, and usage monitoring.
File Access Methods
The way that files are accessed and read into memory is determined by Access methods. Usually a single access method is supported by systems while there are OS's that support multiple access methods.
1. Sequential Access
- Data is accessed one record right after another is an order.
- Read command cause a pointer to be moved ahead by one.
- Write command allocate space for the record and move the pointer to the new End Of File.
- Such a method is reasonable for tape.
2. Direct Access
- This method is useful for disks.
- The file is viewed as a numbered sequence of blocks or records.
- There are no restrictions on which blocks are read/written, it can be dobe in any order.
- User now says "read n" rather than "read next".
- "n" is a number relative to the beginning of file, not relative to an absolute physical disk location.
3. Indexed Sequential Access
- It is built on top of Sequential access.
- It uses an Index to control the pointer while accessing files.
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, it is called folders. 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, block, and words in the file.
- Protection: Access control on read/write/execute/delete.
- Usage: Time of creation, access, modification