180 likes | 411 Views
File Concept. Contiguous logical address space Smallest user allocation Non-volatile Types: Data numeric character binary Program Source Script Binary. File Types – Name, Extension. File Structure. Levels of structuring None - sequence of words, bytes Simple record structure
E N D
File Concept • Contiguous logical address space • Smallest user allocation • Non-volatile • Types: • Data • numeric • character • binary • Program • Source • Script • Binary Operating System Concepts
File Types – Name, Extension Operating System Concepts
File Structure • Levels of structuring • None - sequence of words, bytes • Simple record structure • Lines • Fixed length • Variable length • Complex structures • Formatted document • Relocatable load file • Can simulate last two with first method by inserting appropriate control characters. • Need at least executable binary and data • Type indicated by • “type” extension • Resource fork (Mac) • Magic number (UNIX) • More complexity requires more OS support Operating System Concepts
File Attributes • Name – only information kept in human-readable form. • Type – needed for systems that support different types. • Location – pointer to file location on device. • Size – current file size. • Protection – controls who can do reading, writing, executing. • Time, date – creation, access, modification. • User identification – data for protection, security, and usage monitoring. • Information about files are kept in the directory structure, which is maintained on the disk. Operating System Concepts
Directory Structure • A collection of nodes containing information about all files. Directory Files F 1 F 2 F 3 F 4 F n • Both the directory structure and the files reside on disk. Operating System Concepts
File Operations • Create • Allocate space • Create directory entry • Open • Copy the directory structure on disk to memory. • Read, Write • Identified file • Specified position • Specified data • Update directory • Reposition within file – file seek • Close • Copy the directory structure in memory to disk. • Delete • Release space • Delete directory entry • Rename, Truncate, Append, Copy (can be formed from others) Operating System Concepts
Access Methods • Sequential Access read next write next reset (rewind) no read after last write • Direct Access read n write n position to n read next write next n = relative block number (start, current, end) Operating System Concepts
Directory Operations • Search for a file • By name/pattern • By other attributes • Create a file • Add a new entry • Delete a file • Delete entry • List a directory • Rename a file • Potentially moves file in directory structure • Traverse the file system • E.g., for backups Operating System Concepts
Organize the Directory (Logically) to Obtain • Efficiency – locating a file quickly • Grouping – logical grouping of files by properties, (e.g., all Java programs, all games, …) • Naming – convenient to users. • Two users can have same name for different files. • The same file can have several different names Operating System Concepts
Tree-Structured Directories Operating System Concepts
Tree-Structured Directories • Efficient searching • Grouping capability • Absolute and relative pathnames • Relative to current directory • Absolute to • Root • Current (which absolute to root) • No sharing yet Operating System Concepts
Acyclic-Graph Directories Operating System Concepts
Acyclic-Graph Directories • Have shared subdirectories and files • Allows multiple names for one file or directory • Allows sharing of files and directories • Hard links • Multiple directory nodes refer to the same file • No precedence • Problems of directory entry consistency - UNIX solves with inodes • Delete file (only) when there are no links • Alternatively, have back pointers and delete all directory entries and file when one directory entry is deleted • Beware cyclic directory links (not permitted in UNIX now) • Symbolic (soft) links • Gives name of another directory entry (could also be soft) • Deletion just deletes the link • Have to deal with hanging links when hard link is deleted • Cyclic links are possible Operating System Concepts
General Graph Directory • How do we guarantee no cycles? • Allow only links to file not subdirectories. • Garbage collection. • Every time a new link is added use a cycle detectionalgorithm to determine whether it is OK. Operating System Concepts
Protection • File owner/creator should be able to control: • what can be done • by whom • Modes access: • Files: read, write, execute, delete • Directories: read, write, make current Operating System Concepts
Access Lists and Groups • Access lists provide fine grained control (Windows NT) • Very large • Requires variable size directory entries • Classes of users RWX a) owner access 7 1 1 1 RWX b) group access 6 1 1 0 RWX c) public access 1 0 0 1 • Password protection • Files (too many) • Subdirectories (ala TOPS-20) • Partition (ala VM/CMS) • All user files Operating System Concepts