Terms such as file descriptor, inode, directory entry, block, and index block are often memorised separately, so an allocation calculation or path-resolution question exposes the gaps. A single name-to-block trace connects pathname resolution, open-file state, allocation metadata, permissions, and crash consistency. Seek-time and disk-head algorithms are separate from file-block placement; File systems and disk scheduling in OS connects the two for broader GATE CS preparation.
The file-system mental model
A file is a named logical byte sequence. A directory maps names to file-system objects. Object metadata includes an identifier, type, size, owner, permissions, timestamps, link count, and block-location information. The human-readable name need not be inside the inode or file control block (FCB).
The application call names the bytes, and the file descriptor gives the process a handle for later operations. The per-process open-file entry holds this open's offset and access mode, while the system-wide open-file entry lets separate opens or shared handles coexist. The inode or FCB carries metadata and the block map, and the allocation layer turns logical block numbers into device blocks. Implementations vary, but this model handles standard questions.
Term | What it identifies | What can change independently |
|---|---|---|
Filename | A directory name | Name, without replacing the object |
Descriptor | One process's open handle | Handle, without renaming the file |
Inode | Object and metadata | Directory name, without changing the inode |
Physical block | A data location | Location, while the logical file remains |
The system-call path: open, read, seek, write, close
Suppose open("notes.txt") returns descriptor 3. The open call resolves the pathname once, allocates an open-file entry with the access mode and an offset starting at 0, then returns the handle fd 3, so later calls do not re-walk the path. The offset belongs to open-file state rather than the inode because two independent opens of the same file need separate positions. Each read or write advances that per-open cursor, seek repositions it, and close drops the reference.
At offset 2048, read(fd, 600) requests bytes 2048 through 2647: 2647 - 2048 + 1 = 600. The next offset is 2648. After lseek(fd, 4096, SEEK_SET), reading starts at byte 4096.
Sequential access suits a log scan, direct access jumps to a database record, and indexed access locates part of a large structured file.
An access method describes how a program reaches data. An allocation method describes how the file's data blocks are placed and tracked. They are not synonyms.
Directories, paths, and links
A single-level directory has one namespace; a two-level design separates users; a tree supports nesting; an acyclic graph permits sharing without directory cycles.
An absolute path starts at root; a relative path starts at the current directory. Trace /home/asha/os/notes.txt:
Root maps
hometo inode10.Directory block
200mapsashato inode24.Directory block
315mapsosto inode31.Directory block
410mapsnotes.txtto inode44.
Inode 44 supplies metadata and block mapping. open returns descriptor 3, which reaches inode 44 through open-file state. Renaming the entry need not change the object.
A hard link is another entry for the same object; a symbolic link stores a pathname. Deleting a name need not erase data immediately. Reclamation depends on link and open-reference state.

