Monday, February 21, 2011

6.0 FILE SYSTEM MANAGEMENT

File System

Also referred to as simply a file system or filesystem.
The system that an operating system or program uses to organize and keep track of files.
For example, a hierarchical file system is one that uses directories to organize files into a tree structure. 
Although the operating system provides its own file management system, you can buy separate file management systems.
o  These systems interact smoothly with the operating system but provide more features, such as improved backup procedures and stricter file protection. 


File Sharing
Sharing of files on multi-user systems is desirable
Sharing may be done through a protection scheme
On distributed systems, files may be shared across a network
Network File System (NFS) is a common distributed file-sharing method

File Sharing – Multiple Users
User ID's identify users, allowing permissions and protections to be per-user
Group ID's allow users to be in groups, permitting group access rights

File Sharing – Failure Modes
Remote file systems add new failure modes, due to network failure, server failure
Recovery from failure can involve state information about status of each remote request
Stateless protocols such as NFS include all information in each request, allowing easy recovery but less security

File Sharing – Consistency Semantics
Consistency semantics specify how multiple users are to access a shared file simultaneously
ú Similar to process synchronization algorithms
  •       Tend to be less complex due to disk I/O and network latency (for remote file systems)
ú Andrew File System (AFS) implemented complex remote file sharing semantics
ú 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
ú AFS has session semantics
  •      Writes only visible to sessions starting after the file is closed

File-system Organization




Operations Performed on Directory

Search for a file
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system

Single-Level Directory
A single directory for all users


Naming problem
Grouping problem

Two-Level Directory
Separate directory for each user


Path name
Can have the same file name for different user
Efficient searching
No grouping capability

Tree-Structured Directories


Efficient searching
Grouping Capability
Current directory (working directory)
cd /spell/mail/prog
type list

File Map
File mapping is the association of a file's contents with a portion of the virtual address space of a process.
The system creates a file mapping object (also known as a section object) to maintain this association.
file view is the portion of virtual address space that a process uses to access the file's contents. 
File mapping allows the process to use both random input and output (I/O) and sequential I/O.
It also allows the process to work efficiently with a large data file, such as a database, without having to map the whole file into memory.
Multiple processes can also use memory-mapped files to share data.
Processes read from and write to the file view using pointers, just as they would with dynamically allocated memory.
The use of file mapping improves efficiency because the file resides on disk, but the file view resides in memory.
Processes can also manipulate the file view with the VirtualProtect function.




Open 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