Report Hans-Lanie File-System Interface
-
Upload
haha-hahans -
Category
Documents
-
view
224 -
download
0
Transcript of Report Hans-Lanie File-System Interface
-
8/3/2019 Report Hans-Lanie File-System Interface
1/45
FILE-SYSTEM INTERFACE
ADVANCED OPERATING SYSTEM
FILE MANAGEMENT
-
8/3/2019 Report Hans-Lanie File-System Interface
2/45
FILE-SYSTEM INTERFACE
File ConceptAccess Methods
Directory Structure
File Sharing
Protection
-
8/3/2019 Report Hans-Lanie File-System Interface
3/45
OBJECTIVES
To explain the function of file systemsTo describe the interfaces to file
systems
To discuss file-system designtradeoffs, including accessmethods, file sharing, file locking,and directory structures
To explore file-system protection
-
8/3/2019 Report Hans-Lanie File-System Interface
4/45
A. FILE CONCEPT
Computer can store information on several
different storage media, such as magneticdisks, magnetic tapes, and optical disks.
The operating system abstracts form thephysical properties of its storage devicesto define a logical storage, the file.
Filesare mapped, by the O.S., onto physicaldevices.
A Fileis a named collection of relatedinformation that is recorded on secondarystorage.
-
8/3/2019 Report Hans-Lanie File-System Interface
5/45
FILE CONCEPT (CONT)
From a users perspective, a file is the
smallest allotment of logical secondarystorage; that is, data cannot be written tosecondary memory unless they are within afile.
A file represents:Datanumericcharacter
binaryProgram (both source and object forms)
-
8/3/2019 Report Hans-Lanie File-System Interface
6/45
FILE CONCEPT (CONT)
A file has a certain defined structureaccording to its type.
Text file (characters organized into lines)Source file (sequence of subroutines &functions)Object file (sequence of bytes)Executable file (series of code sections)
-
8/3/2019 Report Hans-Lanie File-System Interface
7/45
A.1 FILE ATTRIBUTES
Name only information kept in human-readable form
Identifier unique tag (number) identifies file withinfile system
Type needed for systems that support differenttypes
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 forprotection, security, and usage monitoring
Information about files are kept in the directorystructure, which is maintained on the disk
-
8/3/2019 Report Hans-Lanie File-System Interface
8/45
A.2 FILE OPERATIONSFile is an abstract data type
Create
Write
Read
Reposition within file
DeleteTruncate
Open(Fi) search the directory structure on disk for entryFi, and move the content of entry to memory
Close (Fi) move the content of entry Fi in memory to
directory structure on disk
per-process current file- position pointer
open-file table,
-
8/3/2019 Report Hans-Lanie File-System Interface
9/45
A.2 FILE OPERATIONS
The implementation of the open() and close()
operations is more complicated in an environmentwhere several processes may open the file at thesame time
per-process table
information regarding the use of the file by the processsystem-wide open-file table
table contains process-independent information, such asthe location of the file on disk, access dates, and file size
-
8/3/2019 Report Hans-Lanie File-System Interface
10/45
A.3 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 openFile-open count: counter of number of times a file
is open to allow removal of data from open-filetable when last processes closes itDisk location of the file: cache of data accessinformation
Access rights: per-process access modeinformation
-
8/3/2019 Report Hans-Lanie File-System Interface
11/45
A.4 OPEN FILE LOCKING
Provided by some operating systems and
file systemsMediates access to a file
A shared lock is akin to a reader lock in
that several processes can acquire thelock concurrently.
An exclusive lock behaves like a writerlock; only one process at a time can
acquire such a lock.
-
8/3/2019 Report Hans-Lanie File-System Interface
12/45
A.4 OPEN FILE LOCKING
Mandatory or advisory:
Mandatory access is denied dependingon locks held and requested
Advisory processes can find status oflocks and decide what to do
-
8/3/2019 Report Hans-Lanie File-System Interface
13/45
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();
-
8/3/2019 Report Hans-Lanie File-System Interface
14/45
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
exclusiveLock.release();
}catch (java.io.IOException ioe) {
System.err.println(ioe);
}finally {
if (exclusiveLock != null)
exclusiveLock.release();
if (sharedLock != null)
sharedLock.release();}
}
}
-
8/3/2019 Report Hans-Lanie File-System Interface
15/45
A.5 FILE TYPES NAME, EXTENSION
-
8/3/2019 Report Hans-Lanie File-System Interface
16/45
A.6 FILE STRUCTUREWho decides:
Operating systemProgram
-
8/3/2019 Report Hans-Lanie File-System Interface
17/45
B. ACCESS METHODS
Sequential Access (simplest method)
read nextwrite nextreset
-
8/3/2019 Report Hans-Lanie File-System Interface
18/45
ACCESS MOTHOD (CONT)
Direct Access (relative access)read n
write n
position to n
read nextwrite next
rewrite n
n= relative block number
A file is make up of fixed-length logical recordsthat allowprograms to read and write records rapidly in noparticular order.
Direct access method is based on a disk model of file,since disks allow random access to any file block.
-
8/3/2019 Report Hans-Lanie File-System Interface
19/45
SEQUENTIAL-ACCESS FILE
S O O S Q CC SS O C CC SS
-
8/3/2019 Report Hans-Lanie File-System Interface
20/45
SIMULATION OF SEQUENTIAL ACCESS ON A DIRECT-ACCESS
FILE
-
8/3/2019 Report Hans-Lanie File-System Interface
21/45
OTHER ACCESS METHOD :
EXAMPLE OF INDEX AND RELATIVE FILES
-
8/3/2019 Report Hans-Lanie File-System Interface
22/45
C. DIRECTORY STRUCTURE
A collection of nodes containing information about
all files
F 1 F 2F 3
F 4
F n
Directory
Files
Both the directory structure and the files reside on diskBackups of these two structures are kept on tapes
-
8/3/2019 Report Hans-Lanie File-System Interface
23/45
A TYPICAL FILE-SYSTEM ORGANIZATION
-
8/3/2019 Report Hans-Lanie File-System Interface
24/45
OPERATIONS PERFORMED ON DIRECTORY
Search for a file
Create a file
Delete a file
List a directory
Rename a fileTraverse the file system It is useful to be able to access every directory, and every file
within a directory structure. For reliability, it is a good idea to savethe contents and structure of the entire file system at regular
intervals.
-
8/3/2019 Report Hans-Lanie File-System Interface
25/45
ORGANIZE THE DIRECTORY (LOGICALLY) TO OBTAIN
Efficiency locating a file quicklyNaming convenient to users
Two users can have same name for differentfiles
The same file can have several differentnames
Grouping logical grouping of files by
properties, (e.g., all Java programs, allgames, )
-
8/3/2019 Report Hans-Lanie File-System Interface
26/45
C.1 SINGLE-LEVEL DIRECTORY
A single directory for all users
Naming problem
-
8/3/2019 Report Hans-Lanie File-System Interface
27/45
C.2 TWO-LEVEL DIRECTORY
Separate directory for each user
Path name
Can have the same file name for different user
Efficient searching
-
8/3/2019 Report Hans-Lanie File-System Interface
28/45
C.3 TREE-STRUCTURED DIRECTORIES
-
8/3/2019 Report Hans-Lanie File-System Interface
29/45
TREE-STRUCTURED DIRECTORIES (CONT)
Efficient searching
Grouping Capability
Current directory (working directory)cd /spell/mail/prog
type list
-
8/3/2019 Report Hans-Lanie File-System Interface
30/45
TREE-STRUCTURED DIRECTORIES (CONT)
Absolute or relative path name
Creating a new file is done in current directory
Delete a file
rm
Creating a new subdirectory is done in current
directorymkdir
Example: if in current directory /mail
mkdir count
mail
prog copy prt exp count
Deleting maildeleting the entire subtree rooted by mail
-
8/3/2019 Report Hans-Lanie File-System Interface
31/45
C.4 ACYCLIC-GRAPH DIRECTORIES
Have shared subdirectories and files
Acyclic graph is graph with no cycle
-
8/3/2019 Report Hans-Lanie File-System Interface
32/45
C.5 GENERAL GRAPH DIRECTORY
-
8/3/2019 Report Hans-Lanie File-System Interface
33/45
GENERAL GRAPH DIRECTORY (CONT.)
How do we guarantee no cycles (self-
referencing)?Allow only links to file not subdirectories.
Garbage collection (involves traversing the filesystem)Used to determine when the last reference has been deleted and
the disk space can be reallocated.
It is necessary only because of possible cycles in the graph
Every time a new link is added use a cycle
detection algorithm to determine whether it is OK
-
8/3/2019 Report Hans-Lanie File-System Interface
34/45
C.6 FILE SHARING
Sharing of files on multi-user systems is
desirable
Sharing may be done through aprotection scheme
On distributed systems, files may beshared across a network
Network File System (NFS) is a commondistributed file-sharing method
-
8/3/2019 Report Hans-Lanie File-System Interface
35/45
FILE SHARING MULTIPLE USERS
User IDs identify users, allowingpermissions and protections to be per-user
Group IDs allow users to be in groups,permitting group access rights
-
8/3/2019 Report Hans-Lanie File-System Interface
36/45
FILE SHARING REMOTE FILE SYSTEMS
Uses networking to allow file system accessbetween systems
Manually via programs like FTP
Automatically, seamlessly using distributed filesystems
Semi automatically via theworld wide web
-
8/3/2019 Report Hans-Lanie File-System Interface
37/45
FILE SHARING REMOTE FILE SYSTEMS
(CONT)
Client-server model allows clients to mount remote file
systems from servers Server can serve multiple clients
Client and user-on-client identification is insecure orcomplicated
NFS is standard UNIX client-server file sharing protocol
Standard operating system file calls are translated into remotecalls
Distributed Information Systems (distributed naming services)such as LDAP, DNS, NIS, Active Directory implementunified access to information needed for remote
computing
-
8/3/2019 Report Hans-Lanie File-System Interface
38/45
FILE SHARING FAILURE MODES
Remote file systems add new failure modes,due to network failure, server failure
Recovery from failure can involve stateinformation about status of each remote
request
Stateless protocols such as NFS include allinformation in each request, allowing easy
recovery but less security
-
8/3/2019 Report Hans-Lanie File-System Interface
39/45
D. PROTECTION
When information is kept in a computer
system, a major concern is itsprotection from both physicaldamage (reliability) and improper
access (protection).File owner/creator should be able to
control:
what can be doneby whom
-
8/3/2019 Report Hans-Lanie File-System Interface
40/45
PROTECTION (CONT)
Types of accessRead. Read from the file.
Write. Write or rewrite the file.
Execute. Load the file into the memory and execute.
Append. Write new information at the end of the file.
Delete. Erase the file and free its space for possiblereuse.
List. Display the name and attributes of the file.
-
8/3/2019 Report Hans-Lanie File-System Interface
41/45
D.1 ACCESS LISTS AND GROUPS
Mode of access: read, write, execute
Three classes of usersRWX
a) owner access 7 1 1 1RWX
b) group access 6 1 1 0RWX
c) public access 1 0 0 1Ask 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 public
chmod 761 game
Attach a group to a filechgrp G game
-
8/3/2019 Report Hans-Lanie File-System Interface
42/45
D.2 OTHER PROTECTION APPROACHAnother protection approach is the association of
Passwordin a file.
If the passwords are chosen randomly and changedoften, this scheme may be effective in limiting accessto a file to only those users who know the password.But, if we associate a separate password with each file,the number of passwords that a user needs to
remember may become large, making the schemeimpractical.
If one password is used for all the files, then, once it isdiscovered, all files are accessible.
Some systems (for example, TOP-20) allow a user to
associate a password with a subdirectory, rather thanwith an individual file, to deal with this problem.
-MANAGEMENT
-
8/3/2019 Report Hans-Lanie File-System Interface
43/45
MANAGEMENT
-
8/3/2019 Report Hans-Lanie File-System Interface
44/45
A SAMPLE UNIX DIRECTORY LISTING
Status/protn #L CN GN FS DC FN
-
8/3/2019 Report Hans-Lanie File-System Interface
45/45
THANKS FOR LISTENING
Have a nice day to all