File Management15
File Management15
management software
5
13
16
20
22
Directly access a block at a known address
Key field required for each record
23
Contains information about files
◦ Attributes
◦ Location
◦ Ownership
Directory itself is a file owned by the
operating system
Provides mapping between file names and
24
List of entries, one for each file
Sequential file with the name of the file
25
One directory for each user and a master
directory
Master directory contains entry for each
user
◦ Provides address and access control information
Each user directory is a simple list of files
for that user
Still provides no help in structuring
collections of files
26
Master directory with user directories
underneath it
Each user directory may have
27
Files can be located by following a path
from the root, or master, directory down
various branches
◦ This is the pathname for the file
Can have several files with the same file
name as long as they have unique path
names
28
Current directory is the working directory
Files are referenced relative to the working
directory
29
30
On secondary storage a file is a collection of
blocks; the operating system or file management
system is responsible for allocating blocks to files
Two management issues
◦ Space on secondary storage must be allocated
to files
◦ Keep track of the space available for allocation
The approach taken for file allocation may
influence the approach taken for available space
management
Three common file allocation methods are
:
◦ Contiguous allocation
Single contiguous set of blocks is allocated to a file
at the time of file creation
◦ Chained allocation
Each block contains a pointer to the next block in the
chain
◦ Indexed allocation
The file allocation table contains a separate one level
index for each file; the index has one entry for each
allocated portion (unit) to the file.
1. Contiguous allocation:
A single contiguous set of blocks assigned to a file when it is
created
Only a single entry in the file allocation table showing the starting
Strategies used are first fit, best fit and next fit.
Disadv
chain
File allocation table consists of
The file index for a file is kept in a separate block and the
00111000011111000011111111111011000
Means 0 1 5 6 7 8 …… are free
Adv:
Easy to find one or more contiguous group of free blocks.
Disadv:
The amount of memory (in bytes) required for a block
bitmap is
disk size in bytes/(8 * file system block size)
2. Super Block
3. Array of inodes
53
Direct block numbers
These contain block numbers that contain the file’s data.
Having these gives us direct access to the file’s data.
Indirect block number
This is a block number of a block that contains a list of
direct block numbers. Each block number is the number
of a block that contains the file’s data.
Double indirect block number
This refers to a block that contains a list of indirect block
numbers. Each indirect block number is the number of a
block that contains a list of direct block numbers.
Triple indirect block number
This refers to a block that contains a list of double
indirect block numbers . Each double indirect block
number is the number of a block that contains a list of
indirect block numbers. Each of these contains a list of
direct block number.
Assume size of each block is 1K(1024) bytes and that a block number
is addressable by a 32 bit integer(4-bytes) ,
Then a block can hold up to 256 block numbers (1024bytes / 4bytes)
Inode contains
4096
0
Single 428
Double 9156
Triple 824
Block size = 1024 bytes, 10 direct,
indirect/double/triple are 1
How does a process access byte 11265 of a file?
10 direct blocks addresses 10240 bytes of file data.
Since 11265>10240, hence byte 11265 lies within
single indirect block number.
11265-10240=1025(within single indirect it is byte no
1025)
Which entry within single indirect block no?
1025/1024=1.0009
Entry numbered 1(Assuming it starts from 0)
In this entry there is a data block no.
Which offset within this block?
1025-(1x1024)=1 {byte offset 1}
Block size = 1024 bytes, 10 direct,
indirect/double/triple are 1
Case 1 : Access byte offset 9000 of a file.
Case 2 : Access byte offset 350,000 of a file.
0 4096 Data Block
228
808 th
Direct Case 1 (9000-
367 1024*8)
8 367
Double Indirect (start from 10K + 256K = 272,384)
9 0 Data Block
Case 2
Single 428 331 816 th
Double 75 3333
9156 350,000
Triple 824 -
272,384 331 3333
9156
= 77,616 75x1024=76800
77616-76800=816
0 45
Eg 75 3333 Data blk
5
331
55
Data blk
234
140
816 Data blk
2
331
3333
140 12
266 266
167
9
9156 121
Double Indirect
blk no 126
16 Data blk
9
If a process wants to access byte offset 350,000 in the
file, it must access a double indirect block, number 9156
in the figure.
Since an indirect block has room for 256 block