Ch10-File System Interface-6 PDF
Ch10-File System Interface-6 PDF
Types:
Data
numeric
character
binary
Program
10.4
File Structure
File Concept
Access Methods
Directory Structure
Lines
File-System Mounting
Fixed length
Variable length
File Sharing
Complex Structures
Protection
Formatted document
Can simulate last two with first method by inserting appropriate control
characters
Who decides:
10.2
Operating system
Program
Objectives
10.5
File Attributes
usage monitoring
Information about files are kept in the directory structure, which is
10.3
10.6
File Operations
disk
10.7
Open Files
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();
10.10
File pointer: pointer to last read/write location, per process that has the
file open
}
}
10.8
10.11
10.9
10.12
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
10.13
Sequential-access File
10.16
Directory Structure
A collection of nodes containing information about all files
Directory
Files
F1
F2
F3
F4
Fn
10.14
10.15
10.17
10.18
Two-Level Directory
Separate directory for each user
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
10.19
10.22
Tree-Structured Directories
10.20
Single-Level Directory
10.23
cd /spell/mail/prog
type list
Naming problem
Grouping problem
10.21
10.24
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.25
Acyclic-Graph Directories
10.26
10.28
Garbage collection
10.29
mount point
Solutions:
Entry-hold-count solution
10.27
10.30
per-user
Group IDs allow users to be in groups, permitting group access
rights
10.31
Mount Point
10.34
10.32
File Sharing
10.35
Remote file systems add new failure modes, due to network failure,
server failure
each remote request
request, allowing easy recovery but less security
Network File System (NFS) is a common distributed file-sharing method
10.33
10.36
file simultaneously
Sharing
10.37
Protection
10.40
by whom
Types of access
Read
Write
Execute
Append
Delete
List
10.38
10.41
b) group access
c) public access
RWX
111
RWX
110
RWX
001
Ask manager to create a group (unique name), say G, and add some users
to the group.
owner
chmod
group
End of Chapter 10
public
761
game
game
10.39