Hasty Briefsbeta

Bilingual

Building a Linux filesystem module in almost pure Rust

6 hours ago
  • ZeroFS introduces a native kernel client: an out-of-tree Linux filesystem module written in Rust, with a small amount of C for netfslib helpers.
  • The kernel client registers with VFS, uses netfslib for I/O, and speaks the 9P2000.L.Z protocol directly over TCP or Unix sockets, eliminating the userspace round trip of FUSE-based mounts.
  • Compared to Linux v9fs, the ZeroFS kernel client supports custom metadata operations, reconnection after server failover, and leader/standby pairs.
  • The module leverages Rust in the kernel (Linux 6.18+) for basic infrastructure, but VFS interactions rely on raw C structs and extern "C" callbacks; most unsafe code is confined to glue, while the protocol implementation is safe.
  • Approximately 250 lines of C code in netfs/compat_helpers.c and vfs/compat_helpers.c handle static inline functions that bindgen cannot process.
  • Netfslib handles buffered I/O; the module implements request operations for reads and writes, with message sizes up to 10 MiB and caching policy options: relaxed (1 second) or strict (server-revalidated, unbuffered).
  • Each mount has a single connection to the server; requests use 16-bit tags for multiplexing, allowing multiple callers to wait on their own tags without blocking others.
  • For kernels without Rust support, the build compiles the module as LLVM bitcode, internalizes Rust symbols, and links with the kernel's normal module tools, supporting x86-64 (GCC/Clang) and little-endian arm64.
  • The source code resides in the kernel/ directory; packages, Secure Boot enrollment, and mount options are documented in the kernel client documentation.