6.1 File-Concept, Attributes, Operations, Types, File System Structure
6.1 File-Concept, Attributes, Operations, Types, File System Structure
6.1 File-Concept, Attributes, Operations, Types, File System Structure
The operating system can provide system calls to create, write, read, reposition, delete,
and truncate files. There are six basic file operations within an Operating system. These
are:
•Creating a file: There are two steps necessary for creating a file. First, space in the file
system must be found for the file. We discuss how to allocate space for the file. Second,
an entry for the new file must be made in the directory.
•Writing a file: To write to a file, you make a system call specify about both the name of
the file along with the information to be written to the file.
•Reading a file: To read from a file, you use a system call which specifies the name of the
file and where within memory the next block of the file should be placed.
•Repositioning inside a file: The directory is then searched for the suitable entry, and
the 'current-file-position' pointer is relocating to a given value. Relocating within a file
need not require any actual I/O. This file operation is also termed as 'file seek.'
•Deleting a file: For deleting a file, you have to search the directory for the specific file.
Deleting that file or directory release all file space so that other files can re-use that
space.
•Truncating a file: The user may wish for erasing the contents of a file but keep the
attributes same. Rather than deleting the file and then recreate it, this utility allows all
attributes to remain unchanged — except the file length — and let the user add or edit
the file content
File System Structure
File System provide efficient access to the disk by allowing data to be stored, located and
retrieved in a convenient way. A file System must be able to store the file, locate the file and
retrieve the file.
• When an application program asks for a file, the first request is directed to the logical file
system. The logical file system contains the Meta data of the file and directory structure.
• Logical file systems also verify the path to the file.
• files are divided into various logical blocks. Files are to be stored in the hard disk and to
be retrieved from the hard disk. Hard disk is divided into various tracks and sectors.
Therefore, in order to store and retrieve the files, the logical blocks need to be mapped
to physical blocks. This mapping is done by File organization module.
• The basic file system is responsible for issuing the commands to I/O control in order to
fetch those blocks.
• I/O controls contain the codes by using which it can access hard disk. These codes are
known as device drivers.