CSE 321 – File System Complete Notes (Teaching + Exam Q&A)
This document contains all File System related content taught so far and will be
continuously expanded. It includes:
- Teaching explanations with real-life examples
- Exam-oriented answers based on previous semester final questions
- Quiz-ready short answers
(Aligned with Summer 2024–2025 question patterns)
PART A: TEACHING MODE (Conceptual Understanding)
1. File System Basics
A file system is a method used by the operating system to organize, store, retrieve, and
manage data on storage devices.
Real-life example:
Think of a library:
- Books = files
- Index pages = inodes
- Library register = bitmaps
2. Files and Metadata
A file is a collection of related data stored on disk and identified by a name.
Metadata is data about the file, not the file content.
Examples: file size, permissions, owner, timestamps, inode number.
Important:
- File data is stored in data blocks
- Metadata is stored in the inode
3. Inodes
An inode (index node) is a data structure that stores all metadata of a file except its name.
Inode contains:
- File type
- File size
- Owner and group ID
- Permissions
- Timestamps
- Pointers to data blocks
- Link count
Directories map file names to inode numbers.
4. Inode Bitmap and Data Bitmap
A bitmap is a sequence of bits used to track allocation status.
Inode Bitmap:
- Tracks free and used inodes
Data Bitmap:
- Tracks free and used data blocks
File creation requires:
- One free inode
- One or more free data blocks
5. File Operations
Common file operations:
- create
- open
- read
- write
- seek
- close
- delete
read() operation:
- Accesses inode
- Reads data blocks
- Updates file offset
- May update access time
- Does NOT modify inode bitmap or data bitmap
6. Links
Hard Link:
- Same inode
- Increases link count
- File deleted only when link count becomes zero
Symbolic Link:
- Different inode
- Stores pathname of target file
- Breaks if target file is deleted
7. Journaling and Crash Consistency
Crash consistency problem occurs when system crashes during file system updates.
Journaling:
- Writes updates to a journal before applying them to disk
- Ensures recovery after crash
Metadata journaling logs only metadata.
Data journaling logs both data and metadata.
Write ordering rule:
- Data blocks must be written before metadata commit
8. FSCK vs Journaling
FSCK (File System Consistency Check):
- Scans entire disk after crash
- Slow for large disks
Journaling:
- Uses journal replay
- Faster crash recovery
Journaling reduces but does not eliminate the need for FSCK.
PART B: EXAM MODE (Previous Semester Style Q&A)
Important Exam Answers
Q: What is an inode?
A: An inode is a data structure that stores all metadata of a file except its name.
Q: Why can a disk have free blocks but no free inode?
A: Because inode bitmap is full, and file creation requires a free inode.
Q: Does read() modify data bitmap?
A: No. read() does not allocate or free data blocks.
Q: When is file data deleted?
A: When link count becomes zero.
Q: Why is metadata journaling used?
A: It ensures metadata consistency with better performance.
Exam Keywords to Use
- metadata
- inode number
- allocation status
- crash consistency
- journal replay
- link count