# raghaddahman/libnfs architecture

> Architecture diagram of the GitHub repository raghaddahman/libnfs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raghaddahman/libnfs
- Repository: https://github.com/raghaddahman/libnfs

## Overview

libnfs is a network NFS client library with raw asynchronous RPC and higher-level asynchronous and synchronous filesystem APIs. An application configures a context and server/share, mounts it, then issues filesystem operations; the sync API offers a blocking interface while the async and raw APIs expose task/callback-driven operation. NFSv3 is the default, with NFSv4.0–4.2 features, including zero-copy I/O and v4.1+ sessions and raw backchannel support. The repository also includes RPC server components. Edges are limited to README-documented relationships or relationships visible in the supplied source index and excerpts; many internal call paths were not sampled.

Main entry points: [`include/nfsc/libnfs.h`](https://github.com/raghaddahman/libnfs/blob/master/include/nfsc/libnfs.h) (Public NFS API), [`servers/libnfs-server.c`](https://github.com/raghaddahman/libnfs/blob/master/servers/libnfs-server.c) (RPC Server Framework), [`lib/pdu.c`](https://github.com/raghaddahman/libnfs/blob/master/lib/pdu.c) (RPC Engine), [`nfs4/libnfs-raw-nfs4.c`](https://github.com/raghaddahman/libnfs/blob/master/nfs4/libnfs-raw-nfs4.c) (NFS4 RPC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client_api["Client APIs"]
  node_public_api["Public NFS API<br/>[libnfs.h]"]
  node_client_context["Client Context<br/>[libnfs.c]"]
  node_sync_api["Sync API Bridge<br/>[libnfs-sync.c]"]
  node_mount_client["Mount Client<br/>[mount.c]"]
end

subgraph group_protocols["NFS Protocols"]
  node_nfs3_client["NFS v2/v3 Client<br/>[nfs_v3.c]"]
  node_nfs4_client["NFS v4 Client<br/>[nfs_v4.c]"]
  node_nfs_helpers["NFS Operations<br/>[nfs.c]"]
  node_nfs4_helpers["NFS4 Operations<br/>[nfs4.c]"]
  node_mount_rpc["Mount RPC<br/>[libnfs-raw-mount.c]"]
  node_nfs_rpc["NFS RPC<br/>[libnfs-raw-nfs.c]"]
  node_nfs4_rpc["NFS4 RPC<br/>[libnfs-raw-nfs4.c]"]
  node_portmap["Portmapper<br/>[portmap.c]"]
  node_lock_services["Lock Services<br/>[nlm.c]"]
  node_status_service["Status Monitor<br/>[nsm.c]"]
  node_quota_service["Quota RPC<br/>[rquota.c]"]
end

subgraph group_rpc_transport["RPC Transport"]
  node_rpc_engine["RPC Engine<br/>[pdu.c]"]
  node_rpc_socket["Socket Transport<br/>[socket.c]"]
  node_zdr["ZDR Encoding<br/>[libnfs-zdr.c]"]
  node_multithreading["Service Thread<br/>[multithreading.c]"]
end

subgraph group_integrations["Transport Integrations"]
  node_tls["TLS Handshake<br/>[handshake.c]"]
  node_rdma["RDMA Transport<br/>[rdma.c]"]
end

subgraph group_rpc_servers["RPC Servers"]
  node_server_framework["RPC Server Framework<br/>[libnfs-server.c]"]
  node_mount_server["Mount Server<br/>[mountd.c]"]
  node_nfs_server["NFS Server<br/>[nfsd.c]"]
  node_rpcbind_server["RPCbind Server<br/>[rpcbind.c]"]
  node_statd_server["Statd Server<br/>[rpc.statd.c]"]
end

node_application(("Application"))

node_application -->|"uses"| node_public_api
node_public_api -.->|"calls"| node_client_context
node_public_api -->|"offers blocking calls"| node_sync_api
node_public_api -->|"offers async filesystem"| node_nfs3_client
node_public_api -->|"selects v4 dialect"| node_nfs4_client
node_application -->|"mounts share"| node_mount_client
node_mount_client -->|"uses mount protocol"| node_mount_rpc
node_nfs4_client -->|"issues compound calls"| node_nfs4_rpc
node_nfs_helpers -.->|"uses NFS RPC"| node_nfs_rpc
node_nfs4_helpers -.->|"uses NFS4 RPC"| node_nfs4_rpc
node_application -->|"can issue raw tasks"| node_nfs4_rpc
node_nfs4_rpc -.->|"queues RPC tasks"| node_rpc_engine
node_portmap -->|"queues RPC tasks"| node_rpc_engine
node_rpc_engine -.->|"encodes RPC data"| node_zdr
node_rpc_engine -.->|"uses socket I/O"| node_rpc_socket
node_rpc_socket -.->|"supports TLS"| node_tls
node_rpc_socket -.->|"supports RDMA"| node_rdma
node_application -->|"starts service thread"| node_multithreading
node_application -.->|"runs RPC services"| node_server_framework
node_server_framework -->|"supports mount service"| node_mount_server
node_server_framework -->|"supports rpcbind service"| node_rpcbind_server
node_server_framework -->|"supports statd service"| node_statd_server

click node_public_api "https://github.com/raghaddahman/libnfs/blob/master/include/nfsc/libnfs.h"
click node_client_context "https://github.com/raghaddahman/libnfs/blob/master/lib/libnfs.c"
click node_sync_api "https://github.com/raghaddahman/libnfs/blob/master/lib/libnfs-sync.c"
click node_mount_client "https://github.com/raghaddahman/libnfs/blob/master/mount/mount.c"
click node_nfs3_client "https://github.com/raghaddahman/libnfs/blob/master/lib/nfs_v3.c"
click node_nfs4_client "https://github.com/raghaddahman/libnfs/blob/master/lib/nfs_v4.c"
click node_nfs_helpers "https://github.com/raghaddahman/libnfs/blob/master/nfs/nfs.c"
click node_nfs4_helpers "https://github.com/raghaddahman/libnfs/blob/master/nfs4/nfs4.c"
click node_mount_rpc "https://github.com/raghaddahman/libnfs/blob/master/mount/libnfs-raw-mount.c"
click node_nfs_rpc "https://github.com/raghaddahman/libnfs/blob/master/nfs/libnfs-raw-nfs.c"
click node_nfs4_rpc "https://github.com/raghaddahman/libnfs/blob/master/nfs4/libnfs-raw-nfs4.c"
click node_portmap "https://github.com/raghaddahman/libnfs/blob/master/portmap/portmap.c"
click node_lock_services "https://github.com/raghaddahman/libnfs/blob/master/nlm/nlm.c"
click node_status_service "https://github.com/raghaddahman/libnfs/blob/master/nsm/nsm.c"
click node_quota_service "https://github.com/raghaddahman/libnfs/blob/master/rquota/rquota.c"
click node_rpc_engine "https://github.com/raghaddahman/libnfs/blob/master/lib/pdu.c"
click node_rpc_socket "https://github.com/raghaddahman/libnfs/blob/master/lib/socket.c"
click node_zdr "https://github.com/raghaddahman/libnfs/blob/master/lib/libnfs-zdr.c"
click node_multithreading "https://github.com/raghaddahman/libnfs/blob/master/lib/multithreading.c"
click node_tls "https://github.com/raghaddahman/libnfs/blob/master/tls/handshake.c"
click node_rdma "https://github.com/raghaddahman/libnfs/blob/master/lib/rdma.c"
click node_server_framework "https://github.com/raghaddahman/libnfs/blob/master/servers/libnfs-server.c"
click node_mount_server "https://github.com/raghaddahman/libnfs/blob/master/servers/nfsd/mountd.c"
click node_nfs_server "https://github.com/raghaddahman/libnfs/blob/master/servers/nfsd/nfsd.c"
click node_rpcbind_server "https://github.com/raghaddahman/libnfs/blob/master/servers/rpcbind/rpcbind.c"
click node_statd_server "https://github.com/raghaddahman/libnfs/blob/master/servers/statd/rpc.statd.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_client_context,node_sync_api,node_mount_client toneBlue
class node_nfs3_client,node_nfs4_client,node_nfs_helpers,node_nfs4_helpers,node_mount_rpc,node_nfs_rpc,node_nfs4_rpc,node_portmap,node_lock_services,node_status_service,node_quota_service toneAmber
class node_rpc_engine,node_rpc_socket,node_zdr,node_multithreading toneMint
class node_tls,node_rdma toneRose
class node_server_framework,node_mount_server,node_nfs_server,node_rpcbind_server,node_statd_server,node_application toneIndigo
```

## Components

### Client APIs

- [Public NFS API](https://github.com/raghaddahman/libnfs/blob/master/include/nfsc/libnfs.h): `include/nfsc/libnfs.h`
- [Client Context](https://github.com/raghaddahman/libnfs/blob/master/lib/libnfs.c): `lib/libnfs.c`
- [Sync API Bridge](https://github.com/raghaddahman/libnfs/blob/master/lib/libnfs-sync.c): `lib/libnfs-sync.c`
- [Mount Client](https://github.com/raghaddahman/libnfs/blob/master/mount/mount.c): `mount/mount.c`

### NFS Protocols

- [NFS v2/v3 Client](https://github.com/raghaddahman/libnfs/blob/master/lib/nfs_v3.c): `lib/nfs_v3.c`
- [NFS v4 Client](https://github.com/raghaddahman/libnfs/blob/master/lib/nfs_v4.c): `lib/nfs_v4.c`
- [NFS Operations](https://github.com/raghaddahman/libnfs/blob/master/nfs/nfs.c): `nfs/nfs.c`
- [NFS4 Operations](https://github.com/raghaddahman/libnfs/blob/master/nfs4/nfs4.c): `nfs4/nfs4.c`
- [Mount RPC](https://github.com/raghaddahman/libnfs/blob/master/mount/libnfs-raw-mount.c): `mount/libnfs-raw-mount.c`
- [NFS RPC](https://github.com/raghaddahman/libnfs/blob/master/nfs/libnfs-raw-nfs.c): `nfs/libnfs-raw-nfs.c`
- [NFS4 RPC](https://github.com/raghaddahman/libnfs/blob/master/nfs4/libnfs-raw-nfs4.c): `nfs4/libnfs-raw-nfs4.c`
- [Portmapper](https://github.com/raghaddahman/libnfs/blob/master/portmap/portmap.c): `portmap/portmap.c`
- [Lock Services](https://github.com/raghaddahman/libnfs/blob/master/nlm/nlm.c): `nlm/nlm.c`
- [Status Monitor](https://github.com/raghaddahman/libnfs/blob/master/nsm/nsm.c): `nsm/nsm.c`
- [Quota RPC](https://github.com/raghaddahman/libnfs/blob/master/rquota/rquota.c): `rquota/rquota.c`

### RPC Transport

- [RPC Engine](https://github.com/raghaddahman/libnfs/blob/master/lib/pdu.c): `lib/pdu.c`
- [Socket Transport](https://github.com/raghaddahman/libnfs/blob/master/lib/socket.c): `lib/socket.c`
- [ZDR Encoding](https://github.com/raghaddahman/libnfs/blob/master/lib/libnfs-zdr.c): `lib/libnfs-zdr.c`
- [Service Thread](https://github.com/raghaddahman/libnfs/blob/master/lib/multithreading.c): `lib/multithreading.c`

### Transport Integrations

- [TLS Handshake](https://github.com/raghaddahman/libnfs/blob/master/tls/handshake.c): `tls/handshake.c`
- [RDMA Transport](https://github.com/raghaddahman/libnfs/blob/master/lib/rdma.c): `lib/rdma.c`

### RPC Servers

- [RPC Server Framework](https://github.com/raghaddahman/libnfs/blob/master/servers/libnfs-server.c): `servers/libnfs-server.c`
- [Mount Server](https://github.com/raghaddahman/libnfs/blob/master/servers/nfsd/mountd.c): `servers/nfsd/mountd.c`
- [NFS Server](https://github.com/raghaddahman/libnfs/blob/master/servers/nfsd/nfsd.c): `servers/nfsd/nfsd.c`
- [RPCbind Server](https://github.com/raghaddahman/libnfs/blob/master/servers/rpcbind/rpcbind.c): `servers/rpcbind/rpcbind.c`
- [Statd Server](https://github.com/raghaddahman/libnfs/blob/master/servers/statd/rpc.statd.c): `servers/statd/rpc.statd.c`

### Other components

- **Application**

## Connections

- Application → Public NFS API: uses (evidence: `README`)
- Public NFS API → Client Context: calls
- Public NFS API → Sync API Bridge: offers blocking calls (evidence: `README`)
- Public NFS API → NFS v2/v3 Client: offers async filesystem (evidence: `README`)
- Public NFS API → NFS v4 Client: selects v4 dialect (evidence: `README`)
- Application → Mount Client: mounts share (evidence: `README`)
- Mount Client → Mount RPC: uses mount protocol (evidence: `mount/mount.c`)
- NFS v4 Client → NFS4 RPC: issues compound calls (evidence: `lib/nfs_v4.c`)
- NFS Operations → NFS RPC: uses NFS RPC
- NFS4 Operations → NFS4 RPC: uses NFS4 RPC
- Application → NFS4 RPC: can issue raw tasks (evidence: `README`)
- NFS4 RPC → RPC Engine: queues RPC tasks
- Portmapper → RPC Engine: queues RPC tasks (evidence: `portmap/portmap.c`)
- RPC Engine → ZDR Encoding: encodes RPC data
- RPC Engine → Socket Transport: uses socket I/O
- Socket Transport → TLS Handshake: supports TLS
- Socket Transport → RDMA Transport: supports RDMA
- Application → Service Thread: starts service thread (evidence: `README`)
- Application → RPC Server Framework: runs RPC services
- RPC Server Framework → Mount Server: supports mount service (evidence: `servers/nfsd/mountd.c`)
- RPC Server Framework → RPCbind Server: supports rpcbind service (evidence: `servers/rpcbind/rpcbind.c`)
- RPC Server Framework → Statd Server: supports statd service (evidence: `servers/statd/rpc.statd.c`)
