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

feat(ofs): introduce ofs macos support #5136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 6 additions & 36 deletions bin/ofs/Cargo.lock

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

4 changes: 2 additions & 2 deletions bin/ofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ tokio = { version = "1.37.0", features = [
] }
url = "2.5.0"

[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
fuse3 = { "version" = "0.7.2", "features" = ["tokio-runtime", "unprivileged"] }
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))'.dependencies]
fuse3 = { git = "https://github.com/oowl/fuse3", branch = "owl/macos-support-recreate", "features" = ["tokio-runtime", "unprivileged"] }
oowl marked this conversation as resolved.
Show resolved Hide resolved
fuse3_opendal = { version = "0.0.7", path = "../../integrations/fuse3" }
libc = "0.2.154"
nix = { version = "0.29.0", features = ["user"] }
Expand Down
12 changes: 2 additions & 10 deletions bin/ofs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn main() -> Result<()> {
execute(cfg).await
}

#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
async fn execute(cfg: Config) -> Result<()> {
use std::env;
use std::str::FromStr;
Expand Down Expand Up @@ -71,7 +71,7 @@ async fn execute(cfg: Config) -> Result<()> {
let mut uid = nix::unistd::getuid().into();
mount_options.uid(uid);

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
let mut mount_handle = if nix::unistd::getuid().is_root() {
if let Some(sudo_gid) = env::var("SUDO_GID")
.ok()
Expand Down Expand Up @@ -100,9 +100,6 @@ async fn execute(cfg: Config) -> Result<()> {
.await?
};

#[cfg(target_os = "freebsd")]
let mut mount_handle = Fuse::new().mount(cfg.mount_path, backend).await?;

let handle = &mut mount_handle;
tokio::select! {
res = handle => res?,
Expand Down Expand Up @@ -190,8 +187,3 @@ async fn execute(cfg: Config) -> Result<()> {

Ok(())
}

#[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "windows")))]
async fn execute(_cfg: Config) -> Result<()> {
Err(anyhow!("platform not supported"))
}
2 changes: 1 addition & 1 deletion integrations/fuse3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ version = "0.0.7"

[dependencies]
bytes = "1.6.0"
fuse3 = { version = "0.7.2", "features" = ["tokio-runtime", "unprivileged"] }
fuse3 = { git = "https://github.com/oowl/fuse3", branch = "owl/macos-support-recreate", "features" = ["tokio-runtime", "unprivileged"] }
futures-util = "0.3.30"
libc = "0.2.155"
log = "0.4.21"
Expand Down
23 changes: 23 additions & 0 deletions integrations/fuse3/src/file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ impl PathFilesystem for Filesystem {
Err(libc::EOPNOTSUPP.into())
}

async fn opendir(&self, _req: Request, path: &OsStr, flags: u32) -> Result<ReplyOpen> {
log::debug!("opendir(path={:?}, flags=0x{:x})", path, flags);
Ok(ReplyOpen { fh: 0, flags })
}

async fn open(&self, _req: Request, path: &OsStr, flags: u32) -> Result<ReplyOpen> {
log::debug!("open(path={:?}, flags=0x{:x})", path, flags);

Expand Down Expand Up @@ -821,6 +826,20 @@ impl PathFilesystem for Filesystem {
copied: u64::from(written),
})
}

async fn statfs(&self, _req: Request, path: &OsStr) -> Result<ReplyStatFs> {
log::debug!("statfs(path={:?})", path);
Ok(ReplyStatFs {
blocks: 1,
bfree: 0,
bavail: 0,
files: 1,
ffree: 0,
bsize: 4096,
namelen: u32::MAX,
frsize: 0,
})
}
}

const fn entry_mode2file_type(mode: EntryMode) -> FileType {
Expand Down Expand Up @@ -855,6 +874,10 @@ const fn dummy_file_attr(kind: FileType, now: SystemTime, uid: u32, gid: u32) ->
gid,
rdev: 0,
blksize: 4096,
#[cfg(target_os = "macos")]
crtime: now,
#[cfg(target_os = "macos")]
flags: 0,
}
}

Expand Down
Loading