Operating Systems Level 10
PART 3 • MEMORY & STORAGE

Turn Persistent Blocks into Named, Protected Files

Trace pathname lookup, separate names from metadata, compare block allocation and explain how journaling limits damage after a crash.

Level 10 of 15 Intermediate 100–130 minutes Allocation lab
BY THE END, YOU CAN

Reason from name to block

  • Explain file metadata and operations.
  • Trace directories and inodes.
  • Compare allocation methods.
  • Manage free space.
  • Explain consistency and journaling.
01 • DEFINE THE PERSISTENT OBJECT

A File Combines Data, Metadata and an Interface

DATA

Byte content

The file-system API commonly presents a sequence of bytes even when applications interpret records, images or source code.

METADATA

Facts about content

Size, owner, permissions, timestamps, type and block pointers support protection and lookup.

OPEN FILE STATE

Per-use context

A descriptor references a kernel open-file entry containing mode, current offset and object identity.

read(fd, buffer, count) write(fd, buffer, count) seek changes current offset close releases descriptor

A filename is not usually stored inside the inode. A directory maps a name to an object number; multiple hard links may map different names to the same inode. A symbolic link stores a pathname and can cross file systems.

02 • RESOLVE A PATH COMPONENT BY COMPONENT

Directories Form a Searchable Namespace

1

Choose start

An absolute path begins at root; a relative path begins at the process’s current directory.

2

Check execute/search permission

Permission is checked while traversing each directory, not only on the final file.

3

Map name to inode

Directory entries provide the next object identifier; caches may accelerate lookup.

4

Open and return descriptor

The kernel validates requested access and installs a descriptor in the process table.

Allocation Sequential access Random access Growth/fragmentation
Contiguous Excellent Direct External fragmentation; hard growth
Linked Good Slow traversal Easy growth; pointer overhead
Indexed Good Direct via index Index overhead; scalable variants
03 • INTERACTIVE BLOCK-ALLOCATION LAB

Place One File using Three Strategies

READY

Select a method

The block map and method trade-off will appear here.

Free-space structures

BITMAP

One bit per block

Fast to locate runs with word operations; bitmap itself consumes predictable space.

FREE LIST

Chain free blocks

Simple allocation but finding a large contiguous run may require traversal.

GROUPING/COUNTING

Compress free ranges

Store groups or starting block plus run length when free blocks cluster.

04 • SURVIVE INTERRUPTED UPDATES

Crash Consistency Is about Legal On-Disk States

Creating a file may update a directory entry, inode allocation bitmap, inode and data blocks. A crash between writes can leak blocks or expose incomplete metadata. Write ordering, journaling, copy-on-write trees and recovery checks address different parts of this problem.

JOURNAL

Log intent/metadata

Record a transaction before applying home-location updates; replay committed work after a crash.

FSCK

Scan and repair

Reconstruct consistency from on-disk structures, often slower on large file systems.

COPY-ON-WRITE

Publish new roots

Write changed blocks elsewhere, then atomically switch metadata to the new version.

05 • PROGRAM TRACING

Trace open("/home/venu/notes.txt")

PATH LOOKUP ·

06 • CHECK YOUR UNDERSTANDING

Ten Concept Checks

Answered correctly: 0 of 10
07 • EXAM & INTERVIEW PREPARATION

Connect Names, Metadata and Blocks

2-MARK
  1. File versus inode?
  2. Hard versus symbolic link?
  3. What is a descriptor?
  4. Define mounting.
  5. What is journaling?
5-MARK
  1. Trace pathname resolution.
  2. Compare allocation methods.
  3. Explain free-space management.
  4. Explain crash consistency.
  5. Describe directory structures.
INTERVIEW
  1. Why can deleted files remain open?
  2. What does fsync promise?
  3. Why are sparse files useful?
  4. How does rename help atomic replace?
  5. What costs random linked access?
LEVEL 10 SUMMARY

You Can Trace a Name to Persistent Blocks

  • Directories map names; inodes hold metadata and block mapping.
  • Descriptors represent per-process access to open objects.
  • Allocation trades locality, direct access, growth and metadata.
  • Free-space structures make reusable blocks discoverable.
  • Journaling and copy-on-write protect update consistency.
COURSE CHECKPOINT

Mark complete after you can compare all three allocation methods.

Saved only in this browser.