Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

6.

1 file-concept, attributes, operations, types, file system structure


• A file is a named collection of related information that is recorded on secondary
storage such as magnetic disks, magnetic tapes and optical disks. In general, a file is
a sequence of bits, bytes, lines or records whose meaning is defined by the files
creator and user.
• file is a collection of logically related entities.
File structure
A File Structure needs to be predefined format in such a way that an operating
system understands . It has an exclusively defined structure, which is based on its
type.
Three types of files structure in OS:
•A text file: It is a series of characters that is organized in 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.
File Attributes
A file has a name and data. Moreover, it also stores meta information like file creation date
and time, current size, last modified date, etc. 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: Points to file location on device.
•Type: This attribute is required for systems that support various types of files.
•Size. Attribute 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 also used for monitoring
File Type
It refers to the ability of the operating system to differentiate various types of files like text files,
binary, and source files. However, Operating systems like MS_DOS and UNIX has the following type of
files:
Character Special File
It is a hardware file that reads or writes data character by character, like mouse, printer, and more.
Ordinary files
•These types of files stores user information.
•It may be text, executable programs, and databases.
•It allows the user to perform operations like add, delete, and modify.
Directory Files
•Directory contains files and other related information about those files. Its basically a folder to hold
and organize multiple files.
Special Files
•These files are also called device files. It represents physical devices like printers, disks, networks,
flash drive, etc.
File types- name, extension
File Type Usual extension Function
Executable exe, com, bin ready-to-run machine- language program
Object obj, o complied, machine language, not linked
Source code c., asm, a source code in various languages
Batch bat, sh Series of commands to be executed
Text txt, doc textual data documents
Word doc,docs, etc. various word-processor formats
processor
Library lib, libraries of routines
Archive arc, zip, tar related files grouped into one file, sometimes
compressed.
File operations:

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.

You might also like