OS-UNIT-5-NOTES-26-SEP-2024
OS-UNIT-5-NOTES-26-SEP-2024
UNIT-5
FILE SYSTEMS
1. A) File Concept :
c) Executable File :is a series of code sections that the loader can bring
into memory and execute.
B) File attributes :
a) Name : The symbolic file name is the only information kept in human
readable form.
b) Identifier : This unique tag, usually a number, identifies the file within
the file system; it is the non-human-readable name for the file.
e) Size : The current size of the file (in bytes) and possibly the maximum
allowed size are included in this attribute.
g) Time, date and user identification : this information may be kept for
creation, last modification, and last use.
1
C) File Operations :
The following is the set of file operations :
a) Creating a file : First, space in the file system must be found for the
file.
f) Truncating a file : The user may want to erase the contents of a file
but keep its attributes.
There are some other points associated with an open file.
a) File Pointer :The system must track the last read-write location as a
current-file-position pointer. This pointer is unique to each process
operating on the file.
2
D) File Types :
The operating system should recognize and support file types.
If an operating system recognizes the types of a file, it can then
operate on the file in reasonable ways.
The following are some of the file types :
2. A) Access Methods :
a) Sequential Access :
The simplest access method is ‘sequential access’.
Information in the file is processed in order, one record after the other.
3
b) Direct Access :
This method is also called ‘Relative Access’.
Here a file is made up of fixed-length logical records that allow programs
to read and write records rapidly in no particular order.
The block number provided by the user to the operating system is
known as a ‘relative block number’.
The disk allows random access to any file block.
For direct access, the file is viewed as a numbered sequence of blocks or
records.
Thus we may read block 14, then read block 53 and then write block 7.
There are no restrictions on the order of reading or writing for a direct-
access file.
Let ‘cp’ defines the ‘current position’.
In the following figure, simulating a direct-access file on a sequential-
access file is shown :
4
c) Index and Relative Files :
This block is read in, and again a binary search is used to find the
block containing the desired record.
5
A typical File System Organization
B) Storage Structure :
Let us consider only general-purpose file systems.
A general-purpose file system has multiple storage devices and those
devices can be sliced up into volumes that hold file systems.
The types of file systems are given below.
tmpfs : a ‘temporary file system’ that is created in volatile main
memory and has its contents erased if the system reboots
or crashes.
objfs : a ‘virtual file system’ that gives debuggers access to kernel
symbols.
ctfs : a ‘virtual file system’ that maintains ‘contract information’ to
manage which processes start when the system boots and
must continue to run during operation.
lofs : a ‘loop back’ file system that allows one file system to be
accessed in place of another one.
procfs : a ‘virtual file system’ that presents information on all
Processes as a file system.
ufs, zfs : general-purpose file systems.
6
C) Directory Overview :
When considering a particular directory structure, one need to keep
in mind the operations that are to be performed on a directory.
a) Search for a file
b) Create a file
c) Delete a file
d) List a directory
e) Rename a file
f) Traverse the file system
D) Single Level Directory :
Here, all files are contained in the same directory, which is easy to
support and understand.
Since all files are in the same directory, they must have unique
names.
In the two-level directory structure, each user has his own ‘user file
directory (UFD).
The UFDs have similar structures, but each lists only the files of a
single user.
When a user job starts or a user logs in, the system’s ‘master file
directory (MFD) is searched.
7
The MFD is indexed by user name or account number, and each
entry points to the UFD for that user.
That is, different users may have files with the same name, as long
as all the file names within each UFD are unique.
To create a file for a user, the operating system searches only that
user’s UFD are unique.
F) Tree-Structured Directories :
It is better to create a separate directory for each user.
The tree has a root directory, and every file in the system has a
unique path name.
8
A directory contains a set of files or subdirectories.
One bit in each directory defines the entry as a file (0) or as a sub
directory (1).
9
Acyclic Graph Directory Structure
H) General Graph Directory :
A serious problem with using an acyclic graph structure is ensuring
that there are no cycles.
10
4. File System Mounting :
A file must be opened before it is used.
A file system should be mounted before it can be available to processes
on the system.
More specifically, the directory structure may be built out of multiple
volumes, which must be mounted to make them available with in the
file-system name space.
Mount procedure : The operating system is given the name of the device
and the mount point – the location within the file structure where the
file system is to be attached.
The operating system verifies that the device contains a valid file system.
It does so by asking the device driver to read the device directory and
verifying that the directory has the expected format.
Finally, the operating system notes in its directory structure that a file
system is mounted at the specified mount point.
Consider the file system depicted here :
11
Here, the triangles represent subtrees of directories that are of interest.
At this point, only the files on the existing file system can be accessed.
The following diagram shows the effects of mounting the volume
residing on /device/dsiover/users.
If the volume is unmounted, the file system is restored to the situation
depicted in the above figure.
Mount Point
12
5. System Protection :
The process in an operating system must be protected from one
another’s activities.
Protection refers to a mechanism for controlling the access of programs,
processes or users to the resources defined by a computer system.
Modern protection concepts have evolved to increase the reliability of
any complex system that makes use of shared resources.
The role of protection in a computer system is to provide a mechanism
for the enforcement of the policies governing resource use.
Mechanisms determine ‘how’ something will be done; policies decided
‘what’ will be done.
Principles of Protection :
A key, time-tested guiding principle for protection is the ‘principle of
least privilege’.
It dictates that programs, users and even systems be given just enough
privileges to perform their tasks.
An operating system following the ‘principle of lest privilege’
implements its features, programs, system calls, and data structures so
that failure or compromise of a component does the minimum damage
and allows the minimum damage to be done.
Domain of Protection :
A computer system is a collection of processes and objects.
By objects, we mean both hardware objects (CPU, memory, disks) and
software objects (files, programs and semaphores).
Each object has a unique name that differentiates it from all other
objects in the system, and each can be accessed only through well-
defined and meaningful operations.
The operations that are possible may depend on the objects.
A process should be allowed to access only those resources for which it
has authorization.
13
Domain Structure :
A process operates within a ‘protection domain’, which specifies the
resources that the process may access.
Each domain defines a set of objects and the types of operations that
may be invoked on each object.
The ability to execute an operation on an object is an ‘access right’.
A domain is a collection of access rights, each of which is an ordered pair
<object-name, rights-set>.
For example, if domain D has the access right <file F, {read, write}>, then
a process executing in domain D can both read and write the file F.
It can not perform any other operation on that object.
The association between a process and a domain may be either ‘static’,
if the set of resources available to the process is fixed throughout the
process’s life time, or ‘dynamic’.
If the association between processes and domains is fixed, and we want
to adhere to the need-to-know principle, then a mechanism must be
available to change the content of a domain.
If the association is dynamic, a mechanism is available to allow ‘domain
switching’, enabling the process to switch from one domain to another.
14
6. Access Matrix :
The general method of protection can be viewed abstractly as a matrix,
called ‘Access Matrix’.
The rows of the access matrix represent ‘domains’, and the columns
represent ‘objects’.
Each entry in the matrix consists of a set of access rights.
The entry access(i,j) defines the set of operations that a process
executing in domain Di can invoke on object Oj.
Consider the access matrix given below :
Access Matrix
Here, there are three files F1, F2 and F3 and One laser Printer.
A process executing in Domain D1 can read files F1 and F3.
A process executing in domain D4 has the same privileges as one
executing in domain D1, it can also write onto files F1 and F3.
The laser printer can be accessed only by a process executing in domain
D2.
The process executing in domain D3 can perform ‘read’ operation on F2
and can perform ‘execute’ operation on F3.
15
Processes should be able to switch from one domain to another.
Switching from domain Di to domain Dj is allowed if and only if the
access right ‘switch’ access(i,j).
Thus, in the following figure, a process executing in domain D2 can
switch to domain D3 or to domain D4 can switch to D1 and one in
domain D1 can switch to D2.
16
Access Matrix with ‘copy’ rights
It is also required a mechanism to allow addition of new rights and
removal of some rights.
The ‘owner’ right controls these operations.
If access(i,j) includes the ‘owner’ right, then a process executing in
domain Di can add and remove any right in any entry in column j.
For example, in the following figure-(a), domain D1 is the owner of F1
and thus can add and delete any valid right in column F1.
Similarly, domain D2 is the owner of F2 and F3 and thus can add and
remove any valid right within these two columns.
Thus, the access matrix of figure-(a) can be modified to the access matrix
shown in figure-(b).
The ‘copy’ and ‘owner’ rights allow a process to change the entries in a
column.
17
Access Matrix with ‘owner’ rights
A mechanism is also needed to change the entries in a ‘row’.
The ‘control’ right is applicable only to domain objects.
If access(i,j) includes the ‘control’ right, then a process executing in
domain Di can remove any access right from row j.
For example, suppose that in the following figure, one can include the
‘control’ right in access(D2, D4).
Then, a process executing in domain D2 could modify domain D4, as
shown in the following figure.
The ‘copy’ and ‘owner rights provide us with a mechanism to limit the
propagation of access rights.
The problem of guaranteeing that no information initially held in an
object can migrate outside of its execution environment is called the
‘confinement problem’.
18
Modified Access Matrix
* * * * *
19