File System Interface
File System Interface
File-System Interface
File-System Interface
File Concept
Access Methods
Directory Structure
Directory implementation
File-System Mounting
Allocation methods
File Sharing
Free-space management
Protection
Efficiency and performance
File Concept
File
Contiguous
Types:
Data
numeric
character
binary
Program
Files
File Attributes
File Operations
1. Per-process
table:
Keeps track of all files that a process has open
Each entry in per-process table points to a
system-wide table
2. System-wide
table:
Contains process-independent information ex:
file size, access dates
Open Files
File Locking
1. Shared
2. Exclusive
File Structure
File Structure
Structure Terms
File
Field
Database
collection of related
data
relationships among
elements of data are
explicit
collection of similar
records
may be referenced by
name
access control
Record
restrictions
usually apply
collection
of related
at the file
level fields
that can be treated as a
unit by some application
program
File Management
System Objectives
Optimize performance
Minimal User
Requirements
Each user:
File Structure
OS
Packing
blocks.
All
Access Methods
1.
Sequential Access
read next
write next
reset
no read after last write
(rewrite)
Ex: editors, compilers
Sequential-access File
Ex: read block 14 then read block 53 and then write block 7
No
Great
Directory Structure
Directory
Files
F1
F2
F3
F4
Fn
Disk Structure
A Typical File-system
Organization
Operations Performed
on a Directory
Obtain
Single-Level Directory
Naming problem
Grouping problem
Two-Level Scheme
Figure 12.4
TreeStructured
Master
Directory
directory with
user
directories
underneath it
Each user
directory may
have
subdirectories
and files as
entries
Two-Level Directory
Path name
Can have the same file name for
different user
Efficient searching
Tree-Structured
Directories
Tree-Structured
Directories
Directory entry:
File 0; subdirectory -(Cont)
1
Efficient searching
cd /spell/mail/prog
type list
Tree-Structured
Directories (Cont)
Acyclic-Graph
Directories
Acyclic-Graph
Directories (Cont.)
Entry-hold-count solution
General Graph
Directory
General Graph
Directory (Cont.)
Garbage collection
Mount
Mount Point
File Sharing
Access
Rights
None
Execution
Appending
Knowledge
Changing protection
Reading
Updating
Deletion
Protection
Types of access
Read
Write
Execute
Append
Delete
List
111
110
001
Ask manager to create a group (unique name), say G, and add some
users to the group.
group
761
public
game
game
Access
Matrix
Access
Control
Lists
A matrix may be
decomposed by
columns, yielding
access control lists
Capabilit
y Lists
Decomposition by
rows yields
capability tickets
A capability
ticket specifies
authorized objects
and operations for
a user
File System
Implementation
File-System Structure
File
structure
File
File
File
File System
Architecture
These file formats are consistent with the collectionof- records approach to files and determine how file
data is accessed
Logical I/O
Basic I/O
Device drivers
Device Drivers
Lowest level
Logical I/O
Logical I/O
This level is the interface between
the
logical commands issued by a
program and the physical details
required by the disk.
Logical units of data versus physical
blocks of data to match disk
requirements.
Access Method
Elements of File
Management
ease of update
economy of storage
simple maintenance
reliability
The Pile
Purpose is simply to
accumulate the mass
of data and save it
Record access is by
exhaustive search
The
Sequential
File
Indexed
Sequential File
Multiple levels of
indexing can be used
to provide greater
efficiency in access
Indexed File
On
disk:
File system
implementation
1. Boot
2. Volume
3. Directory
File system
implementation
In-memory:
1. In-memory
2. In-memory
3. System-wide
4. Per-process
Boot
Systems
Root
can be dual-booted.
VFS architecture in
4 main object types defined byLinux
Linux VFS :
1. inode
2. file
3. superblock
system
4. dentry
Directory
Linear list of file
names with pointers to the data
Implementation
blocks.
1.
2.
simple to program
time-consuming to execute
finding a file requires linear search
Record Blocking
for I/O to be
performed records
must be organized
as blocks
3) Variable-Length Unspanned
Blocking variable-length
records are used, but spanning is
not done
File Allocation
Disks are divided into physical blocks (sectors on a track)
Files are divided into logical blocks (subdivisions of the file)
Logical block size = some multiple of a physical block size
The operating system or file management system is responsible
for allocating blocks to files
Preallocation vs
Dynamic Allocation
Portion Size
Items to be considered:
1) contiguity of space increases performance, especially for
Retrieve_Next operations, and greatly for transactions
running in a transaction-oriented operating system
2) having a large number of small portions increases the size
of tables needed to manage the allocation information
3) having fixed-size portions simplifies the reallocation of
space
4) having variable-size or small fixed-size portions minimizes
waste of unused storage due to overallocation
Summarizing the
Alternatives
Table 12.3
File Allocation Methods
contiguous set
of blocks is
allocated to a
file at the time
of file creation
Preallocation
strategy using
variable-size
portions
12.9
After Compaction
Chained
Allocation
Allocation is on an
No external
fragmentation to worry
about
12.1
1
12.1
2
Linked Allocation
(Cont.)
Simple need only starting address
No random access
Mapping
Disadvantages:
12.1
3
12.1
4
Indexed Allocation
(Cont.)
Need index table
Random
Dynamic
access
Index block
link
link
Index block
link
link
Free Space
Management
Free-Space
Management
Bit vector
2.
Linked list
3.
Grouping
4.
Counting
Free-Space
1. Bit vector or bitManagement
vector (n blocks)
0 1
n-1
bit[i] =
1 block[i] free
0 block[i] occupied
Free-Space
(Cont.)
2. Management
Linked list (free list)
Free-Space
(Cont.)
3.Management
Grouping:
4. Counting:
Efficiency and
Performance
disk
Efficiency and
Performance:
Performance
Buffer cache separate section of main memory for blocks that will
be used again shortly
Unified buffer cache uses the same page cache for both
memory-mapped pages and files
Efficiency and
Performance
Block replacement
mechanisms:
LRU
Free-behind
End of Unit - 6