Ch11 - File System Interface
Ch11 - File System Interface
File-System Interface
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
File Concept
Access Methods
Disk and Directory Structure
File-System Mounting
File Sharing
Protection
Operating System Concepts – 9th Edition 11.2 Silberschatz, Galvin and Gagne ©2013
1
Objectives
Operating System Concepts – 9th Edition 11.3 Silberschatz, Galvin and Gagne ©2013
File Concept
Contiguous logical address space
Types:
Data
numeric
character
binary
Program
Contents defined by file’s creator
Many types
Consider text file, source file, executable file
Operating System Concepts – 9th Edition 11.4 Silberschatz, Galvin and Gagne ©2013
2
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
Protection – controls who can do reading, writing, executing
Time, date, and user identification – data for protection,
security, and usage monitoring
Information about files are kept in the directory structure, which
is maintained on the disk
Many variations, including extended file attributes such as file
checksum
Information kept in the directory structure
Operating System Concepts – 9th Edition 11.5 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.6 Silberschatz, Galvin and Gagne ©2013
3
File Operations
File is an abstract data type
Create
Write – at write pointer location
Read – at read pointer location
Reposition within file - seek
Delete
Truncate
Open(Fi) – search the directory structure on disk for entry Fi,
and move the content of entry to memory
Close (Fi) – move the content of entry Fi in memory to directory
structure on disk
Operating System Concepts – 9th Edition 11.7 Silberschatz, Galvin and Gagne ©2013
Open Files
Operating System Concepts – 9th Edition 11.8 Silberschatz, Galvin and Gagne ©2013
4
Open File Locking
Provided by some operating systems and file systems
Similar to reader-writer locks
Shared lock similar to reader lock – several processes can
acquire concurrently
Exclusive lock similar to writer lock
Mediates access to a file
Mandatory or advisory:
Mandatory – access is denied depending on locks held and
requested
Advisory – processes can find status of locks and decide
what to do
Operating System Concepts – 9th Edition 11.9 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.10 Silberschatz, Galvin and Gagne ©2013
5
File Structure
None - sequence of words, bytes
Simple record structure
Lines
Fixed length
Variable length
Complex Structures
Formatted document
Relocatable load file
Can simulate last two with first method by inserting appropriate
control characters
Who decides:
Operating system
Program
Operating System Concepts – 9th Edition 11.11 Silberschatz, Galvin and Gagne ©2013
Access Methods
Sequential Access
read next
write next
reset (to the beginning)
Operating System Concepts – 9th Edition 11.12 Silberschatz, Galvin and Gagne ©2013
6
Sequential-access File
Operating System Concepts – 9th Edition 11.13 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.14 Silberschatz, Galvin and Gagne ©2013
7
Example of Index and Relative Files
Operating System Concepts – 9th Edition 11.15 Silberschatz, Galvin and Gagne ©2013
Disk Structure
Operating System Concepts – 9th Edition 11.16 Silberschatz, Galvin and Gagne ©2013
8
A Typical File-system Organization
Operating System Concepts – 9th Edition 11.17 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.18 Silberschatz, Galvin and Gagne ©2013
9
Directory Structure
Directory
Files
F1 F2 F4
F3
Fn
Operating System Concepts – 9th Edition 11.19 Silberschatz, Galvin and Gagne ©2013
Directory Organization
Operating System Concepts – 9th Edition 11.20 Silberschatz, Galvin and Gagne ©2013
10
Operations Performed on Directory
Operating System Concepts – 9th Edition 11.21 Silberschatz, Galvin and Gagne ©2013
Single-Level Directory
A single directory for all users
Naming problem
Operating System Concepts – 9th Edition 11.22 Silberschatz, Galvin and Gagne ©2013
11
Two-Level Directory
Separate directory for each user
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
Operating System Concepts – 9th Edition 11.23 Silberschatz, Galvin and Gagne ©2013
Tree-Structured Directories
Operating System Concepts – 9th Edition 11.24 Silberschatz, Galvin and Gagne ©2013
12
Tree-Structured Directories (Cont.)
Efficient searching
Operating System Concepts – 9th Edition 11.25 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.26 Silberschatz, Galvin and Gagne ©2013
13
Acyclic-Graph Directories
Have shared subdirectories and files
Operating System Concepts – 9th Edition 11.27 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.28 Silberschatz, Galvin and Gagne ©2013
14
General Graph Directory
Operating System Concepts – 9th Edition 11.29 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.30 Silberschatz, Galvin and Gagne ©2013
15
File System Mounting
Operating System Concepts – 9th Edition 11.31 Silberschatz, Galvin and Gagne ©2013
Mount Point
Operating System Concepts – 9th Edition 11.32 Silberschatz, Galvin and Gagne ©2013
16
File Sharing
Sharing of files on multi-user systems is desirable
Sharing may be done through a protection scheme
On distributed systems, files may be shared across a network
Network File System (NFS) is a common distributed file-sharing
method
If multi-user system
User IDs identify users, allowing permissions and
protections to be per-user
Group IDs allow users to be in groups, permitting group
access rights
Owner of a file / directory
Group of a file / directory
Operating System Concepts – 9th Edition 11.33 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.34 Silberschatz, Galvin and Gagne ©2013
17
File Sharing – Failure Modes
Operating System Concepts – 9th Edition 11.35 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.36 Silberschatz, Galvin and Gagne ©2013
18
Protection
File owner/creator should be able to control:
what can be done
by whom
Types of access
Read
Write
Execute
Append
Delete
List
Operating System Concepts – 9th Edition 11.37 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.38 Silberschatz, Galvin and Gagne ©2013
19
Windows 7 Access-Control List Management
Operating System Concepts – 9th Edition 11.39 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition 11.40 Silberschatz, Galvin and Gagne ©2013
20
End of Chapter 11
Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013
21