file system interface

52
File System File System Interface Interface Rahul Ajit Rahul Ajit Khin Zayar Htay Khin Zayar Htay

Upload: amelie

Post on 20-Mar-2016

62 views

Category:

Documents


3 download

DESCRIPTION

File System Interface. Rahul Ajit Khin Zayar Htay. File Concept. Files are logical storage units mapped on to physical secondary storage, usually nonvolatile such as magnetic disks, magnetic tapes and optical disks. Types: Data Numeric, alphabetic, alphanumeric, or binary Program - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: File System Interface

File System InterfaceFile System Interface

Rahul AjitRahul AjitKhin Zayar HtayKhin Zayar Htay

Page 2: File System Interface

File ConceptFile Concept Files are logical storage units mapped on to Files are logical storage units mapped on to

physical secondary storage, usually nonvolatile physical secondary storage, usually nonvolatile such as magnetic disks, magnetic tapes and such as magnetic disks, magnetic tapes and optical disks.optical disks.

Types:Types:DataData

Numeric, alphabetic, alphanumeric, or binaryNumeric, alphabetic, alphanumeric, or binaryProgramProgram

Source and object formsSource and object forms

Page 3: File System Interface

File AttributesFile Attributes Name - Only information kept in human-Name - Only information kept in human-

readable form.readable form. Identifier – Unique tag, usually a number Identifier – Unique tag, usually a number

that identifies the file within the file that identifies the file within the file system.system.

Type – Needed for systems that support Type – Needed for systems that support different types.different types.

Location – Pointer to file location on Location – Pointer to file location on device.device.

Page 4: File System Interface

File Attributes (Cont’d)File Attributes (Cont’d) Size – Current file size.Size – Current file size. Protection – Access-control who can write, Protection – Access-control who can write,

read, execute and so on.read, execute and so on. Time, date and user identification – Data Time, date and user identification – Data

for protection, security and usage for protection, security and usage monitoring.monitoring.

Volatility – Frequency with which additions Volatility – Frequency with which additions and deletions are made to the file.and deletions are made to the file.

Page 5: File System Interface

File OperationsFile Operations A file is an abstract data type. To define a A file is an abstract data type. To define a

file, we need to consider the operations file, we need to consider the operations that can be performed on the file.that can be performed on the file.

Creating a file - Allocate space for the file, Creating a file - Allocate space for the file, entry for the file in the directory.entry for the file in the directory.

Writing a file - Make a system call Writing a file - Make a system call specifying both the name of the file and specifying both the name of the file and the information to be written to the file. the information to be written to the file. System keeps a write pointer.System keeps a write pointer.

Page 6: File System Interface

File Operations (Cont’d)File Operations (Cont’d) Reading a file - Make a system call Reading a file - Make a system call

specifying both the name of the file and specifying both the name of the file and where the next block of file should be put. where the next block of file should be put. System keeps a read pointer.System keeps a read pointer.

Repositioning within a file – Also known as Repositioning within a file – Also known as file seek. The directory is searched for the file seek. The directory is searched for the appropriate entry, and the current file-appropriate entry, and the current file-position-pointer is repositioned to a given position-pointer is repositioned to a given value.value.

Page 7: File System Interface

File Operations (Cont’d)File Operations (Cont’d) Deleting a file – Release all file space and erase Deleting a file – Release all file space and erase

the directory entry.the directory entry. Truncating a file – Deletes contents and resets Truncating a file – Deletes contents and resets

length to 0 but directory entry and all file length to 0 but directory entry and all file attributes except file length remains attributes except file length remains unchanged.unchanged.

Opening/closing a file - When a file operation is Opening/closing a file - When a file operation is requested, the file is specified via an index into requested, the file is specified via an index into open-file table usually after an open() system open-file table usually after an open() system call. call.

Page 8: File System Interface

File Operations (Cont’d)File Operations (Cont’d) Information associated with open fileInformation associated with open file

File pointer - If no file offset in File pointer - If no file offset in read()/write() system calls are included.read()/write() system calls are included.

File-open count - The number of processes File-open count - The number of processes have opened the file. When the count have opened the file. When the count reaches 0 the entry is deleted from open-reaches 0 the entry is deleted from open-file table.file table.

Disk location of the fileDisk location of the fileAccess rights - Per process access mode Access rights - Per process access mode

information.information.

Page 9: File System Interface

File LocksFile Locks File locks allow one process to lock a file File locks allow one process to lock a file

and prevent other processes from gaining and prevent other processes from gaining access to it.access to it.

Mandatory file locks - Once a process Mandatory file locks - Once a process acquires an exclusive lock, the operating acquires an exclusive lock, the operating system will prevent any other process system will prevent any other process from accessing the locked file.from accessing the locked file.

Advisory file locks – Is up to software Advisory file locks – Is up to software developers to ensure that locks are developers to ensure that locks are appropriately acquired and released.appropriately acquired and released.

Page 10: File System Interface

Common file typesCommon file types

Page 11: File System Interface

File StructureFile Structure None – Sequence of words, bytes.None – Sequence of words, bytes. Simple record structure – Lines, fixed Simple record structure – Lines, fixed

length, variable length.length, variable length. Complex structures – Formatted Complex structures – Formatted

document, Relocatable load file.document, Relocatable load file. Can simulate last two with first method by Can simulate last two with first method by

inserting appropriate control characters. inserting appropriate control characters. Operating system or program can Operating system or program can establish file structure.establish file structure.

Page 12: File System Interface

File Structure (Cont’d)File Structure (Cont’d) File type may indicate internal structure of File type may indicate internal structure of

file (e.g., source or object).file (e.g., source or object). IBM mainframe systems, for example, IBM mainframe systems, for example,

support a very wide range of access support a very wide range of access methods.methods.

UNIX, MS-DOS, others, support only a UNIX, MS-DOS, others, support only a minimal number of file structures. (UNIX minimal number of file structures. (UNIX files are sequence of 8-bit bytes)files are sequence of 8-bit bytes)

Page 13: File System Interface

File Structure (Cont’d)File Structure (Cont’d) Macintosh resource fork and data fork.Macintosh resource fork and data fork. The logical record size, physical block size, The logical record size, physical block size,

and packing technique determine how and packing technique determine how many logical records are in each physical many logical records are in each physical block. The packing can be done either by block. The packing can be done either by the user's application program or by the the user's application program or by the operating system.operating system.

Page 14: File System Interface

Access MethodsAccess Methods Sequential access – Information in the file Sequential access – Information in the file

is processed in order, one record after the is processed in order, one record after the other.other.read nextread nextWrite nextWrite nextReset or skip nReset or skip n

Page 15: File System Interface

Access Methods (Cont’d)Access Methods (Cont’d) Direct access – Or relative access is based Direct access – Or relative access is based

on a disk model of a file, since disks allow on a disk model of a file, since disks allow random access to any file block.random access to any file block.Read n, write nRead n, write nRead next, write next, position file to n Read next, write next, position file to n

where n is the relative block number.where n is the relative block number.

Page 16: File System Interface

Access Methods (Cont’d)Access Methods (Cont’d) Other access methods – Index and relative Other access methods – Index and relative

files.files.

Page 17: File System Interface

Directory StructureDirectory Structure Storage structure – A collection of nodes Storage structure – A collection of nodes

containing information of all files. Resides containing information of all files. Resides on disk, along with the files.on disk, along with the files.

Page 18: File System Interface

Directory OperationsDirectory Operations Search for a file.Search for a file. Create a file.Create a file. Delete a file.Delete a file. List a directory.List a directory. Rename a file.Rename a file. Traverse the file system usually for back Traverse the file system usually for back

up purposes.up purposes.

Page 19: File System Interface

Single-Level DirectorySingle-Level Directory All files are contained in the same All files are contained in the same

directory. Simple to support and use. But directory. Simple to support and use. But difficult when the number of files increase difficult when the number of files increase and system has more than one user.and system has more than one user.

Page 20: File System Interface

Two-Level DirectoryTwo-Level Directory Each user has own user file directory Each user has own user file directory

(UFD).(UFD). Master file directory (MFD) holds pointers Master file directory (MFD) holds pointers

to UFDs.to UFDs. Disadvantage: Isolation.Disadvantage: Isolation.

Page 21: File System Interface

Tree-Structured DirectoryTree-Structured Directory Natural generalization of two-level Natural generalization of two-level

directories. Contains a set of files and sub-directories. Contains a set of files and sub-directories with the same internal format.directories with the same internal format.

The current directory should contain most The current directory should contain most of the files that are of current interest to of the files that are of current interest to the process.the process.

Special system calls are used to create Special system calls are used to create and delete directories. To change and delete directories. To change directories a system call that takes a directories a system call that takes a directory name as a parameter and uses it directory name as a parameter and uses it to redefine current directory.to redefine current directory.

Efficient searching and group capability.Efficient searching and group capability.

Page 22: File System Interface

Tree-Structured Directory (Cont’d)Tree-Structured Directory (Cont’d)

Page 23: File System Interface

Acyclic-Graph DirectoryAcyclic-Graph Directory A graph with no cycles, allows directories A graph with no cycles, allows directories

to share subdirectories and files.to share subdirectories and files.

Page 24: File System Interface

Acyclic-Graph Directory (Cont’d)Acyclic-Graph Directory (Cont’d) One way of implementation is by creating One way of implementation is by creating

a new directory called link, which is a a new directory called link, which is a pointer to another file or sub directory.pointer to another file or sub directory.

An alternative approach is to duplicate all An alternative approach is to duplicate all information in both sharing directories.information in both sharing directories.

Deleting a file could involve the approach Deleting a file could involve the approach of leaving the links dangling or the of leaving the links dangling or the approach where file is preserved until all approach where file is preserved until all references to it are deleted.references to it are deleted.

Page 25: File System Interface

General Graph DirectoryGeneral Graph Directory We have to guarantee no cycles are We have to guarantee no cycles are

formed by making sure thatformed by making sure thatWe allow only links to files and not sub We allow only links to files and not sub

directoriesdirectoriesGarbage collectionGarbage collectionEvery time a new link is added use a Every time a new link is added use a

cycle detection algorithm to determine if cycle detection algorithm to determine if it is okay.it is okay.

Page 26: File System Interface

General Graph Directory (Cont’d)General Graph Directory (Cont’d)

Page 27: File System Interface

File-System Mounting File-System Mounting The process of incorporating a file The process of incorporating a file

system into the existing directory system into the existing directory structure.structure.

A file system must be mounted A file system must be mounted before it can be accessible to system before it can be accessible to system processes.processes.

A file system is mounted at A file system is mounted at mount mount point point (empty directory).(empty directory).mount -t iso9660 mount -t iso9660 /dev/hdc/dev/hdc /cdrom /cdrom

Page 28: File System Interface

File-System Mounting (Cont’d)File-System Mounting (Cont’d) Mounting Process, OS Mounting Process, OS

Name of deviceName of deviceMount pointMount pointFile system type File system type Verify device contains valid file system.Verify device contains valid file system.File system is mounted at specified File system is mounted at specified

mount point.mount point.

Page 29: File System Interface

File-System Mounting (Cont’d)File-System Mounting (Cont’d) UnixUnix Mount /dev/dsk/c1t4d0s0 under Solaris Mount /dev/dsk/c1t4d0s0 under Solaris

UNIX at /data2, enter:UNIX at /data2, enter:mkdirmkdir /data2 /data2 mountmount /dev/dsk/c1t4d0s0 /data2 /dev/dsk/c1t4d0s0 /data2

To remove mount point run:To remove mount point run:umountumount /data2 /data2

Page 30: File System Interface

File-System Mounting (Cont’d)File-System Mounting (Cont’d)

Page 31: File System Interface

File-System Mounting (Cont’d)File-System Mounting (Cont’d) System impose semantics to clarify System impose semantics to clarify

functionality. System mayfunctionality. System mayDisallow a mount over a directory that Disallow a mount over a directory that

contain filescontain filesA mount over that directory and A mount over that directory and

directory’s existing files are hidden and directory’s existing files are hidden and inaccessibleinaccessible

Allow same file system to be mounted Allow same file system to be mounted repeatedly at different mount pointsrepeatedly at different mount points

Allow one mount per file systemAllow one mount per file system

Page 32: File System Interface

File-System Mounting (Cont’d)File-System Mounting (Cont’d) Mac OSMac OS

Page 33: File System Interface

File-System Mounting (Cont’d)File-System Mounting (Cont’d) Windows OSWindows OS

Page 34: File System Interface

File SharingFile Sharing Sharing of file among users and systems is Sharing of file among users and systems is

desirable.desirable. File Sharing through removable media, File Sharing through removable media,

computer network, Web and etccomputer network, Web and etc File Sharing through protection such as File Sharing through protection such as

access controlaccess control

Page 35: File System Interface

File Sharing : Multiple UsersFile Sharing : Multiple Users Owner, who can change attributes and Owner, who can change attributes and

grant access and have most control over grant access and have most control over the filesthe files

Group, who can share access to the files or Group, who can share access to the files or execute one subset of file operationsexecute one subset of file operations

User ID identifies user and permitting User ID identifies user and permitting requested operations on filesrequested operations on files

Group ID allows user to be in a group and Group ID allows user to be in a group and permitting group access rightpermitting group access right

Page 36: File System Interface

File Sharing : Remote File SystemsFile Sharing : Remote File Systems Network communication among remote Network communication among remote

computes now become possiblecomputes now become possible Networking allows sharing of file system Networking allows sharing of file system

among different systemsamong different systemsFTP: manually transferring files between FTP: manually transferring files between

hostshostsDFS: accessing files from multiple hosts DFS: accessing files from multiple hosts

via network via network WWW: A browser gains access to the WWW: A browser gains access to the

remote files and separate operations for remote files and separate operations for file transfer.file transfer.

Page 37: File System Interface

File Sharing : Remote File Systems (Cont’d)File Sharing : Remote File Systems (Cont’d)

Client-Server model allows client to mount Client-Server model allows client to mount one or more file systems from serversone or more file systems from serversA server can serve multiple clients.A server can serve multiple clients.A client can access multiple servers.A client can access multiple servers.Client identification is complex and Client identification is complex and

unsecure authentication methods are most unsecure authentication methods are most commonly usedcommonly used

UNIX and its NFS, authentication takes place UNIX and its NFS, authentication takes place via client network information by defaultvia client network information by default

NFS is Unix File Sharing ProtocolNFS is Unix File Sharing ProtocolCIFS and SMB are Window File Sharing CIFS and SMB are Window File Sharing

ProtocolsProtocols

Page 38: File System Interface

File Sharing : Remote File Systems (Cont’d)File Sharing : Remote File Systems (Cont’d)

Client-Server model file sharingClient-Server model file sharingOnce remote file system is mounted, Once remote file system is mounted,

client sends file operation requests to client sends file operation requests to server via DFSserver via DFS

Server applies standard access checks Server applies standard access checks to see if user has credentials to access to see if user has credentials to access the file in the mode requestedthe file in the mode requested

The request is either grant or denyThe request is either grant or denyIf access is granted, client performs If access is granted, client performs

requested operationsrequested operationsClient closes the fileClient closes the file

Page 39: File System Interface

File Sharing : Remote File Systems (Cont’d)File Sharing : Remote File Systems (Cont’d)

Distributed Information Systems provide unified Distributed Information Systems provide unified access to the information needed for remote access to the information needed for remote computingcomputingDNS provides host-name-to-network-address DNS provides host-name-to-network-address

translation for internettranslation for internetSome DIS provides user name, password, user ID Some DIS provides user name, password, user ID

and group ID for distributed facilityand group ID for distributed facilityUNIX employs a variety of distributed-information UNIX employs a variety of distributed-information

methods.methods.Sun Microsystems introduced NIS and NIS+Sun Microsystems introduced NIS and NIS+Microsoft CIFS, network information is used with Microsoft CIFS, network information is used with

user authentication for network login user authentication for network login Microsoft uses domain and active directory naming Microsoft uses domain and active directory naming

technology for distributed naming structures.technology for distributed naming structures.Lightweight directory-access protocol (LDAP)Lightweight directory-access protocol (LDAP)

Page 40: File System Interface

File Sharing : Failure ModesFile Sharing : Failure Modes Local file system can fail for a variety of Local file system can fail for a variety of

reasonsreasonsDisk failure, Directory structure or Disk-Disk failure, Directory structure or Disk-

management information corruption, Disk-management information corruption, Disk-controller failure, cable failure, user or controller failure, cable failure, user or system administrator failure and etcsystem administrator failure and etc

Remote file system have more failure Remote file system have more failure modes.modes.Network interruption and etcNetwork interruption and etc

Recover from failure involves some kind of Recover from failure involves some kind of state information about remote requeststate information about remote request

NFS, which employs DFS statelessNFS, which employs DFS stateless NFS version 4 is statefulNFS version 4 is stateful

Page 41: File System Interface

File Sharing : Consistency SemanticsFile Sharing : Consistency Semantics

An important criterionAn important criterion How modifications of data by one user will How modifications of data by one user will

be observable by other usersbe observable by other users Andrew file system implemented complex Andrew file system implemented complex

sharing semantics.sharing semantics.

Page 42: File System Interface

File Sharing : Consistency Semantics (Cont’d)File Sharing : Consistency Semantics (Cont’d) UNIX SemanticsUNIX Semantics

Writes to an open file by a user are visible Writes to an open file by a user are visible immediately to other users who have this file openimmediately to other users who have this file open

Supports a mode of sharing where users share Supports a mode of sharing where users share pointer of current location into the filepointer of current location into the file

Session Semantics (eg. AFS)Session Semantics (eg. AFS)Writes to an open file by a user are not visible Writes to an open file by a user are not visible

immediately to other users who have this file openimmediately to other users who have this file openOnce a file is closed, the changes are visible only in Once a file is closed, the changes are visible only in

sessions starting later. Already open file instances sessions starting later. Already open file instances doe not reflect changes.doe not reflect changes.

Page 43: File System Interface

File Sharing : Consistency Semantics (Cont’d)File Sharing : Consistency Semantics (Cont’d)

Immutable-Shared-Files SemanticsImmutable-Shared-Files SemanticsOnce a file is declared as shared by its Once a file is declared as shared by its

creator, it cannot be modified.creator, it cannot be modified.Two properties: name and content are Two properties: name and content are

immutableimmutableSimple implementation as read-only Simple implementation as read-only

sharingsharing

Page 44: File System Interface

ProtectionProtection Keep information stored in system safe Keep information stored in system safe

from physical damage and improper or from physical damage and improper or unauthorized accessunauthorized access

Protect files by limiting types of access to Protect files by limiting types of access to files and by whomfiles and by whom

Page 45: File System Interface

Protection : Access TypesProtection : Access Types Types of AccessTypes of Access

ReadReadWriteWriteExecuteExecuteAppendAppendDeleteDeleteListList

Page 46: File System Interface

Protection : Access ControlProtection : Access Control Common approach is granting access based on Common approach is granting access based on

the identity of userthe identity of user Access-Control ListAccess-Control List

Specify user names and type of access allowed for Specify user names and type of access allowed for each usereach user

Associate access-control list with each fileAssociate access-control list with each fileMaintenance problems as its length and unknown Maintenance problems as its length and unknown

size of system users size of system users The variable size directory entry, resulting in more The variable size directory entry, resulting in more

complicated space management.complicated space management.

Page 47: File System Interface

Protection : Access Control (Cont’d)Protection : Access Control (Cont’d)

Categories of accessCategories of accessOwnerOwnerGroupGroupUniverseUniverseMaintenance of groups in the system are Maintenance of groups in the system are

not connected with the specific file or not connected with the specific file or directorydirectory

Each file has owner and group associated Each file has owner and group associated with it. Permissions are specified to each of with it. Permissions are specified to each of themthem

Page 48: File System Interface

Protection : Access Control (Cont’d)Protection : Access Control (Cont’d)

Permission and access control lists must Permission and access control lists must be controlled tightlybe controlled tightly

Examples in Unix System Examples in Unix System File name: book, chapter1File name: book, chapter1Group name: text, ownerGroup name: text, ownerUser name: visitor not in groupsUser name: visitor not in groups-rwxrw-r-- 2 Sara text 2048 Sep 30 -rwxrw-r-- 2 Sara text 2048 Sep 30

2010 book 2010 book Chmod text-w bookChmod text-w booksetfacl -m u:visitor:rx / chapter1setfacl -m u:visitor:rx / chapter1

Page 49: File System Interface

Protection : Access Control (Cont’d)Protection : Access Control (Cont’d)

WindowsWindows

Page 50: File System Interface

Protection : OthersProtection : Others PasswordsPasswords

Associating a password with each file Associating a password with each file IssuesIssues

Large number of passwords to rememberLarge number of passwords to remember One password for all files is used, One password for all files is used,

protection is on all-or-none basisprotection is on all-or-none basisSome system allow user to associate a Some system allow user to associate a

password with subdirectory rather than password with subdirectory rather than individual file.individual file.

MS-DOS and early version of Mac OS provide MS-DOS and early version of Mac OS provide little in term of file protection.little in term of file protection.

Page 51: File System Interface

ReferencesReferences Operating System Concepts 8Operating System Concepts 8thth Edition by Edition by

ABRAHAM SILBERSCHATZ, PETER BAER GALVIN and GREG GAGNE

http://arstechnica.com/apple/reviews/1999/12/http://arstechnica.com/apple/reviews/1999/12/macos-x-dp2.ars/6macos-x-dp2.ars/6

http://www.dartmouth.edu/~rc/help/faq/http://www.dartmouth.edu/~rc/help/faq/permissions.htmlpermissions.html

http://www-rohan.sdsu.edu/doc/debian/ch-disks.html

http://catcode.com/teachmod/index.html http://www.softpanorama.org/Access_control/http://www.softpanorama.org/Access_control/

acl.shtmlacl.shtml

Page 52: File System Interface

Thank youThank you