1 A Typical File-system Organization. 2 Directories Record information about groups of files...
-
Upload
elwin-greer -
Category
Documents
-
view
213 -
download
0
Transcript of 1 A Typical File-system Organization. 2 Directories Record information about groups of files...
1
A Typical File-system OrganizationA Typical File-system Organization
2
DirectoriesDirectories
Record information about groups of filesRecord information about groups of files
Management of filesManagement of files
Single-Level directory: most simple; all files in the same directorySingle-Level directory: most simple; all files in the same directory
Two-Level directory: separate directory for each userTwo-Level directory: separate directory for each user
Tree-Structured (hierarchical) directories: most commonTree-Structured (hierarchical) directories: most common
Operations on directories:Operations on directories:
Search for a file Search for a file
Create a file (directory entry) Create a file (directory entry)
Delete a file (directory entry) Delete a file (directory entry)
List a directory List a directory
Rename a file Rename a file
Traverse the file system (recursive) Traverse the file system (recursive)
3
Single-Level DirectorySingle-Level Directory
A single directory for all usersA single directory for all users
Naming problem
Grouping problem
4
Two-Level DirectoryTwo-Level Directory
Separate directory for each userSeparate directory for each user
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
5
Tree-Structured DirectoriesTree-Structured Directories
6
Directory StructureDirectory Structure
A collection of nodes containing information about all filesA 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
7
Operations Performed on DirectoryOperations Performed on Directory
Search for a fileSearch for a file
Create a fileCreate a file
Delete a fileDelete a file
List a directoryList a directory
Rename a fileRename a file
Traverse the file systemTraverse the file system
8
Organize the Directory (Logically) to Organize the Directory (Logically) to ObtainObtain
Efficiency – locating a file quicklyEfficiency – locating a file quickly
Naming – convenient to usersNaming – convenient to users
Two users can have same name for different Two users can have same name for different filesfiles
The same file can have several different The same file can have several different namesnames
Grouping – logical grouping of files by Grouping – logical grouping of files by properties, (e.g., all Java programs, all properties, (e.g., all Java programs, all games, …)games, …)
9
Tree-Structured Directories (Cont)Tree-Structured Directories (Cont)
Efficient searchingEfficient searching
Grouping CapabilityGrouping Capability
Current directory (working directory)Current directory (working directory)
cd /spell/mail/progcd /spell/mail/prog
type listtype list
10
Tree-Structured Directories (Cont)Tree-Structured Directories (Cont)AbsoluteAbsolute or or relativerelative path name path name
Creating a new file is done in current directoryCreating a new file is done in current directory
Delete a fileDelete a file
rm <file-name>rm <file-name>
Creating a new subdirectory is done in current directoryCreating a new subdirectory is done in current directory
mkdir <dir-name>mkdir <dir-name>
Example: if in current directory Example: if in current directory /mail/mail
mkdir countmkdir countmail
prog copy prt exp count
Deleting “mail” deleting the entire subtree rooted by “mail”
11
Acyclic-Graph DirectoriesAcyclic-Graph Directories
Have shared subdirectories and filesHave shared subdirectories and files
12
Acyclic-Graph Directories (Cont.)Acyclic-Graph Directories (Cont.)Two different names (aliasing)Two different names (aliasing)
If If dictdict deletes deletes listlist dangling pointer dangling pointer
Solutions:Solutions:
Backpointers, so we can delete all pointersBackpointers, so we can delete all pointersVariable size records a problemVariable size records a problem
Backpointers using a daisy chain organizationBackpointers using a daisy chain organization
Entry-hold-count solutionEntry-hold-count solution
New directory entry typeNew directory entry type
LinkLink – another name (pointer) to an existing file – another name (pointer) to an existing file
Resolve the linkResolve the link – follow pointer to locate the file – follow pointer to locate the file
13
General Graph DirectoryGeneral Graph Directory
14
General Graph Directory (Cont.)General Graph Directory (Cont.)
How do we guarantee no cycles?How do we guarantee no cycles?
Allow only links to file not subdirectoriesAllow only links to file not subdirectories
Garbage collectionGarbage collection
Every time a new link is added use a cycle Every time a new link is added use a cycle detectiondetectionalgorithm to determine whether it is OKalgorithm to determine whether it is OK
15
UNIX DirectoriesUNIX DirectoriesFully hierarchical, tree-structuredFully hierarchical, tree-structured
Directories are represented as files Directories are represented as files
Problem: Truncation Problem: Truncation
Processes have a current working directory Processes have a current working directory
pwd commandpwd command
Each user has a home directory Each user has a home directory
cd; echo $HOME – commands to obtain info about the home dir.cd; echo $HOME – commands to obtain info about the home dir.
The file system has a single root directory The file system has a single root directory
cd / - command changes working directory to root directorycd / - command changes working directory to root directory
Special names identify neighbors in the directory treeSpecial names identify neighbors in the directory tree
./ - the current directory./ - the current directory
../ - the directory one level above the current directory../ - the directory one level above the current directory
16
Linking Names and File ContentLinking Names and File Content
UNIX separates file names and UNIX separates file names and file contentfile content
file content may have file content may have multiple (different) namesmultiple (different) names
ln command associates new ln command associates new name with existing file name with existing file
File content identified by:File content identified by:
(Device, File system on (Device, File system on device, i-node)device, i-node)
i-node contains references to i-node contains references to all blocks making up a fileall blocks making up a file
a free-node list is maintained a free-node list is maintained for each file systemfor each file system
Information contained in a UNIX i-node
17
File File ProtectionProtection
Access rights can be independently defined for:Access rights can be independently defined for:
(u) user (u) user – Owner (creator) of a file – Owner (creator) of a file
(g) group (g) group – Group– Group
(o) other (o) other – all other users of the UNIX system – all other users of the UNIX system
Example:Example:
luna test ( 48 )-% ls -lisaluna test ( 48 )-% ls -lisa
total 2total 2
421908 1 drwxr-xr-x 421908 1 drwxr-xr-x 2 2 apolze 1024 apolze 1024 Jan 7 15:06 .Jan 7 15:06 .
116884 1 drwxr-xr-x 116884 1 drwxr-xr-x 13 13 apolze 2048 apolze 2048 Jan 7 15:06 ..Jan 7 15:06 ..
116992 0 -rw------- 116992 0 -rw------- 1 1 apolze apolze 0 0 Jan 7 15:05 Mail.txtJan 7 15:05 Mail.txt
116991 0 -rw-rw-rw- 116991 0 -rw-rw-rw- 1 1 apolze 0 apolze 0 Jan 7 15:05 test.cJan 7 15:05 test.c
18
File ProtectionFile Protection (contd.)(contd.)
Access rights for a file:Access rights for a file:
(r) (r) Read access right; List right for directorisyRead access right; List right for directorisy
(w) (w) Write access right; includes delete/append rights Write access right; includes delete/append rights
(x) (x) Execute access right; Traverse right for directoriesExecute access right; Traverse right for directories
Binary representation:Binary representation:
(x): (x): Bit 0 (+1) Bit 0 (+1)
(w): (w): Bit 1 (+2) Bit 1 (+2)
(r): (r): Bit 2 (+4) Bit 2 (+4)
Rights can be combinedRights can be combined
Read+Write access right: 6 Read+Write access right: 6
Read+Execute access right: 3 Read+Execute access right: 3
Read-only: 2 Read-only: 2
19
ProtectionProtectionFile owner/creator should be able to control:File owner/creator should be able to control:
what can be donewhat can be done
by whomby whom
Types of accessTypes of access
ReadRead
WriteWrite
ExecuteExecute
AppendAppend
DeleteDelete
ListList
20
Access Lists and GroupsAccess Lists and Groups
Mode of access: read, write, executeMode of access: read, write, execute
Three classes of usersThree classes of users
RWXRWX
a) a) owner accessowner access 77 1 1 11 1 1RWXRWX
b) b) group accessgroup access 66 1 1 01 1 0
RWXRWX
c) c) public accesspublic access 11 0 0 10 0 1
Ask manager to create a group (unique name), say G, and add Ask manager to create a group (unique name), say G, and add some users to the group.some users to the group.
For a particular file (say For a particular file (say gamegame) or subdirectory, define an ) or subdirectory, define an appropriate access.appropriate access.
owner group public
chmod 761 game
Attach a group to a file chgrp G game
21
Windows XP Access-control List Windows XP Access-control List ManagementManagement
22
A Sample UNIX Directory ListingA Sample UNIX Directory Listing
23
File SharingFile Sharing
Sharing of files on multi-user systems is desirableSharing of files on multi-user systems is desirable
Sharing may be done through a Sharing may be done through a protectionprotection schemescheme
On distributed systems, files may be shared On distributed systems, files may be shared across a networkacross a network
Network File System (NFS) is a common Network File System (NFS) is a common distributed file-sharing methoddistributed file-sharing method
24
File Sharing – Multiple UsersFile Sharing – Multiple Users
User IDsUser IDs identify users, allowing identify users, allowing permissions and protections to be per-userpermissions and protections to be per-user
Group IDsGroup IDs allow users to be in groups, allow users to be in groups, permitting group access rightspermitting group access rights
25
File Sharing – Remote File File Sharing – Remote File SystemsSystems
Uses networking to allow file system access between systemsUses networking to allow file system access between systems
Manually via programs like FTPManually via programs like FTP
Automatically, seamlessly using Automatically, seamlessly using distributed file systemsdistributed file systems
Semi automatically via theSemi automatically via the world wide webworld wide web
Client-serverClient-server model allows clients to mount remote file systems model allows clients to mount remote file systems from serversfrom servers
Server can serve multiple clientsServer can serve multiple clients
Client and user-on-client identification is insecure or complicatedClient and user-on-client identification is insecure or complicated
NFSNFS is standard UNIX client-server file sharing protocol is standard UNIX client-server file sharing protocol
CIFSCIFS is standard Windows protocol is standard Windows protocol
Standard operating system file calls are translated into remote callsStandard operating system file calls are translated into remote calls
Distributed Information Systems Distributed Information Systems (distributed naming services)(distributed naming services) such as LDAP, DNS, NIS, Active Directory implement unified such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computingaccess to information needed for remote computing
26
File Sharing – Failure ModesFile Sharing – Failure Modes
Remote file systems add new failure Remote file systems add new failure modes, due to network failure, server modes, due to network failure, server failurefailure
Recovery from failure can involve state Recovery from failure can involve state information about status of each remote information about status of each remote requestrequest
Stateless protocols such as NFS Stateless protocols such as NFS include all information in each request, include all information in each request, allowing easy recovery but less securityallowing easy recovery but less security
27
File Sharing – Consistency File Sharing – Consistency SemanticsSemantics
Consistency semanticsConsistency semantics specify how multiple users are to specify how multiple users are to access a shared file simultaneouslyaccess a shared file simultaneously
Similar to process synchronization algorithmsSimilar to process synchronization algorithms
Tend to be less complex due to disk I/O and network latency (for Tend to be less complex due to disk I/O and network latency (for remote file systemsremote file systems
Andrew File System (AFS) implemented complex remote file Andrew File System (AFS) implemented complex remote file sharing semanticssharing semantics
Unix file system (UFS) implements:Unix file system (UFS) implements:
Writes to an open file visible immediately to other users of the same Writes to an open file visible immediately to other users of the same open fileopen file
Sharing file pointer to allow multiple users to read and write Sharing file pointer to allow multiple users to read and write concurrentlyconcurrently
AFS has session semanticsAFS has session semantics
Writes only visible to sessions starting after the file is closedWrites only visible to sessions starting after the file is closed
28
Distribution – Network File SystemsDistribution – Network File Systems
Various approaches towards distributed file systems:Various approaches towards distributed file systems:
SUN Network File System (Standard) SUN Network File System (Standard)
UNIX United UNIX United
Andrew FileAndrew File S System ystem
Sprite Sprite
Locus Locus
SUN NFSSUN NFS
Client/Server-System (based on remote procedure call (RPC))Client/Server-System (based on remote procedure call (RPC))
File system operations are forwarded from client to server File system operations are forwarded from client to server
Server executes actual file system operations, returns results Server executes actual file system operations, returns results
Client has access to remote resourcesClient has access to remote resources
Stateless operation (Reliability !)Stateless operation (Reliability !)
29
Operation of a Network File SystemOperation of a Network File System
A set of operations is implemented as RPC-callable functions:A set of operations is implemented as RPC-callable functions:
Searching for a file in a directory Searching for a file in a directory
Reading a set of directory entries Reading a set of directory entries
Manipulating links and directories Manipulating links and directories
Accessing file attributes Accessing file attributes
Reading and writing files Reading and writing files
Logical connection between client and server has to be establishedLogical connection between client and server has to be established
mount protocolmount protocol
NFS works in heterogeneous environmentsNFS works in heterogeneous environments
Machine-independent protocol for data representation (XDR) Machine-independent protocol for data representation (XDR)
Stateless protocolStateless protocol
Network file system may tolerate client crashes (reboots)Network file system may tolerate client crashes (reboots)
30
Mounting a Remote File SystemMounting a Remote File System
Computer "sun" exports the "/local"-file system to computer "moon" Computer "sun" exports the "/local"-file system to computer "moon"
Exported to moonExported to all computers on the net
31
Windows – UNIX File System Windows – UNIX File System InteroperabilityInteroperability
Windows uses per default the Server Message Block (SMB) Windows uses per default the Server Message Block (SMB) protocol to implement distributed file systemsprotocol to implement distributed file systems
SMB/CIFS (remote) resource sharing:SMB/CIFS (remote) resource sharing:
Samba – de.samba.orgSamba – de.samba.org
POSIX libraries/tool chains for Windows API:POSIX libraries/tool chains for Windows API:
Cygwin – sources.redhat.com/cygwin/Cygwin – sources.redhat.com/cygwin/
U/WIN – www. research.att.com/sw/tools/uwin/U/WIN – www. research.att.com/sw/tools/uwin/
NuTCracker / MKS Toolkit – www.datafocus.comNuTCracker / MKS Toolkit – www.datafocus.com
Interix, SFU – www.microsoft.com/windowsserversystem/sfu/Interix, SFU – www.microsoft.com/windowsserversystem/sfu/
32
What's Samba all What's Samba all about?about?
Free SMB and CIFS client/server for UNIX & other Free SMB and CIFS client/server for UNIX & other OSOS
Functionality:Functionality:
a SMB server, to provide Windows NT and LAN a SMB server, to provide Windows NT and LAN Manager-style file and print services to SMB clients Manager-style file and print services to SMB clients such as Windows, Warp Server, smbfs and others.such as Windows, Warp Server, smbfs and others.
a NetBIOS (rfc1001/1002) nameserver, which amongst a NetBIOS (rfc1001/1002) nameserver, which amongst other things gives browsing support. Samba can be the other things gives browsing support. Samba can be the master browser on your LAN if you wish. master browser on your LAN if you wish.
a ftp-like SMB client so you can access PC resources a ftp-like SMB client so you can access PC resources (disks and printers) from UNIX, Netware and other (disks and printers) from UNIX, Netware and other operating systemsoperating systems