Skip to main content

nfs-rs

CI crates.io docs.rs license

An asynchronous, pure Rust client library for NFSv3, NFSv4.0, and NFSv4.1.

nfs-rs implements the NFS client protocol without linking to a C NFS implementation. It is intended for applications that need to access NFS exports directly from Rust, including services that cannot rely on a kernel-mounted filesystem.

Status

  • NFSv3 client operations are supported.
  • NFSv4.0 (experimental) is supported through the common Mount API using an AUTH_SYS interoperability profile. RPCSEC_GSS/Kerberos is not implemented, so this release does not claim unconditional RFC 7530 conformance.
  • NFSv4.1 client operations are supported.
  • NFSv4.2 may be accepted in a URL preference list but is not implemented.
  • The library uses Tokio and communicates with the server over TCP.
  • Linux is exercised by CI and by the physical NFS integration lab.

The public API is still evolving while the crate is below version 1.0.

Installation

[dependencies]
nfs-rs = "0.5"
bytes = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

The minimum supported Rust version is 1.95.

For Python on Linux x86_64:

python -m pip install nfs-rs

See the Python API guide for synchronous and asyncio examples, typing, large-transfer guidance, cancellation and uncertain outcomes, and the precise first-release support boundaries.

Example

use bytes::Bytes;
use nfs_rs::{OPEN_READ, Result, parse_url_and_mount};

#[tokio::main]
async fn main() -> Result<()> {
    let mount = parse_url_and_mount(
        "nfs://127.0.0.1/some/export?version=4.1&noresvport=true",
    )
    .await?;

    let created = mount.create_path("hello.txt", Some(0o644)).await?;
    mount
        .write(created.fh.clone(), 0, Bytes::from_static(b"hello NFS"))
        .await?;
    mount.commit(created.fh.clone(), 0, 9).await?;
    mount.close(created.fh).await?;

    let opened = mount.open_path("hello.txt", OPEN_READ).await?;
    let contents = mount.read(opened.fh.clone(), 0, 9).await?;
    mount.close(opened.fh).await?;
    assert_eq!(&contents[..], b"hello NFS");

    mount.umount().await?;
    Ok(())
}

URL format

nfs://<server|ipv4|ipv6>[:<port>]/path[?arg=value[&arg=value]*]

Supported arguments:

  • uid=<integer> — UID sent to the server. It defaults to the process UID on Unix and 65534 on Windows.
  • gid=<integer> — GID sent to the server. It defaults to the process GID on Unix and 65534 on Windows.
  • version=<3|4.0|4.1|4.2> — preferred protocol version or a comma-separated preference list such as 4.1,4.0,3. The default is 3. The exact 4.0 selector selects the experimental NFSv4.0 engine; ambiguous 4 is rejected. Version 4.2 is not currently implemented.
  • retain-delegations=true — opt into automatic delegation retention. It is disabled by default; NFSv4.0 publishes a separately reachable callback listener when enabled.
  • nfsport=<port> — NFS service port. This bypasses portmapper discovery.
  • mountport=<port> — MOUNT protocol port for NFSv3.
  • readdir-buffer=<count> or <dircount>,<maxcount> — response buffer limits for directory reads. Both values default to 8192.
  • rsize=<bytes> — maximum read request size.
  • wsize=<bytes> — maximum write request size.
  • noresvport=<true|false> — use an ephemeral source port when true. It defaults to false.

When noresvport=false, the client binds below port 1024 for servers enforcing the RFC 1813 secure-port convention. This may require elevated privileges. Setting noresvport=true avoids privileged-port exhaustion, but the NFS server must accept non-privileged source ports (the insecure export option on Linux).

NFSv4.0 migration notes

Use exact version=4.0; the ambiguous selector version=4 is invalid. Existing NFSv3 remains the default. NFSv4.0 uses the same public Mount methods as v3 and v4.1, but reports session and pNFS capabilities as unavailable. Delegation retention is optional and automatic; applications never handle raw stateids. The experimental profile has real FAS2750 reconnect and lease validation, but dedicated-server restart grace/reclaim evidence remains an explicit exception until a safe maintenance fixture is available.

Documentation

The complete API documentation is published on docs.rs. See the Mount trait for supported filesystem operations.

Testing

Normal unit and integration tests run without access to an NFS server. The ignored physical-lab test exercises NFSv3 and NFSv4.1 against dedicated exports; its setup is documented in the source repository and is not part of the published crate.

License

Licensed under the Apache License 2.0.

Contributing

See CONTRIBUTING.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nfs_rs-0.5.7.tar.gz (341.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nfs_rs-0.5.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

File details

Details for the file nfs_rs-0.5.7.tar.gz.

File metadata

  • Download URL: nfs_rs-0.5.7.tar.gz
  • Upload date:
  • Size: 341.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nfs_rs-0.5.7.tar.gz
Algorithm Hash digest
SHA256 36c9745144209aa5d2968df48f55a5ec6dcd83947a9d7ccc163358c4cdcb9a2e
MD5 9994649222f35bb85ed01561a5eab57f
BLAKE2b-256 74d96597e6fbab32117bbb7307a61d05480a8543f9ead9accfb974218583da68

See more details on using hashes here.

Provenance

The following attestation bundles were made for nfs_rs-0.5.7.tar.gz:

Publisher: release.yml on JayTsu-sh/nfs-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nfs_rs-0.5.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nfs_rs-0.5.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f695763a715d3bc46a0a9e68b840e308ba9e9dce39bd8f93349621ce7a0aca0
MD5 7a1ae3da42d7a3416154b844f6fce3bc
BLAKE2b-256 e5488b53a9e95ddd1059c6df507e49ce4779d6cc1fde9a7f956c234048891013

See more details on using hashes here.

Provenance

The following attestation bundles were made for nfs_rs-0.5.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on JayTsu-sh/nfs-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.7.1

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.8

2 files

This release

0.5.7 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page