# psankar/simplefs architecture

> Architecture diagram of the GitHub repository psankar/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/psankar/simplefs
- Repository: https://github.com/psankar/simplefs

## Overview

##### Core Components
a. Filesystem Driver Layer
- Mount/Unmount Operations
- VFS (Virtual File System) Interface
b. File Operations Layer
- Create/Read/Write Operations
- Directory Operations
c. Storage Management Layer
- Block Management
- Inode Management

##### Top Level (User Space)
- System calls interface

##### Middle Level (Kernel Space)
- VFS Layer
- SimpleFS Driver
- File Operations
- Directory Operations

##### Bottom Level (Storage)
- Physical Layout
- Block Organization
- Inode Structure

Specific Elements to Include:

##### Data Structures
- Super Block (from super.h)
- Inode Structure
- Directory Entry Format

##### Operations Flow
- File Creation Path
- Directory Creation Path
- Read/Write Operations
- Mount/Unmount Sequence

- Blue: User space components
- Green: Kernel space components
- Orange: Storage components
- Gray: External interfaces

Important Relationships to Show:

##### Control Flow
- Error paths in red

##### Data Flow
- How data moves from user space to storage
- Buffer cache interactions
- Synchronization points

Special Considerations:

##### Limitations (mark these clearly)
- Single block file size limit
- Limited number of filesystem objects
- Basic locking scheme

##### Version-Specific Features
- Version 1.0 basic features
- Planned features for 2.0 (extents)
- Planned features for 3.0 (journaling)

- All symbols used
- Component types
- Version markers

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef userspace fill:#a8d1f0,stroke:#000
    classDef kernel fill:#90EE90,stroke:#000
    classDef storage fill:#FFA500,stroke:#000
    classDef interface fill:#D3D3D3,stroke:#000
    classDef limitation fill:#FFB6C1,stroke:#000
    classDef version fill:#DDA0DD,stroke:#000

    %% User Space Layer
    subgraph UserSpace
        App[Applications]:::userspace
        Syscall["System Calls Interface"]:::interface
    end

    %% Kernel Space Layer
    subgraph KernelSpace
        VFS["VFS Layer"]:::kernel
        
        subgraph SimpleFS["SimpleFS Driver"]
            FSDriver["Filesystem Driver"]:::kernel
            FileOps["File Operations"]:::kernel
            DirOps["Directory Operations"]:::kernel
            BlockMgmt["Block Management"]:::kernel
            InodeMgmt["Inode Management"]:::kernel
        end
    end

    %% Storage Layout
    subgraph Storage
        SuperBlock["Block 0: Super Block"]:::storage
        InodeStore["Block 1: Inode Store"]:::storage
        DataBlocks["Block 2+: Data Blocks"]:::storage
    end

    %% Limitations
    subgraph Limitations
        L1["Single Block File Size"]:::limitation
        L2["Limited FS Objects"]:::limitation
        L3["Basic Locking"]:::limitation
    end

    %% Version Features
    subgraph Versions
        V1["v1.0: Basic Features"]:::version
        V2["v2.0: Extents (Planned)"]:::version
        V3["v3.0: Journaling (Planned)"]:::version
    end

    %% Relationships
    App --> Syscall
    Syscall --> VFS
    VFS --> FSDriver
    FSDriver --> FileOps
    FSDriver --> DirOps
    FileOps --> BlockMgmt
    DirOps --> BlockMgmt
    FileOps --> InodeMgmt
    DirOps --> InodeMgmt
    BlockMgmt --> SuperBlock
    BlockMgmt --> DataBlocks
    InodeMgmt --> InodeStore

    %% Click Events
    click SuperBlock "https://github.com/psankar/simplefs/blob/master/super.h"
    click FSDriver "https://github.com/psankar/simplefs/blob/master/simple.c"
    click FileOps "https://github.com/psankar/simplefs/blob/master/simple.h"
    click BlockMgmt "https://github.com/psankar/simplefs/blob/master/mkfs-simplefs.c"
    click App "https://github.com/psankar/simplefs/blob/master/simple-test.sh"

    %% Legend
    subgraph Legend
        L_US["User Space"]:::userspace
        L_KS["Kernel Space"]:::kernel
        L_ST["Storage"]:::storage
        L_IF["Interface"]:::interface
        L_LM["Limitation"]:::limitation
        L_VR["Version"]:::version
    end
```
