operating-systems file-management

Definition

File Allocation

File allocation maps logical file blocks to physical disk addresses. The goal is to balance performance, storage efficiency, and the ability to grow files.

Methods

Contiguous Allocation

Each file occupies adjacent disk blocks.

  • Benefit: Excellent sequential and random access (minimal head movement)
  • Cost: External fragmentation, difficult file expansion
  • Usage: Read-only media (CD-ROMs, DVDs)

Chained (Linked) Allocation

Each block contains a pointer to the next block.

  • Benefit: No external fragmentation, easy file growth
  • Cost: Slow random access, pointer overhead, poor reliability (corrupted pointer breaks file)

Indexed Allocation

All file pointers stored in a central File Allocation Table (FAT) in memory.

  • Benefit: Good sequential and direct access, blocks used entirely for data
  • Cost: FAT can become very large and must reside in RAM

i-nodes

Per-file structure storing attributes and pointers to data blocks.

  • Direct pointers: Point to first data blocks
  • Indirect pointers: Point to blocks containing more pointers
  • Double/Triple indirect: For extremely large files
  • Efficiency: i-node only resident in memory while file is open