Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Session to allow users to mount it themselves #301

Closed
wants to merge 3 commits into from

Conversation

colinmarc
Copy link
Contributor

This is a stab at addressing #300. It's made up of three steps:

  1. Drop support for libfuse, in favor of the pure-rust / fusermount bits
  2. Instead of automatically calling fusermount if mount(2) fails, let the user choose which to call
  3. Add impl AsFd to Session, and split the unmount-on-drop into a separate type

Each of the commits are reviewable independently. Obviously, I'm aware these are breaking changes. I understand if you're not very inclined to accept them.

Dropping libfuse is necessary here because there's no way to tell libfuse to run a session that was mounted elsewhere, or to tell it [not] to use fusermount explicitly. Splitting out fusermount explicitly is necessary because fusermount doesn't let you send it the /dev/fuse FD; it wants to open it itself. So the create-session-and-mount-separately path only works if you don't use fusermount.

@colinmarc colinmarc force-pushed the mount-fd-2 branch 3 times, most recently from ae810df to af91b06 Compare October 7, 2024 10:02
There are multiple ways to mount FUSE filesystems. Processes with
elevated privileges (CAP_SYS_ADMIN) can use the mount(2) syscall
directly or via a suitable helper. libfuse also installs a helper
program, fusermount(1), which is setuid root, to perform this mounting
operation.

Previously, we would attempt the syscall, and then fallback to trying
fusermount (if we can find it) automatically. This is a little bit too
magical, so it's better to make the option explicit.
This is a minor refactor of `Session`, to make the API slightly more
flexible. Splitting `Mount` into a separate object allows callers to

 - Create a mount without a Session object
 - Create a session given an existing /dev/fuse FD

One use case for this is when mounting inside containers, when you need
to handle the session and mounting in separate processes.

Fixes cberner#300
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