You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/04/23 12:52:38 UTC
(opendal) branch main updated: feat(bin/ofs): privileged mount (#4507)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 2f91f60ec5 feat(bin/ofs): privileged mount (#4507)
2f91f60ec5 is described below
commit 2f91f60ec5969565e7dddacf9746c659d30e3eba
Author: Ho 229 <ho...@gmail.com>
AuthorDate: Tue Apr 23 20:52:33 2024 +0800
feat(bin/ofs): privileged mount (#4507)
* feat: privileged mount
* chore
---
bin/ofs/Cargo.lock | 32 ++------------------------------
bin/ofs/Cargo.toml | 6 +++---
bin/ofs/src/bin/ofs.rs | 3 ++-
bin/ofs/src/lib.rs | 14 +++++++++++---
4 files changed, 18 insertions(+), 37 deletions(-)
diff --git a/bin/ofs/Cargo.lock b/bin/ofs/Cargo.lock
index c7dc875920..37b942b9fa 100644
--- a/bin/ofs/Cargo.lock
+++ b/bin/ofs/Cargo.lock
@@ -472,7 +472,7 @@ dependencies = [
"futures-channel",
"futures-util",
"libc",
- "nix 0.28.0",
+ "nix",
"serde",
"slab",
"tokio",
@@ -611,12 +611,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
-[[package]]
-name = "hermit-abi"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f"
-
[[package]]
name = "hex"
version = "0.4.3"
@@ -872,17 +866,6 @@ dependencies = [
"windows-sys 0.48.0",
]
-[[package]]
-name = "nix"
-version = "0.27.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
-dependencies = [
- "bitflags",
- "cfg-if",
- "libc",
-]
-
[[package]]
name = "nix"
version = "0.28.0"
@@ -905,16 +888,6 @@ dependencies = [
"autocfg",
]
-[[package]]
-name = "num_cpus"
-version = "1.16.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
-dependencies = [
- "hermit-abi",
- "libc",
-]
-
[[package]]
name = "object"
version = "0.32.2"
@@ -937,7 +910,7 @@ dependencies = [
"futures-util",
"libc",
"log",
- "nix 0.27.1",
+ "nix",
"opendal",
"sharded-slab",
"tempfile",
@@ -1509,7 +1482,6 @@ dependencies = [
"bytes",
"libc",
"mio",
- "num_cpus",
"pin-project-lite",
"signal-hook-registry",
"socket2",
diff --git a/bin/ofs/Cargo.toml b/bin/ofs/Cargo.toml
index b0e3e99252..8560bb4d2d 100644
--- a/bin/ofs/Cargo.toml
+++ b/bin/ofs/Cargo.toml
@@ -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",
] }
diff --git a/bin/ofs/src/bin/ofs.rs b/bin/ofs/src/bin/ofs.rs
index 62999c0b05..5d953e1956 100644
--- a/bin/ofs/src/bin/ofs.rs
+++ b/bin/ofs/src/bin/ofs.rs
@@ -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();
diff --git a/bin/ofs/src/lib.rs b/bin/ofs/src/lib.rs
index 779c84cd32..6a88c90d36 100644
--- a/bin/ofs/src/lib.rs
+++ b/bin/ofs/src/lib.rs
@@ -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;