Skip to content

feat(session): add from_fds for externally pre-cloned fds#679

Open
XciD wants to merge 1 commit intocberner:masterfrom
XciD:upstream/from-fds
Open

feat(session): add from_fds for externally pre-cloned fds#679
XciD wants to merge 1 commit intocberner:masterfrom
XciD:upstream/from-fds

Conversation

@XciD
Copy link
Copy Markdown

@XciD XciD commented May 4, 2026

Summary

Adds Session::from_fds(filesystem, primary_fd, extra_fds, acl, config) for callers that receive /dev/fuse fds cloned by a privileged helper (e.g. a CSI driver sending fds over SCM_RIGHTS).

When extra_fds is non-empty:

  • Worker count = 1 + extra_fds.len() (config.n_threads is ignored).
  • Workers use the supplied fds directly; config.clone_fd and the internal clone_fd() path (which opens /dev/fuse and so requires CAP_SYS_ADMIN) are skipped.

Each extra fd must already be bound to the same FUSE connection as the primary (FUSE_DEV_IOC_CLONE ioctl); FUSE_INIT still happens on the primary during handshake().

from_fd is preserved as a thin wrapper over from_fds with no extras.

Motivation

In some deployments (e.g. Kubernetes CSI drivers), an unprivileged process should not hold CAP_SYS_ADMIN and so cannot itself open /dev/fuse to clone the session fd. A privileged sidecar opens /dev/fuse, performs FUSE_DEV_IOC_CLONE, and passes the resulting fds to the worker over a Unix socket. This API lets the worker drive a multi-threaded session over those externally-cloned fds without ever opening /dev/fuse itself.

@XciD XciD marked this pull request as ready for review May 4, 2026 08:41
Add Session::from_fds(filesystem, primary_fd, extra_fds, acl, config)
for callers that receive /dev/fuse fds cloned by a privileged helper
(e.g. a CSI driver sending fds over SCM_RIGHTS).

When extra_fds is non-empty:
- Worker count = 1 + extra_fds.len() (config.n_threads ignored).
- Workers use the supplied fds directly; config.clone_fd and the
  internal clone_fd() path (which opens /dev/fuse and so requires
  CAP_SYS_ADMIN) are skipped.

Each extra fd must already be bound to the same FUSE connection as
the primary (FUSE_DEV_IOC_CLONE ioctl); FUSE_INIT still happens on
the primary during handshake().

from_fd is preserved as a thin wrapper over from_fds with no extras.
@XciD XciD force-pushed the upstream/from-fds branch from eb49733 to c2b0183 Compare May 4, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant