File Management
File Management
TOPICS
• File-Concepts,Attributes,types
• File System Structure
• Access Methods-Sequential,Direct
• File Allocation methods-Contiguous,Linked,Indexed
• Directory Structure-Single level,two level,tree structured directory
• Disk organization
• RAID
• RAID levels
Information management
• Two Main Modules
• File System
• It allows the user to define files and directories
• It allocate and de allocate the disk space to each file
• Device Driver
• Operating System takes help from device drivers to handle all I/O devices
• Device drivers are software modules that can be plugged into an OS to
handle a particular device
FILE AND FILE OPERATIONS
• A file is a collection of correlated information which is recorded on
secondary or non-volatile storage like magnetic disks, optical disks, and
tapes.
• For each file, OS makes an entry in directory called Volume Table of
Contents(VTOC)
• It mentions details about the file such as name, size, extension, no of
processes using it, file type, file owner, etc
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.
• 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 OPERATIONS
1.Create operation:
This operation is used to create a file in the file system. To create a new file of a
particular type the associated application program calls the file system. This file system
allocates space to the file. As the file system knows the format of directory structure, so
entry of this new file is made into the appropriate directory.
2. Open operation:
Once the file is created, it must be opened before performing the file processing
operations. When the user wants to open a file, it provides a file name to open the
particular file in the file system. It tells the operating system to invoke the open system
call and passes the file name to the file system.
3. Write operation:
This operation is used to write the information into a file. A system call write is issued
that specifies the name of the file and the length of the data has to be written to the
file. Whenever the file length is increased by specified value and the file pointer is
repositioned after the last byte written.
FILE OPERATIONS
4. Read operation:
• This operation reads the contents from a file. A Read pointer is maintained by the OS,
pointing to the position up to which the data has been read.
5. Re-position or Seek operation:
• The seek system call re-positions the file pointers from the current position to a specific
place in the file i.e. forward or backward depending upon the user's requirement. This
operation is generally performed with those file management systems that support direct
access files.
6. Delete operation:
• Deleting the file will not only delete all the data stored inside the file it is also used so that
disk space occupied by it is freed. In order to delete the specified file the directory is
searched. When the directory entry is located, all the associated file space and the directory
entry is released.
7. Truncate operation:
• Truncating is simply deleting the file except deleting attributes. The file is not completely
deleted although the information stored inside the file gets replaced.
8. Close operation:
• When the processing of the file is complete, it should be closed so
that all the changes made permanent and all the resources occupied
should be released. On closing it deallocates all the internal
descriptors that were created when the file was opened.
9. Append operation:
• This operation adds data to the end of the file.
10. Rename operation:
• This operation is used to rename the existing file.
DISK ALLLOCATION METHODS
• The allocation methods define how the files are stored in the blocks
on disk
• There are two main disk space or file allocation methods
• Contiguous Allocation
• Non-Contiguous Allocation
• Chained Allocation
• Indexed Allocation
• The main idea behind these methods is to provide:
• Efficient space utilization
• Fast access to the file blocks
Disk ALLOCATION METHODS :
Contiguous allocation
• In this scheme, each file occupies a contiguous set of blocks on the disk.
• Ex. if a file requires n blocks and is given a block b as the starting location,
then the blocks assigned to the file will be: b, b+1, b+2,……b+n-1.
• If there are multiple free blocks the it is chosen based on any of the following
methods :
• First Fit: allocate the first free partition large enough which can
accommodate the process.
• Best Fit: allocating the smallest free partition which meets the
requirement of the requesting process.
• Worst Fit: to locate largest available free portion so that the portion left
will be big enough to be useful
DISK ALLLOCATION METHODS:
NON CONTIGUOUS
• CHAINED/LINKED ALLOCATION
• In this scheme, each file is a linked list of
disk blocks which need not be contiguous.
• The disk blocks can be scattered anywhere
on the disk
• The directory entry contains a pointer to
the starting and the ending file block
• Each block contains a pointer to the next
block occupied by the file
FILE ALLLOCATION METHODS:
NON CONTIGUOUS
• Indexed allocation
• In this scheme, a special block known as
the Index block contains the pointers to all
the blocks occupied by a file.
• Each file has its own index block.
• The ith entry in the index block contains
the disk address of the ith file block.
• The directory entry contains the address of
the index block
FILE ORGANIZATION
• File organization refers to the way data is stored in a file
• File organization is very important because it determines the methods of
access, efficiency, flexibility and storage devices to use
• There are two methods of organizing files on a storage media. This include:
• Sequential file organization
• The records of files are stored in physical order one after other as created
• The order remains same for reading and writing
• Suitable for devices like tapes
• Direct file organization
• It accesses the records through record’s physical address on direct access
storage devices like optical disks
Information Storage
• BLOCK
• OS keeps all its data on terms of blocks
• OS would view the disk as comprising of number of blocks
• Each block has one or more sectors
• DISK
• Main secondary storage device
• Ex. Floppy disk, Optical disk , Hard disk
HARD DISK
• A hard disk consists of one or more
circular aluminium platters of which
either or both surfaces are coated with
a magnetic substance used for recording
the data.
• For each surface, there is a read-write
head that for recording and reading.
• Read/write head foe each surface is
connected to arm
• The platters rotate on a common axis;
typical rotation speed is 5400 or 7200
rotations per minute
Directory
• Directory can be defined as the listing of the related files on the
disk. The directory may store some or the entire file attributes.
• To get the benefit of different file systems on the different
operating systems, A hard disk can be divided into the number of
partitions of different sizes. The partitions are also called volumes
or mini disks.
• Each partition must have at least one directory in which, all the
files of the partition can be listed. A directory entry is maintained
for each file in the directory which stores all the information
related to that file.
Directory STRUCTURE
OPERATIONS PERFORMED ON THE
DIRECTORY
• SEARCH FOR A FILE
• CREATE A FILE
• DELETE A FILE
• LIST A DIRECTORY
• RENAME A FILE
• TRAVERSE THE FILE SYSTEM
• Single Level Directory
• The simplest method is to have one big list of all the files on the disk.
The entire system will contain only one directory which is supposed to
mention all the files present in the file system. The directory contains
one entry per each file present on the file system.
Single Level Directory
ADVANTAGES DISADVENTAGES
• EASY IMPLEMENTATIONN • CHANCE OF NAME COLLISION
• FAST SEARCHING • IF DIRECTORY GROWS
• IMPROVED EFFICIENCY LARGER,SEARCHING WILL TAKE
TIME
• UPDATION IS EASY
• NO FILE GROUPING
• Two Level Directory
• In two level directory systems, we can create a separate directory for
each user. There is one master directory which contains separate
directories dedicated to each user. For each user, there is a different
directory present at the second level, containing group of user's file.
The system doesn't let a user to enter in the other user's directory
without permission.
• Advantages:
• Naming conflict can be solved
• Improved security
• Searching is comparatively easier and faster
• Disadvantage:
• Limited sharing of files among users
• Users don’t have the ability to create sub directories
• No grouping
• Tree Structured Directory
• In Tree structured directory system, any directory entry can either be
a file or sub directory.
• Root directory contains all directories for each user
• The users can create subdirectories and even store files in their
directory
• A user do not have access to root directory and cannot modify it
• Advantages:
• Allows users to create subdirectories
• Searching is easier
• File sorting is easier
• More scalable
• Disadvantages:
• Prevents file sharing
• If number of subdirectories increase, searching becomes complicated
Thank you