Skip to content

A Rust-based experimental filesystem built for systems engineers who love to understand storage from first principles.

Notifications You must be signed in to change notification settings

bradley101/filefs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

57 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

filefs πŸ—‚οΈ

A simple file-backed filesystem written in Rust β€” built from scratch to learn filesystem internals.


πŸ” Overview

filefs is a minimal, educational filesystem implemented in Rust, designed to run on top of a regular file acting as a virtual block device.
It explores the fundamental concepts behind real-world filesystems β€” inodes, data blocks, superblocks, free-space tracking, and persistence β€” while staying small, hackable, and easy to understand.

Unlike large production filesystems (like ext4 or XFS), filefs focuses on clarity over complexity.
It’s built for experimentation, learning, and systems programming enthusiasts who want to peek under the hood of how a filesystem really works.


βš™οΈ Features

  • File-backed storage β€” uses a single file as the underlying "disk"
  • Superblock, Inodes, and Block Management β€” core structures implemented from scratch
  • Directory hierarchy β€” supports nested directories and file creation
  • Basic commands β€” cd, ls, touch, mkdir, etc. implemented as built-in filesystem operations
  • Persistent metadata β€” inodes and superblocks are serialized and written back to disk
  • Clean layering β€” clear separation between the block layer, inode layer, and higher-level operations
  • Rust safety guarantees β€” no unsafe blocks; leverages ownership and borrowing for consistency
  • Extensible design β€” easy to extend for journaling, caching, or even FUSE integration later

πŸ“ Architecture

filefs/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ core/ β”‚ β”œβ”€β”€ β”œβ”€β”€ block.rs # Block I/O abstraction layer β”‚ β”œβ”€β”€ β”œβ”€β”€ inode.rs # Inode Structure β”‚ β”œβ”€β”€ β”œβ”€β”€ block_bitmap.rs # Bitmap Implementation of free blocks β”‚ β”œβ”€β”€ β”œβ”€β”€ inode_bitmap.rs # Bitmap Implementation of free inodes β”‚ β”œβ”€β”€ β”œβ”€β”€ super_block.rs # Structure for SuperBlock β”‚ β”œβ”€β”€ fs.rs # High-level filesystem operations └── README.md

🧩 Core Concepts

  • Superblock β€” stores filesystem metadata (block size, total blocks, inode count, magic number)
  • Inode β€” represents files and directories, holds size, block pointers, and type
  • Block Manager β€” handles reading/writing fixed-size blocks to the backing file
  • Bitmap β€” tracks used/free blocks dynamically
  • Persistence Layer β€” flushes updates atomically to the underlying file

πŸš€ Getting Started

Prerequisites

  • Rust (latest stable version)
  • Linux / macOS (for now)
  • Cargo build system

Build

git clone https://github.com/bradley101/filefs.git
cd filefs
cargo build
Goal Description
Clarity Keep each module small, explicit, and readable
Correctness Strict invariants enforced by Rust’s type system
Modularity Easy to swap storage backends or change on-disk layout
Safety No unsafe Rust; rely on compile-time guarantees
Learnability Serve as a reference for how filesystems work internally

πŸ“˜ Learning Focus

This project is not meant to replace a production filesystem. Instead, it’s built to demystify how storage, metadata, and allocation interact under the hood β€” similar to simplified educational systems like xv6 or littlefs, but written in safe Rust. If you’ve ever wondered how mkfs, touch, or ls actually interact with on-disk structures β€” this project will show you exactly that.

🀝 Contributing

Contributions are welcome! If you find bugs, have design suggestions, or want to extend the implementation, feel free to open a PR or issue. Before contributing: Keep modules clean and well-commented Preserve Rust safety (no unsafe) Maintain simplicity β€” prefer readability over premature optimization

About

A Rust-based experimental filesystem built for systems engineers who love to understand storage from first principles.

Topics

Resources

Stars

Watchers

Forks

Languages