Learning Module: Surigao State College of Technology
Learning Module: Surigao State College of Technology
Module No. 4
CHAPTER 4: DEVICE MANAGEMENT AND FILE SYSTEMS
In this chapter, we will discuss the following:
4.1. Characteristics of I/O) Devices
4.2 Overview of File Systems
4.3 Directories
4.4 File System Hierarchy
4.5 File System Implementation
4.6 Directory Implementation
4.7 File System Reliability
Time Frame: 15 hrs
Introduction:
I/O device management is a very important activity of the operating system. I/O is
important for the communication of users to computer. The following are services of
the operating system as I/O manager:
• Monitoring all the I/O devices
• Order the I/O devices, capture interrupts and manage bugs related to I/O
• Avail communication channel between I/O devices and all other hardware
components
Accessing and storing information is the task of every computer application. A clear
and obvious requirement of an operating system is thus, the provision of a convenient,
efficient, and robust information handling system. A process can use its address space
to store some amount of information. However, three main problems are associated
with this method.
• One is the adequacy of the space to accommodate all information to be stored
by the application as the size of the address space is determined by the size of
the virtual address space.
• The second problem is the data loss as the process terminates the information
kept on its address space is also lost though the information is required to be
retained for long period of time.
• The third problem is concurrent accessibility of the information by other
processes as information saved in one process’s address space is accessible
only to that process and sometimes there is a need to make this information as
whole or part of it available to other processes as well. Solving these problems
by separately managing information resulted by a process from its process is a
concern of any operating system which is usually done by storing the information
on external media in units called files.
The operating system manages naming, structure, access, use, protection and
implementation of these files. Thus, component of an operating system and monitors
activities related with files is known as a file system which is to be addressed in this
section. File management system consists of system utility programs that run as
privileged applications concerned with secondary storages.
Objectives
Upon completion of this unit you should be able to:
Learning Activities
Read Me!
4.1 Characteristics of I/O Devices
➢ The I/O devices are varied that operating systems devotes a subsystem
to handle the variety. The range of devices on a modern computer system
include from mice, keyboards, disk drives, display adapters, USB devices,
network connections, audio I/O, printers, special devices for the handicapped,
and many special-purpose peripherals. These devices can be roughly
categorized as storage, communications, and user-interface. The peripheral
devices can communicate with the computer via signals sent over wires or
through the air and connect with the computer via ports, e.g. a serial or parallel
port. A common set of wires connecting multiple devices is termed as a bus.
➢ Device drivers are modules that can be plugged into an OS to handle a
particular device or category of similar devices.
➢ Principles of I/O hardware
➢ I/O devices have three sections:
• I/O devices: - concerned with the way data are handled by the I/O device.
There are two types of I/O devices known as blocked and character devices.
• Blocked devices (such as disks) - are devices with fixed-size slots having
unique addresses and stores data accordingly.. Byte ranges of 512 to 32,768
are the general block size ranges. The ability to read and write each blocks
regardless of the other blocks is an important feature of these devices. A disk
is the commonly known block device which allows moving the read/write arm
any time to any required cylinder position and awaits for the needed block to
spin under the head
• Character devices (such as printers, mouse and NIC) - The other type of
I/O device is the character device. A character device delivers or accepts
stream of character, without regard to any block structure. It is not addressable
and does not have any seek operation.
I/O Unit:
• The Device driver starts its operations by first testing for any error on the I/O
device
• If no error is identified and everything is properly functioning, data is passed
from the driver to the requester software
• If the driver couldn’t get any request in the queue, it will move back to block
state and waits until a request comes in.
Device Independent I/O Software
➢ It is large fraction of I/O software
➢ Services it provides are:
Uniform interfacing for device drivers – perform I/O function common to all
drives
Device Naming – responsible for mapping symbolic devices names onto the
proper driver
Device protection – secures devices by blocking illegitimate or non-allowed
access requests of users
Providing device-independent block size – provide uniform block size to
Buffering: if a user process write half a block, the OS will normally keep the
data in buffer until the rest of the data are written. Keyboard inputs that arrive
before it is needed also require buffering.
Storage allocation on block devices: when a file is created and filled with data,
new disk blocks have to be allocated to the file. To perform this allocation, the
OS needs a list of free blocks and used some algorithms for allocation
Allocating and releasing dedicated devices: The OS is solely responsible to
validate any device request and act accordingly by either granting or denying
the service.
Error reporting: Errors handling, by and large, is done by drivers. Most errors
are device dependent. When a device request comes to the driver, it attempts
to communicate the requested block certain number of times.
If it is unable to read the block during these times, it stops trying and
communicate the requester software the status and finally reports to the caller
User Space I/O Software
➢ A situation where a small portion of the I/O software is outside the OS
In this case, library procedures are used to perform system calls including I/O
system calls. For instance, if a C program has a function call count=write(fd,
buffer, n bytes); the write procedure from the library will be linked with it and kept
in the binary program which will be loaded to memory during execution
➢ The library procedures are also responsible to format the I/O requests
The following is an example how the I/O system works during reading by an
application
Step 1: system call to do file reading is passed from the user program.
Disk
➢ All real disks are organized into cylinders, each one containing many
tracks. Each of the tracks then will be divided into sectors (equal number
of sectors or different number of sectors)
➢ In the case of equal number of sectors
➢ The data density as closer to the center (hub) is high
➢ The speed increases as the read/write moves to the outer tracks
➢ Modern large hard drives have more sectors per track on outer tracks e.g.
IDE drives
➢ Many controllers, except floppy disk controllers, are capable of doing a
read or write operation on one drive and also seek operation on one or
more other drives simultaneously.
Disk Access Time
➢ Three factors determine the time required to read or write a disk block :
➢ The seek time (the time to move the arm to the proper cylinder)
➢ The rotational delay (the time for the proper sector to rotate under the
head)
The actual data transfer time
➢ For most disks, the seek time dominates the other two times, so reducing the
mean seek time can improve system performance substantially.
➢ Disk requests can come from processes while the arm is doing a seek operation
of another process. A table of waiting disk requests is kept by disk drivers. The
table is indexed by cylinder number and pending requests of each cylinder is
linked through a linked list that is headed by the table entries.
Disk Arm Scheduling Algorithm
➢ The OS maintains queue of requests for each I/O operation and it uses various
disk scheduling algorithms. To mention some:
➢ First Come First Served (FCFS) : Accept single request at a time and perform
the requests in same order
➢ E.g. Track initial position: 11
Track request: 1,36,16,34,9,12
Service order: 1,36,16,34,9,12
Arm motion required: 10, 35, 20, 18, 25, 3,
Total= 111 tracks
➢ The simplest and the fairest of all, but it doesn’t improve performance
➢ Shortest Seek First (SSF): It handles the closest (the least disk arm movement)
request next, to minimize seek time.
➢ E.g. Track initial position: 11
Track request: 1,36,16,34,9,12
Service order: 12,9,16, 1, 34, 36
Arm motion required: 1, 3, 7, 15, 33, 2
Total= 61 tracks
➢ Advantage: Performance (efficiency), provides better performance
➢ Disadvantage: Possibility of starvation (it lacks fairness)
2. Discuss the two most widely used approaches to improve disk I/O performance
Byte sequence
➢ The file is organized in unstructured sequence of bytes where the operating
system is unaware of the file content. Meaning of the bytes is imposed by user
programs providing maximum flexibility but minimal support. This structure is
advantageous for users who want to define their own semantics on files. UNIX
and MS-DOS operating systems use this structure
Record sequence
➢ The file is treated as a sequence of internally structured fixed length records. In
such a structure, reading from or writing into a file interacts with one record. No
systems currently use this method though they were very popular in early times
in mainframe computers.
Tree
➢ The file consists of a tree of records that may differ in length and each having
a key parameter in a fixed position in the record which is used to interact with
the records. The operating system can add new records to the file deciding the
place for the record. The records on the tree are sorted based on the key field
which makes searching faster. Large mainframe computers use this structure.
File types
➢ Several types of files exist that are supported by an operating system.
➢ Regular files: are the most common types of files consisting user information.
Regular files may contain ASCII characters which are texts, binary data, non-
texts and not readily readable, executable program binaries, program input or
output. The contents of such files is structured with no kernel level support
➢ Directory: is a binary file consisting of list of files contained in it. These are
system files used to manage file system structure which may contain any kind
of files, in any combination. . and .. refer to directory itself and its parent
directory. The two commands used to manage directories are mkdir, to create
a directory, and rmdir, to remove a directory
➢ Character-special files: are I/O related files that allows the device drivers to
perform their own I/O buffering. These files are used for unbuffered data
transfer to and from a device. The files generally have names beginning with
r(for raw), such as/dev/rsd0a
➢ Block-special files: are files used for modeling disks and other devices that
handle I/O in large chunks, known as blocks. These files expect the kernel to
perform buffering for them. They generally have names without the r, such as
/dev/sd0a.
File access
➢ Files can be accessed either sequentially or randomly. In a sequential file
access, a system reads the bytes in order starting from the beginning without
skipping any in between. Rewinding or backing up is possible but with limited
accuracy and slow performance. Such files were available during the magnetic
tape era. In a random file access, a system can traverse the file directly in any
order. Bytes or records can be read out of order and access is based on key
rather than position. Disks made possible this random accessibility of files.
These are essential for database systems.
File attributes
➢ Attributes of a file are extra information associated with files in addition to name
and data. Some of these attributes are listed in table7.1 below
File operations
➢ Storage and retrieval of files is handled with different types of operations
provided by a system. The operating system can provide system calls to create,
write, read, reposition, delete, and truncate files. Some of the operations
defined on files are:
➢ Create file: Create a new file of size zero or with no data. The attributes are set
by the environment in which the file is created. The task of this system call is to
inform about the file and define the attributes it has
➢ Open file: used to establish a logical connection between process and file. It
fetches the attributes and list of disk addresses into main memory for rapid
access during subsequent calls
➢ Write: Transfer the memory into a logical record starting at current position in
file. This would increase the size of the file if current position is the end of file,
or may overwrite and cause content loss if current position is found at the center
of the file
➢ Read: Transfer the logical record starting at current position in file to memory
starting at buffer known as input buffer. It is the task of the caller to indicate the
amount of data to be read and where to read
➢ Close: Disconnects file from the current process. The file will not be accessible
to the process after close
➢ Delete: removing a file when no more needed so that some disk space is
utilized.
➢ Append: used to perform restricted write operation by adding data at the end
of an existing file
➢ Seek: used to specify from where a data should be accessed in a randomly
accessible file by repositioning the current-file-position pointer to a given value.
In addition to these basic operations, there are also common operations defined
on files such as rename, copy, set and get attributes, etc. most of these
operations require searching for a named file in the directory of files causing
continuous search.
➢ To overcome this continuous searching, most systems perform a call to open
operation before the file is first brought active.
Conclusion
➢ When a process has information to be maintained, it keeps it in its address
space which causes three main problems. Storage capacity of a system is
restricted to the size of available virtual memory which may not be enough for
applications involving large data; the virtual memory is volatile which may not
be good for long term storage and information need not be dependent upon
process as there might be a need to modify that data by different processes.
➢ To overcome these limitations, long term information storage, file, is essential.
A file is a named collection of related information defined by its creator. It is an
abstraction used by the kernel to represent and organize the system’s non-
volatile storage resources, including hard disks, CD-ROMs, and optical disks.
File system is part of the operating system that manages files.
➢ Every file has a name attribute associated with it which is used to communicate
with it.
➢ File names have a different extension they end with according to the file type.
A file can represent a program or data and can support free form or rigid form.
➢ A file can be structured in byte, record or tree form and can be accessed either
sequentially or randomly. The operating system uses several types of
operations, through system calls, to interact with files.
Assessment:
Instructions: Answer the following. Write your answers in the space provided
a. What is file?
4.3 Directories
Introduction
➢ Directory is collection of nodes that contains information about files. Directories
shall be logically organized to achieve efficiency, facilitate convenient naming,
and allow file grouping. This activity covers overview of file directory,
organization of directories and operations that can be carried out on directories
by users or applications. A general purpose computer maintains thousands and
millions of files on secondary storages.
➢ An entire space of a secondary storage device may be used to store a file or
only its portion. Directory is a means provided by the file system to keep track
of files. In most systems, directories, also known as folders, are files themselves
owned by the operating system and have their own organization, properties and
operations. They provide mapping between file names and the files themselves.
Directory contains a number of entries about files such as attributes, location,
ownership etc.. The directory may keep the attributes of a file within itself, like
a table, or may keep them elsewhere and access them through a pointer. In
opening a file, the OS puts all the attributes in main memory for subsequent
usage.
➢ Files can be organized in a single-level directory structure or multi-level
directory structure. In a single level directory structure, all the files in a system
are kept in one directory, which may also be referred as root directory. This
organization scheme is known to be simple and results in fast file search.
However, it encounters a problem when the number of files to be maintained
increases or when used in a multi-user systems as names of each file is
required to be unique. If two or more users create files with same name, this
uniqueness requirement is overridden and in such cases the last file created
overwrites the previous one causing the first file being replaced with another
file of same name.
➢ In a two-level directory structure, a private user level directory is assigned for
each user which elevates the naming conflicts encountered in a single-level
directory structure. The basic implementation of this organization requires all
users to access only their own directory. But with little modification, it can
extend to allow users to also access other user’s directories through some
notification mechanism. In this organization, it is possible to provide same
names for files of different user. The system implicitly knows where to search
for a file when asked to open a file since each user is associated with a private
directory. This organization also has its own drawbacks. It creates total isolation
between users which is not required in systems where processes share and
exchange data. It may also not be satisfactory if users have many files. Figure
4.3 and figure4.4 below shows the single-level and two-level directory
organizations respectively.
➢ Organizing files in a two level directory system does not suffice for systems with
several files and where a logical organization is required. A general hierarchical
structure of several directories needs to be allowed for each user where files
are organized in their natural categorical manner by extending the two level
directory organizations. This hierarchical organization of directories is called
tree structure where the top directory is the root sitting at the top of the tree and
all directories spring out of the root allowing logical grouping of files. Every
process can have its own working directory also referred as current directory to
avoid affecting other processes. A directory or sub-directory has a set of files
or other directories inside.
➢ When a process references a file, it will be searched in the current directory
which contains files which are currently active. Otherwise, if user needs to
access a file not residing in the current directory, file name should be specified
through path names or the current directory should be set to the directory
holding the desired file through a system call which takes the name of the
directory as parameter. Path names are conventions used to specify a file in
Directory Operations
➢ There are various system calls associated with directory management. Let’s
discuss some of these operations defined on directories.
➢ Create: is an operation used to create a new and empty directory except for the
two special components that are automatically included by a hierarchical
directory structure supporting systems. These are the dot (.) and dot dot (..) that
refers to the current directory and its parent respectively. The mkdir command
is used in both UNIX and MS-DOS to create a directory.
➢ Delete: a call used to remove an existing directory from a system. A directory
with no component (except the dot and dot dot) can be deleted from a system.
The rmdir command does the magic in UNIX and MS-DOS.
➢ Open directory: used to open a directory for reading through an opendir
system call.
➢ Close directory: calls the closedir operation and is used to exit a directory that
was opened for reading to free space on internal table
➢ Read directory: done by the readdir system call to access an opened directory
by returning the next entry of the directory
➢ Rename: change the previous directory name
➢ Link: is creation of pointers to other files or directories so that same file can
appear in multiple directories enabling file sharing. The system call generates
a link from an existing file to a given path taking an existing file name and a
path name. A file may have any number of links but all will not affect the
attributes of the file. A link can be either a hard link done by the link() system
call, where links are made only to existing files in one file system not across file
systems and requires all links to the file must be removed before the file itself
is removed , or a symbolic link done by the symlink() system call, which points
to another named file spanning across file systems. The original file can be
removed without affecting the links.
➢ Unlink: used to remove a directory entry. If the file being removed is present in
one directory, it is removed from the file system. Whereas, if the file being
removed is present in multiple directories, only the path name specified is
removed; others remain. The rm/rmdir user commands and the unlink() system
call can be used to unlink a file.
Conclusion
➢ A directory is a means through which files are organized and managed by a file
system. A single directory may contain all available files in a system or a two
level directory organization can be used where by each user is assigned its own
directory. A logical structuring of files in a system can be achieved through a
tree like hierarchical organization of directories where users can create their
own subdirectories and impose different structures to their files.
➢ A tree structure has an efficient search and grouping advantages to users.
Referencing of files in such organizations is done through path names which
can be specified either absolutely or relatively in reference to user’s current
directory. A number of operations can be carried out on directories either
through system calls or user commands.
Assessment:
Instructions: Answer the following. Write your answers in the space
provided.
a. What is a directory?
d. What is a path?
e. What is the difference between absolute path and relative path of a file?
➢ Using disks to efficiently store, search and read data on disks is made possible
through file systems. Two quite different design issues are faced by a file
system: defining the file system interface to the user through defining a file with
its attributes, the operations allowed on a file, and the directory structure for
organizing files and defining algorithms and data structures to plot the logical
file system onto the physical secondary-storage devices.
➢ The file system is generally structured with several levels making a layered
design used to abstract the lower level details associated with it from the higher
level components but each high level layer making use of the lower level layers
functions to produce new features. Figure 7.4 below shows this hierarchy of a
file system design.
➢ The top level, the application programs, are codes making file requests and
handle the content of the files as they have knowledge of the file’s internal
structure.
➢ The logical file system layer is responsible for managing the metadata of the
file system, not the data in the files. It also manages directory structures and
maintains file structures through a file control block that contains information
about the file.
➢ The file-organization module layer translates logical block addresses to
physical ones as logical addresses of files do not match to physical addresses.
This layer also has free space managers that tracks and inform it about free
blocks.
➢ The basic file system layer makes generic requests to appropriate device
drivers to read or write the physical blocks on the disk. Memory buffers and
caches where file systems and data blocks reside are also managed by this
layer.
➢ The I/O control layer presents device drivers and interrupts handlers used to
transfer information between the device and main memory. It generally
interfaces with the hardware devices and handles different interrupts
associated with the I/O devices.
➢ The last layer is the device layer which presents the actual devices like disks,
tapes, etc. a new file is created through a call made by application program to
logical file system which, as been mentioned, knows about directory structures
and defines a new file control block to the file. The system then uploads the
indicated directory into memory and updates its content with the new file name
and file control block and finally return it back to the disk.
➢ The file organization module is then called by the logical file system so that the
directory I/O is mapped to a disk block numbers which is then used by basic file
system and I/O control components concluding a file creation call. I/O can then
be performed on this file once it is opened for such operations. All modern
operating systems have adopted the hierarchical directory model to represent
collections of files as they support more than one file system both removable-
media based and disk based file systems.
➢ In a layered file system structure, code reusability is enhanced and duplication
of codes highly reduced as the I/O control and also the basic file system
modules can be used by more than one file system each then defining their
own logical file system and file organization module. However, layering also
has its own drawback which is performance overhead on the operating system.
Thus, decisions about hierarchical file system structure are a serious design
issue that needs to be addressed when new systems are brought.
Conclusion
➢ In this activity, files are discussed from the operating system’s kernel
perspective. The operating system has a file management system by which
secondary storage devices are utilized to maintain data permanently through
files. The file system has a hierarchical arrangement so that lower level
technical details of how files are handled by the system are abstracted from the
Assessment:
Instructions: Answer the following. Write your answers in the space provided.
4. What are the two design issues related with file systems?
➢ I-nodes: a data structure called an index node (i-node) listing the attributes
and disk addresses of the file’s blocks is associated with each file in this
method. The I-node is created at the time of file system creation (disk
partition) and remains always in the same position on the file system. I-node
table size determines the maximum number of files, including directories,
special files, and links that can be stored into the files system.
➢ Each file uses an index block on disk to contain addresses of other disk
blocks used by the file. When the ith block is written, the address of a free
block is placed at the ith position in the index block. Such method requires
the i-node to be in memory only when the file is open which solves the
limitations of the FAT system by reducing the space requirement. An I-node
creates an array of size proportional to the maximum number of concurrently
accessed files which differs it from the FATof linked list allocation system
which has a proportional size to the disk size growing linearly as the disk
grows. The i-node also has its limitation if each node is of fixed number of
disk addresses and can’t address when files exceed this limitation.
Conclusion
➢ From a top level perspective, a file system is perceived as set of files,
directories and operations defined to manipulate them which is quite
different from its internal arrangements. File system implementers’ or
designers need to deal with storage allocation of files and also maintain the
block file associations in order to place inline an efficient and reliable file
manipulation schemes.
Assessment:
Instructions: Answer the following. Write your answers in the space provided.
1. Discuss in pair the cons and pros of the three file storage allocation methods
on hard disks. Present your answer thru a concept map. Provide a brief
explanation of the concept map created.
of a search or using a hash table of each directory can be used to speed up the
search. The cache is first checked for the file name before starting the search
avoiding the long lookup if it is found in the cache.
➢ Through hash table method, file name is entered by representing it with value
between 0 and n-1 by performing division by n and taking the remainder of the
division or by adding the words in the file name and dividing it by n where n is
the size of the hash table. This hash code is inspected to determine if it is used
or not. If the slot is occupied, a linked list headed at that table entry is created
those threads through all entries with same hash table. But if the slot is
unexploited, a pointer to the file entry that follows the hash table will be kept
there. Searching for a file is done by hashing the file name and select a hash
table entry and checking if the file is present in all the chain entries. If the file is
not found, the file is not available in the directory. While searching is improved
in hash table implementation, administration complexity is also inevitable.
File sharing
➢ In a multiuser system, there is a frequent need to share files among users which
demands the need to present common files within different directories of
multiple users at a time. Two important issues needs to be addressed in
association with file sharing. These are access rights and simultaneous access
of files. One thing to note is the difference between shared file (or directory)
and two copies of the file. With two copies of a file, the copy is accessible by
each user not the original, and if one user updates the file, the changes will not
appear in the other’s copy. With a shared file, however, only one actual file
exists, making immediately visible any changes made by one person to the
other. Sharing is particularly important for subdirectories as a newly created file
by one user will automatically appear in all the shared subdirectories. Several
implementation possibilities are there for shared files.
➢ The advantage of symbolic link implementation is their use to link to files over
networks through the network address specification of the machine that holds
the shared file as link. But the problem with this implementation is the resulting
of two or more paths of same file. Another problem associated with the symbolic
link implementation is the extra overhead incurred as a result of parsing the
path component wise through extra disc accesses.
➢ Another shared file implementation approach is through simple duplication of
all information about the shared files in both directories resulting in identical and
During file creation, the blocks needed are captured from the blocks of pointers
that are read from the disk when file creation ends.. Deleting a file adds the
freed space to the block of pointers in memory which is written to disk. There
are cases where this method is not efficient due to unnecessary disk I/O.
traversing the list requires reading each block which requires a substantial I/O
time though it is done less frequently as the first free block is always allocated
to a file that needs a space. The FAT method’s allocation data structure has
this free-block accounting which avoids the need for a separate method of free
block management.
Disk quotas
➢ In multiuser operating systems, there is a need to limit the maximum allotment
of files and blocks for each user to prevent users from monopolizing the disk
space and the system assures no user exceeds the limit set. Among the
attributes of a file is the owner entry specifying by whom the file is owned and
this will be reviewed when a file is opened to charge the owner for any increase
in the file’s size. Another table defining the quota of each user with a currently
open file is also maintained by the system whose records are written back to
the quota file once the opened files are closed. This table has a pointer to the
quota file of the user which is used to check the limits of the user every time a
block is added to the opened file resulting in error if the limit is exceeded.
Conclusion
➢ In this activity, we tried to discuss issues related with directory implementation.
File naming conventions, file searching efficiency, file sharing methods among
users and applications, disk space management schemes, and disk quotas
were explored all of which are concern of system designers for the betterment
of structured file arrangement.
Assessment:
Instructions: Answer the following. Write your answers in the space provided.
1. What are the file sharing schemes used by a file management system?
3. What is a free block space management? Why is it necessary for the system to
identify free blocks? What schemes are used by the system to manage these
free blocks?
➢ A logical dump has some critical issues that we need to be aware of. One, it
doesn’t save the free disk block list and the system needs to reconstruct this
block after restore is performed. Second, for a linked file, the system should
make sure this fie is restored only once. Thirdly, files with holes inside, the hole
should neither be dumped nor restored so system should carefully inspect such
types of files before restoring them from the dump taken.
File system consistency
➢ A file system is always dealing with blocks through Reading, modifying and
writing blocks. Inconsistency may arise if a file system updates a block but the
system is interrupted before the changes are written. This inconsistency
becomes even worse when the unwritten block is free list, i-node or directory
blocks. To overcome this problem, most systems implement a utility program
to check for file system consistency that is run after each system boot like the
scandisk for windows and fsck for UNIX. The consistency check can be
performed on blocks or files. Two tables are constructed by the utility program
during block consistency checking each table with counters for each block that
is initialized with 0. The first table’s counters count the number of times each
block exist in that file while the second table’s counters keep track of the number
of times each block is found in the free list. List of all block numbers used in a
file is constructed by the program from the i-node. The counter at the first table
is then incremented for every block read. The program also checks the bitmap
to see blocks not in use and increments the counter of the second table for
every occurrence of a block in the bitmap. The consistency of the blocks will
then be checked by checking the counters from the two tables.
➢ If each block has a 1 value either in the first or second table, the program returns
fine indicating block consistency while a value 0 in both tables corresponding
to a block number indicates file inconsistency.
➢ The utility program then fixes the inconsistency and informs the user. File
consistency checking is also done in same fashion in a directory system. The
inspection starts from the root directory and recursively descends through the
tree. The file’s usage counter is incremented for every file in each directory
which will be checked against a list sorted by i-node numbers that indicates the
number of directories where each file is found in. When a file is created, the
counter starts at 1 and increments every time a file is linked. If the counters
value match, the file is determined to be consistent. The inconsistency happens
if the values of the counters do not match in which case the program should
take measures to correct the values.
Three methods are used to allocate space to file systems among which the i-
node is known to be the optimal way. Directory-management routines must
consider efficiency, performance, and reliability. A hash table is a commonly
used method, as it is fast and efficient. Unfortunately, damage to the table or a
system crash can result in inconsistency between the directory information and
the disk’s contents. A consistency checker can be used to repair the damage.
Operating-system backup tools allow disk data to be copied to tape, enabling
the user to recover from data or even disk loss due to hardware failure,
operating system bug, or user error.
Assessment:
Instructions: Answer the following. Write your answers in the space
provided.
1. What are the mechanisms used by a file system to check for consistency?
3. What are the main issues need to be addressed in disk space management in
relation to file systems?
Self-Evaluation
1. Input
2. Output
3. File
4. Directory
6. What are the three space allocation methods used in file systems?
Review of Concepts:
A file is a named collection of related information that are treated
as a single entity defined by its creator and kept on secondary
storage devices. File names can be of fixed length or variable
length and are used to interact with it. A file can be structured in
bytes, records or trees. Several user programs or system calls
can be carried out to interact with files. Each device in a file
system keeps a volume table of contents or a device directory
listing the location of the files on the device. In addition, it is
useful to create directories to allow files to be organized.
Three directory organization methods are available: a single-
level, two-level and tree directory organization. A tree-structured
directory allows a user to create subdirectories to organize files.
The file system resides permanently on secondary storage
devices, mostly on disks which is designed to hold a large
amount of data permanently. Physical disks may be segmented
into partitions to control media use and to allow multiple,
possibly varying, file systems on a single spindle. These file
systems are mounted onto a layered logical file system
architecture to make use of them. The lower levels deal with the
physical properties of storage devices while the upper levels
deal with symbolic file names and logical properties of files. The
Intermediate levels map the logical file concepts into physical
device properties. Disk space is allocated to files through three
different mechanisms. Directory-management routines must
consider efficiency, performance, and reliability of file systems