Lecture 11-File Management
Lecture 11-File Management
g
Systems
:
Internals Chapter 12
and File Management
Design Eighth Edition
Principle By William Stallings
s
Files
Data collections created by users
The File System is one of the most important parts of the
OS to a user
Desirable properties of files:
Long-term existence
• files are stored on disk or other secondary storage and do not disappear when a
user logs off
Sharable between
processes
• files have names and can have associated access permissions that permit
controlled sharing
Structure
• files can be organized into hierarchical or more complex structure to reflect the
relationships among files
File Systems
Provide a means to store data organized as files as well as
a collection of functions that can be performed on files
Maintain a set of attributes associated with the file
Typical operations include:
Create
Delete
Open
Close
Read
Write
File Structure
Provides
general-
Enables purpose
users and record I/O
capability Maintains
applications basic data
to access about file
records
Access Method
Level of the file system closest to the user
Provides a standard interface between applications
and the file systems and devices that hold the data
Different access methods reflect different file
structures and different ways of accessing and
processing the data
File Organization and Access
File organization is the logical structuring of the records as
determined by the way in which they are accessed
In choosing a file organization, several criteria are important:
short access time
ease of update
economy of storage
simple maintenance
reliability
The
The direct, sequential
or hashed, file
file
Five of the
common file
organizations are:
The
The indexed
indexed sequential
file file
The Pile
Least complicated form
of file organization
Data are collected in
the order they arrive
Each record consists of
one burst of data
Purpose is simply to
accumulate the mass
of data and save it
Record access is by
exhaustive search
The
Sequential
File
Most common form of
file structure
A fixed format is used
for records
Key field uniquely
identifies the record
Typically used in batch
applications
Only organization that is
easily stored on tape as
well as disk
Indexed
Sequential File
Adds an index to the
file to support
random access
Adds an overflow file
Greatly reduces the
time required to
access a single record
Multiple levels of
indexing can be used
to provide greater
efficiency in access
Indexed File
Records are accessed only
through their indexes
Variable-length records can be
employed
Exhaustive index contains one
entry for every record in the
main file
Partial index contains entries to
records where the field of
interest exists
Used mostly in applications
where timeliness of information
is critical
Examples would be airline
reservation systems and
inventory control systems
Direct or Hashed File
Access directly any block of a known
address
Makes use of hashing on the key
value Examples are:
Often used where: • directories
very rapid access is required • pricing tables
fixed-length records are used • schedules
records are always accessed • name lists
one at a time
Table 12.1
Information
Elements of
a File
Directory
List Update
Create Delete
Search director director
files files
y y
Two-Level Scheme
Master directory
has an entry for
There is one each user Each user
directory for directory directory is a
each user and a providing address simple list of the
master directory and access files of that user
control
information
Names must be
File system can
unique only within
easily enforce
the collection of
access restriction
files of a single
on directories
user
File Sharing
Two issues arise
when allowing
files to be
shared among a
number of users:
management
of
access rights
simultaneous
access
Access
Rights
None Appending
the user would not be allowed
to read the user directory that
the user can add data to the
includes the file file but cannot modify or
delete any of the file’s
Knowledge contents
the user can determine that
the file exists and who its
Updating
owner is and can then petition the user can modify, delete,
the owner for additional access and add to the file’s data
rights
Execution
Changing protection
the user can load and execute the user can change the
a program but cannot copy it access rights granted to
Reading
other users
the user can read the file for Deletion
any purpose, including copying
and execution
the user can delete the file
from the file system
User Access Rights
Specifi User
Owner c Group All
usually the Users s
initial all users
creator of who have
the file access to
individual a set of
this system
users who users who
has full
are are not
rights
designated individually
by user ID defined
may grant these are
rights to public files
others
Access Matrix
(user,filename,rights)
Access Control List
(user,rights)
Capability Lists
(filename,rights)
Record Blocking
1) Fixed-Length Blocking –
Blocks are the unit of fixed-length records are used,
I/O with secondary and an integral number of
records are stored in a block
storage
for I/O to be Internal fragmentation –
performed records unused space at the end of
each block
must be organized
as blocks 2) Variable-Length Spanned
Blocking – variable-length
records are used and are packed
into blocks with no unused space
3) Variable-Length Unspanned
Given the size of a Blocking – variable-length
block, three methods of records are used, but spanning
blocking can be used: is not employed
File Allocation
On secondary storage, a file consists of a collection of
blocks
The operating system or file management system is
responsible for allocating blocks to files
The approach taken for file allocation may influence the
approach taken for free space management
Space is allocated to a file as one or more portions
(contiguous set of allocated blocks)
File allocation table (FAT)
data structure used to keep track of the portions assigned
to a file
Preallocation vs
Dynamic Allocation
A preallocation policy requires that the maximum size of a
file be declared at the time of the file creation request
For many applications it is difficult to estimate reliably the
maximum potential size of the file
tends to be wasteful because users and application
programmers tend to overestimate size