File Systems, Pt. 1 Flashcards
Two File System Design Problems
- Interface (how file system looks to users)
- Implementation (data structures/algorithms to map logical file systems onto physical devices)
File System: Layered Structure
Application programs -> logical file system -> file-organization module -> basic file system -> I/O control -> devices
Logical File System
- View files as logical blocks
- Maintain metadata
File-Organization Module
Maps logical blocks to physical blocks
Basic File System
View data as physical blocks present on devices
I/O Control
- Device drivers and device-specific instructions
- Read/write bit patterns to device controller
From user’s perspective, file is a…
…storage unit
A file is a named collection of…
…related information recorded on a secondary storage
File Attributes
- Name (only information kept in human-readable form)
- Identifier (unique tag identifies file within file system)
- Type (needed for systems that support different types)
- Location (pointer to file location on device)
- Size (self explanatory)
- Protection (rwx)
- Time/date/user identification (for protection and usage monitoring)
Information about files is kept in a…
…directory, which is maintained on the disk as well
Primitive File Operations
- Create
- Write
- Read
- Reposition within file
- Delete
- Truncate
To perform operations on a file, we must first…
…open it (duh)
Directory
- A logical grouping of files
- Contains an entry for each file under it
- Some systems treat directories just as files
Directory Operations
- Search for a file
- Create a file
- Delete a file
- List a directory
- Rename a file
- Traverse the system
Design the directory architecture to achieve:
- Efficiency (quickly locating files)
- Naming (convenient to users; ie. two users can have the same name for different files, the same file can have different names, etc.)
- Grouping (logical grouping of files by properties)
____ structured directories are the most common
Tree
Links make tree structures complicated. Why?
The directory is no longer a tree because different files can link to each other outside of the hierarchy
Problem with Acyclic Graph Directories
When a file gets deleted, links may still point to it.
Solutions for Dangling Links in Unix
- Symbolic link (let the user figure it out)
- Hard link (keep a reference counter, and only delete the file after all links to it have been deleted)
Problems with General Graph Directories
When searching for a file or backing up the system, we may visit the same directory several times, or even infinite times if there are cycles.
Solution to Cycles in General Graph Directories
Ignore links when traversing the file system
A file system must be ____ before it can be accessed
Mounted
How File System Mounting Works
- OS is given name of the device and a mount point
- OS checks device to make sure it has a valid file system
- OS makes the new file system available
True or False: Multiple file systems can be mounted at the same time
True (typically)
Each file system has its own:
- File/directory structure
- Allocation methods
- Algorithms and data structure
Virtual File System
-VFS layer shields users from differences between file systems
VFS provides a ____ to all file systems
Common interface (API)
To implement a file system, we need:
- On-disk structures
- In-memory structures
On-disk Structure Examples
Directory structure, data blocks, number of blocks, location of free blocks, boot information
In-memory Structures:
- Improve performance (caching)
- Manage file system
Volume Control Block (VCB)
- On-disk structure
- Information about the volume (partition)
- Num. blocks, block size, free block count, etc.
File Control Block (FCB)
- On-disk structure
- Details about each file (one per file)
- Size, location of data blocks, permissions, ownership
- Unix calls it “inode”
Mount Table
- In-memory structure
- Info on each mounted volume (partition)
Directory Structure Cache
- In-memory structure
- Info on recently accessed directories
System-wide Open-file Table
- In-memory structure
- Copy of the FCB of each open file in the system
- Info on which process is currently using which file
Per-process Open-file Table
- In-memory structure
- Pointer to entry in the system-wide open-file table
- Info regarding file usage by the current process (current file pointer, open mode, etc.)