CSS Prepare

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

MethodHow it worksBest suited for
Sequential AccessRecords read/written strictly in order from the start; reaching record N requires reading through N−1 firstBulk processing, magnetic tape, log files
Direct (Random) AccessAny block can be accessed directly by its block number, no need to pass through preceding blocksDatabases, 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 recordSystems 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

  1. Sequential organisation — simple, efficient for batch processing, slow for locating one record.
  2. Indexed (Indexed-Sequential) organisation — sequential order plus an index for fast lookup.
  3. 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)

AspectUNIX (e.g. ext4)Windows (NTFS)
StructureSingle hierarchical tree rooted at "/"; all devices mounted as subdirectories of one treeMultiple independent root volumes, each with its own drive letter (C:, D:, …)
PermissionsSimple owner/group/other model, read-write-execute (rwx) bitsAccess Control Lists (ACLs) — fine-grained, per-user/per-group permissions
Metadata structureInodes — data structures holding metadata + block pointersMaster File Table (MFT) tracking metadata and locations
NamingCase-sensitiveCase-insensitive but case-preserving
Philosophy"Everything is a file" — devices/pipes treated as files tooRicher 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)

MethodHow it worksStrengthWeakness
Contiguous AllocationEach file occupies a single run of consecutive disk blocks, located by (start block, length)Excellent sequential AND direct-access performance; minimal seek movementExternal fragmentation; a file cannot easily grow if blocks after it are already in use
Linked AllocationEach block holds a pointer to the next block of the file (like a linked list); the directory stores only the first (and often last) blockNo external fragmentation; files can grow freelyPoor 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 blocksSupports efficient direct access (jump straight to the index block, then the desired data block) with no external fragmentationIndex 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

TechniqueHow 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 ListFree 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
GroupingThe 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
CountingSince 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

StructureDescriptionLimitation
Single-LevelOne directory for the entire file systemAll files need unique names; no organization for multiple users
Two-LevelOne directory per user, all under one master directoryUsers are isolated from each other but still cannot organize their own files into sub-groups
Tree-StructuredDirectories 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-GraphAllows shared subdirectories/files via links (hard links/symbolic links) while still disallowing cyclesA shared file needs careful reference-counting so deleting it from one path doesn't break other links; naming can get complex
General GraphLike acyclic-graph but cycles are allowedNeeds 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

YearQuestionMarks
2017Direct Access vs Random Access storage methods8
2019Sequential Access vs Indexed Sequential Access, with example6
2020Three file organisation techniques + basic Linux file system security6
2022Functions of the Logical File System4
2024UNIX vs Windows file systems — structure, permissions, organization, suitability7

⚠️ 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 with chown and chgrp
    • 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.

BasisUNIX/Linux (ext4, XFS)Windows (NTFS)
StructureA single tree rooted at /, with other file systems mounted into itSeparate drive letters (C:, D:), each a tree
Path separator and case/, case-sensitive\, case-insensitive (case-preserving)
PermissionsOwner, group, others with r/w/x bits, and optional ACLsDetailed ACLs per user or group (full control, modify, read and so on)
File organisationInodes hold metadata and block pointers. Everything is a file (devices too)Master File Table (MFT) records for every file
ExtrasLinks, journaling, mount pointsJournaling, 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).