optional · CSS study notes
File Systems
CSS Optional — Paper-II, Section-A · P-II.III.VII
1. File Concept & Attributes
A file is a named collection of related information recorded on secondary storage. Typical attributes tracked by the OS: name, identifier (unique internal number), type, size, location (pointer to storage blocks), protection (permissions), and timestamps (creation/last-modified/last-accessed).
2. File Access Methods
| Method | How it works | Best suited for |
|---|---|---|
| Sequential Access | Records read/written strictly in order from the start; reaching record N requires reading through N−1 first | Bulk processing, magnetic tape, log files |
| Direct (Random) Access | Any block can be accessed directly by its block number, no need to pass through preceding blocks | Databases, indexed files, magnetic/solid-state disks |
| Indexed Sequential Access (ISAM) | Records kept in sequential order PLUS a separate index maps key values to approximate locations — a fast index lookup narrows the search, then a short sequential scan finds the exact record | Systems needing both fast direct lookup and full sequential scans, e.g. a keyed database table |
Random Access (as a memory/storage property, distinct from "Direct Access" file method): any location can be accessed in approximately equal time regardless of physical position — true of RAM and, at the block level, of disks; NOT true of sequential media like magnetic tape.
3. File Organization Techniques
- Sequential organisation — simple, efficient for batch processing, slow for locating one record.
- Indexed (Indexed-Sequential) organisation — sequential order plus an index for fast lookup.
- Direct/Hashed organisation — a hash function maps a key directly to a storage location, giving near-O(1) average access without an index structure.
4. Logical File System — Functions
The Logical File System layer manages metadata and provides the file abstraction to applications (as opposed to the physical layer that manages actual disk blocks):
- Maintains the directory structure (hierarchy, naming).
- Manages file metadata (owner, permissions, size, timestamps, location pointers) typically in a File Control Block (FCB) / inode.
- Translates symbolic file names into the identifiers lower layers use.
- Enforces access control — checks permissions before allowing an operation.
- Presents files as a simple byte/record stream, hiding physical block-allocation details.
5. UNIX vs Windows File Systems (a favourite comparative question)
| Aspect | UNIX (e.g. ext4) | Windows (NTFS) |
|---|---|---|
| Structure | Single hierarchical tree rooted at "/"; all devices mounted as subdirectories of one tree | Multiple independent root volumes, each with its own drive letter (C:, D:, …) |
| Permissions | Simple owner/group/other model, read-write-execute (rwx) bits | Access Control Lists (ACLs) — fine-grained, per-user/per-group permissions |
| Metadata structure | Inodes — data structures holding metadata + block pointers | Master File Table (MFT) tracking metadata and locations |
| Naming | Case-sensitive | Case-insensitive but case-preserving |
| Philosophy | "Everything is a file" — devices/pipes treated as files too | Richer per-object security model for desktop/enterprise use |
Both support journaling for crash recovery. UNIX's simpler, uniform model suits portable, scriptable, multi-user server environments; NTFS's richer ACL-based model suits Windows' typical desktop/enterprise environments needing granular per-user security control.
Linux file security basics: Discretionary Access Control — every file/directory has an owner (uid) and group (gid), plus three rwx permission triplets (owner/group/other), shown symbolically (rwxr-xr--) or in octal (e.g. 754). Special bits (setuid, setgid, sticky bit) grant temporary elevated privileges or restrict deletion in shared directories like /tmp. Beyond this basic model, Linux also supports ACLs and Mandatory Access Control frameworks (SELinux, AppArmor).
6. File Allocation Methods (how a file's blocks are laid out on disk — a very frequently asked comparison)
| Method | How it works | Strength | Weakness |
|---|---|---|---|
| Contiguous Allocation | Each file occupies a single run of consecutive disk blocks, located by (start block, length) | Excellent sequential AND direct-access performance; minimal seek movement | External fragmentation; a file cannot easily grow if blocks after it are already in use |
| Linked Allocation | Each block holds a pointer to the next block of the file (like a linked list); the directory stores only the first (and often last) block | No external fragmentation; files can grow freely | Poor direct access (must follow pointers from the start); pointer storage overhead; a single corrupted pointer breaks the rest of the chain |
| Indexed Allocation (FAT/inode-style) | A separate index block holds pointers to all of the file's data blocks | Supports efficient direct access (jump straight to the index block, then the desired data block) with no external fragmentation | Index block itself is overhead; a single-level index block has a maximum file size limit unless multi-level/linked indexing is added |
FAT (File Allocation Table), used historically by DOS/Windows (FAT32), is a table-based variant of linked allocation: one big table in a reserved disk area holds "next block" pointers for every block on the volume, avoiding scattering pointers inside the data blocks themselves. UNIX inodes are the indexed-allocation approach: an inode holds direct pointers to the first several data blocks, plus single/double/triple indirect pointers (a pointer to a block that itself holds more pointers) to support arbitrarily large files without a fixed index-block-size limit — worth naming explicitly since it directly extends the UNIX-vs-Windows comparison already on this page.
7. Free-Space Management
| Technique | How it works |
|---|---|
| Bit Vector (Bitmap) | One bit per block (1=allocated, 0=free) — see the identical technique already covered for memory in [Memory Management]; simple, but scanning for a large free run can be slow on a big disk |
| Linked List | Free blocks are chained together via pointers stored within the free blocks themselves — no extra storage needed, but no fast way to find a large contiguous run |
| Grouping | The first free block stores the addresses of the next N free blocks (one of which itself stores the next N, and so on) — finds many free blocks quickly compared to a plain linked list |
| Counting | Since files are often allocated/freed in contiguous chunks, store (start-block, count) pairs instead of one entry per free block — much more compact when free space is not badly fragmented |
8. Directory Structures
| Structure | Description | Limitation |
|---|---|---|
| Single-Level | One directory for the entire file system | All files need unique names; no organization for multiple users |
| Two-Level | One directory per user, all under one master directory | Users are isolated from each other but still cannot organize their own files into sub-groups |
| Tree-Structured | Directories can contain subdirectories, forming a hierarchy (today's standard model) | A file can only exist at one place in the tree — no sharing without copying |
| Acyclic-Graph | Allows shared subdirectories/files via links (hard links/symbolic links) while still disallowing cycles | A shared file needs careful reference-counting so deleting it from one path doesn't break other links; naming can get complex |
| General Graph | Like acyclic-graph but cycles are allowed | Needs cycle detection (garbage collection or reference counting) to know when a file is truly no longer reachable and can be deleted |
🎯 CSS Exam Angle
"Compare UNIX and Windows file systems" is asked with an explicit second half — "how do these cater to diverse computing environments" (2024) — don't stop at the technical comparison table; close with one sentence linking each system's design to the environment it targets (UNIX → portable multi-user servers; NTFS → desktop/enterprise granular security). For allocation-method questions, always name a concrete real system alongside the abstract method (FAT for linked-style tables, UNIX inodes for indexed allocation).
📌 Past CSS Paper Frequency
| Year | Question | Marks |
|---|---|---|
| 2017 | Direct Access vs Random Access storage methods | 8 |
| 2019 | Sequential Access vs Indexed Sequential Access, with example | 6 |
| 2020 | Three file organisation techniques + basic Linux file system security | 6 |
| 2022 | Functions of the Logical File System | 4 |
| 2024 | UNIX vs Windows file systems — structure, permissions, organization, suitability | 7 |
⚠️ MCQ Traps
- "Direct Access" (a file-access method) ≠ "Random Access" (a storage-location property) — they're related but examined as separate terms; don't merge them into one answer without distinguishing the framing the question used.
- Indexed Sequential still keeps records in sequential order — the index is an addition, not a replacement, for the sequential ordering.
- NTFS is case-preserving, not case-sensitive — a very commonly mis-stated fact.
- Inodes (UNIX) vs MFT entries (NTFS) are functionally parallel (both hold metadata + block/location pointers) but examiners test that you know the correct name for each system.
- Contiguous allocation gives the best performance but the worst flexibility — a file that needs to grow may have no room, unlike linked or indexed allocation.
- Bit Vector, Linked List, Grouping, and Counting are free-space techniques — not allocation methods. Don't confuse "how a file's own blocks are found" (allocation) with "how the OS tracks which blocks are free" (free-space management); a question can ask about either independently.
📜 Past-Paper Questions & MCQs (CSS 2016–2026)
2019 · Paper-II · Q4(c) · 6 marks
Q. Explain the difference between sequential access and indexed sequential access in the context of file access, using a suitable example.
Ans.
- Sequential access: records are read or written one after another in order. To reach record n, the n − 1 earlier records are passed. It is simple and good for processing every record (a payroll run, a log file), but slow for finding one record.
- Indexed sequential access: the file is kept in key order and has an index (key → block address). To find a record the index is searched, then the system jumps to the block (direct access) and reads sequentially from there. It supports both fast single-record lookup and sequential processing.
- Example: an employee file. Sequential access reads employees 1, 2, 3 … to find employee 5000. With an index on the employee number, the system looks up 5000 in the index, jumps to its block and reads it. It is also possible to list all employees in order. (This is the idea of IBM ISAM and of database indexes.)
2020 · Paper-II · Q4(c) · 6 marks
Q. List and briefly define any three file organisation techniques. Also explain basic Linux file-system security.
Ans.
- Sequential file: records are stored one after another, in order (tape-like). Simple, but slow for random lookups.
- Direct (hashed) file: the record address is computed from the key by a hash function. It gives very fast direct access.
- Indexed sequential file: ordered records with an index for fast lookup (see above). Others: heap (pile) and indexed files.
- Linux file security:
- every file has an owner, a group and others
- three permissions each: read (r = 4), write (w = 2), execute (x = 1), for example
rwxr-xr--= 754 - changed with
chmod, and ownership changed withchownandchgrp - special bits: setuid, setgid and the sticky bit
- ACLs give finer control, and authentication is by user ID with passwords
2022 · Paper-II · Q3(b) · 4 marks
Q. Give an account of the different functions of the Logical File System.
Ans.
- The logical file system is the layer that works with metadata and the directory structure and does not deal with the disk blocks themselves.
- Functions:
- manages the directory structure and translates a file name into a file identifier (the file control block or inode)
- keeps file metadata (name, size, owner, permissions, timestamps) in the file control block
- performs protection and security checks (access permissions)
- manages open-file tables and file handles, and provides the system calls (open, read, write, close) to applications
- passes the request to the file-organisation module, which maps logical blocks to physical blocks
2024 · Paper-II · Q5(a) · 7 marks
Q. Compare the file systems of UNIX and Windows in terms of structure, permissions and file organisation. How do these systems cater to the needs of diverse computing environments?
Ans.
| Basis | UNIX/Linux (ext4, XFS) | Windows (NTFS) |
|---|---|---|
| Structure | A single tree rooted at /, with other file systems mounted into it | Separate drive letters (C:, D:), each a tree |
| Path separator and case | /, case-sensitive | \, case-insensitive (case-preserving) |
| Permissions | Owner, group, others with r/w/x bits, and optional ACLs | Detailed ACLs per user or group (full control, modify, read and so on) |
| File organisation | Inodes hold metadata and block pointers. Everything is a file (devices too) | Master File Table (MFT) records for every file |
| Extras | Links, journaling, mount points | Journaling, compression, encryption (EFS), alternate data streams |
- Diverse environments: UNIX file systems suit servers, scientific and embedded systems (stability, scripting, multi-user). NTFS suits desktops and enterprise networks (rich permissions, Active Directory integration, desktop features).