File Management in Operating Systems: From File Offset to Disk I/O
Follow report.bin from pathname lookup to inode mapping, byte-offset translation, physical placement and disk scheduling through one consistent worked example.
KnowledgeGate Team
Exam prep & CS education

File-management definitions feel easy until one question crosses several layers. A pathname becomes an inode, an inode supplies logical-block pointers, a byte offset reaches a physical block, and block placement becomes disk-head movement. This report.bin example turns its own scattered block map into the scheduler's queue, so file mapping and service order are solved as one trace.
Follow one file read through the operating system

An application calls open("/exam/report.bin"). Lookup finds report.bin -> inode 37, which supplies size, permissions and pointers. A read uses the open-file offset to select a logical block. The file system maps it to a physical block, the block layer submits I/O, the scheduler orders requests, and the driver completes the transfer. The OS returns bytes and advances the offset.
/exam/report.bin is a pathname; inode 37 identifies metadata; L5 is the sixth logical block; and P16 is a storage location. Lookup and mapping connect them. For path resolution, allocation comparisons, bitmap sizing and inode capacity, use File Management in Operating Systems: Complete GATE Guide with Worked Examples. File systems and disk scheduling in OS: allocation, directories and seek time compares file-system foundations with a standalone cylinder queue. This report.bin trace instead turns its own scattered block map into FCFS and SSTF input while preserving the same mapping across both service orders.
Separate the data structures learners commonly merge
Structure | Worked value | Job | Common confusion |
|---|---|---|---|
Directory entry |
| Maps a name to metadata | Does not contain all file data |
Inode or file control block | inode | Describes the file | Is not the per-process cursor |
System-wide open-file entry | Access state and reference count | Tracks an open instance | Is not the directory entry |
Per-process descriptor |
| Refers to the open instance | Is not a disk block |
File offset |
| Selects the next byte | Is not a physical address |
Free-space map | Unallocated-block marks | Supports allocation | Does not map this file's order |
Disk request queue | Pending track requests | Feeds the scheduler | Is not the directory tree |
Opening resolves inode 37 into an open-file entry and gives descriptor 3. read(fd, ..., n) starts at its offset and advances by bytes read. Descriptors may have separate or shared offsets depending on their origin. The filename does not fix the cursor.
Cache state changes the I/O count: a warm mapping needs no metadata read, while a cold mapping may need the directory, inode or index block.
Work the allocation and fragmentation values first
Let B = 1,024 bytes, S = 6,500 bytes, and each pointer be 4 bytes.
Data blocks required:
ceil(6,500 / 1,024) = ceil(6.34765625) = 7.Six full blocks hold
6 x 1,024 = 6,144 bytes.The seventh holds
6,500 - 6,144 = 356 bytes, leaving1,024 - 356 = 668 bytesunused.
Direct pointers map L0 -> 8, L1 -> 44, L2 -> 92, L3 -> 20. Index block 73, reached through the single-indirect pointer, maps L4 -> 84, L5 -> 16, L6 -> 108.
P73 holds 1,024 / 4 = 256 pointers. The scheme addresses 4 + 256 = 260 data blocks, or 260 x 1,024 = 266,240 bytes. This file uses seven blocks and three indirect entries.
Data blocks reserve 7 x 1,024 = 7,168 bytes; internal fragmentation is 7,168 - 6,500 = 668 bytes. P73 adds 1,024 bytes of metadata, not fragmentation. Excluding directory and inode blocks, storage is 7,168 + 1,024 = 8,192 bytes.
Translate byte offset 5,500 without guessing
Offsets and logical blocks are zero-based:
floor(5,500 / 1,024) = 5, 5,500 mod 1,024 = 380, and the reconstruction is 5 x 1,024 + 380 = 5,500. The target is displacement 380 in L5. Direct pointers cover L0 to L3, so use indirect entry 5 - 4 = 1, which contains P16:
offset 5,500 -> L5 + 380 -> indirect entry 1 -> P16 + 380.
The linear model gives byte address 16 x 1,024 + 380 = 16,764. It is not universal; real storage adds translation layers.
With inode 37 and P73 cached, reading L5 requires only P16; a cold P73 adds one metadata read. The scheduling queue therefore contains the seven data-block tracks, not P73.
Turn file placement into disk-head movement

