Transcript FileSystems
File Concept
Contiguous logical address space
Smallest user allocation
Non-volatile
Types:
Data
numeric
character
binary
Program
Source
Script
Binary
Operating System Concepts
11.1
Silberschatz, Galvin and Gagne 2002
File Types – Name, Extension
Operating System Concepts
11.2
Silberschatz, Galvin and Gagne 2002
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
11.3
Silberschatz, Galvin and Gagne 2002
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
11.4
Silberschatz, Galvin and Gagne 2002
Directory Structure
A collection of nodes containing information about all
files.
Directory
Files
F1
F2
F3
F4
Fn
Both the directory structure and the files reside on disk.
Operating System Concepts
11.5
Silberschatz, Galvin and Gagne 2002
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
11.6
Silberschatz, Galvin and Gagne 2002
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
11.7
Silberschatz, Galvin and Gagne 2002
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
11.8
Silberschatz, Galvin and Gagne 2002
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
11.9
Silberschatz, Galvin and Gagne 2002
Tree-Structured Directories
Operating System Concepts
11.10
Silberschatz, Galvin and Gagne 2002
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
11.11
Silberschatz, Galvin and Gagne 2002
Acyclic-Graph Directories
Operating System Concepts
11.12
Silberschatz, Galvin and Gagne 2002
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
11.13
Silberschatz, Galvin and Gagne 2002
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.
Operating System Concepts
11.14
Silberschatz, Galvin and Gagne 2002
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
11.15
Silberschatz, Galvin and Gagne 2002
Access Lists and Groups
Access lists provide fine grained control (Windows NT)
Very large
Requires variable size directory entries
Classes of users
a) owner access
7
b) group access
6
c) public access
1
RWX
111
RWX
110
RWX
001
Password protection
Files (too many)
Subdirectories (ala TOPS-20)
Partition (ala VM/CMS)
All user files
Operating System Concepts
11.16
Silberschatz, Galvin and Gagne 2002