Operating System File Management
Operating System File Management
10.1
Access Methods
Directory Structure
File-System Mounting
10.2
File Concept
A file is a named collection of related
10.3
File Structure
A file has a certain defined structure which depends
on its types:
10.4
File Systems
process
3. Multiple processes can access INFO
concurrently
10.5
Files
INFO stored in the files must be persistent,
----------
O.S.
view
10.6
10.7
File Attributes
Name only information kept in human-readable form
Identifier unique tag (number) identifies file within file system
Type needed for systems that support different types
Location pointer to file location on device
Size current file size
10.8
File Attributes
Deals with:
Location: where the file is physically located
Size: how big is the file
Type : what kind of file it is
Protection: who can access the file
Time & Date: when was the last access or
modification
User: who created the file
and other information. Some of the attributes
are shown in the next slide
10.9
10.10
File Operations
File is an abstract data type
Create
Write
Read
10.11
Open Files
Several pieces of data are needed to manage open
files:
10.12
10.13
Access Methods
Sequential Access
read next
write next
reset
no read after last write
(rewrite)
Direct Access
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
Operating System Concepts with Java 8th Edition
10.14
Sequential-access File
10.15
10.16
10.17
Disk Structure
Disk can be subdivided into partitions
10.18
10.19
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system
10.20
DIRECTORY STRUCTURE
ONE LEVEL DIRECTORY STRUCTURE
TWO LEVEL DIRECTORY STRUCTURE
TREE DIRECTORY STRUCTURE
ACYCLIC GRAPH DIRECTORY STRUCTURE
10.21
Directories
Directories are the mechanism provided by O.S. to keep track of files.
10.22
Single-Level Directory
A single directory for all users
Naming problem
Grouping problem
10.23
Two-Level Directory
Separate directory for each user
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
10.24
Tree-Structured Directories
10.25
cd /spell/mail/prog
type list
10.26
rm <file-name>
Creating a new subdirectory is done in current directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
mail
prog copy prt exp count
10.27
Acyclic-Graph Directories
Have shared subdirectories and files
10.28
Solutions:
Entry-hold-count solution
10.29
Directory Structure
Single level directory system
10.30
Directory Structure
Two-level directory system
Search in directories is based on user name.
10.31
Directory Structure
Hierarchical directory system
10.32
Path Names
Absolute path name: /usr/ast/mailbox. Always starts with /
(i.e.,separator)
Relative Path Name: mailbox
Current directory or working directory determines the relative path
name
In Unix . is current directory and
.. refers to parent
For example: cp ../lib/abdy.doc .
10.33
Tree-Structured Directories
Absolute path: begins at the root and follows a path down to the
specified file. root/spell/mail/prt/first
Relative path: defines a path from the current directory. prt/first
given root/spell/mail as current path.
Operating System Concepts with Java 8th Edition
10.34
Grouping Capability
Current directory (working directory)
pwd
cd
/spell/mail/prog
10.35
rm <file-name>
Creating a new subdirectory is done in current directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
mail
prog
10.36
Acyclic-Graph Directories
Have shared subdirectories and files
Only one file exists. Any changes made by one person are
10.37
10.38
be accessed
A unmounted file systemis mounted at a
10.39
10.40
Mount Point
10.41
10.42
File-System Implementation
Directory Implementation
Allocation Methods
Free-Space Management
10.43
File-System Structure
File structure
10.44
10.45
File-System Implementation
Boot control block contains info needed by
10.46
system.
Sector is the smallest user-accessible portion of the disk, usually it is 512 bytes
for magnetic disks and 2048 bytes for optical disks. The term block was used
earlier for sector. Nowadays, sector has become a common name. A file block
usually consists of several (power of 2) contiguous disk blocks. Usually file block
size is a configuration parameter that can be set.
On-disk structures
A FCB contains the files details such as owner, permissions, location of data
blocks, etc. In UFS, it is called inode.
10.47
performance improvement
10.48
FILE SYSTEM
In computing, a file system (or filesystem) is a type of data
store which can be used to store, retrieve and update a set of files. The
term refers to either the abstract data structures used to define files, or
the actual software or firmware components that implement the
abstract ideas.
Some file systems are used on local data storage devices; others
10.49
10.50
File-System Structure
File structure
10.51
10.52
10.53
Application programs
Logical file system
Manages metadata information which includes all of the information about the file
system structure
It manages the directory structure to provide the file-organization module with the
information its needs, given a symbolic name.
It maintains file structure via File Control Blocks (FCB).
It is also responsible for protection and security
File organization module
Knows about the files and their logical and physical blocks
Can translate logical block address to physical block address for the basic file
system to transfer
It also includes a free-space manager which keeps track of unallocated blocks
Basic file system
This needs only issue generic commands to the appropriate device drivers to read
and write physical blocks on the disk
Each physical block is identified by its disk address (e.g., drive 3, cylinder 10, track
2, sector 20)
I/O control
Contains the device drivers and interrupt handlers to transfer information between
main memory and the disk.
10.54
10.55
To illustrate the use of these structures, let us look at how create and open work
Creating a file: application program calls the logical file system to create a
file. The logical file system allocates a new FCB, reads the appropriate
directory into memory, and updates it with the new file name and FCB and
writes back to disk
Opening a file: The open call passes a file name to the file system.
The file systems searches the directory structure for the given file
name, and the FCB of the file is copied into a system-wide open-file
table in memory.
An entry is also made in the per-process open file table, with a pointer
to the entry in the system-wide open-file table and some other fields.
The other fields can include a pointer to the current location in the file
and access mode in which the file is open.
10.56
10.57
10.58
10.59
system.
10.60
10.61
simple to program
time-consuming to execute
for example, to create a file in a directory the entire list has to
be searched to check if there is a file with the same name
To delete a file, the entire directory needs to be searched as
well
Hash Table linear list with hash data structure.
decreases directory search time
collisions situations where two file names hash to the same
location
10.62
10.63
10.64
Directory Implementation
Linear list of file names with pointer to the data
blocks.
simple to program
time-consuming to execute
fixed size
10.65
Allocation Methods
An allocation method refers to how disk
10.66
10.67
Linked Allocation
Each file is a linked list of disk blocks: blocks may be
pointer
10.68
Linked Allocation
10.69
File-Allocation Table
10.70
Indexed Allocation
Brings all pointers together into the index block
Logical view
index table
10.71
10.72
outer-index
index table
10.73
file
10.74
Free-Space Management
Bit vector (n blocks)
0 1
n-1
bit[i] =
0 block[i] free
1 block[i] occupied
10.75
Example:
block size = 212 bytes
disk size = 230 bytes (1 gigabyte)
n = 230/212 = 218 bits (or 32K bytes)
No waste of space
10.76
Bit map
Must be kept on disk
Copy in memory and disk may differ
Cannot allow for block[i] to have a situation where bit[i] =
1 in memory and bit[i] = 0 on disk
Solution:
Set bit[i] = 1 in disk
Allocate block[i]
10.77
10.78
End of Chapter 11
10.79