diff --git a/bin/ofs/src/bin/ofs.rs b/bin/ofs/src/bin/ofs.rs index 89a619928724..62999c0b05a0 100644 --- a/bin/ofs/src/bin/ofs.rs +++ b/bin/ofs/src/bin/ofs.rs @@ -23,5 +23,5 @@ async fn main() -> Result<()> { let cfg = ofs::Config::parse(); env_logger::init(); - ofs::new_app(cfg).await + ofs::execute(cfg).await } diff --git a/bin/ofs/src/config.rs b/bin/ofs/src/config.rs index 6afa729a79ef..4544ff99e40c 100644 --- a/bin/ofs/src/config.rs +++ b/bin/ofs/src/config.rs @@ -22,12 +22,13 @@ use url::Url; #[command(version, about)] pub struct Config { /// fuse mount path + #[cfg(target_os = "linux")] #[arg(env = "OFS_MOUNT_PATH", index = 1)] - pub(crate) mount_path: String, + pub mount_path: String, /// location of opendal service /// format: ://?=&= /// example: fs://?root=/tmp #[arg(env = "OFS_BACKEND", index = 2)] - pub(crate) backend: Url, + pub backend: Url, } diff --git a/bin/ofs/src/fuse.rs b/bin/ofs/src/fuse.rs index 0f81135a95af..f671cad58d98 100644 --- a/bin/ofs/src/fuse.rs +++ b/bin/ofs/src/fuse.rs @@ -68,14 +68,14 @@ impl FileKey { } } -pub(super) struct Ofs { +pub(super) struct Fuse { op: Operator, gid: u32, uid: u32, opened_files: Slab, } -impl Ofs { +impl Fuse { pub fn new(op: Operator, uid: u32, gid: u32) -> Self { Self { op, @@ -128,7 +128,7 @@ impl Ofs { } #[async_trait] -impl PathFilesystem for Ofs { +impl PathFilesystem for Fuse { type DirEntryStream = BoxStream<'static, Result>; type DirEntryPlusStream = BoxStream<'static, Result>; diff --git a/bin/ofs/src/lib.rs b/bin/ofs/src/lib.rs index d95e99d6bdfd..02417adbb4ea 100644 --- a/bin/ofs/src/lib.rs +++ b/bin/ofs/src/lib.rs @@ -29,7 +29,7 @@ pub use config::Config; #[cfg(target_os = "linux")] mod fuse; -pub async fn new_app(cfg: Config) -> Result<()> { +pub async fn execute(cfg: Config) -> Result<()> { if cfg.backend.has_host() { log::warn!("backend host will be ignored"); } @@ -52,7 +52,7 @@ pub async fn new_app(cfg: Config) -> Result<()> { mount_path: cfg.mount_path, backend, }; - execute(args).await + execute_inner(args).await } #[derive(Debug)] @@ -63,13 +63,13 @@ struct Args { } #[cfg(not(target_os = "linux"))] -async fn execute(args: Args) -> Result<()> { +async fn execute_inner(args: Args) -> Result<()> { _ = args.backend; Err(anyhow::anyhow!("platform not supported")) } #[cfg(target_os = "linux")] -async fn execute(args: Args) -> Result<()> { +async fn execute_inner(args: Args) -> Result<()> { use fuse3::path::Session; use fuse3::MountOptions; @@ -81,10 +81,10 @@ async fn execute(args: Args) -> Result<()> { mount_option.gid(gid.into()); mount_option.no_open_dir_support(true); - let ofs = fuse::Ofs::new(args.backend, uid.into(), gid.into()); + let adapter = fuse::Fuse::new(args.backend, uid.into(), gid.into()); let mount_handle = Session::new(mount_option) - .mount_with_unprivileged(ofs, args.mount_path) + .mount_with_unprivileged(adapter, args.mount_path) .await?; mount_handle.await?;