Allocation and free-space methods compared
The three allocation methods differ in how they track blocks and balance access, growth, and space costs, and no method is universally best.
Method | How blocks are tracked | Main trade-off |
|---|---|---|
Contiguous | Start block plus length | Fast sequential and direct access, but growth may relocate blocks and external fragmentation can block a large request |
Linked | Blocks chained with a pointer per block | Easy growth and sequential access, but costly direct access and pointer overhead |
Indexed | Addresses stored in an index block | Supports direct access and growth, but costs index space |
Useful formulas are:
Data blocks required
= ceil(file size / usable bytes per data block).Last-block internal fragmentation
= allocated data bytes - file size.One-level index entries
= floor(index-block bytes / pointer bytes).Maximum directly indexed data
= entries x data-block bytes.
A bitmap stores one status bit per block, making runs easy to scan, while a free list makes each free block point to the next with no extra table. Grouping packs several free-block addresses into one free block, and counting stores each run's start plus length, which suits clustered free space. Extents track a whole run by start and length, so one pointer covers many blocks. External fragmentation means free space exists but not as one adequate contiguous run, whereas internal fragmentation is unused space inside an allocated block.
A worked allocation problem, start to finish
Assume 1024-byte blocks, a 10,500-byte file, and 4-byte addresses. Contiguous and indexed allocation keep their metadata outside the data blocks, so each block carries 1024 bytes of file data. Linked allocation stores one 4-byte pointer inside each block, leaving 1020 bytes for file data. Free extents are 40-43, 70-75, and 90-96.
The inclusive extents contain 4, 6, and 7 blocks: 4 + 6 + 7 = 17 free blocks, with a largest run of 7.
Calculate each requirement:
Contiguous or indexed data blocks required
= ceil(10,500 / 1024) = ceil(10.25390625) = 11.Allocated data capacity
= 11 x 1024 = 11,264 bytes.Last-block internal fragmentation
= 11,264 - 10,500 = 764 bytes.Linked-allocation data blocks required
= ceil(10,500 / 1020) = ceil(10.29411765) = 11.
Contiguous allocation fails because no 11-block run exists, despite 17 free blocks.
Linked allocation can use [40, 41, 42, 43, 70, 71, 72, 73, 74, 75, 90]. Its 11 pointer fields consume 11 x 4 = 44 bytes, leaving 11 x 1020 = 11,220 bytes of payload capacity and 11,220 - 10,500 = 720 bytes of unused payload capacity. Indexed allocation can use block 96 to point to those 11 data blocks, consuming 11 + 1 = 12 blocks.
A 1024-byte index block holds 1024 / 4 = 256 addresses. One-level direct indexing covers 256 x 1024 = 262,144 bytes = 256 KiB of file data.
For logical offset 5300, floor(5300 / 1024) = 5, with remainder 5300 - (5 x 1024) = 180. Zero-based entry 5 points to physical block 71, so the byte is at offset 180 within block 71. Entry 5 is the sixth address.

Deletion, protection, and crash consistency
Deletion updates a directory entry and link metadata, then returns blocks when reclamation conditions are met. Our indexed example must eventually release data blocks 40, 41, 42, 43, 70, 71, 72, 73, 74, 75, 90, and index block 96.
Unix-style permission 640 sets three octal digits for owner, group, and others, in order. Each digit combines read, write, and execute permissions, so 6 means read plus write, 4 means read only, and 0 means no access. The owner can read and write it, the group can only read, and others get nothing. This Unix model is not a universal file-system rule.
With write-back, a change may become visible before it reaches storage. A crash between data, metadata, and free-space updates can therefore leave the file system inconsistent; ordering constrains the write sequence to reduce unsafe states. Journalling records selected changes so recovery can reach a consistent state. Metadata journalling restores structural consistency across directories, inodes, and free-space accounting, but does not guarantee that every in-flight user-data byte survived the crash.
How GATE and interviews test file management
The official GATE 2026 CS syllabus lists “File systems” under Operating System, but gives no file-management subtopic weightage. The syllabus confirms the topic's scope, not its marks or trend.
The official GATE 2022 CS paper includes a question on inserting a block between the 50th and 51st blocks of a 100-block file under contiguous and linked allocation. It tests update cost, not a future trend. Operating Systems for GATE places this topic in the wider subject map.
Common prompts ask you to:
compute block or pointer capacity;
translate offsets and trace paths;
compare allocation growth costs;
distinguish hard and symbolic links;
explain what
openchanges.
Try broader Operating System MCQs after mastering the model, but solve focused allocation questions first.
Common traps and the next step
Avoid floor where block count needs ceiling, forgetting the index block, mixing bytes with KiB or blocks, and treating total free space as a contiguous run. Remember that zero-based entry 5 is sixth. Do not confuse access with allocation or ignore pointers stored inside payload blocks.
The short version
Names resolve through directories.
Descriptors represent open state.
Metadata identifies and describes the object.
Allocation maps logical data to blocks.
Free-space structures track reusable blocks.
Consistency mechanisms protect metadata transitions.
Solve File Systems and Allocation MCQs, then redo the example unaided. Use GATE Guidance by Sanchit Sir for exam-structured study or Zero to Hero: Complete CS Course for broader CS fundamentals.




