From 2b0a2a6631d4fd7bb436a7ac0c3f03c9ed929976 Mon Sep 17 00:00:00 2001 From: Xin Yin Date: Wed, 6 Dec 2023 20:04:48 +0800 Subject: [PATCH] builder: fix compile error for macos Fix the compile error for macos due to upgrading fuse-backend-rs. Signed-off-by: Xin Yin --- rafs/src/fs.rs | 15 ++++++++++++++- service/src/fusedev.rs | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/rafs/src/fs.rs b/rafs/src/fs.rs index c053d2e0c81..15a1848c4ce 100644 --- a/rafs/src/fs.rs +++ b/rafs/src/fs.rs @@ -502,6 +502,15 @@ impl FileSystem for Rafs { type Inode = Inode; type Handle = Handle; + #[cfg(target_os = "macos")] + fn init(&self, _opts: FsOptions) -> Result { + Ok( + // These fuse features are supported by rafs by default. + FsOptions::ASYNC_READ | FsOptions::BIG_WRITES | FsOptions::ATOMIC_O_TRUNC, + ) + } + + #[cfg(target_os = "linux")] fn init(&self, _opts: FsOptions) -> Result { Ok( // These fuse features are supported by rafs by default. @@ -823,7 +832,10 @@ impl FileSystem for Rafs { _flags: u32, ) -> Result<(Option, OpenOptions)> { // Cache dir since we are readonly - Ok((None, OpenOptions::CACHE_DIR | OpenOptions::KEEP_CACHE)) + #[cfg(target_os = "macos")] + return Ok((None, OpenOptions::KEEP_CACHE)); + #[cfg(target_os = "linux")] + return Ok((None, OpenOptions::CACHE_DIR | OpenOptions::KEEP_CACHE)); } fn releasedir(&self, _ctx: &Context, _inode: u64, _flags: u32, _handle: u64) -> Result<()> { @@ -1033,6 +1045,7 @@ mod tests { assert_eq!(ent.inode, 0); assert_eq!(ent.generation, 0); assert_eq!(ent.attr_flags, 0); + #[cfg(target_os = "linux")] rafs.init(FsOptions::ASYNC_DIO).unwrap(); rafs.open(&Context::default(), Inode::default(), 0, 0) .unwrap(); diff --git a/service/src/fusedev.rs b/service/src/fusedev.rs index c6b983bef90..5dc9da598fa 100644 --- a/service/src/fusedev.rs +++ b/service/src/fusedev.rs @@ -632,6 +632,18 @@ pub fn create_fuse_daemon( } /// Create vfs backend with rafs or passthrough as the fuse filesystem driver + +#[cfg(target_os = "macos")] +pub fn create_vfs_backend( + _fs_type: FsBackendType, + _is_fuse: bool, + _hybrid_mode: bool, +) -> Result> { + let vfs = fuse_backend_rs::api::Vfs::new(fuse_backend_rs::api::VfsOptions::default()); + Ok(Arc::new(vfs)) +} + +#[cfg(target_os = "linux")] pub fn create_vfs_backend( fs_type: FsBackendType, is_fuse: bool,