0% found this document useful (0 votes)
56 views12 pages

File Management System

Files are collections of related information stored on secondary storage. A file system manages files and directories on storage devices. There are three main file allocation methods: contiguous allocation stores a file in adjacent blocks, linked allocation uses non-contiguous blocks chained together, and indexed allocation uses a table to index the blocks. Directories allow organizing files and provide attributes, operations, and path names to locate files. File systems aim to efficiently utilize storage space while allowing fast access to file data.

Uploaded by

Chair wazir
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)
56 views12 pages

File Management System

Files are collections of related information stored on secondary storage. A file system manages files and directories on storage devices. There are three main file allocation methods: contiguous allocation stores a file in adjacent blocks, linked allocation uses non-contiguous blocks chained together, and indexed allocation uses a table to index the blocks. Directories allow organizing files and provide attributes, operations, and path names to locate files. File systems aim to efficiently utilize storage space while allowing fast access to file data.

Uploaded by

Chair wazir
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/ 12

File Systems in Operating System

A file is a collection of related information that is recorded on secondary


storage. Or file is a collection of logically related entities. From user’s
perspective a file is the smallest allotment of logical secondary storage.
The name of the file is divided into two parts as shown below:
 name
 extension, separated by a period.

Files attributes and its operations:

Attributes Types Operations

Name Doc Create

Type Exe Open

Size Jpg Read

Creation Data Xis Write

Author C Append

Last Modified Java Truncate

protection class Delete

Close

Usual
File type extension Function

exe, com, bin Read to run machine language program


Executable
obj, o Compiled, machine language not linked
Object
C, java, pas, asm,
a Source code in various languages
Source Code
bat, sh Commands to the command interpreter
Batch
txt, doc Textual data, documents
Text
Word wp, tex, rrf, doc Various word processor formats
Processor
arc, zip, tar Related files grouped into one compressed file
Archive
mpeg, mov, rm For containing audio/video information
Multimedia
xml, html, tex It is the textual data and documents
Markup
lib, a ,so, dll It contains libraries of routines for programmers
Library
It is a format for printing or viewing a ASCII or
gif, pdf, jpg binary file.
Print or View
FILE DIRECTORIES:
Collection of files is a file directory. The directory contains information about
the files, including attributes, location and ownership. Much of this information,
especially that is concerned with storage, is managed by the operating
system. The directory is itself a file, accessible by various file management
routines.
Information contained in a device directory are:
 Name
 Type
 Address
 Current length
 Maximum length
 Date last accessed
 Date last updated
 Owner id
 Protection information
Operation performed on directory are:
 Search for a file
 Create a file
 Delete a file
 List a directory
 Rename a file
 Traverse the file system
Advantages of maintaining directories are:
 Efficiency: A file can be located more quickly.
 Naming: It becomes convenient for users as two users can have
same name for different files or may have different name for same
file.
 Grouping: Logical grouping of files can be done by properties e.g.
all java programs, all games etc.
SINGLE-LEVEL DIRECTORY
In this a single directory is maintained for all the users.
 Naming problem: Users cannot have same name for two files.
 Grouping problem: Users cannot group files according to their
need.

TWO-LEVEL DIRECTORY
In this separate directories for each user is maintained.

 Path name:Due to two levels there is a path name for every file to
locate that file.
 Now,we can have same file name for different user.
 Searching is efficient in this method.
TREE-STRUCTURED DIRECTORY :
Directory is maintained in the form of a tree. Searching is efficient and also
there is grouping capability. We have absolute or relative path name for a file.
Disadvantage –
 External fragmentation will occur, making it difficult to find contiguous
blocks of space of sufficient length. Compaction algorithm will be
necessary to free up additional space on disk.
 Also, with pre-allocation, it is necessary to declare the size of the file
at the time of creation.
2. Linked Allocation(Non-contiguous allocation) –
Allocation is on an individual block basis. Each block contains a pointer to the
next block in the chain. Again the file table needs just a single entry for each
file, showing the starting block and the length of the file. Although pre-
allocation is possible, it is more common simply to allocate blocks as needed.
Any free block can be added to the chain. The blocks need not be continuous.
Increase in file size is always possible if free disk block is available. There is
no external fragmentation because only one block at a time is needed but
there can be internal fragmentation but it exists only in the last disk block of
file.
Disadvantage –
 Internal fragmentation exists in last disk block of file.
 There is an overhead of maintaining the pointer in every disk block.
 If the pointer of any disk block is lost, the file will be truncated.
 It supports only the sequential access of files.
3. Indexed Allocation –
It addresses many of the problems of contiguous and chained allocation. In
this case, the file allocation table contains a separate one-level index for each
file: The index has one entry for each block allocated to the file. Allocation
may be on the basis of fixed-size blocks or variable-sized blocks. Allocation by
blocks eliminates external fragmentation, whereas allocation by variable-size
blocks improves locality. This allocation technique supports both sequential
and direct access to the file and thus is the most popular form of file
allocation.

Disk Free Space Management :


Just as the space that is allocated to files must be managed ,so the space that
is not currently allocated to any file must be managed. To perform any of the
file allocation techniques,it is necessary to know what blocks on the disk are
available. Thus we need a disk allocation table in addition to a file allocation
table.The following are the approaches used for free space management.

