Chapter 10 2 File System Interface Chapter 10 File System Interface Chapter 10 1 File Concept Access Methods Chapter 10 2 Directory Structure continued File System Mounting Protection Operating System Concepts 10 2 Silberschatz Galvin and Gagne 2005 Directory Structure Operating System Concepts 10 3 Silberschatz Galvin and Gagne 2005 Directories Systems may have zero or more file systems and each of these may be of various types used to manage data Files systems themselves may consist of millions of files scattered and organized or not well organized in a many of ways All files must be managed and organized as files constitute a major component of any computing system For files that are organized again they don t have to be the principal way of organizing files is by using a directory But there are many different directory structures used to organize manage files These various directories can contain different data items too We will look at the key ways in which directories are organized Operating System Concepts 10 4 Silberschatz Galvin and Gagne 2005 Directories 2 While disks may certainly be dedicated it is frequently the case that we may have multiple file systems on a single disk These can be organized in many ways and termed also in many ways Disks themselves may be partitioned can have raw disk regular formatted disk etc Disks can be sliced and diced by manufacturers and vendors many ways For the time being refer to a storage device holding a file system as a volume A volume may be thought of as a virtual disk because volumes can actually span physical devices A disk itself can not only store data files program files directories all with a variety of formats and more but also a host of other storable items such as other operating systems A Volume Table of Contents VTOC which is a device directory contains information describing the volume contents Simply refer to these structures as directories Operating System Concepts 10 5 Silberschatz Galvin and Gagne 2005 Directory Structure A directory can be organized in various ways A directory may be considered a table mapping file names to a specific files A directory may be considered a collection of nodes containing information about all files that is the directory entry not only points to a file but also contains much informaton about the file Directory Files F1 F2 F3 F4 Fn Both the directory structure and the files reside on disk Backups of these two structures are often kept on magnetic tapes Operating System Concepts 10 6 Silberschatz Galvin and Gagne 2005 Operations Performed on Directory Search for a file Given a file name we need to be able to search the directory to find the file Create a file Delete a file Need to be able to create delete file on disk and hence maintain an appropriate entry in the directory List a directory We need to be able to list the contents of a directory and see characteristics of the files contained in the directory Rename a file Often need to rename a file its name may imply its position in a directory a full path name Traverse the file system Here we want to be able to access the directory and every file contained in the directory structure We want to be able to do all this very quickly Operating System Concepts 10 7 Silberschatz Galvin and Gagne 2005 Single Level Directory A single directory for all users the simplest format All files in the same directory Problems Files must have unique names This is very difficult not practical for multiple users using the same directory Not uncommon for a single user to have hundreds of files on a single computing system I know that I do on my local Linux machine Operating System Concepts 10 8 Silberschatz Galvin and Gagne 2005 Two Level Directory Here we have a separate directory for each user Similar structure A master file directory contains the user name account number and points to the file directory for that user In creating a file the OS uses the user s user file directory UFD as part of the pathname and thus ensures file names and other entries are unique Creation of a new directory will normally require a system administrator Every entry has a path name to uniquely define locate a file Other systems require a volume as in C mydir pgr1 java Operating System Concepts 10 9 Silberschatz Galvin and Gagne 2005 Two Level Directory Important to note that for system files such as loaders linkers assemblers compilers and various other commands these too are defined as files and when we invoke them the file is loaded and executed e g gcc pgm1 c This invokes the compiler and passes a file name as a parameter But where is gcc Search Path So many commonly used files such as system files are put in a special directory for system files Because the user s directory is always searched first a not found will result in a search of this system directory The sequence of directories searched when a file is named is called a search path and this can have many fully defined directories in it Both Unix and Windows machines use this approach Operating System Concepts 10 10 Silberschatz Galvin and Gagne 2005 Tree Structured Directories So we ve seen a two level directory The natural extension to a two level directory is a tree inverted tree of arbitrary height A tree by definition has one root and because it is a tree not a graph supports only a single path to each item At each level we either have files or directories subdirectories for a lower levels Be sure to continue to recognize that a directory is itself simply a file but directories are used for special things and are organized and managed differently than a standard datafile as we shall see Operating System Concepts 10 11 Silberschatz Galvin and Gagne 2005 Tree Structured Directories 2 Running Processes Each running process has a current directory References made to files by a running process causes the OS to search the current directory to locate the reference If the desired item is NOT in the current directory then the user must specify a path name or path name s that can be alternatively used to search for the desired item In Unix Linux The current directory is indicated with a dot Typically when one logs onto a system one is in a login shell The operating system searches this directory for some kind of information identifying this user perhaps a profile file You can edit your profile in various ways Easiest is pico profile if you don t mind pico Notice the dot in front of profile You can set search PATHs in
View Full Document