File Fat Systsems Flashcards
(21 cards)
Virtual File-system
Common interface hides– File-system differences
Shared Files
If we allow multiple links to a file: Supporting links to directories
would allow loops
* Processes scanning
directories might get
trapped
* Not generally allowed
Common File Attributes
- Name
- Unique Identifier
- File type
- Location
- Size
- Access Control Lists/ Flags
- Time and Date (accessed, modified, …)
- Ownership (user/ group)
Common File System Operations
- Create
- Open
- Read
- Write
- Seek
- Close
- Link
- Unlink
Contiguous Allocation(File allocation)
Each file fills set of adjacent disk blocks in filesystem
Each process is allocated a single continuous block of memory.
Key Points:
Simple & fast: Easy to implement and access.
Base + Limit registers used for protection.
Drawback: Can lead to external fragmentation (small unused holes between blocks).
Hard to grow: If a process needs more memory, it might need to move.
Linked-List Allocation
Avoids external fragmentation problem as Blocks no longer need to be contiguous (we accept overhead)
* All blocks can be used, but pointers take space– Fragmentation (in this case internal) confined to last block
* Only offers sequential access– Must follow each block link to reach given file position
In linked list allocation, each file is stored as a linked list of disk blocks.
Each block stores:
Data, and a pointer to the next block in the file.
Indexed Allocation
Each file has an index block that contains pointers to all the disk blocks used by the file.
Key Points:
No need for contiguous space — blocks can be scattered anywhere on disk.
Solves the problem of external fragmentation.
Allows random access to any block of the file.
* Can support holes *– i.e. we don’t allocate space for ‘empty’, 0 filled blocks–
pros and cons of index allocation
Handles growing files easily.
No external fragmentation.
Fast random access.
Cons:
The index block itself must fit in memory.
Large files may require multi-level indexing (slower).
Linked-List: File Allocation Table (FAT)
- Separates pointers from data blocks
- File Allocation Table (FAT) holds block numbers
– Keep multiple on-disk copies of FAT for resilience
Typically copy of whole FAT can reside in memory
– Allows fast access to any block in any file
Every block on disk has an entry in the FAT.
Each FAT entry stores the number of the next block in the file.
Files are chains of blocks linked by FAT entries, not direct pointers in blocks.
Inode (Index Node)
Stores metadata about a file: permissions, owner, timestamps, size, block pointers, etc.
Has direct, single indirect, double indirect, and triple indirect pointers to data blocks.
Does not store the filename – that’s handled in the directory entry.
Direct vs Indirect Pointers
Direct: Point straight to data blocks.
Single Indirect: Points to a block that holds more block pointers.
Double Indirect: A pointer to a block that holds pointers to other blocks of pointers.
Triple Indirect: Three levels deep; allows large file support.
Reference Count (Hard Links)
Counts how many directory entries point to the inode.
When count = 0, data can be deleted.
Hard links can’t span file systems or point to directories
Symbolic Links (Soft Links)
A file that contains a path to another file.
Can span across file systems.
Can point to non-existent files (broken links).
Directory Structure
A directory is a file containing mappings of filename → inode number.
Can become fragmented.
Inodes and directory entries are separate.
Efficiency and Waste
Larger block sizes = more data per block, better for large files but may waste space for small ones.
Systems sometimes allow block fragments to minimize waste.
Balance is crucial between access speed and space efficiency.
If you always use small blocks, large files will be slow to access.
If you always use large blocks, small files will waste space.
Open File Descriptor Table
Each process has its own File Descriptor Table.
Maps to entries in the system-wide Open File Table.
Includes file position and inode pointer.
Children processes inherit file descriptors from the parent (important for pipes, redirection).
Kernel Tables & Inode Caching
The kernel stores inodes in an Active Inode Table to speed up file access.
Inode IDs are valid only within their filesystem—kernel uses a hash of inode + device ID.
Each process has its own open file table, while the system maintains global open files and inode cache.
Buffering & Block Caching
Processes read and write bytes
– Disks handle blocks
Buffering bridges this gap using a buffer cache:
Holds disk blocks in memory.
Enables read-ahead and write-behind.
Improves efficiency using LRU (Least Recently Used) strategies.
Filesystem Flush & Sync
Buffers marked “dirty” are scheduled to be written to disk.
The system periodically flushes dirty buffers (e.g. on shutdown) to prevent data loss.
sync() system call can force this flush.
Delayed Allocation
Writing data is delayed to allow efficient allocation.
When data is finally written, it’s often possible to allocate a contiguous block run, reducing fragmentation.
Extents
Modern filesystems (e.g., ext4) use extents
stores files
Improves read speed, reduces metadata, and minimizes fragmentation.
Each extent records:
Logical file block start.
Number of blocks.
Starting disk block.