Upload
bendek
View
28
Download
0
Embed Size (px)
DESCRIPTION
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 - PowerPoint PPT Presentation
Citation preview
Silberschatz, Galvin and Gagne 200211.1Operating System Concepts
File Concept
Contiguous logical address space Smallest user allocation Non-volatile Types:
Data numeric character binary
Program Source Script Binary
Silberschatz, Galvin and Gagne 200211.2Operating System Concepts
File Types – Name, Extension
Silberschatz, Galvin and Gagne 200211.3Operating 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
Silberschatz, Galvin and Gagne 200211.4Operating 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.
Silberschatz, Galvin and Gagne 200211.5Operating System Concepts
Directory Structure
A collection of nodes containing information about all files.
F 1 F 2F 3
F 4
F n
Directory
Files
Both the directory structure and the files reside on disk.
Silberschatz, Galvin and Gagne 200211.6Operating 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)
Silberschatz, Galvin and Gagne 200211.7Operating System Concepts
Access Methods
Sequential Accessread nextwrite next reset (rewind)no read after last write
Direct Accessread nwrite nposition to nread nextwrite next n = relative block number (start, current, end)
Silberschatz, Galvin and Gagne 200211.8Operating 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
Silberschatz, Galvin and Gagne 200211.9Operating 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
Silberschatz, Galvin and Gagne 200211.10Operating System Concepts
Tree-Structured Directories
Silberschatz, Galvin and Gagne 200211.11Operating 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
Silberschatz, Galvin and Gagne 200211.12Operating System Concepts
Acyclic-Graph Directories
Silberschatz, Galvin and Gagne 200211.13Operating 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
Silberschatz, Galvin and Gagne 200211.14Operating 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 detection
algorithm to determine whether it is OK.
Silberschatz, Galvin and Gagne 200211.15Operating 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
Silberschatz, Galvin and Gagne 200211.16Operating System Concepts
Access Lists and Groups Access lists provide fine grained control (Windows NT)
Very large Requires variable size directory entries
Classes of usersRWX
a) owner access 7 1 1 1RWX
b) group access 6 1 1 0RWX
c) public access 1 0 0 1
Password protection Files (too many) Subdirectories (ala TOPS-20) Partition (ala VM/CMS) All user files