Chapter 13: File-System Interface

Chapter 13: File-System Interface

Chapter 13: File-System Interface Operating System Concepts – 10th dition Silberschatz, Galvin and Gagne ©2018 Chapter 13: File-System Interface File Concept Access Methods Disk and Directory Structure File-System Mounting File Sharing Protection Operating System Concepts – 10th dition 1!"2 Silberschatz, Galvin and Gagne ©2018 Objectives To explain the function of file systems To describe the interfaces to file systems To discuss file-system design tradeo!s, including access methods, file sharing, file locking, and directory structures To explore file-system protection Operating System Concepts – 10th dition 1!"! Silberschatz, Galvin and Gagne ©2018 File Concept Contiguous logical address space Types: Data numeric character binary Program Contents defined y file’s creator Many types Consider text file, source file, exec&table file Operating System Concepts – 10th dition 1!"# Silberschatz, Galvin and Gagne ©2018 File Attributes (ame – only information kept in human-reada le form )denti%er – uni&ue tag 'num er( identifies file )ithin file system *ype – needed for systems that support different types +ocation – pointer to file location on device Size % current file size ,rotection % controls )ho can do reading" )riting" executing *ime, date, and &ser identi%cation % data for protection" security, and usage monitoring ,nformation about files are kept in the directory structure" )hich is maintained on the disk Many variations, including extended file attri utes such as file checksum ,nformation kept in the directory structure Operating System Concepts – 10th dition 1!"' Silberschatz, Galvin and Gagne ©2018 File info Window on Mac OS X Operating System Concepts – 10th dition 1!"- Silberschatz, Galvin and Gagne ©2018 File Operations File is an abstract data type Create /rite – at write pointer location Read – at read pointer location Reposition within file - see3 Delete *r&ncate Open(Fi) – search the directory structure on disk for entry Fi" and move the content of entry to memory Close (Fi) – move the content of entry Fi in memory to directory structure on disk Operating System Concepts – 10th dition 1!". 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 5ile-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 – 10th dition 1!"8 Silberschatz, Galvin and Gagne ©2018 Open File Locking Provided by some operating systems and file systems Similar to reader-writer locks Shared lock similar to reader lock % several processes can acquire concurrently Exclusive lock similar to )riter lock Mediates access to a file Mandatory or ad*isory: Mandatory % access is denied depending on locks held and requested Advisory – processes can find status of locks and decide what to do Operating System Concepts – 10th dition 1!"6 Silberschatz, Galvin and Gagne ©2018 File Locking Example – Java API import java.io.01 import java.nio.channels/01 public class Locking3xample { pu lic static final boolean 35C26S,73 = false; pu lic static final boolean S9A:3D = true; pu lic static *oid main(String arsg[<( thro)s ,=3xception { FileLock sharedLock 8 null1 FileLock exclusi*eLock 8 null1 try { :andomAccessFile raf 8 new RandomAccessFile(>file.txt>" "r)>(1 -- get the channel for the file FileChannel ch 8 raf.getChannel'(1 -- this locks the first half of the file - exclusi*e exclusi*eLock = ch.lock'?, raf/length((-2, 35C26S,73(1 -00 Aow modify the data . 0- -- release the lock exclusi*eLock.release((1 Operating System Concepts – 10th dition 1!"10 Silberschatz, Galvin and Gagne ©2018 File Locking Example – Java API (Cont.) -- this locks the second half of the file - shared sharedLock 8 ch.lock(raf/length((-@BC" raf/length((" S9A:3D(1 -00 Aow read the data / / / 0- -- release the lock sharedLock.release((1 D catch '.ava.io.,=3xception ioe) 4 System/err/println(ioe)1 Dfinally 4 if 'exclusiveLock E8 null( exclusi*eLock.release((1 if 'sharedLock E8 null( sharedLock.release((1 D D D Operating System Concepts – 10th dition 1!"11 Silberschatz, Galvin and Gagne ©2018 File Types – Name, Extension Operating System Concepts – 10th dition 1!"12 Silberschatz, Galvin and Gagne ©2018 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 t)o with first method by inserting appropriate control characters Fho decides: =perating system Program Operating System Concepts – 10th dition 1!"1! Silberschatz, Galvin and Gagne ©2018 Sequential-access File Operating System Concepts – 10th dition 1!"1# Silberschatz, Galvin and Gagne ©2018 Access Methods Seq&ential 8ccess read next write next reset no read after last )rite 're)rite( 4irect 8ccess – file is fixed length logical records read n write n position to n read next write next rewrite n n 8 relative lock number :elati*e block num ers allow =S to decide )here file should be placed See allocation problem in Ch C@ Operating System Concepts – 10th dition 1!"1' Silberschatz, Galvin and Gagne ©2018 Simulation of Sequential Access on Direct-access File Operating System Concepts – 10th dition 1!"1- Silberschatz, Galvin and Gagne ©2018 Other Access Methods Can e built on top of ase methods General involve creation of an index for the file Heep index in memory for fast determination of location of data to e operated on (consider 6PC code plus record of data about that item) If too large" index (in memory( of the index (on disk) IBM indexed sequential-access method (ISAM) Small master index, points to disk blocks of secondary index File kept sorted on a defined key All done y the OS 7MS operating system provides index and relative files as another example (see next slide) Operating System Concepts – 10th dition 1!"1. Silberschatz, Galvin and Gagne ©2018 Example of Index and Relative Files Operating System Concepts – 10th dition 1!"18 Silberschatz, Galvin and Gagne ©2018 Directory Structure A collection of nodes containing information about all files Directory Files F 2 F 4 F 1 F 3 F n Both the directory structure and the files reside on disk Operating System Concepts – 10th dition 1!"16 Silberschatz, Galvin and Gagne ©2018 Disk Structure Disk can e subdivided into partitions Disks or partitions can e 18)4 protected against failure Disk or partition can e used ra0 – without a file system, or :ormatted with a file system Partitions also known as minidisks, slices Entity containing file system known as avolume 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 – 10th dition 1!"20 Silberschatz, Galvin and Gagne ©2018 A Typical File-system Organization Operating System Concepts – 10th dition 1!"21 Silberschatz, Galvin and Gagne ©2018 Types of File Systems We mostly talk of general-purpose file systems Iut systems frequently have may file systems, some general- and some special- purpose Consider Solaris has tmpfs – memory-based volatile FS for fast, temporary I-= objfs – interface into kernel memory to get kernel sym ols 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 – 10th dition 1!"22 Silberschatz, Galvin and Gagne ©2018 Operations Performed on Directory Search for a file Create a file Delete a file 2ist a directory :ename a file Traverse the file system Operating System Concepts – 10th dition 1!"2! Silberschatz, Galvin and Gagne ©2018 Directory Organization The directory is organized logically to obtain 3Lciency – locating a file quickly Aaming – con*enient to users Two users can have same name for different files The same file can have several different names Grouping – logical grouping of files by properties, (e/g/, all Java programs, all games, N( Operating System Concepts – 10th dition 1!"2# Silberschatz, Galvin and Gagne ©2018 Single-Level Directory A single directory for all users Aaming problem Grouping problem Operating System Concepts – 10th dition 1!"2' Silberschatz, Galvin and Gagne ©2018 Two-Level Directory Separate directory for each user Path name Can ha*e the same file name for different user 3Lcient searching No grouping capability Operating System Concepts – 10th dition 1!"2- Silberschatz, Galvin and Gagne ©2018 Tree-Structured Directories Operating System Concepts – 10th dition 1!"2. Silberschatz, Galvin and Gagne ©2018 Tree-Structured Directories (Cont.) 3Lcient searching Grouping Capability Current directory (working directory( cd /spell/mail/prog type list Operating System Concepts – 10th dition 1!"28 Silberschatz, Galvin and Gagne ©2018 Tree-Structured Directories (Cont) 8bsolute or relative path name Creating a new file is done in current directory Delete a file rm <file-name> Creating a new subdirectory is done in current directory mkdir <dir-name> Example#

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    44 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us