Modern Operating Systems by Herbert Bos ...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Showing 344 out of 1137
Modern Operating Systems by Herbert Bos and Andrew...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Modern Operating Systems by Herbert...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Page 344
SEC. 4.4
FILE-SYSTEM MANAGEMENT AND OPTIMIZATION
313
1
1
0
1
0
1
1
1
1
0
0
1
1
1
0
0
0 1 2 3 4 5 6 7 8 9101112131415
Block number
Blocks in use
0
0
1
0
1
0
0
0
0
1
1
0
0
0
1
1
Free blocks
(a)
1
1
0
1
0
1
1
1
1
0
0
1
1
1
0
0
0 1 2 3 4 5 6 7 8 9101112131415
Blocks in use
0
0
1
0
2
0
0
0
0
1
1
0
0
0
1
1
Free blocks
(c)
1
1
0
1
0
1
1
1
1
0
0
1
1
1
0
0
0 1 2 3 4 5 6 7 8 9101112131415
Block number
Blocks in use
0
0
0
0
1
0
0
0
0
1
1
0
0
0
1
1
Free blocks
(b)
1
1
0
1
0
2
1
1
1
0
0
1
1
1
0
0
0 1 2 3 4 5 6 7 8 9101112131415
Blocks in use
0
0
1
0
1
0
0
0
0
1
1
0
0
0
1
1
Free blocks
(d)
Block number
Block number
Figure 4-27.
File-system states.
(a) Consistent.
(b) Missing block.
(c) Dupli-
cate block in free list.
(d) Duplicate data block.
The appropriate action for the file-system checker to take is to allocate a free
block, copy the contents of block 5 into it, and insert the copy into one of the files.
In this way, the information content of the files is unchanged (although almost
assuredly one is garbled), but the file-system structure is at least made consistent.
The error should be reported, to allow the user to inspect the damage.
In addition to checking to see that each block is properly accounted for, the
file-system checker also checks the directory system.
It, too, uses a table of count-
ers, but these are per file, rather than per block.
It starts at the root directory and
recursively descends the tree, inspecting each directory in the file system. For
every i-node in every directory, it increments a counter for that file’s usage count.
Remember that due to hard links, a file may appear in two or more directories.
Symbolic links do not count and do not cause the counter for the target file to be
incremented.
When the checker is all done, it has a list, indexed by i-node number, telling
how many directories contain each file. It then compares these numbers with the
link counts stored in the i-nodes themselves. These counts start at 1 when a file is
created and are incremented each time a (hard) link is made to the file. In a consis-
tent file system, both counts will agree.
However, two kinds of errors can occur:
the link count in the i-node can be too high or it can be too low.
If the link count is higher than the number of directory entries, then even if all
the files are removed from the directories, the count will still be nonzero and the i-
node will not be removed. This error is not serious, but it wastes space on the disk
with files that are not in any directory.
It should be fixed by setting the link count
in the i-node to the correct value.
The other error is potentially catastrophic.
If two directory entries are linked
to a file, but the i-node says that there is only one, when either directory entry is re-
moved, the i-node count will go to zero. When an i-node count goes to zero, the


Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
Concordia University
Concordia_University
School:
Operating_Systems
Course:
Great resource for chem class. Had all the past labs and assignments
Leland P.
Santa Clara University
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades

Students also viewed documents