Files are the building blocks of any operating system. Permanent storage of information and data is a file. File provides an easy means of information sharing. The operating system is not interested in the information stored in the files.
UNIT
IV: Storage Management
Chapter
6:
Syllabus
• Files are the building blocks of any
operating system. Permanent storage of information and data is a file. File
provides an easy means of information sharing. The operating system is not
interested in the information stored in the files. Operating system map files
with physical devices.
• An unstructured sequence of data means
a file. It is also logical units of information created by processes.
Information stored in the files must be persistent. File is any organized
information and stored within the secondary storage. It is physical view of a
file.
•
A program which user prepare is a file. File represents programs and data. The
output from complier may be an object code file or an executable file.
• Content or information/data of file is
decided by the creator of the file. File contains various types of data like
source program, object program, text and numeric data, images, graphs, sounds,
payroll records, dead-stock records etc.
• File store information on the disk. It
is an abstract mechanism. File name is given, when process creates a file. File
name continues to exist even after closing a file. It is accessed by other
process.
• File name rule is changed according
the operating system. All operating system allowed upto 8 string as a file
name. Special characters and numbers are allowed to use as a file name. Many
file systems support names as long as 255 characters. File names contains two
parts. It is separated by a period. For example: sorting.c
• In the file name, after period is
called file extension. File extension indicates something about a file. UNIX
operating system support more than one file extension. It is up to the user,
for extending the file extension.
• MS-DOS
support only one file extension. File extension after period contains upto
three characters. Following is the list of file extension.
•
File type represents the internal structure of the file. According to the
structure, file is divided into certain types: text, source, executable and
object file.
1.
Text file: It is
sequence of character which organized into lines. Text file is a regular file.
2.
Source file:
It contains sequence of subroutines, procedure and functions.
3.
Executable file: It contains
a series of code sections. This file is input to the loader and loader loads
this file into memory and then execute.
4. Object file:
Object file is input to the linker. An Object file is a binary file that the
compiler creates that converts the source to object code.
File
is divided into following types:
1. Ordinary file
2.
Directory file
3.
FIFO file
4. Character device file
5.
Block device file.
Ordinary
file
• Also called regular file. It contains only data as a stream
of characters. An bis ordinary file cannot contain another file, or directory.
•
It is either text file or a binary file.
• Examples of ordinary files include
simple text files, application data files, files containing high-level source
code, executable text files, and binary image files.
•
Text file: It contains only printable characters.
• Binary
file: It contains printable and unprintable characters that cover the
entire ASCII range.
•
Regular files may be created, browsed through, and modified by various means
such as text editors.
Directory
file
•
A directory file is like a folder that contains other files, including
subdirectory files.
• Directory files act as a container for other files, of any
category. Directory files don't contain data in the user sense of data; they
merely contain references to the files contained within them.
•
Directory is created in UNIX by the mkdir command.
•
The UNIX directory is considered empty if it contains no other files except the
"." and "..".
• Directory is removed by using rmdir
command. Content of directory is displayed. by ls command.
Device
file
• Special
files are also known as device files. In UNIX all physical devices are accessed
via device files; they are what programs use to communicate with hardware.
• Files hold information on location,
type, and access mode for a specific device. There are two types of device
files; character and block.
•
Block device files are used to
access block device I/O. Block devices do buffered ar I/O, meaning that the
data is collected in a buffer until a full block can be transferred.
• Character
device files are associated with character or raw device access. They are
used for un-buffered data transfers to and from a device. Rather than
transferring data in blocks the data is transferred character by character.
• One transfer can consist of multiple
characters.
• Some devices, such as disk partitions,
may be accessed in block or character mode. Because each device file
corresponds to a single access mode, physical devices that have more than one
access mode will have more than one device file.
• Device files are found in the /dev
directory. Each device is assigned a major and minor device number."
•
The major device number identifies the type of device, i.e. all SCSI devices,
would have the same number as would all the keyboards.
•
The minor device number identifies a specific device, i.e. the keyboard
attached to workstation.
• Device files are created using the
mknod command.
• Example
of character device files is printers, modems and consoles.
FIFO
file
•
FIFO file is special pipe device file which provides temporary buffers for two
or more processes to communicate by writing data to and reading data from the
buffer.
•
A FIFO is created by the mknod system call and may be opened and accessed by
any process that knows the name and has the permissions.
• The buffer associated with a FIFO file
is allocated when the first process opens the FIFO file for read or write. The
buffer is discarded when all processes which are connected to the FIFO close
their reference to the FIFO file.
• FIFO file may be removed like any
regular file. FIFO files can be removed in UNIX via the rm command.
•
One of the characteristics of file is a set of file attributes that give the
operating system more information about the file and how it is intended to be
used. For human users convenience bane is given to the file. File attributes
are varies from system to system.
• File attributes are as follows:
1.
Name
2.
Identifier
3.
Type
4.
Location/place
5.
Size
6.
Protection
7.
Date and Time
• File name is in human readable. User
can perform any operation on file using its name.
•
When file is created by user, operating system assigns unique identification
number to each file. OS uses this identifier for its operation.
•
Type
information is required for systems that support different types of files.
• Location/place
information is pointer to a device and actual location of files on the device.
The information needed to locate the file on disk is kept in memory.
• Size
is measured in bits or bytes. It gives idea about current size of the file.
• Protection:
This information is stored on the per-process table so the operating system can
allow or deny subsequent requests. Attributes like protection, password,
creator and owner provides protection to a file.
•
Date and time: This information is
related to creation and modification of files. Protection, security and
monitoring purposes this data is used by operating system.
•
File operations are simply those things that user can perform on a file. For
example, user can create a file, save a file, open a file, read a file and
modify a file. There are many different types of file operations supported by
operating system.
• Operating system can provides system
call for performing various operations on the file. Six basic file operations
are creating, write, read, delete, repositioning and truncating.
• Following are the some list of file
operation:
1.
Create
2.
Write
3.
Closes
4.
Read
5.
Delete
6. Repositioning.
• All these operations require that the
directory structure be first searched for the target file.
•
File creation:
Any time user can create a file. File is also created without data. The steps for creating a file.
a. Space: File system must provide a
space for the file.
b. New file entry is made in the
directory.
•
Write: To
perform write operation on the file, file name and data is required. It updates
a file by adding new data and changes some content of the file. For writing
into a file, operating system searches the directory for particular file. Write
pointer is kept at the location where the writing starts. Write pointer position
is at middle of the file or end of the file. Write pointer is updated when
writing to file is completed.
•
Close:
Process is not used a file after closing. Process can not perform any operation
on file. Operating system remove it entry from open file table.n
• Read:
A process reads all or some portion of the data in a file. Read system call is
used for reading a file. For reading a file, name and position of the memory is
specified. Read pointer is kept into the file for next read operation. Read
pointer is updated after completion of the read system call. Information about
read pointer is stored in per process current file position pointer.
•
Delete:
Operating system remove the file from file structure. For deleting a file, no
directory is searched with particular name and file is deleted. Deleting means making space free from memory and disk. Operating system
also removes the directory entry. This free space is used by another file.
ein
• Repositioning: The directory is searched for the proper entry, and
the current-file-position pointer is repositioned to a given value.
Repositioning within
• Other file operations are open,
append, seek, get and set attributes and rename.
•
Open: Before
performing any operation on file, it is necessary to
•
Append: Append is related to write operation of file. Append
only add data to the end of the file.
•
Get and set attributes:
Get attribute is used before performing operation on file. When user request a
file for any operation, get attributes is executed by the process. Depending
upon the attributes, user can allow or deny the operation. User can set the
attributes and it changed after creation of file.
•
Rename:
User can change the name of existing file.
• File structure is represented by field, record, file and
database. It is also represented by byte sequence, record sequence and tree.
• Fig. 6.1.1 shows the three different
kinds of files. Unix and windows both use unstructured byte sequence
• Byte
sequence is unstructured file. Operating system is nothing to do with content of file. All
content is in byte format. Windows and UNIX operating system uses this byte
sequence method. It provides more flexibility to the user. User can put
anything in the file and assign name whatever they want to the file.
• In
record sequence model, file contains a sequence of fixed length record. Read
and write operation on this type of file will perform one record at a time. It
uses an idea of 80 column punched card. Most of the operating system based
their file system on file consisting of 80 character records.
• Record sequence model also support 132
character records. Line printer uses 132 characters for printing.
• Last method is tree structure. File
consists of tree of records. Each record contains key field in the fixed
position. Key field is used to sort the tree record.
• Field, record, file and database is
used in these file structure. Field is a basic element of data. Persons last
name and date example of the field. It contains single value. Length and data
type is characteristics of field.
•
Collection of related field is records. A student record contains name,
address, mobile number, university exam number, college name etc. Records may
be fixed length or variable length. A record also contains sub-records.
Sub-records may be one or more than one.
•
File is collection of similar records. From user view, file is single entity
and reference by name.
• Database is a
collection of related data. All records have some relation in database.
Engineering college database contains information about college, student,
staff, university, syllabus, timetable, fee' structure, various departments
etc. One or more field is used in database.
Introduction to Operating Systems: Unit IV(b): File System : Tag: : File System - Introduction to Operating Systems - Basic File Concepts
Introduction to Operating Systems
CS3451 4th Semester CSE Dept | 2021 Regulation | 4th Semester CSE Dept 2021 Regulation