10 - File System Organization

Class: CSCE-313


Notes:

Outline

  1. File System Abstraction
  2. File System Organization
  3. UNIX File API
  4. Hard links vs. soft links

The file system abstraction

Notes:

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-7.png465

Example:

An example data layout on disk

Consider the disk to be a linear sequence of blocks.

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-8.png500

Notes:

Data region in a file system

How do we store these inodes in the file system?

Notes:

Inode table in a file system

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-10.png500

Notes:

Allocation Structures

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-11.png500

Notes:

Super Block

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-12.png500

Notes:

File Organization: The inode

2026-03-18_14-09-24.png

Notes:

File System Layout

How do you build a hierarchy (tree) of files from the flat model of data blocks?

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-14.png449

Notes:

Characteristics of a magnetic disk

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-15.png331x256

Why are magnetic disks slow?

How a block is read from disk

  1. The arm moves the disk head to the right track. This is a "seek". Extremely slow (10 ms).
  2. Then, the head waits for the correct sector to come below. This is relatively faster because of constant motion (<<10 ms), determined by disk RPM.
  3. Read the sector and send to the CPU. Much faster (SATA rate: 500MB/s ).

Notes:

Building a hierarchy

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-16.png327

Filesystems terms

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-17.png348

Notes:

Hard link example:

> ln foo.md bar.md
> ls -li foo.md bar.md
69312997 -rw-r--r--  2 macc  staff  0 Mar 18 14:37 bar.md
69312997 -rw-r--r--  2 macc  staff  0 Mar 18 14:37 foo.md

Soft link example:

> ln -s foo.md fib.md
> ls -li foo.md fib.md
69313223 lrwxr-xr-x  1 macc  staff  6 Mar 18 14:38 fib.md -> foo.md
69312997 -rw-r--r--  2 macc  staff  0 Mar 18 14:37 foo.md

Hard link

Soft link or Symbolic link

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-22.png400

shell command

ln /dirA/name1 /dirB/name2

is typically implemented using the link system call:

#include <stdio.h>
#include <unistd.h>

if (link(“/dirA/name1”, “/dirB/name2”) == -1)
perror(“failed to make new link in /dirB”);

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-23.png429

  1. inode #
  2. links

00 - TAMU Brain/6th Semester (Spring 26)/CSCE-313/Lecture/Visual Aids/image-24.png400

#include <stdio.h>
#include <unistd.h>

if (unlink(“/dirA/name1”) == -1)
perror(“failed to delete link in /dirA”);

if (unlink(“/dirB/name2”) == -1)
perror(“failed to delete link in /dirB”);

File System Organization

image-25.png600