# jaylogue/retro-fuse architecture

> Architecture diagram of the GitHub repository jaylogue/retro-fuse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jaylogue/retro-fuse
- Repository: https://github.com/jaylogue/retro-fuse

## Overview

##### Main Components

a. User Space Layer:
- Modern OS Applications
- FUSE Interface
- retro-fuse Main Handlers (v6fs, v7fs, bsd29fs, bsd211fs)

b. Adaptation Layer:
- Adaptation Components (v6adapt, v7adapt, bsd29adapt, bsd211adapt)
- Un-adaptation Components (v6unadapt, v7unadapt, etc.)

c. Historic Unix Kernel Code:
- File System Operations
- I/O Subsystem
- Device Drivers

d. Disk I/O Layer:
- Modern Disk I/O Interface (dskio.c)

##### Component Relationships

- User requests flowing from modern applications through FUSE
- Request translation through the adaptation layer
- Interaction with historic Unix code
- Physical storage access through the disk I/O layer

##### Specific Implementation Details

Key architectural elements:
- Common FUSE interface (fusecommon.c)
- ID mapping system (idmap.c)
- Filesystem-specific handlers for each Unix version
- Original Unix kernel code integration points

**┌─────────────────────────┐**
- Modern Applications  │
- ┬──────────┘
- ▼
**┌─────────────────────────┐**
- FUSE Interface      │
- ┬──────────┘
- ▼
**┌─────────────────────────┐**
- retro-fuse Handlers   │
- (v6fs, v7fs, bsd*fs)  │
- ┬──────────┘
- ▼
**┌─────────────────────────┐**
- Adaptation Layer      │
- (*adapt/*unadapt)      │
- ┬──────────┘
- ▼
**┌─────────────────────────┐**
- Historic Unix Code      │
- (filesystem operations) │
- ┬──────────┘
- ▼
**┌─────────────────────────┐**
- Disk I/O Layer      │
- ┬──────────┘
- ▼
**┌─────────────────────────┐**
- Physical Storage      │
- ┘

##### Additional Elements

Annotations for:
- Supported filesystem types (V6, V7, BSD 2.9, BSD 2.11)
- Key API entry points
- Data transformation points
- Error handling paths

##### Implementation Notes

- Clean separation between modern and historic code
- Adaptation layer's role in code modernization
- FUSE integration points
- Multiple filesystem support architecture

This design captures the unique aspect of retro-fuse: its use of original Unix kernel code adapted to run in user space while maintaining historical fidelity of on-disk structures.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef modern fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef adaptation fill:#fff3b3,stroke:#333,stroke-width:2px
    classDef historic fill:#b3ffb3,stroke:#333,stroke-width:2px
    classDef io fill:#e6b3ff,stroke:#333,stroke-width:2px
    
    %% User Space Layer
    ModernApps["Modern OS Applications"]:::modern
    FUSE["FUSE Interface"]:::modern
    click FUSE "https://github.com/jaylogue/retro-fuse/blob/master/src/fusecommon.c"
    
    %% Main Handlers
    subgraph Handlers["retro-fuse Handlers"]
        V6FS["V6 FS Handler"]:::modern
        V7FS["V7 FS Handler"]:::modern
        BSD29FS["BSD 2.9 FS Handler"]:::modern
        BSD211FS["BSD 2.11 FS Handler"]:::modern
    end
    click V6FS "https://github.com/jaylogue/retro-fuse/blob/master/src/v6fs.c"
    click V7FS "https://github.com/jaylogue/retro-fuse/blob/master/src/v7fs.c"
    click BSD29FS "https://github.com/jaylogue/retro-fuse/blob/master/src/bsd29fs.c"
    click BSD211FS "https://github.com/jaylogue/retro-fuse/blob/master/src/bsd211fs.c"
    
    %% Adaptation Layer
    subgraph Adaptation["Adaptation Layer"]
        V6Adapt["V6 Adapter"]:::adaptation
        V7Adapt["V7 Adapter"]:::adaptation
        BSD29Adapt["BSD 2.9 Adapter"]:::adaptation
        BSD211Adapt["BSD 2.11 Adapter"]:::adaptation
    end
    click V6Adapt "https://github.com/jaylogue/retro-fuse/blob/master/src/v6adapt.c"
    click V7Adapt "https://github.com/jaylogue/retro-fuse/blob/master/src/v7adapt.c"
    click BSD29Adapt "https://github.com/jaylogue/retro-fuse/blob/master/src/bsd29adapt.c"
    click BSD211Adapt "https://github.com/jaylogue/retro-fuse/blob/master/src/bsd211adapt.c"
    
    %% Un-adaptation Layer
    subgraph UnAdaptation["Un-adaptation Layer"]
        V6UnAdapt["V6 Un-adapter"]:::adaptation
        V7UnAdapt["V7 Un-adapter"]:::adaptation
        BSD29UnAdapt["BSD 2.9 Un-adapter"]:::adaptation
        BSD211UnAdapt["BSD 2.11 Un-adapter"]:::adaptation
    end
    click V6UnAdapt "https://github.com/jaylogue/retro-fuse/blob/master/src/v6unadapt.h"
    click V7UnAdapt "https://github.com/jaylogue/retro-fuse/blob/master/src/v7unadapt.h"
    click BSD29UnAdapt "https://github.com/jaylogue/retro-fuse/blob/master/src/bsd29unadapt.h"
    click BSD211UnAdapt "https://github.com/jaylogue/retro-fuse/blob/master/src/bsd211unadapt.h"
    
    %% Historic Unix Code
    subgraph Historic["Historic Unix Kernel Code"]
        V6Kernel["V6 Kernel Code"]:::historic
        V7Kernel["V7 Kernel Code"]:::historic
        BSD29Kernel["BSD 2.9 Kernel Code"]:::historic
        BSD211Kernel["BSD 2.11 Kernel Code"]:::historic
    end
    click V6Kernel "https://github.com/jaylogue/retro-fuse/tree/master/ancient-src/v6"
    click V7Kernel "https://github.com/jaylogue/retro-fuse/tree/master/ancient-src/v7"
    click BSD29Kernel "https://github.com/jaylogue/retro-fuse/tree/master/ancient-src/bsd29"
    click BSD211Kernel "https://github.com/jaylogue/retro-fuse/tree/master/ancient-src/bsd211"
    
    %% I/O Layer
    DiskIO["Disk I/O Interface"]:::io
    click DiskIO "https://github.com/jaylogue/retro-fuse/blob/master/src/dskio.c"
    
    IDMap["ID Mapping System"]:::modern
    click IDMap "https://github.com/jaylogue/retro-fuse/blob/master/src/idmap.c"
    
    Storage[("Physical Storage")]:::io
    
    %% Connections
    ModernApps --> FUSE
    FUSE --> Handlers
    
    V6FS --> V6Adapt
    V7FS --> V7Adapt
    BSD29FS --> BSD29Adapt
    BSD211FS --> BSD211Adapt
    
    V6Adapt --> V6UnAdapt
    V7Adapt --> V7UnAdapt
    BSD29Adapt --> BSD29UnAdapt
    BSD211Adapt --> BSD211UnAdapt
    
    V6UnAdapt --> V6Kernel
    V7UnAdapt --> V7Kernel
    BSD29UnAdapt --> BSD29Kernel
    BSD211UnAdapt --> BSD211Kernel
    
    V6Kernel --> DiskIO
    V7Kernel --> DiskIO
    BSD29Kernel --> DiskIO
    BSD211Kernel --> DiskIO
    
    DiskIO --> Storage
    
    %% Legend
    subgraph Legend
        Modern["Modern Components"]:::modern
        Adapt["Adaptation Components"]:::adaptation
        Hist["Historic Components"]:::historic
        IO["I/O Components"]:::io
    end
```