1. Bit Tables : This method uses a vector containing one bit for each
block on the disk. Each entry for a 0 corresponds to a free block and
each 1 corresponds to a block in use.
For example: 00011010111100110001
In this vector every bit correspond to a particular block and 0 implies
that, that particular block is free and 1 implies that the block is
already occupied. A bit table has the advantage that it is relatively
easy to find one or a contiguous group of free blocks. Thus, a bit
table works well with any of the file allocation methods. Another
advantage is that it is as small as possible.
2. Free Block List : In this method, each block is assigned a number
sequentially and the list of the numbers of all free blocks is
maintained in a reserved block of the disk.
File Allocation Methods
The allocation methods define how the files are stored in the disk blocks.
There are three main disk space or file allocation methods.
 Contiguous Allocation
 Linked Allocation
 Indexed Allocation
The main idea behind these methods is to provide:
 Efficient disk space utilization.
 Fast access to the file blocks.
All the three methods have their own advantages and disadvantages as
discussed below:
1. Contiguous Allocation
In this scheme, each file occupies a contiguous set of blocks on the disk. For
example, 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. This means that given the starting block address and the length of the file
(in terms of blocks required), we can determine the blocks occupied by the
file.
The directory entry for a file with contiguous allocation contains
 Address of starting block
 Length of the allocated portion.
The file ‘mail’ in the following figure starts from the block 19 with length = 6
blocks. Therefore, it occupies 19, 20, 21, 22, 23, 24 blocks.

Advantages:
 Both the Sequential and Direct Accesses are supported by this. For
direct access, the address of the kth block of the file which starts at
block b can easily be obtained as (b+k).
 This is extremely fast since the number of seeks are minimal
because of contiguous allocation of file blocks.
Disadvantages:
 This method suffers from both internal and external fragmentation.
This makes it inefficient in terms of memory utilization.
 Increasing file size is difficult because it depends on the availability
of contiguous memory at a particular instance.
2. Linked List 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.
The file ‘jeep’ in following image shows how the blocks are randomly
distributed. The last block (25) contains -1 indicating a null pointer and does
not point to any other block.

Advantages:
 This is very flexible in terms of file size. File size can be increased
easily since the system does not have to look for a contiguous chunk
of memory.
 This method does not suffer from external fragmentation. This
makes it relatively better in terms of memory utilization.
Disadvantages:
 Because the file blocks are distributed randomly on the disk, a large
number of seeks are needed to access every block individually. This
makes linked allocation slower.
 It does not support random or direct access. We can not directly
access the blocks of a file. A block k of a file can be accessed by
traversing k blocks sequentially (sequential access ) from the starting
block of the file via block pointers.
 Pointers required in the linked allocation incur some extra overhead.
3. 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 as shown in the
image:

Advantages:
 This supports direct access to the blocks occupied by the file and
therefore provides fast access to the file blocks.
 It overcomes the problem of external fragmentation.
Disadvantages:
 The pointer overhead for indexed allocation is greater than linked
allocation.
 For very small files, say files that expand only 2-3 blocks, the
indexed allocation would keep one entire block (index block) for the
pointers which is inefficient in terms of memory utilization. However,
in linked allocation we lose the space of only 1 pointer per block.
For files that are very large, single index block may not be able to hold all the
pointers.
Following mechanisms can be used to resolve this:
1. Linked scheme: This scheme links two or more index blocks
together for holding the pointers. Every index block would then
contain a pointer or the address to the next index block.
2. Multilevel index: In this policy, a first level index block is used to
point to the second level index blocks which inturn points to the disk
blocks occupied by the file. This can be extended to 3 or more levels
depending on the maximum file size.
3. Combined Scheme: In this scheme, a special block called
the Inode (information Node) contains all the information about the
file such as the name, size, authority, etc and the remaining space of
Inode is used to store the Disk Block addresses which contain the
actual file as shown in the image below. The first few of these
pointers in Inode point to the direct blocks i.e the pointers contain
the addresses of the disk blocks that contain data of the file. The
next few pointers point to indirect blocks. Indirect blocks may be
single indirect, double indirect or triple indirect. Single Indirect
block is the disk block that does not contain the file data but the disk
address of the blocks that contain the file data. Similarly, double
indirect blocks do not contain the file data but the disk address of
the blocks that contain the address of the blocks containing the file
data.

emote File System (RFS) in File


Management
 Last Updated : 25 May, 2020
Files can be shared across the network via variety of methods –
 Using FTP i.e., file transfer protocol is used to transfer file from one
computer to other.
 Using distributed file system (DFS) in which remote directories are
visible from local machine.
 Using Remote File System (RFS) in which the arrival of networks
has allowed communication between remote computer. These
networks allows various hardware and software resources to be
shared throughout the world.
Remote file sharing (RFS) is a type of distributed file system technology.
It was developed in 1980 by AT&T. Later, it was delivered with UNIX System
version V (five) release 3 (SVR3). It enables file and/or data access to multiple
remote users over the Internet or a network connection. It is also known as a
general process of providing remote user access to locally stored files and/or
data.
It was relied on the STREAMS Transport Provider Interface feature of the
operating system.
To implement remote file system we use client-server model. It was one of
the basic application of Remote File System.
Client-Server Model in RFS :
RFS allows a computer to support one or more file systems from one or more
remote machines. In this case, the machine containing the files is server and
the machine wanting access to the files is the client. The server specifies
which file can be accessed by a particular client(s). Files are usually specified
on a partition level.
A server can serve multiple clients, and a client can access multiple
servers, depending on the implementation details of a given client-server
facility. Once it is mounted, file operation requests are sent on the behalf of
the user to the server, via network.
For example, a user sends a file open request to the server along with its ID.
The server then check file access to determine if the user has rights to access
the file requested mode. This request is either allowed or denied. If it is
allowed, a file is returned to the client application, and the application then
may perform read, write and other operations on file.
After the required operation is performed, the client closes the files.

You might also like