0% found this document useful (0 votes)
16 views25 pages

File Management

The document provides an overview of file systems, detailing the definition, structure, attributes, and access methods of files. It discusses directory structures, protection mechanisms, and implementation methods for file systems, including allocation and free space management techniques. Key concepts include sequential, direct, and indexed access methods, as well as various directory structures like single-level, two-level, and tree-structured directories.

Uploaded by

santar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views25 pages

File Management

The document provides an overview of file systems, detailing the definition, structure, attributes, and access methods of files. It discusses directory structures, protection mechanisms, and implementation methods for file systems, including allocation and free space management techniques. Key concepts include sequential, direct, and indexed access methods, as well as various directory structures like single-level, two-level, and tree-structured directories.

Uploaded by

santar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

File System Interface

File
• A file is collection of specific information
stored in the memory of computer system.
• File management is defined as the process of
manipulating files in computer system,
it management includes the process of
creating, modifying and deleting the files.
• The file may have attributes like name, creator,
date, type, permissions etc.
File Structure
• A File Structure should be according to a required
format that the operating system can understand.
• A file has a certain defined structure according to
its type.
• A text file is a sequence of characters organized
into lines.
• A source file is a sequence of procedures and
functions.
• An object file is a sequence of bytes organized
into blocks that are understandable by the
machine.
• When operating system defines different file
structures, it also contains the code to support
these file structure.
Attributes of a File
• Following are some of the attributes of a file :
• Name . It is the only information which is in human-readable
form.
• Identifier. The file is identified by a unique tag(number)
within file system.
• Type. It is needed for systems that support different types of
files.
• Location. Pointer to file location on device.
• Size. The current size of the file.
• Protection. This controls and assigns the power of reading,
writing, executing.
• Time, date, and user identification. This is the data for
protection, security, and usage monitoring.
File Access Methods
• The way that files are accessed and read into
memory is determined by Access methods.
• Usually a single access method is supported by
systems while there are OS's that support
multiple access methods.
• There are three access methods:
• 1. Sequential Access
• 2.Direct Access
• 3.Index Access
1.Sequential Access
• Data is accessed one record right after another
is an order.
• Read command cause a pointer to be moved
ahead by one.
• Such a method is reasonable for tape.
• It is the simplest access method.
• Information in the file is processed in order,
one record after the other.
• This mode of access is by far the most
common;
• 2. Direct Access
• Direct access method also known as relative
access method.
• It is a logical record that allows the program to
read and write record rapidly in no particular
order.
• The direct access is based on the disk model of a
file since disk allows random access to any file
block.
• For direct access, the file is viewed as a numbered
sequence of block or record
• Thus, we may read block 14 then block 59 and
then we can write block 17.
• There is no restriction on the order of reading and
writing for a direct access file.
• 3. Indexed Sequential Access
• It is built on top of Sequential access.
• It uses an Index to control the pointer while
accessing files.
• These methods construct an index for the file.
• The index, like an index in the back of a book,
contains the pointer to the various blocks.
• To find a record in the file, we first search the
index and then by the help of pointer we
access the file directly.
What is a Directory?
• Information about files is maintained by
Directories.
• A directory can contain multiple files.
• It can even have directories inside of them.
• In Windows we also call these directories as
folders.
• Following is the information maintained in a
directory :
• Name : The name visible to user.
• Location : Device and location on the device
where the file header is located.
• Size : Number of bytes/words/blocks in the file.
• Usage : Time of creation, access, modification
etc.
Directory Structure:
• There are several logical structures of a directory,
these are given below.
• 1. Single-level directory –
The single-level directory is the simplest directory
structure.
• In it, all files are contained in the same directory
which makes it easy to support and understand.
• A single level directory has a significant
limitation, however, when the number of files
increases or when the system has more than one
user.
• Since all the files are in the same directory, they
must have a unique name
1.Single level directory:
2.Two level Directory structure:

• 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.
2.Two level directory:
3. Tree-structured directory –

• Once we have seen a two-level directory as a tree of


height 2, the natural generalization is to extend the
directory structure to a tree of arbitrary height.
• It allows the user to create their own subdirectories
and to organize their files accordingly.
• A tree structure is the most common directory
structure.
• The tree has a root directory, and every file in the
system has a unique path.
Tree Structured Directory:
Protection:
• The objective of the operating system is to keep
safe the data of the user from the improper access
to the system.
• For a single laptop system, we might provide
protection by locking the computer in a desk
drawer or file cabinet.
• For multi-user systems, different mechanisms are
used for the protection.
• the files which have direct access of the any user
have the need of protection.
• The mechanism of the protection provide the
facility of the controlled access by just limiting
the types of access to the file.
• Access can be given or not given to any user
depends on several factors, one of which is the
type of access required.
many systems recognize three classification of
users in connection with each file:
• Owner –
Owner is the user who has created the file.
• Group –
A group is a set of members who has similar
needs and they are sharing the same file.
• Universe –
In the system, all other users are under the
category called universe.
• The most common recent approach is to
combine access-control lists with the normal
general owner, group, and universe access
control scheme..
• Other Protection Approaches:
• The access to any system is also controlled by
the password.
• The use of passwords has a few disadvantages:
• The number of passwords are very large so it
is difficult to remember the large passwords.
• If one password is used for all the files, then
once it is discovered, all files are accessible
Implementation of File System:

• Allocation Methods for File:


• Files are allocated disk spaces by operating
system.
• Operating systems provides following three
main ways to allocate disk space to files.
1.Contiguous Allocation
2.Linked Allocation
3.Indexed Allocation
1.Contiguous Allocation

• If the blocks are allocated to the file in such a


way that all the logical blocks of the file get
the contiguous physical block in the hard disk
then such allocation scheme is known as
contiguous allocation.
• Each file occupies a contiguous address space
on disk.
• Assigned disk address is in linear order.
• Easy to implement.
2.Linked list allocation:
• In linked list allocation, each file is considered
as the linked list of disk blocks.
• However, the disks blocks allocated to a
particular file need not to be contiguous on the
disk.
• Each disk block allocated to a file contains a
pointer which points to the next disk block
allocated to the same file.
3. Indexed Allocation

• A index block is created having all pointers to


files.
• Each file has its own index block which stores
the addresses of disk space occupied by the
file.
• Directory contains the addresses of index
blocks of files
Free Space Management:
• A file system is responsible to allocate the free
blocks to the file therefore it has to keep track
of all the free blocks present in the disk.
• There are mainly two approaches by using
which, the free blocks in the disk are managed.
• 1. Bit Vector
• 2.Linked list
• 1. Bit Vector
• In this approach, the free space list is
implemented as a bit map vector.
• It contains the number of bits where each bit
represents each block.
• If the block is empty then the bit is 1 otherwise it
is 0.
• Initially all the blocks are empty therefore each
bit in the bit map vector contains 1.
• As the space allocation proceeds, the file system
starts allocating blocks to the files and setting the
respective bit to 0.
• 2. Linked List
• It is another approach for free space
management.
• This approach suggests linking together all the
free blocks.
• Therefore, all the free blocks on the disks will
be linked together with a pointer.
• Whenever a block gets allocated, its previous
free block will be linked to its next free block.

You might also like