0% found this document useful (0 votes)
17 views23 pages

File Allocation and Protectionop

Uploaded by

125158030
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)
17 views23 pages

File Allocation and Protectionop

Uploaded by

125158030
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/ 23

UNIT IV

File Allocation & File Protection

S.Rajarajan
School of Computing
SASTRA
• 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
File Allocation Methods
Contiguous file allocation
• Contiguous allocation requires that each file occupy a set of
contiguous blocks on the disk like an array
• Disk addresses define a linear ordering on the disk.
• If the file is n blocks long and starts at location b, then it
occupies blocks 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.
• Advantages:
• It Is the best from the point of view of the individual sequential file
• Multiple blocks can be read at a time to improve IO performance
for sequential processing
• 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).
• Disadvantages
• One difficulty is finding space for a new file.
• Increasing file size is difficult because it depends on the availability
of contiguous memory
• Both internal and External fragmentation will occur.
• It will be necessary to do compaction
Linked (chained) 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.
• Each block contains a pointer to the next block in the chain
• The directory entry contains a pointer to the starting and the ending file
block.
• Better for sequential files
• Advantage
• 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.
• Disadvantage
• To select an individual block of a file requires tracing through
the chain to the desired block
• No accommodation of principle of locality. Thus it is
necessary to bring in several blocks of a file at a time, then a
series of accesses to different parts of the disk are required
• This method does not suffer from external fragmentation.
• Another disadvantage is the space required for the pointers.
• If a pointer requires 4 bytes out of a 512-byte block, then 0.78
percent of the disk is being used for pointers, rather than for
information.
• The usual solution to this problem is to collect blocks into
multiples, called clusters, and to allocate clusters rather than
blocks.
• For instance, the file system may define a cluster as four blocks
and operate on the disk only in cluster units.
• Pointers then use a much smaller percentage of the file’s disk
space.
• Yet another problem of linked allocation is reliability.
• A bug in the operating-system software or a disk hardware failure
might result in picking up the wrong pointer
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
• Typically the file indexes are not physically stored as part of the file
allocation table.
• Rather the file index for a file is kept in a separate block, and the
entry for the file in the file allocation table points to that block.
• Allocation may be based on Fixed or Variable
• File consolidation may be done from time to time
• Advantage
• 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.
Protection
• Three requirements – confidentiality, integrity, availability
• When information is stored in a computer system, we want to
keep it safe from physical damage (the issue of reliability) and
improper access (the issue of protection).
• Reliability is generally provided by duplicate copies of files.
• File systems can be damaged by hardware problems (such as
errors in reading or writing), power surges or failures, head
crashes, dirt, temperature extremes, and vandalism.
• Files may be deleted accidentally.
• Bugs in the file-system software can also cause file contents to
be lost
Types of Access
• The need to protect files is a direct result of the ability to
access files.
• Systems that do not permit access to the files of other users
do not need protection.
• Thus, we could provide complete protection by prohibiting
access.
• Alternatively, we could provide free access with no
protection.
• What is needed is controlled access.
• Protection mechanisms provide controlled access by limiting
the types of file access that can be made
• Several different types of operations may be controlled:

• Other operations, such as renaming, copying, and editing the


file, may also be controlled.
Access Control
• The most common approach to the protection problem is to make
access dependent on the identity of the user.
• Different users may need different types of access to a file or
directory.
• The most general scheme to implement identity dependent access
is to associate with each file and directory an access-control list
(ACL) specifying user names and the types of access allowed for
each user
• When a user requests access to a particular file, the operating
system checks the access list associated with that file.
• If that user is listed for the requested access, the access is allowed.
• Otherwise, a protection violation occurs, and the user job is
denied access to the file.
• To condense the length of the access-control list, many
systems recognize three classifications of users in connection
with each file:
Other Protection Approaches
• Another approach to the protection problem is to associate
a password.
• The use of passwords has a few disadvantages, however.
• First, the number of passwords that a user needs to
remember may become large, making the scheme
impractical.
• Second, if only one password is used for all the files, then
once it is discovered, all files are accessible.
• In a multilevel directory structure, we need to protect not only
individual files but also collections of files in subdirectories.
• We need to provide a mechanism for directory protection.
• We want to control the creation and deletion of files in a
directory.

You might also like