# cberner/fuser architecture

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

## Overview

##### Project Type Analysis
This is a specialized library that serves as a middleware between the kernel's FUSE driver and userspace filesystem implementations. It's a Rust rewrite of the libfuse C library.

##### Main Components

a. Core Components:
- Kernel FUSE Driver
- FUSE-Rust Library (This Project)
- User Implementation
- Operating System Interface

b. Internal Library Components (based on src/ structure):
- Channel Management (channel.rs)
- Session Handling (session.rs)
- Request Processing (request.rs)
- Reply Handling (reply.rs)
- Notification System (notify.rs)
- Low-Level (ll/) Interface
- Mount Operations (mnt/)

**┌─────────────────────┐**
- User Implementation│
- ┤
- FUSE-Rust Lib    │
- ┤
- Kernel FUSE Driver  │
- ┘

##### Detailed Component Representation

- Rectangles: Main components
- Rounded rectangles: Internal modules
- Hexagons: External interfaces

- Blue: Core library components
- Green: External interfaces
- Gray: Kernel/OS components
- Orange: User implementation

##### Key Relationships

a. External Interactions:
- User Implementation ↔ FUSE-Rust Library (via Filesystem trait)
- FUSE-Rust Library ↔ Kernel Driver (via FUSE protocol)
- Mount Operations ↔ OS-specific mounting (fuse2/fuse3)

b. Internal Flows:
- Channel → Session → Request/Reply handling
- Low-level interface connections
- Notification system pathways

##### Important Details

- Cross-platform support indicators (Linux, FreeBSD, macOS)
- FUSE protocol version compatibility (FUSE2/FUSE3)
- Clear separation between high-level and low-level APIs
- Mount operation variants (with/without libfuse)

##### Additional Recommendations

- Version compatibility notes
- Optional components (libfuse dependency)
- Async/sync operation paths
- Public interfaces vs internal components

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef kernel fill:#d3d3d3,stroke:#333
    classDef library fill:#b3d1ff,stroke:#333
    classDef external fill:#90EE90,stroke:#333
    classDef user fill:#FFB366,stroke:#333
    classDef mount fill:#DDA0DD,stroke:#333
    classDef interface fill:#F0E68C,stroke:#333

    %% User Implementation Layer
    subgraph UserLayer
        UserImpl["User Filesystem Implementation"]:::user
        HighLevelAPI["High-Level API Interface"]:::interface
    end

    %% FUSE-Rust Library Layer
    subgraph LibraryLayer
        MainLib["Library Interface"]:::library
        Channel["Channel Management"]:::library
        Session["Session Handler"]:::library
        Request["Request Processor"]:::library
        Reply["Reply Handler"]:::library
        Notify["Notification System"]:::library
    end

    %% Low-Level Interface Layer
    subgraph LowLevelLayer
        LLInterface["Low-Level Interface"]:::interface
        LLABI["FUSE ABI"]:::interface
        LLRequest["LL Request Handler"]:::library
        LLReply["LL Reply Handler"]:::library
        LLNotify["LL Notification"]:::library
    end

    %% Mount Operations Layer
    subgraph MountLayer
        MountOps["Mount Operations"]:::mount
        MountOpt["Mount Options"]:::mount
        FUSE2["FUSE2 Mount"]:::mount
        FUSE3["FUSE3 Mount"]:::mount
        FUSEPure["Pure FUSE Mount"]:::mount
    end

    %% Kernel Layer
    subgraph KernelLayer
        KernelDriver["Kernel FUSE Driver"]:::kernel
    end

    %% Relationships
    UserImpl --> HighLevelAPI
    HighLevelAPI --> MainLib
    MainLib --> Channel
    Channel --> Session
    Session --> Request
    Session --> Reply
    Session --> Notify
    
    Request --> LLInterface
    Reply --> LLInterface
    Notify --> LLInterface
    
    LLInterface --> LLABI
    LLInterface --> LLRequest
    LLInterface --> LLReply
    LLInterface --> LLNotify
    
    LLABI --> MountOps
    MountOps --> FUSE2
    MountOps --> FUSE3
    MountOps --> FUSEPure
    MountOps --> MountOpt
    
    FUSE2 --> KernelDriver
    FUSE3 --> KernelDriver
    FUSEPure --> KernelDriver

    %% Click Events
    click Channel "https://github.com/cberner/fuser/blob/master/src/channel.rs"
    click Session "https://github.com/cberner/fuser/blob/master/src/session.rs"
    click Request "https://github.com/cberner/fuser/blob/master/src/request.rs"
    click Reply "https://github.com/cberner/fuser/blob/master/src/reply.rs"
    click Notify "https://github.com/cberner/fuser/blob/master/src/notify.rs"
    click LLInterface "https://github.com/cberner/fuser/blob/master/src/ll/mod.rs"
    click MountOps "https://github.com/cberner/fuser/blob/master/src/mnt/mod.rs"
    click FUSE2 "https://github.com/cberner/fuser/blob/master/src/mnt/fuse2.rs"
    click FUSE3 "https://github.com/cberner/fuser/blob/master/src/mnt/fuse3.rs"
    click FUSEPure "https://github.com/cberner/fuser/blob/master/src/mnt/fuse_pure.rs"
    click LLABI "https://github.com/cberner/fuser/blob/master/src/ll/fuse_abi.rs"
    click LLRequest "https://github.com/cberner/fuser/blob/master/src/ll/request.rs"
    click LLReply "https://github.com/cberner/fuser/blob/master/src/ll/reply.rs"
    click LLNotify "https://github.com/cberner/fuser/blob/master/src/ll/notify.rs"
    click MountOpt "https://github.com/cberner/fuser/blob/master/src/mnt/mount_options.rs"
    click MainLib "https://github.com/cberner/fuser/blob/master/src/lib.rs"

    %% Legend
    subgraph Legend
        L1["Kernel Component"]:::kernel
        L2["Library Component"]:::library
        L3["External Interface"]:::external
        L4["User Component"]:::user
        L5["Mount Component"]:::mount
        L6["Interface Component"]:::interface
    end
```
