Computer Operating System - Chapter 13: File-System Interface
File Concept
■ Access Methods
■ Disk and Directory Structure
■ File-System Mounting
■ File Sharing
■ Protection
■ Access Methods
■ Disk and Directory Structure
■ File-System Mounting
■ File Sharing
■ Protection
Bạn đang xem 20 trang mẫu của tài liệu "Computer Operating System - Chapter 13: File-System Interface", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.
File đính kèm:
- computer_operating_system_chapter_13_file_system_interface.pdf
Nội dung text: Computer Operating System - Chapter 13: File-System Interface
- Chapter 13: File-System Interface ■ File Concept ■ Access Methods ■ Disk and Directory Structure ■ File-System Mounting ■ File Sharing ■ Protection Operating System Concepts 13.2 Silberschatz, Galvin and Gagne ©2018
- File Concept ■ Contiguous logical address space ■ Types: ● Data 4 complexe 4 numeric 4 character 4 binary ● Program ■ Contents defined by file’s creator ● Many types 4 Text file 4 Source file 4 Executable file Operating System Concepts 13.4 Silberschatz, Galvin and Gagne ©2018
- A window of file info on Mac OS X Operating System Concepts 13.6 Silberschatz, Galvin and Gagne ©2018
- Open Files ■ Several pieces of data are needed to manage open files: ● Open-file table: tracks 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 13.8 Silberschatz, Galvin and Gagne ©2018
- 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(); Operating System Concepts 13.10 Silberschatz, Galvin and Gagne ©2018
- File Types – Name, Extension Operating System Concepts 13.12 Silberschatz, Galvin and Gagne ©2018
- Sequential-Access File Operating System Concepts 13.14 Silberschatz, Galvin and Gagne ©2018
- Simulation of Sequential-Access on Direct-Access File Operating System Concepts 13.16 Silberschatz, Galvin and Gagne ©2018
- Example of Index and Relative Files Operating System Concepts 13.18 Silberschatz, Galvin and Gagne ©2018
- Disk Structure ■ Disk can be subdivided into partitions ● Disks or partitions can be RAID protected against failure ● Disk or partition can be used raw – without a file system, or formatted with a file system ■ Partitions also known as minidisks, slices ■ Entity containing file system known as a volume ● Each volume containing file system also tracks that file system s info in device directory or volume table of contents ■ As well as general-purpose file systems there are many special- purpose file systems, frequently all within the same operating system or computer Operating System Concepts 13.20 Silberschatz, Galvin and Gagne ©2018
- Types of File Systems ■ We mostly talk of general-purpose file systems ■ But systems frequently have many file systems, some general- and some special- purpose ■ E.g., Solaris has ● tmpfs – memory-based volatile FS for fast, temporary I/O ● objfs – interface into kernel memory to get kernel symbols for debugging ● ctfs – contract file system for managing daemons ● lofs – loopback file system allows one FS to be accessed in place of another ● procfs – kernel interface to process structures ● ufs, zfs – general purpose file systems Operating System Concepts 13.22 Silberschatz, Galvin and Gagne ©2018
- Directory Organization ■ The directory is organized logically to obtain ● Efficiency – locating a file quickly ● Naming – convenient to users 4 Two users can have same name for different files 4 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 13.24 Silberschatz, Galvin and Gagne ©2018
- Two-Level Directory ■ Separate directory for each user ● Master file directory (MFD) ● User file directory (UFD) ■ Path name ■ Can have the same file name for different user ■ Efficient searching ■ No grouping capability Operating System Concepts 13.26 Silberschatz, Galvin and Gagne ©2018
- Tree-Structured Directories (Cont.) ■ Efficient searching ■ Grouping Capability ■ Current directory (or working directory) ● E.g., For Linux OS, cd /spell/mail/prog type list Operating System Concepts 13.28 Silberschatz, Galvin and Gagne ©2018
- Acyclic-Graph Directories ■ Have shared subdirectories and files ● Two different names (aliasing) 4 If dict deletes list Þ dangling pointer. ● Solutions: 4 Backpointers, so we can delete all pointers Variable size records a problem – Backpointers using a daisy chain organization 4 Entry-hold-count solution Operating System Concepts 13.30 Silberschatz, Galvin and Gagne ©2018
- General Graph Directory Operating System Concepts 13.32 Silberschatz, Galvin and Gagne ©2018
- File System Mounting ■ A file system must be mounted before it can be accessed ■ A unmounted file system (i.e., Fig. (b)) is mounted at a mount point / users bill fred sue jane help doc prog (a) (b) Operating System Concepts 13.34 Silberschatz, Galvin and Gagne ©2018
- File Sharing ■ Sharing of files on multi-user systems is desirable ■ Sharing may be done through a protection scheme ■ On distributed systems, files may be shared across a network ● Network File System (NFS) is a common distributed file-sharing method ■ If multi-user system ● Owner of a file / directory 4 User IDs identify users, allowing permissions and protections to be per-user ● Group of a file / directory 4 Group IDs allow users to be in groups, permitting group access rights Operating System Concepts 13.36 Silberschatz, Galvin and Gagne ©2018
- File Sharing – Failure Modes ■ All file systems have failure modes ● For example corruption of directory structures or other non-user data, called metadata ■ Remote file systems add new failure modes, due to network failure, server failure ■ Recovery from failure can involve state information about status of each remote request ■ Stateless protocols such as NFS v.3 include all information in each request, allowing easy recovery but less security Operating System Concepts 13.38 Silberschatz, Galvin and Gagne ©2018
- 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 13.40 Silberschatz, Galvin and Gagne ©2018
- Windows 7 Access-Control List Management Operating System Concepts 13.42 Silberschatz, Galvin and Gagne ©2018
- Summary ■ A file is an abstract data type defined and implemented by the operating system. It is a sequence of logical records. A logical record may be a byte, a line (of fixed or variable length), or a more complex data item. The operating system may specifically support various record types or may leave that support to the application program. ■ A major task for the operating system is to map the logical file concept onto physical storage devices such as hard disk or NVM device. Since the physical record size of the device may not be the same as the logical record size, it may be necessary to order logical records into physical records. Again, this task may be supported by the operating system or left for the application program. ■ Within a file system, it is useful to create directories to allow files to be organized. A single-level directory in a multiuser system causes naming problems, since each file must have a unique name. A two-level directory solves this problem by creating a separate directory for each user’s files. The directory lists the files by name and includes the file’s location on the disk, length, type, owner, time of creation, time of last use, Operating System Concepts 13.44 Silberschatz, Galvin and Gagne ©2018
- End of Chapter 13 Operating System Concepts Silberschatz, Galvin and Gagne ©2018