Work Words Frames Shelf Hello

Project - 2019

AFS File System

A Unix file system simulation in C - directories, files, and disk block allocation on a virtual disk.

SystemsCFile Systems
AFS file system terminal output

AFS in action - creating directories and files on a simulated disk.

Understanding file systems
by building one from scratch

AFS is a trivial file system implementation that emulates the core concepts of Unix file systems. It operates on a simulated disk composed of fixed-size blocks, implementing directory trees, file creation, and block allocation - the fundamental operations that underpin every modern operating system.

The project strips away the complexity of real kernel-level file systems to expose the essential algorithms: how directories map names to inodes, how inodes track block pointers, and how free space is managed across a block device.

Language

C

Domain

Systems

Model

Unix FS

Storage

Block Device

Structure

Inodes

Interface

CLI

Layers of abstraction

┌─────────────────────────────────────┐ │ User Commands (CLI) │ │ mkdir, touch, ls, cat, rm, cd │ └──────────────────┬──────────────────┘ │ ┌──────────────────▼──────────────────┐ │ Directory Layer │ │ Name resolution, path traversal │ └──────────────────┬──────────────────┘ │ ┌──────────────────▼──────────────────┐ │ Inode Layer │ │ File metadata, block pointers │ └──────────────────┬──────────────────┘ │ ┌──────────────────▼──────────────────┐ │ Block Allocation Layer │ │ Free list, block read/write │ └──────────────────┬──────────────────┘ │ ┌──────────────────▼──────────────────┐ │ Simulated Disk (memory/file) │ │ Fixed-size blocks on virtual disk │ └─────────────────────────────────────┘

The mechanics of a file system

The simulated disk is divided into fixed-size blocks. A superblock tracks file system metadata. Inodes store file attributes and block pointers. Directories are special files that map names to inode numbers. Free space tracking uses a bitmap or free list to allocate and reclaim blocks.

Operations like mkdir, touch, and ls traverse this structure just like their real Unix counterparts - resolving paths component by component, reading directory entries, and following inode pointers to data blocks.