Chapter 10 File-system interface

42 449 0
Chapter 10 File-system interface

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 10: File-System Interface Chapter 10: File-System Interface s File Concept s Access Methods s Directory Structure s File-System Mounting s File Sharing s Protection Operating System Concepts – 7th Edition, Jan 1, 2005 10.2 Silberschatz, Galvin and Gagne ©2005 Objectives s To explain the function of file systems s To describe the interfaces to file systems s To discuss file-system design tradeoffs, including access methods, file sharing, file locking, and directory structures s To explore file-system protection Operating System Concepts – 7th Edition, Jan 1, 2005 10.3 Silberschatz, Galvin and Gagne ©2005 File Concept s Contiguous logical address space s Types: q Data   character  q numeric binary Program Operating System Concepts – 7th Edition, Jan 1, 2005 10.4 Silberschatz, Galvin and Gagne ©2005 File Structure s None - sequence of words, bytes s Simple record structure q q Fixed length q s Lines Variable length Complex Structures q Formatted document q Relocatable load file s Can simulate last two with first method by inserting appropriate control characters s Who decides: q Operating system q Program Operating System Concepts – 7th Edition, Jan 1, 2005 10.5 Silberschatz, Galvin and Gagne ©2005 File Attributes s Name – only information kept in human-readable form s Identifier – unique tag (number) identifies file within file system s Type – needed for systems that support different types s Location – pointer to file location on device s Size – current file size s Protection – controls who can reading, writing, executing s Time, date, and user identification – data for protection, security, and usage monitoring s Information about files are kept in the directory structure, which is maintained on the disk Operating System Concepts – 7th Edition, Jan 1, 2005 10.6 Silberschatz, Galvin and Gagne ©2005 File Operations s File is an abstract data type s Create s Write s Read s Reposition within file s Delete s Truncate s Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry to memory s Close (Fi) – move the content of entry Fi in memory to directory structure on disk Operating System Concepts – 7th Edition, Jan 1, 2005 10.7 Silberschatz, Galvin and Gagne ©2005 Open Files s Several pieces of data are needed to manage open files: q File pointer: pointer to last read/write location, per process that has the file open q 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 q Disk location of the file: cache of data access information q Access rights: per-process access mode information Operating System Concepts – 7th Edition, Jan 1, 2005 10.8 Silberschatz, Galvin and Gagne ©2005 Open File Locking s Provided by some operating systems and file systems s Mediates access to a file s Mandatory or advisory: q Mandatory – access is denied depending on locks held and requested q Advisory – processes can find status of locks and decide what to Operating System Concepts – 7th Edition, Jan 1, 2005 10.9 Silberschatz, Galvin and Gagne ©2005 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 – 7th Edition, Jan 1, 2005 10.10 Silberschatz, Galvin and Gagne ©2005 General Graph Directory Operating System Concepts – 7th Edition, Jan 1, 2005 10.28 Silberschatz, Galvin and Gagne ©2005 General Graph Directory (Cont.) s How we guarantee no cycles? q Allow only links to file not subdirectories q Garbage collection q Every time a new link is added use a cycle detection algorithm to determine whether it is OK Operating System Concepts – 7th Edition, Jan 1, 2005 10.29 Silberschatz, Galvin and Gagne ©2005 File System Mounting s A file system must be mounted before it can be accessed s A unmounted file system (i.e Fig 11-11(b)) is mounted at a mount point Operating System Concepts – 7th Edition, Jan 1, 2005 10.30 Silberschatz, Galvin and Gagne ©2005 (a) Existing (b) Unmounted Partition Operating System Concepts – 7th Edition, Jan 1, 2005 10.31 Silberschatz, Galvin and Gagne ©2005 Mount Point Operating System Concepts – 7th Edition, Jan 1, 2005 10.32 Silberschatz, Galvin and Gagne ©2005 File Sharing s Sharing of files on multi-user systems is desirable s Sharing may be done through a protection scheme s On distributed systems, files may be shared across a network s Network File System (NFS) is a common distributed file-sharing method Operating System Concepts – 7th Edition, Jan 1, 2005 10.33 Silberschatz, Galvin and Gagne ©2005 File Sharing – Multiple Users s User IDs identify users, allowing permissions and protections to be per-user s Group IDs allow users to be in groups, permitting group access rights Operating System Concepts – 7th Edition, Jan 1, 2005 10.34 Silberschatz, Galvin and Gagne ©2005 File Sharing – Remote File Systems s Uses networking to allow file system access between systems q q Automatically, seamlessly using distributed file systems q s Manually via programs like FTP Semi automatically via the world wide web Client-server model allows clients to mount remote file systems from servers q q Client and user-on-client identification is insecure or complicated q NFS is standard UNIX client-server file sharing protocol q CIFS is standard Windows protocol q s Server can serve multiple clients Standard operating system file calls are translated into remote calls Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing Operating System Concepts – 7th Edition, Jan 1, 2005 10.35 Silberschatz, Galvin and Gagne ©2005 File Sharing – Failure Modes s Remote file systems add new failure modes, due to network failure, server failure s Recovery from failure can involve state information about status of each remote request s Stateless protocols such as NFS include all information in each request, allowing easy recovery but less security Operating System Concepts – 7th Edition, Jan 1, 2005 10.36 Silberschatz, Galvin and Gagne ©2005 File Sharing – Consistency Semantics s Consistency semantics specify how multiple users are to access a shared file simultaneously q Similar to Ch process synchronization algorithms  Tend to be less complex due to disk I/O and network latency (for remote file systems q Andrew File System (AFS) implemented complex remote file sharing semantics q Unix file system (UFS) implements:   q Writes to an open file visible immediately to other users of the same open file Sharing file pointer to allow multiple users to read and write concurrently AFS has session semantics  Writes only visible to sessions starting after the file is closed Operating System Concepts – 7th Edition, Jan 1, 2005 10.37 Silberschatz, Galvin and Gagne ©2005 Protection s File owner/creator should be able to control: q q s what can be done by whom Types of access q Read q Write q Execute q Append q Delete q List Operating System Concepts – 7th Edition, Jan 1, 2005 10.38 Silberschatz, Galvin and Gagne ©2005 Access Lists and Groups s Mode of access: read, write, execute s Three classes of users a) owner access ⇒ b) group access ⇒ c) public access ⇒ RWX 111 RWX 110 RWX 001 s Ask manager to create a group (unique name), say G, and add some users to the group s For a particular file (say game) or subdirectory, define an appropriate access owner chmod group public 761 game Attach a group to a file chgrp Operating System Concepts – 7th Edition, Jan 1, 2005 G game 10.39 Silberschatz, Galvin and Gagne ©2005 Windows XP Access-control List Management Operating System Concepts – 7th Edition, Jan 1, 2005 10.40 Silberschatz, Galvin and Gagne ©2005 A Sample UNIX Directory Listing Operating System Concepts – 7th Edition, Jan 1, 2005 10.41 Silberschatz, Galvin and Gagne ©2005 End of Chapter 10 .. .Chapter 10: File-System Interface s File Concept s Access Methods s Directory Structure s File-System Mounting s File Sharing s Protection Operating... Edition, Jan 1, 2005 10. 2 Silberschatz, Galvin and Gagne ©2005 Objectives s To explain the function of file systems s To describe the interfaces to file systems s To discuss file-system design... Concepts – 7th Edition, Jan 1, 2005 10. 17 Silberschatz, Galvin and Gagne ©2005 A Typical File-system Organization Operating System Concepts – 7th Edition, Jan 1, 2005 10. 18 Silberschatz, Galvin and

Ngày đăng: 13/05/2014, 00:36

Từ khóa liên quan

Mục lục

  • Chapter 10: File-System Interface

  • Slide 2

  • Objectives

  • File Concept

  • File Structure

  • File Attributes

  • File Operations

  • Open Files

  • Open File Locking

  • File Locking Example – Java API

  • File Locking Example – Java API (cont)

  • File Types – Name, Extension

  • Access Methods

  • Sequential-access File

  • Simulation of Sequential Access on a Direct-access File

  • Example of Index and Relative Files

  • Directory Structure

  • A Typical File-system Organization

  • Operations Performed on Directory

  • Organize the Directory (Logically) to Obtain

Tài liệu cùng người dùng

Tài liệu liên quan