Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Implementing a Backend

This tutorial walks you through implementing a complete filesystem backend from scratch. By the end, you’ll have a working in-memory filesystem that implements all traits up to FsPosix.

What You’ll Build

An in-memory filesystem (TutorialFs) that:

  • Stores files and directories in memory
  • Supports symlinks
  • Tracks permissions and timestamps
  • Provides inode-based access for FUSE
  • Implements file handles and locking

Prerequisites

  • Basic Rust knowledge (structs, traits, Result)
  • Understanding of filesystem concepts (files, directories, symlinks)

Tutorial Structure

Each chapter introduces one or more traits:

  1. Core Data Structures - Design the internal state
  2. FsRead - Read files and metadata
  3. FsWrite - Write and delete files
  4. FsDir - Directory operations
  5. The Fs Trait - Combining the basics
  6. FsLink - Symlink support
  7. FsFull - Permissions, sync, stats
  8. FsInode - FUSE inode operations
  9. FsPosix - Handles and locking

Running the Examples

Each chapter has runnable example code. Clone the repository and run:

cargo run --example tutorial_backend_complete

The End Result

After completing this tutorial, you’ll understand:

  • How each trait fits into the hierarchy
  • What each method should do and return
  • Error handling conventions
  • Thread-safety requirements
  • How blanket implementations work

Let’s start with Core Data Structures →