Assume four blocks per track: track = floor(physical block / 4). Blocks [8,44,92,20,84,16,108] produce [2,11,23,5,21,4,27]. All are pending, the head starts at 15, metadata is cached, and every movement counts. This is not an SSD latency claim or universal HDD layout.
FCFS follows 15 -> 2 -> 11 -> 23 -> 5 -> 21 -> 4 -> 27: 13 + 9 + 12 + 18 + 16 + 17 + 23 = 108 tracks, averaging 108 / 7 = 15.43.
SSTF chooses the nearest pending track: 15 -> 11 -> 5 -> 4 -> 2 -> 21 -> 23 -> 27. Movement is 4 + 6 + 1 + 2 + 19 + 2 + 4 = 38 tracks, averaging 38 / 7 = 5.43. There are no ties; SSTF is not always best or starvation-free.
Allocation selects blocks; scheduling reorders requests without changing L5 -> P16. Contiguous P80 to P86 occupy tracks [20,20,20,20,21,21,21]. From track 15, a sequential pass moves 5 + 1 = 6 tracks, illustrating locality, not a universal winner.
Cross-concept traps and their exact corrections
6,500 / 1,024needs seven blocks because partial data cannot be dropped.The last block holds
356 bytes;668 bytesis unused tail space.P73 is metadata, not an eighth data block. Indirect entries extend the four direct pointers.
Offset 5,500 is zero-based
L5, indirect entry5 - 4 = 1, displacement380, not356.P16 is a block number;
16,764is an address only in this model.A directory maps a name to inode 37. Descriptor 3 is not the inode; a free-space map does not give file order.
Scheduling changes service order, not mapping.
38 < 108applies only here. Movement is not total I/O time, caches alter metadata reads, and SSTF may postpone distant requests.
How exams combine the concepts in one question
Exam questions can combine blocks and waste, structure roles, offset mapping, index capacity, a track model, FCFS versus SSTF, and cache-dependent I/O. The exact mix varies by paper, but each step follows from the same mapping chain.
Try this drill before reading the key:
For
S = 6,500andB = 1,024, find the data-block count and internal fragmentation.With four direct pointers and this inode, map offset
5,500.From head 15, compare FCFS and SSTF for
[2,11,23,5,21,4,27].
Answer key: 7 blocks and 668 bytes; L5, displacement 380, indirect entry 1, P16, model byte address 16,764; FCFS 108 and SSTF 38.
For focused drills, use File Systems and Allocation MCQs: 12 solved questions with explanations for block mapping and Disk Scheduling MCQs: 12 solved questions (FCFS, SSTF, SCAN) for service-order arithmetic.
Short version and the next learning step
Retrieve the chain: pathname /exam/report.bin -> directory entry -> inode 37 -> logical block and displacement -> pointer -> physical block -> track request -> scheduler order -> bytes returned and offset updated.
Here, 6,500 bytes needs seven 1,024-byte blocks with 668 bytes of fragmentation. Offset 5,500 maps to L5 + 380, entry 1 and P16. The queue costs 108 movements under FCFS and 38 under SSTF.
Use Zero to Hero: Complete CS Course for a structured core-CS route. If you only need this topic, redraw the block map and recompute both scheduling paths before opening another example.
Close your notes and reconstruct the block map and both scheduling paths. Then set S = 8,300 bytes, keep B = 1,024, and recompute blocks and final-block waste. Check: ceil(8,300 / 1,024) = 9 blocks; the ninth holds 108 bytes, leaving 916 bytes unused.
Keep learning
File Management in Operating Systems: Complete GATE Guide with Worked Examples
Follow report.bin from its pathname to its inode and data blocks, compare three allocation methods, size a free-space bitmap, and calculate multi-level inode capacity.
File Management in Operating Systems: Allocation, Directories and Worked Examples
Connect a filename to its inode, open-file state, and physical blocks. Then compare allocation methods and solve one complete block-allocation example.
File systems and disk scheduling in OS: allocation, directories and seek time
A file system is the operating system's answer to a simple-sounding question: where on the disk does each file's data actually live, and how do we find it again quickly? Disk scheduling is the follow-up: when many read and write requests are queued, in what order should the head service them so the disk arm travels least? The two meet in one place: how the file system scatters a file's blocks decides how far the arm travels to read them back. Both are steady exam scorers.
Disk Scheduling in Operating Systems: 6 Algorithms with Worked Examples
Use one request queue to compare all six disk-scheduling algorithms. Every service path, endpoint rule, total movement and per-request average is worked out.





