embednfs
An embeddable NFSv4.1 server library in Rust. You implement a small filesystem trait; the library handles the wire protocol, sessions, filehandles, locking, and TCP serving.
The implementation target is Apple/macOS NFSv4.1 client compatibility first, with a localhost FUSE-replacement use case. The public API is intentionally opinionated and minimal.
Support Boundary
This project currently makes two important non-promises:
- It does not guarantee correct or robust behavior over a real network. The target deployment is localhost. Running it over non-localhost transport may work in some cases, but that is not a supported or validated use case.
- It does not guarantee correct behavior for non-macOS clients. The implementation and live validation target the macOS kernel NFSv4.1 client and Finder workflows. Other clients may work, but they are not a compatibility target.
In short: the supported target is macOS over localhost.
Architecture
This is a Cargo workspace with three crates:
embednfs-proto— XDR encoding/decoding and NFSv4.1 protocol typesembednfs— Embeddable server library with the filesystem traits and COMPOUND handlerembednfsd— NFSv4.1 server daemon powered by embednfs
Quick Start
use ;
async
Then mount:
# macOS
Note: on macOS, vers=4 means NFSv4.0. Use vers=4.1 explicitly.
Non-macOS clients are not a supported compatibility target, even if they happen to mount successfully.
Filesystem API
The public API is split into a small required core trait plus opt-in extension traits.
Core Trait
use async_trait;
use ;
Core types:
NodeInfo { kind, size }is the only required per-node metadataDirEntry { fileid, name }is the only required directory-entry payloadFileIdidentifies real filesystem objects only; the server synthesizes attrdirs, named-attr files, and other protocol-only objects internally
Extension Traits
The server will use these when present:
NfsNamedAttrsfor macOS named attributes / xattrs / named streamsNfsSymlinksforCREATE symlinkandREADLINKNfsHardLinksforLINKNfsSyncfor explicitCOMMIT
If an extension trait is absent, the server returns the appropriate NFS unsupported/type errors and does not advertise the feature where that matters.
Apple-Focused Operation Support
Implemented for normal Apple/macOS client flows:
EXCHANGE_ID,CREATE_SESSION,SEQUENCE,DESTROY_SESSION,DESTROY_CLIENTIDPUTROOTFH,PUTFH,GETFH,LOOKUP,LOOKUPP,SAVEFH,RESTOREFHGETATTR,ACCESS,OPEN,CLOSE,OPEN_DOWNGRADEREAD,WRITE,COMMIT,READDIR,SETATTRCREATEfor directories and symlinksREMOVE,RENAMELOCK,LOCKT,LOCKUSECINFO_NO_NAMEOPENATTRNVERIFYRECLAIM_COMPLETE,FREE_STATEID
Supported through extensions:
READLINKLINK- macOS named-attribute and xattr flows behind
OPENATTR
Kept as cheap compatibility ops:
SECINFOPUTPUBFHVERIFYTEST_STATEIDDELEGPURGEBIND_CONN_TO_SESSIONDELEGRETURN
Explicitly unsupported:
BACKCHANNEL_CTLGETDEVICEINFO,GETDEVICELISTGET_DIR_DELEGATIONLAYOUTGET,LAYOUTRETURN,LAYOUTCOMMITSET_SSVWANT_DELEGATION
Rejected in NFSv4.1 because they are v4.0-only:
OPEN_CONFIRMRENEWSETCLIENTIDSETCLIENTID_CONFIRMRELEASE_LOCKOWNER
Testing
The integration suite exercises the full RPC path over TCP and includes raw OPENATTR/named-attribute flows for macOS-style clients.
License
MIT