Chapter 11: �File-System Interface
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Chapter 11: File-System Interface
11.2
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Objectives
11.3
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Concept
11.4
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Attributes
11.5
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File info Window on Mac OS X
11.6
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Operations
11.7
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Open Files
11.8
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Open File Locking
11.9
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Locking Example – Java API
import java.io.*;
import java.nio.channels.*;
public class LockingExample {
public static final boolean EXCLUSIVE = false;
public static final boolean SHARED = true;
public static void main(String arsg[]) throws IOException {
FileLock sharedLock = null;
FileLock exclusiveLock = null;
try {
RandomAccessFile raf = new RandomAccessFile("file.txt", "rw");
// get the channel for the file
FileChannel ch = raf.getChannel();
// this locks the first half of the file - exclusive
exclusiveLock = ch.lock(0, raf.length()/2, EXCLUSIVE);
/** Now modify the data . . . */
// release the lock
exclusiveLock.release();
11.10
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Locking Example – Java API (Cont.)
// this locks the second half of the file - shared
sharedLock = ch.lock(raf.length()/2+1, raf.length(), SHARED);
/** Now read the data . . . */
// release the lock
sharedLock.release();
} catch (java.io.IOException ioe) {
System.err.println(ioe);
}finally {
if (exclusiveLock != null)
exclusiveLock.release();
if (sharedLock != null)
sharedLock.release();
}
}
}
11.11
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Types – Name, Extension
11.12
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Structure
11.13
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Sequential-access File
11.14
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Access Methods
read next
write next
reset
no read after last write
(rewrite)
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
11.15
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Simulation of Sequential Access on Direct-access File
11.16
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Other Access Methods
11.17
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Example of Index and Relative Files
11.18
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Directory Structure
F 1
F 2
F 3
F 4
F n
Directory
Files
Both the directory structure and the files reside on disk
11.19
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Disk Structure
11.20
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
A Typical File-system Organization
11.21
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Types of File Systems
11.22
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Operations Performed on Directory
11.23
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Directory Organization
The directory is organized logically to obtain
11.24
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Single-Level Directory
11.25
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Two-Level Directory
11.26
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Tree-Structured Directories
11.27
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Tree-Structured Directories (Cont.)
11.28
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Tree-Structured Directories (Cont)
rm <file-name>
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
Deleting “mail” ⇒ deleting the entire subtree rooted by “mail”
11.29
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Acyclic-Graph Directories
11.30
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Acyclic-Graph Directories (Cont.)
Solutions:
11.31
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
General Graph Directory
11.32
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
General Graph Directory (Cont.)
11.33
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File System Mounting
11.34
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Mount Point
11.35
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Sharing
11.36
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Sharing – Remote File Systems
11.37
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Sharing – Failure Modes
11.38
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
File Sharing – Consistency Semantics
11.39
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Protection
11.40
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Access Lists and Groups
RWX
a) owner access 7 ⇒ 1 1 1� RWX
b) group access 6 ⇒ 1 1 0
RWX
c) public access 1 ⇒ 0 0 1
Attach a group to a file� chgrp G game
11.41
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Windows 7 Access-Control List Management
11.42
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
A Sample UNIX Directory Listing
11.43
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
End of Chapter 11
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition