1 / 52

File System Interface

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

amelie
Download Presentation

File System Interface

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. File System Interface Rahul Ajit Khin Zayar Htay

  2. 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 Source and object forms

  3. File Attributes Name - Only information kept in human-readable form. Identifier – Unique tag, usually a number that identifies the file within the file system. Type – Needed for systems that support different types. Location – Pointer to file location on device.

  4. File Attributes (Cont’d) Size – Current file size. Protection – Access-control who can write, read, execute and so on. Time, date and user identification – Data for protection, security and usage monitoring. Volatility – Frequency with which additions and deletions are made to the file.

  5. File Operations A file is an abstract data type. To define a file, we need to consider the operations that can be performed on the file. Creating a file - Allocate space for the file, entry for the file in the directory. Writing a file - Make a system call specifying both the name of the file and the information to be written to the file. System keeps a write pointer.

  6. File Operations (Cont’d) Reading a file - Make a system call specifying both the name of the file and where the next block of file should be put. System keeps a read pointer. Repositioning within a file – Also known as file seek. The directory is searched for the appropriate entry, and the current file-position-pointer is repositioned to a given value.

  7. File Operations (Cont’d) Deleting a file – Release all file space and erase the directory entry. Truncating a file – Deletes contents and resets length to 0 but directory entry and all file attributes except file length remains unchanged. Opening/closing a file - When a file operation is requested, the file is specified via an index into open-file table usually after an open() system call.

  8. File Operations (Cont’d) • Information associated with open file • File pointer - If no file offset in read()/write() system calls are included. • File-open count - The number of processes have opened the file. When the count reaches 0 the entry is deleted from open-file table. • Disk location of the file • Access rights - Per process access mode information.

  9. File Locks • File locks allow one process to lock a file and prevent other processes from gaining access to it. • Mandatory file locks - Once a process acquires an exclusive lock, the operating system will prevent any other process from accessing the locked file. • Advisory file locks – Is up to software developers to ensure that locks are appropriately acquired and released.

  10. Common file types

  11. File Structure • None – Sequence of words, bytes. • Simple record structure – Lines, fixed length, variable length. • Complex structures – Formatted document, Relocatable load file. • Can simulate last two with first method by inserting appropriate control characters. Operating system or program can establish file structure.

  12. File Structure (Cont’d) • File type may indicate internal structure of file (e.g., source or object). • IBM mainframe systems, for example, support a very wide range of access methods. • UNIX, MS-DOS, others, support only a minimal number of file structures. (UNIX files are sequence of 8-bit bytes)

  13. File Structure (Cont’d) • Macintosh resource fork and data fork. • The logical record size, physical block size, and packing technique determine how many logical records are in each physical block. The packing can be done either by the user's application program or by the operating system.

  14. Access Methods • Sequential access – Information in the file is processed in order, one record after the other. • read next • Write next • Reset or skip n

  15. Access Methods (Cont’d) • Direct access – Or relative access is based on a disk model of a file, since disks allow random access to any file block. • Read n, write n • Read next, write next, position file to n where n is the relative block number.

  16. Access Methods (Cont’d) • Other access methods – Index and relative files.

  17. Directory Structure • Storage structure – A collection of nodes containing information of all files. Resides on disk, along with the files.

  18. Directory Operations • Search for a file. • Create a file. • Delete a file. • List a directory. • Rename a file. • Traverse the file system usually for back up purposes.

  19. Single-Level Directory • All files are contained in the same directory. Simple to support and use. But difficult when the number of files increase and system has more than one user.

  20. Two-Level Directory • Each user has own user file directory (UFD). • Master file directory (MFD) holds pointers to UFDs. • Disadvantage: Isolation.

  21. Tree-Structured Directory • Natural generalization of two-level directories. Contains a set of files and sub-directories with the same internal format. • The current directory should contain most of the files that are of current interest to the process. • Special system calls are used to create and delete directories. To change directories a system call that takes a directory name as a parameter and uses it to redefine current directory. • Efficient searching and group capability.

  22. Tree-Structured Directory (Cont’d)

  23. Acyclic-Graph Directory • A graph with no cycles, allows directories to share subdirectories and files.

  24. Acyclic-Graph Directory (Cont’d) • One way of implementation is by creating a new directory called link, which is a pointer to another file or sub directory. • An alternative approach is to duplicate all information in both sharing directories. • Deleting a file could involve the approach of leaving the links dangling or the approach where file is preserved until all references to it are deleted.

  25. General Graph Directory • We have to guarantee no cycles are formed by making sure that • We allow only links to files and not sub directories • Garbage collection • Every time a new link is added use a cycle detection algorithm to determine if it is okay.

  26. General Graph Directory (Cont’d)

  27. File-System Mounting • The process of incorporating a file system into the existing directory structure. • A file system must be mounted before it can be accessible to system processes. • A file system is mounted at mount point (empty directory). • mount -t iso9660 /dev/hdc /cdrom

  28. File-System Mounting (Cont’d) • Mounting Process, OS • Name of device • Mount point • File system type • Verify device contains valid file system. • File system is mounted at specified mount point.

  29. File-System Mounting (Cont’d) • Unix • Mount /dev/dsk/c1t4d0s0 under Solaris UNIX at /data2, enter: • mkdir /data2 • mount /dev/dsk/c1t4d0s0 /data2 • To remove mount point run: • umount /data2

  30. File-System Mounting (Cont’d)

  31. File-System Mounting (Cont’d) • System impose semantics to clarify functionality. System may • Disallow a mount over a directory that contain files • A mount over that directory and directory’s existing files are hidden and inaccessible • Allow same file system to be mounted repeatedly at different mount points • Allow one mount per file system

  32. File-System Mounting (Cont’d) • Mac OS

  33. File-System Mounting (Cont’d) • Windows OS

  34. File Sharing • Sharing of file among users and systems is desirable. • File Sharing through removable media, computer network, Web and etc • File Sharing through protection such as access control

  35. File Sharing : Multiple Users • Owner, who can change attributes and grant access and have most control over the files • Group, who can share access to the files or execute one subset of file operations • User ID identifies user and permitting requested operations on files • Group ID allows user to be in a group and permitting group access right

  36. File Sharing : Remote File Systems • Network communication among remote computes now become possible • Networking allows sharing of file system among different systems • FTP: manually transferring files between hosts • DFS: accessing files from multiple hosts via network • WWW: A browser gains access to the remote files and separate operations for file transfer.

  37. File Sharing : Remote File Systems (Cont’d) • Client-Server model allows client to mount one or more file systems from servers • A server can serve multiple clients. • A client can access multiple servers. • Client identification is complex and unsecure authentication methods are most commonly used • UNIX and its NFS, authentication takes place via client network information by default • NFS is Unix File Sharing Protocol • CIFS and SMB are Window File Sharing Protocols

  38. File Sharing : Remote File Systems (Cont’d) • Client-Server model file sharing • Once remote file system is mounted, client sends file operation requests to server via DFS • Server applies standard access checks to see if user has credentials to access the file in the mode requested • The request is either grant or deny • If access is granted, client performs requested operations • Client closes the file

  39. File Sharing : Remote File Systems (Cont’d) • Distributed Information Systems provide unified access to the information needed for remote computing • DNS provides host-name-to-network-address translation for internet • Some DIS provides user name, password, user ID and group ID for distributed facility • UNIX employs a variety of distributed-information methods. • Sun Microsystems introduced NIS and NIS+ • Microsoft CIFS, network information is used with user authentication for network login • Microsoft uses domain and active directory naming technology for distributed naming structures. • Lightweight directory-access protocol (LDAP)

  40. File Sharing : Failure Modes • Local file system can fail for a variety of reasons • Disk failure, Directory structure or Disk-management information corruption, Disk-controller failure, cable failure, user or system administrator failure and etc • Remote file system have more failure modes. • Network interruption and etc • Recover from failure involves some kind of state information about remote request • NFS, which employs DFS stateless • NFS version 4 is stateful

  41. File Sharing : Consistency Semantics • An important criterion • How modifications of data by one user will be observable by other users • Andrew file system implemented complex sharing semantics.

  42. File Sharing : Consistency Semantics (Cont’d) • UNIX Semantics • Writes to an open file by a user are visible immediately to other users who have this file open • Supports a mode of sharing where users share pointer of current location into the file • Session Semantics (eg. AFS) • Writes to an open file by a user are not visible immediately to other users who have this file open • Once a file is closed, the changes are visible only in sessions starting later. Already open file instances doe not reflect changes.

  43. File Sharing : Consistency Semantics (Cont’d) • Immutable-Shared-Files Semantics • Once a file is declared as shared by its creator, it cannot be modified. • Two properties: name and content are immutable • Simple implementation as read-only sharing

  44. Protection • Keep information stored in system safe from physical damage and improper or unauthorized access • Protect files by limiting types of access to files and by whom

  45. Protection : Access Types • Types of Access • Read • Write • Execute • Append • Delete • List

  46. Protection : Access Control • Common approach is granting access based on the identity of user • Access-Control List • Specify user names and type of access allowed for each user • Associate access-control list with each file • Maintenance problems as its length and unknown size of system users • The variable size directory entry, resulting in more complicated space management.

  47. Protection : Access Control (Cont’d) • Categories of access • Owner • Group • Universe • Maintenance of groups in the system are not connected with the specific file or directory • Each file has owner and group associated with it. Permissions are specified to each of them

  48. Protection : Access Control (Cont’d) • Permission and access control lists must be controlled tightly • Examples in Unix System • File name: book, chapter1 • Group name: text, owner • User name: visitor not in groups • -rwxrw-r-- 2 Sara text 2048 Sep 30 2010 book • Chmod text-w book • setfacl -m u:visitor:rx / chapter1

  49. Protection : Access Control (Cont’d) • Windows

  50. Protection : Others • Passwords • Associating a password with each file • Issues • Large number of passwords to remember • One password for all files is used, protection is on all-or-none basis • Some system allow user to associate a password with subdirectory rather than individual file. • MS-DOS and early version of Mac OS provide little in term of file protection.

More Related