Skip to content

Commit

Permalink
feat(bin/ofs): privileged mount (#4507)
Browse files Browse the repository at this point in the history
* feat: privileged mount

* chore
  • Loading branch information
ho-229 committed Apr 23, 2024
1 parent d20ecf3 commit 2f91f60
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 37 deletions.
32 changes: 2 additions & 30 deletions bin/ofs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bin/ofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ fuse3 = { "version" = "0.7.1", "features" = ["tokio-runtime", "unprivileged"] }
futures-util = "0.3.30"
libc = "0.2.151"
log = "0.4.21"
nix = { version = "0.27.1", features = ["user"] }
nix = { version = "0.28.0", features = ["user"] }
opendal = { version = "0.45.1", path = "../../core" }
sharded-slab = "0.1.7"
tokio = { version = "1.37", features = [
tokio = { version = "1.37.0", features = [
"fs",
"macros",
"rt-multi-thread",
"rt",
"io-std",
"signal",
] }
Expand Down
3 changes: 2 additions & 1 deletion bin/ofs/src/bin/ofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use anyhow::Result;
use clap::Parser;

#[tokio::main]
// FIXME: https://github.com/apache/opendal/issues/4512
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
let cfg = ofs::Config::parse();

Expand Down
14 changes: 11 additions & 3 deletions bin/ofs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@ async fn execute_inner(args: Args) -> Result<()> {
mount_option.uid(uid.into());
mount_option.gid(gid.into());
mount_option.no_open_dir_support(true);
mount_option.read_only(true);

let adapter = fuse::Fuse::new(args.backend, uid.into(), gid.into());

let mut mount_handle = Session::new(mount_option)
.mount_with_unprivileged(adapter, args.mount_path)
.await?;
let session = Session::new(mount_option);

let mut mount_handle = if uid.is_root() {
session.mount(adapter, args.mount_path).await?
} else {
log::warn!("unprivileged mount may not detect external unmount, tracking issue: https://github.com/Sherlock-Holo/fuse3/issues/72");
session
.mount_with_unprivileged(adapter, args.mount_path)
.await?
};

let handle = &mut mount_handle;

Expand Down

0 comments on commit 2f91f60

Please sign in to comment.