Reaves.dev

v0.1.0

built using

Phoenix v1.7.12

File System Refresher

Stephen M. Reaves

::

2024-01-14

Refresher about File Systems for CS-6210

Summary

File System Concept

Abstractions over where data is located on disk

Key Abstractions:

Access Rights

Unix-like filesystems provide an owner and a group to each file, then specify rwx for owner, group, and others.

Access Control Lists can be used to extend this.

Developer’s Interface

Two ways to think of a file:

Position Cursor

int fd = open("file.txt", ...);
read(fd, ...);
write(fd, ...); // Overwrites
lseek(fd, ...); // Moves cursor
close(fd, ...);

MMap

fd = open("file.txt", ...);
buf = mmap(..., fd, ...);
// Manipulate buffer
munmap(buf, ...);
close(fd);

Allocation Strategies

Platter is full disk

Track is a circle on the disk

Sector is an arc on the track

Block is one or more sectors

There are several ways to keep track of which blocks are free

Ideally FS will allow:

Examples:

File Allocation Table

Each file is a linked list of blocks

Block NumberBusyNext
00
11-1
216

This stores all links for all files, but not where files start

Directory table has filename, starting block, and metadata (permissions)

Inode Structure

Used in Ext{2,3,4} file formats

Inodes are fixed length, and contain metdata, and 15 pointers.

Directories are inodes that map to other inodes

Buffer Cache

Contents of disk can be cached in main system memory

Journaling

Journaling reserves contiguous blocks on disk to try and transform random IO into sequential IO

Direct Memory Access

Hard drives have DMA controller