Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
microsandbox-filesystem
Filesystem backends for microsandbox virtual machines. This crate provides four pluggable backends that give each sandbox a complete, Linux-compatible filesystem — from bind-mounting a host directory to stacking OCI image layers with copy-on-write.
- No root required — runs unprivileged; guest-visible ownership and permissions are virtualized without touching the host filesystem
- Runs on macOS too — the guest sees a full Linux filesystem even when the host is macOS
- Zero-copy I/O — file reads and writes flow directly between host and guest with no intermediate allocation
- Real OCI layer semantics — OverlayFs handles whiteouts, opaque directories, and atomic copy-up correctly
- Composable — all four backends implement
DynFileSystemand can be nested freely
Backends
PassthroughFs
Exposes a single host directory to the guest VM. The guest sees standard Linux ownership, permissions, and file types even when the host runs macOS.
let fs = builder
.root_dir
.build?;
Metadata like uid, gid, and mode are stored in an extended attribute on the host, so the actual host file permissions stay untouched. Special files (devices, sockets, FIFOs) are stored as regular files with their type bits in the xattr. Path confinement prevents the guest from escaping the root directory.
OverlayFs
Stacks N read-only layers with one writable upper layer — like Linux kernel overlayfs, but in userspace. This is how OCI container images work.
let fs = builder
.layer // bottom layer (e.g. base OS)
.layer // stacked on top (e.g. pip install)
.writable // sandbox-local writable layer
.staging // must be on same filesystem as upper
.build?;
When the guest modifies a file from a lower layer, it's copied to the upper layer first (copy-on-write). Deleting a lower-layer file creates a whiteout marker so it appears gone. The lower layers are never modified.
MemFs
A pure in-memory filesystem — no host I/O at all. Good for scratch space and ephemeral workloads.
use SizeExt;
let fs = builder
.capacity
.max_inodes
.build?;
DualFs
Combines two backends under a single mount point with a dispatch policy that routes each operation to the right backend.
let fs = builder
.backend_a
.backend_b
.policy
.build?;
Built-in policies:
| Policy | Behavior |
|---|---|
ReadBackendBWriteBackendA |
Reads from B, writes to A (default) |
BackendAOnly |
Everything goes to A |
BackendAFallbackToBackendBRead |
Reads try A first, fall back to B |
MergeReadsBackendAPrecedence |
Merge directory listings, A wins on conflicts |
When a write targets a file that lives on the other backend, DualFs copies it over automatically.
Composability
Backends can be nested freely since they all implement DynFileSystem. For example, a DualFs can combine an OverlayFs with a MemFs:
let overlay = builder
.layer
.layer
.writable
.staging
.build?;
let mem = builder
.capacity
.build?;
let dual = builder
.backend_a
.backend_b
.policy
.build?;
Cache Policies
All backends support configurable kernel caching:
| Policy | Behavior |
|---|---|
Never |
No caching — every read hits the backend (DIRECT_IO) |
Auto |
Kernel decides (default for PassthroughFs, OverlayFs, DualFs) |
Always |
Aggressive caching (default for MemFs, since memory is authoritative) |
let fs = builder
.root_dir
.cache_policy
.build?;