Chapter 10 File System Interface Chapter 10 File System Interface Chapter 10 1 File Concept Access Methods Chapter 10 2 Directory Structure File System Mounting File Sharing Protection Operating System Concepts 10 2 Silberschatz Galvin and Gagne 2005 Storage Management New block File Systems a k a Storage Management An Operating System is often described as a program that manages processes processors memory and storage Listing these operating systems control and manage Processes both user and system Processors the CPUs Memory management primary cache and Storage management data programs directories used for access etc Operating System Concepts 10 3 Silberschatz Galvin and Gagne 2005 Storage Management more Disk storage primary medium for primary online storage Contains files collections of related items defined by file creator Normally grouped into directories for ease of use and reference Organized in a variety of structures Disk Access sometimes character at a time often blocks at a time sometimes access sequentially sometimes randomly Some file systems dedicated some shared Some support data transfer data asynchronously others synchronously Differ greatly in speed many parameters as cited above This chapter the File System Interface Operating System Concepts 10 4 Silberschatz Galvin and Gagne 2005 Objectives of this Chapter To explain the function of file systems To describe the interfaces to file systems To discuss file system design tradeoffs including access methods file sharing file locking and directory structures To explore file system protection Operating System Concepts 10 5 Silberschatz Galvin and Gagne 2005 File Concept A File System consists of two parts Files the actual storage of data on a medium Stored on sequential or some kind of direct access storage device Directory Structure structures the information for access Size location logical record length block size format ownership security paths to files directories etc A file may be defined as a contiguous logical address space which is mapped by the operating system onto some kind of physical devices Note logical does not mean physical Almost all storage devices are non volatile data remains when power is removed Magnetic tapes Magnetic disks Optical disks Jump drives CDs DVDs And others Operating System Concepts 10 6 Silberschatz Galvin and Gagne 2005 File Concept To a user a file is the smallest allocation of logical secondary storage All data is written to a file Data may be numeric alphabetic alphanumeric or binary Can be free form text Can be rigidly formatted records Fixed length records variable length records Bright Lights application Generally a file is a sequence of bits bytes lines or records whose meaning is interpreted by the creator of the file and how it is used One man s program is another man s data Operating System Concepts 10 7 Silberschatz Galvin and Gagne 2005 File Concept continued Data files many forms and structures Differentiate between a file s organization and how it may be accessed not the same Program files Source programs Object files Executable files May not be directly executable May be understandable by a linker May be ready for loader to bring into memory Much of the data about programs and data files revolves simply as how they are used Operating System Concepts 10 8 Silberschatz Galvin and Gagne 2005 File Attributes Name Typically the only information kept in human readable form Usually independent of the process and system that created it Save for possible extensions or types such as doc or ppt etc But names often are constrained by the operational environment NIHPOO Each positions often means something very important in a commercial non academic environment Identifier unique tag number identifies file within file system NIHP00 System Code IH Source programs N subsystem P Programs within subsystem 00 01 Type needed for systems that support different types c java cpp exe dll dat wpd doc etc xls css And bringing up certain processes to process these files by type Location pointer to file location on device Size current file size generally in bytes or blocks especially blocks Protection controls who can do reading writing executing Yes Read write execute Time date and user identification data for protection security and usage monitoring Maybe date last accesses OPR security Operating System Concepts 10 9 Silberschatz Galvin and Gagne 2005 File Operations File is an abstract data type This means it has data which will be unique to its implementation realization how organized and use how accessed and processed and File operations that can be performed on the data dependent upon how it is implemented Accessed sequentially randomly etc Let s look at the six basic functions that can be performed on most files Operating System Concepts 10 10 Silberschatz Galvin and Gagne 2005 Create Typical File Operations Need to allocate space Adds entry in disk directory load data onto storage device Write System call supplies name of file and data to be written A pointer usually needs to be available to point to the place where the next item is to be written pointer updated Read Another system call specifies file name location in memory where read data is to be placed and using a pointer locates data to be read Pointer needs to be updated to point to next item to be read Pointer for read and write called a current file position pointer Operating System Concepts 10 11 Silberschatz Galvin and Gagne 2005 Typical File Operations more Reposition within file This refers to moving a file pointer to point to a specific position record in the file Really this is a file seek Delete Using the directory release the file space for reuse Clears directory entry referring to this file Truncate often used in recreating a file Delete entries in file but keeps file attributes Changed attribute is file length File length reset to zero and its file space is released Operating System Concepts 10 12 Silberschatz Galvin and Gagne 2005 Typical File Operations Other operations include Append data to end of a file Rename a file Copy a file Other file utilities get length of file get attributes etc Many OS utilities such as file prints allocating space Some files open a file at first reference others require a specific open or fopen system call etc Some files are automatically close when program terminates others suggest an explicit file close My take always close your files Keep things clean Open usually validates the
View Full Document