Chapter 10: File-System Interface – 7 Silberschatz, Galvin and Gagne ©2007

advertisement
Chapter 10: File-System Interface
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
Silberschatz, Galvin and Gagne ©2007
Chapter 10: File-System Interface






File Concept
Access Methods
Directory Structure
File-System Mounting
File Sharing
Protection
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.2
Silberschatz, Galvin and Gagne ©2007
Objectives




To explain the function of file systems
To describe the interfaces to file systems
To discuss file-system design tradeoffs, including
access methods, file sharing, file locking, and
directory structures
To explore file-system protection
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.3
Silberschatz, Galvin and Gagne ©2007
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
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.4
Silberschatz, Galvin and Gagne ©2007
File Operations








Create
Write
Read
Reposition within file
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 with Java – 7th Edition, Nov 15, 2006
10.5
Silberschatz, Galvin and Gagne ©2007
Open Files

Several pieces of data are needed to manage
open files:
 File pointer: pointer to last read/write location,
per process that has the file open
 File-open count: counter of number of times a
file is open – to allow removal of data from
open-file table when last processes closes it
 Disk location of the file: cache of data access
information
 Access rights: per-process access mode
information
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.6
Silberschatz, Galvin and Gagne ©2007
File Types – Name, Extension
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.7
Silberschatz, Galvin and Gagne ©2007
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 – 7th Edition, Nov 15, 2006
10.8
Silberschatz, Galvin and Gagne ©2007
Sequential-access File
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.9
Silberschatz, Galvin and Gagne ©2007
Simulation of Sequential Access on a Direct-access File
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.10
Silberschatz, Galvin and Gagne ©2007
Example of Index and Relative Files
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.11
Silberschatz, Galvin and Gagne ©2007
A Typical File-system Organization
 Could use entire disk for FS, but
 system could have multiple FS types (e.g., swap)
 Disk divided into miniature disks called partitions or slices
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.12
Silberschatz, Galvin and Gagne ©2007
Directory Structure

A collection of nodes containing information about all files
Directory
Files
F1
F2
F3
F4
Fn
Both the directory structure and the files reside on disk
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.13
Silberschatz, Galvin and Gagne ©2007
Operations Performed on Directory






List directory contents
Search for a file
Create a file
Delete a file
Rename a file
Traverse the file system
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.14
Silberschatz, Galvin and Gagne ©2007
Organize the Directory (Logically) to Obtain



Efficiency – locating a file quickly
Naming – convenient to users
 Two users can have same name for different
files
 The same file can have several different
names
Grouping – logical grouping of files by properties,
(e.g., all Java programs, all games, …)
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.15
Silberschatz, Galvin and Gagne ©2007
Single-Level Directory

A single directory for all users
 Called the root directory
 Pros: Simple, easy to quickly locate files
 Cons: inconvenient naming (uniqueness), no grouping
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.16
Silberschatz, Galvin and Gagne ©2007
Two-Level Directory

Separate directory for each user
 Introduces the notion of a path name
 Can have the same file name for different user
 Efficient searching
 No grouping capability
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.17
Silberschatz, Galvin and Gagne ©2007
Tree-Structured Directories
 Directories can now contain files and subdirectories
 Efficient searching, allows grouping
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.18
Silberschatz, Galvin and Gagne ©2007
Path Names



To access a file, the user should either:
 Go to the directory where file resides, or
 Specify the path where the file is
Path names are either absolute or relative
 Absolute: path of file from the root directory
 Relative: path from the current working directory
Most OSes have two special entries in each directory:
 “.” for current directory and “..” for parent
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.19
Silberschatz, Galvin and Gagne ©2007
Acyclic-Graph Directories

Allow sharing of subdirectories and files
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.20
Silberschatz, Galvin and Gagne ©2007
Acyclic-Graph Directories (Cont.)



Two different names (aliasing)
If dict deletes list  dangling pointer
Solutions:
 Backpointers, so we can delete all pointers
Variable size records a problem
 Backpointers using a daisy chain organization
 Reference count for each file
New directory entry type
 Link – another name (pointer) to an existing file
 Resolve the link – follow pointer to locate the file
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.21
Silberschatz, Galvin and Gagne ©2007
General Graph Directory
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.22
Silberschatz, Galvin and Gagne ©2007
General Graph Directory (Cont.)

How do we guarantee no cycles?
 Allow only links to files not subdirectories
 Garbage collection
 Every time a new link is added use a
cycle detection algorithm to determine
whether it is OK
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.23
Silberschatz, Galvin and Gagne ©2007
File System Mounting

Mount allows two FSes to be merged into one
 For example you insert your floppy into the root FS:
mount(“/dev/fd0”, “/mnt”, 0)
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.24
Silberschatz, Galvin and Gagne ©2007
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 with Java – 7th Edition, Nov 15, 2006
10.25
Silberschatz, Galvin and Gagne ©2007
Categories of Users


Individual user
 Log in establishes a user-id
 Might be just local on the computer or could be
through interaction with a network service
Groups to which the user belongs
 For example, “nahum” is in “w4118”
 Again could just be automatic or could involve talking
to a service that might assign, say, a temporary
cryptographic key
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.26
Silberschatz, Galvin and Gagne ©2007
UNIX Access Rights




Mode of access: read, write, execute
Three classes of users
RWX
a) owner access
7

111
RWX
b) group access
6
 110
RWX
c) public access
1
 001
Ask manager to create a group (unique name), say G, and
add some users to the group.
For a particular file (say game) or subdirectory, define an
appropriate access.
owner group
Attach a group to a file: chgrp G game
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.27
public
chmod 761 game
Silberschatz, Galvin and Gagne ©2007
Issues with UNIX Access Rights


Just a single owner, a single group and the public
 Pro: Compact enough to fit in just a few bytes
 Con: Not very expressive
Access Control List: This is a per-file list that tells who
can access that file
 Pro: Highly expressive
 Con: Harder to represent in a compact way
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.28
Silberschatz, Galvin and Gagne ©2007
Windows XP Access-control List Management
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.29
Silberschatz, Galvin and Gagne ©2007
File Sharing
Sharing of files on multi-user systems is
desirable
 Sharing may be done through the
protection scheme
 On distributed systems, files may be
shared across a network
 Use a distributed file system such as
Network File System (NFS)
 Use distributed naming systems such as
NIS, LDAP, Active Directory for networkwide user information

Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.30
Silberschatz, Galvin and Gagne ©2007
Remote File System Mounting



Same idea, but file system is actually on some
other machine
Implementation uses remote procedure call
 Package up the user’s file system operation
 Send it to the remote machine where it gets
executed like a local request
 Remote sends back the answer
Very common in modern systems
 E.g., the CLIC lab, compute nodes, etc.
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.31
Silberschatz, Galvin and Gagne ©2007
File Sharing – Client-Server Model





Client-server model allows clients to mount
remote file systems from servers
Server can serve multiple clients
NFS is a standard UNIX client-server file sharing
protocol
 Multiple versions; V4 is standard now
 We use it on CLIC, compute nodes
CIFS is standard Windows protocol
Standard operating system file calls are translated
into remote procedure calls
 Package up the user’s file system operation
 Send it to the remote machine where it gets
executed like a local request
 Remote sends back the answer
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
10.32
Silberschatz, Galvin and Gagne ©2007
End of Chapter 10
Operating System Concepts with Java – 7th Edition, Nov 15, 2006
Silberschatz, Galvin and Gagne ©2007
Download