File Concept n n Contiguous logical address space

  • Slides: 16
Download presentation
File Concept n n Contiguous logical address space Smallest user allocation Non-volatile Types: F

File Concept n n Contiguous logical address space Smallest user allocation Non-volatile Types: F Data 4 numeric 4 character 4 binary F Program 4 Source 4 Script 4 Binary Operating System Concepts 11. 1 Silberschatz, Galvin and Gagne 2002

File Types – Name, Extension Operating System Concepts 11. 2 Silberschatz, Galvin and Gagne

File Types – Name, Extension Operating System Concepts 11. 2 Silberschatz, Galvin and Gagne 2002

File Structure n Levels of structuring F None - sequence of words, bytes F

File Structure n Levels of structuring F None - sequence of words, bytes F Simple record structure 4 Lines 4 Fixed length 4 Variable length F Complex structures 4 Formatted document 4 Relocatable load file F Can simulate last two with first method by inserting appropriate control characters. n Need at least executable binary and data n Type indicated by F “type” extension F Resource fork (Mac) F Magic number (UNIX) n More complexity requires more OS support Operating System Concepts 11. 3 Silberschatz, Galvin and Gagne 2002

File Attributes n Name – only information kept in human-readable form. n Type –

File Attributes n Name – only information kept in human-readable form. n Type – needed for systems that support different types. n Location – pointer to file location on device. n Size – current file size. n Protection – controls who can do reading, writing, executing. n Time, date – creation, access, modification. n User identification – data for protection, security, and usage monitoring. n 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

Directory Structure n A collection of nodes containing information about all files. Directory Files

Directory Structure n A collection of nodes containing information about all files. Directory Files F 1 F 2 F 3 F 4 Fn n Both the directory structure and the files reside on disk. Operating System Concepts 11. 5 Silberschatz, Galvin and Gagne 2002

File Operations n Create F Allocate space F Create directory entry n Open F

File Operations n Create F Allocate space F Create directory entry n Open F Copy the directory structure on disk to memory. n Read, Write F Identified file F Specified position F Specified data F Update directory n Reposition within file – file seek n Close F Copy the directory structure in memory to disk. n Delete F Release space F Delete directory entry n Rename, Truncate, Append, Copy (can be formed from others) Operating System Concepts 11. 6 Silberschatz, Galvin and Gagne 2002

Access Methods n Sequential Access read next write next reset (rewind) no read after

Access Methods n Sequential Access read next write next reset (rewind) no read after last write n Direct Access read n write n position to n read next write next n = relative block number (start, current, end) Operating System Concepts 11. 7 Silberschatz, Galvin and Gagne 2002

Directory Operations n Search for a file F By name/pattern F By other attributes

Directory Operations n Search for a file F By name/pattern F By other attributes n Create a file F Add a new entry n Delete a file F Delete entry n List a directory n Rename a file F Potentially moves file in directory structure n Traverse the file system F E. g. , for backups Operating System Concepts 11. 8 Silberschatz, Galvin and Gagne 2002

Organize the Directory (Logically) to Obtain n Efficiency – locating a file quickly n

Organize the Directory (Logically) to Obtain n Efficiency – locating a file quickly n Grouping – logical grouping of files by properties, (e. g. , all Java programs, all games, …) n Naming – convenient to users. F Two users can have same name for different files. F The same file can have several different names Operating System Concepts 11. 9 Silberschatz, Galvin and Gagne 2002

Tree-Structured Directories Operating System Concepts 11. 10 Silberschatz, Galvin and Gagne 2002

Tree-Structured Directories Operating System Concepts 11. 10 Silberschatz, Galvin and Gagne 2002

Tree-Structured Directories n Efficient searching n Grouping capability n Absolute and relative pathnames F

Tree-Structured Directories n Efficient searching n Grouping capability n Absolute and relative pathnames F Relative to current directory F Absolute to 4 Root 4 Current (which absolute to root) n No sharing yet Operating System Concepts 11. 11 Silberschatz, Galvin and Gagne 2002

Acyclic-Graph Directories Operating System Concepts 11. 12 Silberschatz, Galvin and Gagne 2002

Acyclic-Graph Directories Operating System Concepts 11. 12 Silberschatz, Galvin and Gagne 2002

Acyclic-Graph Directories n Have shared subdirectories and files F Allows multiple names for one

Acyclic-Graph Directories n Have shared subdirectories and files F Allows multiple names for one file or directory F Allows sharing of files and directories n Hard links F Multiple directory nodes refer to the same file F No precedence F Problems of directory entry consistency - UNIX solves with inodes F Delete file (only) when there are no links 4 Alternatively, have back pointers and delete all directory entries and file when one directory entry is deleted F Beware cyclic directory links (not permitted in UNIX now) n Symbolic (soft) links F Gives name of another directory entry (could also be soft) F Deletion just deletes the link F Have to deal with hanging links when hard link is deleted F Cyclic links are possible Operating System Concepts 11. 13 Silberschatz, Galvin and Gagne 2002

General Graph Directory n How do we guarantee no cycles? F Allow only links

General Graph Directory n How do we guarantee no cycles? F Allow only links to file not subdirectories. F Garbage collection. F Every time a new link is added use a cycle detection algorithm to determine whether it is OK. Operating System Concepts 11. 14 Silberschatz, Galvin and Gagne 2002

Protection n File owner/creator should be able to control: F what can be done

Protection n File owner/creator should be able to control: F what can be done F by whom n Modes access: F Files: read, write, execute, delete F Directories: read, write, make current Operating System Concepts 11. 15 Silberschatz, Galvin and Gagne 2002

Access Lists and Groups n Access lists provide fine grained control (Windows NT) F

Access Lists and Groups n Access lists provide fine grained control (Windows NT) F Very large F Requires variable size directory entries n Classes of users RWX 7 RWX 6 RWX 1 a) owner access b) group access c) public access 111 110 001 n Password protection F Files (too many) F Subdirectories (ala TOPS-20) F Partition (ala VM/CMS) F All user files Operating System Concepts 11. 16 Silberschatz, Galvin and Gagne 2002