
Chapter 11: File-System Interface Chapter Outline I File Concept I Access Methods I Directory Structure I File System Mounting I File Sharing I Protection Operating System Concepts 11.1 Silberschatz, Galvin and Gagne 2002 File Systems I File System consists of ✦ A collection of files ✦ A directory structure ✦ (possibly) partitions I Important Issues ✦ File protection ✦ The semantics of file sharing I Note: Historically, operating systems and file systems have been viewed as distinct entities. I From the perspective of the modern user, this distinction is often blurred. Operating System Concepts 11.2 Silberschatz, Galvin and Gagne 2002 File Concept I The operating system provides a uniform logical abstraction for the physical storage of information. I Storage devices are nonvolatile. I A file is a named collection of related information that is recorded on secondary storage. I Contiguous logical address space I Types: ✦ Data ✔ numeric ✔ character ✔ binary ✦ Program ✔ Source, object and executable file formats Operating System Concepts 11.3 Silberschatz, Galvin and Gagne 2002 File Attributes I Name – only information kept in human-readable form. I Identifier – a unique tag (i.e., an internal number) that identifies the file within the file system. I Type – needed for systems that support different types. I Location – a pointer to file location on device. I Size – current file size. I Protection – controls who can do reading, writing, executing. I Time, date, and user identification – data for protection, security, and usage monitoring. I Information about files are kept in the directory structure, which is maintained on the disk. Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Operations I Create I Write I Read I Reposition within file – file seek I Delete I Truncate I Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry to memory. I Close (Fi) – move the content of entry Fi in memory to directory structure on disk. Operating System Concepts 11.5 Silberschatz, Galvin and Gagne 2002 Claypool Example: Unix open() int open(char *path, int flags [, int mode]) I path is name of file I flags is bitmap to set switch ✦ O_RDONLY, O_WRONLY… ✦ O_CREATE then use mode for perms I On success, returns index Operating System Concepts 11.6 Silberschatz, Galvin and Gagne 2002 Claypool Example: Unix open() Under the Hood int fid = open(“blah”, flags); read(fid, …); User Space System Space 0 stdin 1 stdou 2 stdert ... r 3 File File Structure ... Descriptor ... (where blocks are) (index) (attributes) (Per process) (Per device) Operating System Concepts 11.7 Silberschatz, Galvin and Gagne 2002 Claypool Example: WinNT/2000 CreateFile() I Returns file object handle: HANDLE CreateFile ( lpFileName, // name of file dwDesiredAccess, // read-write dwShareMode, // shared or not lpSecurity, // permissions ... ) I File objects used for all: files, directories, disk drives, ports, pipes, sockets and console Operating System Concepts 11.8 Silberschatz, Galvin and Gagne 2002 File Types – Name, Extension Operating System Concepts 11.9 Silberschatz, Galvin and Gagne 2002 File Structure I File types may be used to indicate the internal structure of a file. I An OS may require a file to have a specific structure so that the OS will provide special operations for those files conforming to the set of system-supported file structures. ✦ e.g., VMS supported three defined file structures. ✦ Others (UNIX, MS-DOS) support a minimal number of file structures. I This is an obvious tradeoff between flexibility and system support! Operating System Concepts 11.10 Silberschatz, Galvin and Gagne 2002 Access Methods I Access methods determine the way that files are accessed and read into memory. I Some systems only support one access method while other OS’s support many access methods. I Sequential Access ✦ The most common method used by editors and compilers. ✦ Information is processed in order. read next write next reset no read after last write (rewrite) Operating System Concepts 11.11 Silberschatz, Galvin and Gagne 2002 Sequential Access File I Based on a tape model of a file. I May be able to skip forward nnrecords. Operating System Concepts 11.12 Silberschatz, Galvin and Gagne 2002 Direct Access File I File is made up of fixed-length logical records that allow programs to read and write records in no particular order. I The files is viewed as a numbered sequence of blocks or records. I Very useful in databases. I Direct Access {n = relative block number} read n write n position to n read next write next rewrite n Operating System Concepts 11.13 Silberschatz, Galvin and Gagne 2002 Simulation of Sequential Access on a Direct-access File Operating System Concepts 11.14 Silberschatz, Galvin and Gagne 2002 Example of Index and Relative Files I Index Sequential Access Method (ISAM) – uses indexes in a hierarchy to point to records in a file. Operating System Concepts 11.15 Silberschatz, Galvin and Gagne 2002 Directory Structure I Partitions (or Volumes) – can be viewed as the abstraction of virtual disks. I Disks can be partitioned into separate areas such that each partition is treated as a separate storage device. I The other way -- a partition may be defined to be more than one disk device. I Partitions can store multiple operating systems such that a system can boot more than one OS. I Each partition contains information about files in a device directory (or a VTOC – Volume Table of Contents). I Each directory records file attribute information. Operating System Concepts 11.16 Silberschatz, Galvin and Gagne 2002 Directory Structure I 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. Backups of these two structures are kept on tapes. Operating System Concepts 11.17 Silberschatz, Galvin and Gagne 2002 A Typical File System Organization I A directory can viewed as a “symbol table” that translates file names into their directory entries. Operating System Concepts 11.18 Silberschatz, Galvin and Gagne 2002 Information in a Device Directory I Name I Type I Address I Current length I Maximum length I Date last accessed (for archival) I Date last updated (for dump) I Owner ID (who pays) I Protection information (discuss later) Operating System Concepts 11.19 Silberschatz, Galvin and Gagne 2002 Directory Operations I Search for a file – need to find a particular entry or be able to find file names based on a pattern match. I Create a file - and add its entry to the directory. I Delete a file –and remove it from the directory. I List a directory – list both the files in the directory and the directory contents for each file. I Rename a file – renaming may imply changing the position of the file entry in the directory structure. I Traverse the file system – the directory needs a logical structure such that every directory and every file within each directory can be accessing efficiently. Operating System Concepts 11.20 Silberschatz, Galvin and Gagne 2002 Directory Design Goal To organize the logical structure to obtain: I Efficiency – locating a file quickly. I Naming – convenient to users. ✦ Two users can have same name for different files. ✦ The same file can have several different names. I Grouping – logical grouping of files by properties, (e.g., all Java programs, all games, …) Operating System Concepts 11.21 Silberschatz, Galvin and Gagne 2002 Single-Level Directory I The simplest solution:: A single-level directory with file entries for all users contained in the same directory. I Advantages: ✦ Easy to support and understand. I Disadvantages:: ✦ Requires unique file names {the naming problem}. ✦ No natural system for keeping track of file names {the grouping problem}. Operating System Concepts 11.22 Silberschatz, Galvin and Gagne 2002 Two-Level Directory I Standard solution: a separate directory for each user. I The system’s Master File Directory (MFD) has pointers to individual User File Directories ((UFD’sUFD’sUFD’s).). I File names default to localized UFD for all operations. Operating System Concepts 11.23 Silberschatz, Galvin and Gagne 2002 TwoTwo---LevelLevel Directory I Advantages ✦ Solves the name-collision problem. ✦ Isolates users from one another ! a form of protection. ✦ Efficient searching. I Disadvantages ✦ Restricts user cooperation. ✦ No logical grouping capability (other than by user). Operating System Concepts 11.24 Silberschatz, Galvin and Gagne 2002 Path Name I If a user can access another user’s files, the concept of path name is needed. I In two-level directory, this tree structure has MFD as root of path through UFD to user file name at leaf. I Path name :: username + filename I Standard syntax -- /user/file.ext Add Partitions I Additional syntax needed to specify partition ✦ e.g. in MS-DOS C:C:\\\useruseruser\\\file.extfile.ext System files I Dotted files in Unix Operating System Concepts 11.25 Silberschatz, Galvin and Gagne 2002 Path Name System File Issues I Those programs provided as part of the system (e.g. loaders, compilers, utility routines) I e.g., Dotted files in Unix I Another tradeoff issue ✦ Copy all system files into each UFD OR ✦ Create special user file directory that contains the system files. ✔ Note: This complicates the file search procedure. ✔ Default is to search local UFD, and then special UFD. I To override this default search scheme, the user specifies a specific sequence of directories to be searched when a files is named – the search path. Operating System Concepts 11.26 Silberschatz, Galvin and Gagne 2002 Tree-Structured Directories I This generalization to a directory tree structure of arbitrary height allows users to create their own subdirectories and organize their files accordingly. Directory I Becomes simply another file. I Contains a set of files or subdirectories.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages41 Page
-
File Size-