# sysprog21/simplefs architecture

> Architecture diagram of the GitHub repository sysprog21/simplefs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sysprog21/simplefs
- Repository: https://github.com/sysprog21/simplefs

## Overview

##### Component Relationships

a. File System Operations:
- VFS → Operation Tables → Simplefs Handlers
- Superblock Operations
- Inode Operations
- File Operations

b. Storage Structure:
- Partition Layout
- Superblock (Block 0)
- Inode Store
- Inode Bitmap
- Block Bitmap
- Data Blocks

c. Journaling System:
- External Journal Device
- Journal Superblock
- Descriptor Blocks
- Metadata/Data Blocks
- Commit Blocks

##### Implementation Details

Key structures:
- struct simplefs_inode {
- mode_t i_mode;
- uint64_t i_size;
- uint32_t i_blocks;
- uint32_t ei_block;
- }

- struct simplefs_extent {
- uint32_t ee_block;
- uint32_t ee_len;
- uint32_t ee_start;
- }

##### Limitations Section

A notes section showing:
- File size limits (10.65 MiB)
- Directory entry limits
- Journal size constraints (8 MB)
- Current metadata recording limitations

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Define styles
    classDef vfs fill:#a8d1f0,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef storage fill:#FFB347,stroke:#333
    classDef journal fill:#DDA0DD,stroke:#333
    classDef utility fill:#E6E6FA,stroke:#333

    %% VFS Interface Layer
    subgraph VFS["VFS Interface Layer"]
        VFSInterface["Linux VFS Interface"]:::vfs
        OpTables["Operation Tables"]:::vfs
        subgraph Operations
            SB["Superblock Operations"]:::vfs
            IN["Inode Operations"]:::vfs
            FO["File Operations"]:::vfs
        end
    end

    %% Core Layer
    subgraph Core["Simplefs Core Layer"]
        MountOps["Mount Operations"]:::core
        FileOps["File Operations"]:::core
        DirOps["Directory Operations"]:::core
        LinkOps["Link Operations"]:::core
        ExtentMgmt["Extent Management"]:::core
        JournalMgmt["Journal Management"]:::core
        BitmapMgmt["Bitmap Management"]:::core
    end

    %% Storage Layer
    subgraph Storage["Storage Layout Layer"]
        direction TB
        PartLayout["Partition Layout"]:::storage
        subgraph DiskStructures["On-Disk Structures"]
            direction TB
            SBlock["Superblock (Block 0)"]:::storage
            IStore["Inode Store"]:::storage
            IBitmap["Inode Bitmap"]:::storage
            BBitmap["Block Bitmap"]:::storage
            DBlocks["Data Blocks"]:::storage
        end
    end

    %% Journal Section
    subgraph Journal["Journal System"]
        JournalDev["External Journal Device"]:::journal
        JSuperblock["Journal Superblock"]:::journal
        JDescriptor["Descriptor Blocks"]:::journal
        JData["Metadata/Data Blocks"]:::journal
        JCommit["Commit Blocks"]:::journal
    end

    %% Utility Components
    subgraph Utils["Utility Components"]
        FSCreate["Filesystem Creation"]:::utility
        TestFrame["Testing Framework"]:::utility
        CI["CI/CD Pipeline"]:::utility
    end

    %% Relationships
    VFSInterface --> OpTables
    OpTables --> SB & IN & FO
    SB --> MountOps
    IN --> FileOps & DirOps & LinkOps
    FO --> FileOps
    FileOps & DirOps & LinkOps --> ExtentMgmt
    ExtentMgmt --> DBlocks
    JournalMgmt --> JournalDev
    BitmapMgmt --> IBitmap & BBitmap

    %% Click events
    click VFSInterface "https://github.com/sysprog21/simplefs/blob/master/simplefs.h"
    click SB "https://github.com/sysprog21/simplefs/blob/master/super.c"
    click IN "https://github.com/sysprog21/simplefs/blob/master/inode.c"
    click FO "https://github.com/sysprog21/simplefs/blob/master/file.c"
    click DirOps "https://github.com/sysprog21/simplefs/blob/master/dir.c"
    click ExtentMgmt "https://github.com/sysprog21/simplefs/blob/master/extent.c"
    click FileOps "https://github.com/sysprog21/simplefs/blob/master/fs.c"
    click BitmapMgmt "https://github.com/sysprog21/simplefs/blob/master/bitmap.h"
    click FSCreate "https://github.com/sysprog21/simplefs/blob/master/mkfs.c"
    click TestFrame "https://github.com/sysprog21/simplefs/blob/master/script/test.sh"
    click CI "https://github.com/sysprog21/simplefs/blob/master/.ci/build-n-run.sh"

    %% Legend
    subgraph Legend
        L1["VFS Components"]:::vfs
        L2["Core Components"]:::core
        L3["Storage Components"]:::storage
        L4["Journal Components"]:::journal
        L5["Utility Components"]:::utility
    end
```
