File Systems
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 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.
The File system takes care of the following issues
- File Structure
- Recovering Free space
- disk space assignment to the files
- tracking data location
We have seen various data structures in which the file can be stored. The task of the file system is to maintain an optimal file structure.
Whenever a file gets deleted from the hard disk, there is a free space created in the disk. There can be many such spaces which need to be recovered in order to reallocate them to other files.
The major concern about the file is deciding where to store the files on the hard disk. There are various disks scheduling algorithm which will be covered later in this tutorial.
A File may or may not be stored within only one block. It can be stored in the non contiguous blocks on the disk. We need to keep track of all the blocks on which the part of the files reside.
The name of the file is divided into two parts as shown below:
- name
- extension, separated by a period.
Files attributes and its operations:
Attributes | Types | Operations |
---|---|---|
Name | Doc | Create |
Type | Exe | Open |
Size | Jpg | Read |
Creation Data | Xis | Write |
Author | C | Append |
Last Modified | Java | Truncate |
protection | class | Delete |
Close |
File type | Usual extension | Function |
---|---|---|
Executable | exe, com, bin | Read to run machine language program |
Object | obj, o | Compiled, machine language not linked |
Source Code | C, java, pas, asm, a | Source code in various languages |
Batch | bat, sh | Commands to the command interpreter |
Text | txt, doc | Textual data, documents |
Word Processor | wp, tex, rrf, doc | Various word processor formats |
Archive | arc, zip, tar | Related files grouped into one compressed file |
Multimedia | mpeg, mov, rm | For containing audio/video information |
Markup | xml, html, tex | It is the textual data and documents |
Library | lib, a ,so, dll | It contains libraries of routines for programmers |
Print or View | gif, pdf, jpg | It is a format for printing or viewing a ASCII or binary file. |
FILE DIRECTORIES:
Collection of files is a file directory. The directory contains information about the files, including attributes, location and ownership. Much of this information, especially that is concerned with storage, is managed by the operating system. The directory is itself a file, accessible by various file management routines
Information contained in a device directory are:
- Name
- Type
- Address
- Current length
- Maximum length
- Date last accessed
- Date last updated
- Owner id
- Protection information
Operation performed on directory are:
- Search for a file
- Create a file
- Delete a file
- List a directory
- Rename a file
- Traverse the file system
Advantages of maintaining directories are:
- Efficiency: A file can be located more quickly.
- Naming: It becomes convenient for users as two users can have same name for different files or may have different name for same file.
- Grouping: Logical grouping of files can be done by properties e.g. all java programs, all games etc.
SINGLE-LEVEL DIRECTORY
In this a single directory is maintained for all the users.
- Naming problem: Users cannot have same name for two files.
- Grouping problem: Users cannot group files according to their need.