Title: File Management, file system
1File Management, file system
2File-System Structure
- File structure
- Logical storage unit
- Collection of related information
- File system resides on secondary storage (disks)
- File system organized into layers
- File control block storage structure consisting
of information about a file
3Model of I/O organization
Logical I/O
Basic File System
Basic I/O Supervisor file I/O initiation and
termination scheduling access to optimize
performance
4File System I/O and Software Architecture
Basic File System physical I/O, placement,
buffering of blocks
Logical I/O Enables programs to access records
provides general-purpose record I/O capability
maintains basic data about file
Basic I/O Supervisor file I/O initiation and
termination scheduling access to optimize
performance
create,delete open, close, read, write, append,
seek get-attributes, set-attributes
5File Structure
- Some kinds of files
- byte sequence
- record sequence
- tree
6File Operations
- File is an abstract data type
- Create
- Write
- Read
- Reposition within file
- Delete
- Truncate
- Open(Fi) search the directory structure on disk
for entry Fi, and move the content of entry to
memory - Close (Fi) move the content of entry Fi in
memory to directory structure on disk
7File Attributes
- Name only information kept in human-readable
form - Identifier unique tag (number) identifies file
within file system - 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, and user identification data for
protection, security, and usage monitoring - Information about files are kept in the directory
structure, which is maintained on the disk
8Access Methods
- Sequential Access
- read next
- write next
- reset
- no read after last write
- (rewrite)
- Direct Access
- read n
- write n
- position to n
- read next
- write next
- rewrite n
- n relative block number
9More access methods Indexed File
- Index provides lookup capability
- Contains key field and a pointer to the main file
- May be exhaustive or partial index
- Scheme may use multiple indexes for different key
fields - new records are added to an overflow file
structure
10More access methods The Hashed File
- Directly access a block at a known address
(using, e.g. modulo operation on the main key)
11A Typical File-system Organization
A.T. MOS fig of same concept
12Directory 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 Backups of these two structures are kept
on tapes
13Operations Performed on Directory
- Search for a file
- Create a file
- Delete a file
- List a directory
- Rename a file
- Traverse the file system
14Organize the Directory (Logically) to Obtain
- Efficiency locating a file quickly
- Naming convenient to users
- Two users can have same name for different files
- The same file can have several different names
- Grouping logical grouping of files by
properties, (e.g., all Java programs, all games,
)
15Single-Level Directory
- A single directory for all users
Naming problem Grouping problem
16Two-Level Directory
- Separate directory for each user
- Path name
- Can have the same file name for different user
- Efficient searching
- Limited grouping capability
17Tree-Structured Directories
- (sub)directory a file
- Grouping Capability
- Current directory (working directory)
- cd /spell/mail/prog
- type list
- Absolute or relative path name
18Acyclic-Graph Directories
- shared subdirectories and files
- Two different names (aliasing)
- w deletes list ? dangling ptr Solutions
- Backpointers, so we can delete all pointers
-Variable size records a problem - Entry-hold-count solution
- New directory entry type
- Link another name (pointer) to an existing file
- Resolve the link follow pointer to locate the
file
19Open Files
- Several pieces of data are needed to manage open
files - File pointer pointer to last read/write
location, per process that has the file open - File-open count counter of number of times a
file is open to allow removal of data from
open-file table when last processes closes it - Disk location of the file cache of data access
information - Access rights per-process access mode information
20In-Memory File System Structures
fd
FCBs
21File System Mounting
- A file system must be mounted before it can be
accessed - file system is mounted at a mount point
22File Sharing
- allow files to be shared among users
- issues
- Access rights
- Management of simultaneous access
23Access Rights (managed by owner)
- Knowledge User can only determine that the file
exists and who its owner is - Execute user can load and execute a program but
cannot copy it - Read user can read the file
- Append user can add data to the file but cannot
modify/delete contents - Update user can modify, deleted, and add to the
files data. - Change protection user can change access rights
granted to other users
24Domain Structure, Access Matrices
- Access-right ltobject-name, rights-setgt
- rights-set a subset of all valid operations on
the object.
- For a process in Di to do op on object Oj, op
must be in the access matrix. - Can be expanded to dynamic protection.
- Operations to add, delete access rights.
- Special access rights
- owner of Oi
- copy op from Oi to Oj
- control Di can modify Dj access rights
- transfer switch from domain Di to Dj
25Simultaneous Access
- Locks
- on entire file when it is to be updated
- on the individual records during the update (cf
2-phase locking in DBs) - OS may provide different read/write locks
- Mutual exclusion and deadlock are issues for
shared access
26Open File Locking
- Provided by some operating systems and file
systems - Mediates access to a file
- Mandatory or advisory
- Mandatory access is denied depending on locks
held and requested - Advisory processes can find status of locks and
decide what to do
27File Sharing Consistency Semantics
- Consistency semantics specify how multiple users
are to access a shared file simultaneously - Similar to Ch 7 process synchronization
algorithms - Unix file system (UFS) implements
- Writes to an open file visible immediately to
other users of the same open file - Sharing file pointer to allow multiple users to
read and write concurrently - Andrew File System (AFS) implemented complex
remote file sharing semantics - AFS has session semantics
- Writes only visible to sessions starting after
the file is closed
28Disks
29Secondary Storage Management
- Space must be allocated to files
- Must keep track of the space available for
allocation - Methods of File Allocation
- Contiguous allocation
- External fragmentation will occur
- Chained allocation
- Each block contains a pointer to next block
- No external fragmentation
- Best for sequential files
- Indexed allocation
- File allocation table contains a separate
one-level index for each file
30(No Transcript)
31(No Transcript)
32(No Transcript)
33(No Transcript)
34Combined Scheme UNIX
35Implementing Directories (1)
- (a) A simple directory
- fixed size entries
- disk addresses and attributes in directory entry
- (b) Directory in which each entry just refers to
an i-node
36Implementing Directories (2)
- Two ways of handling long file names in directory
- (a) In-line
- (b) In a heap
37Discussion
- Q how does the OS keep info on free/occupied
disk blocks (memory frames)? - What if file system is distributed/network-based?
38Free-Space Management
0
1
2
n-1
0 ? blocki free 1 ? blocki occupied
biti
???
Block number calculation
(number of bits per word) (number of 0-value
words) offset of first 1 bit
39Free-Space Management (Cont.)
- Bit map requires extra space
- Example
- block size 212 bytes
- disk size 230 bytes (1 gigabyte)
- n 230/212 218 bits (or 32K bytes)
- Easy to get contiguous files
- Linked list (free list)
- Cannot get contiguous space easily
- No waste of space
40Schematic View of Virtual File System
41Schematic View of NFS Architecture
- Network interface client-server protocol
- Uses UDP (over IP over most commonly- ethernet)
- Mounting and caching