Operating Systems Internals and Design Principles 6E William




















































- Slides: 52
Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 12 File Management Patricia Roy Manatee Community College, Venice, FL © 2008, Prentice Hall 1
File Management • File management system consists of system utility programs that run as privileged applications • Concerned with secondary storage • Long-term existence • Shared between processes • Structure (internal or directories) 2
File Attributes Possible file attributes 3
File System Calls • Principle Win 32 API functions for file I/O • Second column gives nearest UNIX equivalent 4
Files System Software Architecture 5
Elements of File Management 6
File Management Functions • Identify and locate a selected file • Use a directory to describe the location of all files plus their attributes • On a shared system describe user access control 7
Criteria for File Organization • Quick random access – Needed when accessing a single record • Ease of update • Economy of storage – Should be minimum redundancy in the data – Redundancy can be used to speed access such as an index • Simple maintenance • Reliability 8
The Pile 9
The Sequential File 10
Indexed Sequential File 11
Indexed File 12
File Organization • The Direct or Hashed File – Directly access a block at a known address – Key field required for each record 13
Performance 14
File Directories • Contains information about files – Attributes – Location – Ownership • Directory itself is a file owned by the operating system • Provides mapping between file names and the files themselves 15
Information Elements of a File Directory 16
Information Elements of a File Directory 17
Hierarchical, or Tree-Structured Directory • Master directory with user directories underneath it • Each user directory may have subdirectories and files as entries 18
Tree-Structured Directory 19
Example of Tree-Structured Directory 20
Hierarchical, or Tree-Structured Directory • Files can be located by following a path from the root, or master, directory down various branches – This is the pathname for the file • Can have several files with the same file name as long as they have unique path names • Current directory is the working directory • Files are referenced relative to the working directory 21
Directory System Calls • Principle Win 32 API functions for directory management • Second column gives nearest UNIX equivalent, when one exists 22
File Sharing • In multiuser system, allow files to be shared among users • Two issues – Access rights (read, write, execute) – Management of simultaneous access (cf. interprocess communication, mutual exclusion) 23
Access Matrix 24
Access Control List 25
Capability Lists 26
File System Implementation A possible file system layout 27
Secondary Storage Management • Space must be allocated to files • Must keep track of the space available for allocation 28
Disk Space Management Block size • Dark line (left hand scale) gives data rate of a disk • Dotted line (right hand scale) gives disk space efficiency • All files 2 KB 29
Contiguous Allocation • Single set of blocks is allocated to a file at the time of creation • Only a single entry in the file allocation table – Starting block and length of the file • External fragmentation will occur – Need to perform compaction 30
Contiguous File Allocation 31
Contiguous File Allocation 32
Chained Allocation • Allocation on basis of individual block • Each block contains a pointer to the next block in the chain • Only single entry in the file allocation table – Starting block and length of file 33
Chained Allocation • No external fragmentation • Best for sequential files • No accommodation of the principle of locality 34
Chained Allocation 35
Chained Allocation 36
Indexed Allocation • File allocation table contains a separate onelevel index for each file • The index has one entry for each portion allocated to the file • The file allocation table contains block number for the index 37
Indexed Allocation 38
The MS-DOS File System (1) The MS-DOS directory entry 39
The MS-DOS File System (2) • Maximum partition for different block sizes • The empty boxes represent forbidden combinations 40
Inodes • Index node • Control structure that contains key information for a particular file: attributes and location of blocks 41
Free. BSD File Allocation 42
UNIX Directories and Inodes 43
The UNIX File System The steps in looking up /usr/ast/mbox 44
Shared Files (1) File system containing a shared file 45
Shared Files (2) (a) Situation prior to linking (b) After the link is created (c) After the original owner removes the file 46
Windows 2000 (1) The NTFS master file table 47
Windows 2000 (2) An MFT record for a three-run, nine-block file 48
Windows 2000 (3) A file that requires three MFT records to store its runs 49
Linux Virtual File System • Uniform file system interface to user processes • Represents any conceivable file system’s general feature and behavior • Assumes files are objects that share basic properties regardless of the target file system 50
Linux Virtual File System Context 51
Linux Virtual File System Concept 52