Skip to content

Commit

Permalink
feat: fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
oowl committed Mar 31, 2024
1 parent cc33d1e commit 9d6f88b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ use raw::abi::{
FATTR_MODE, FATTR_MTIME, FATTR_MTIME_NOW, FATTR_SIZE, FATTR_UID,
};

#[cfg(target_os = "macos")]
use raw::abi::{FATTR_CHGTIME, FATTR_CRTIME, FATTR_BKUPTIME, FATTR_FLAGS};

mod errno;
mod helper;
mod mount_options;
Expand Down Expand Up @@ -169,6 +172,26 @@ impl From<&fuse_setattr_in> for SetAttr {
set_attr.ctime = fsai2ts!(setattr_in.ctime, setattr_in.ctimensec);
}

#[cfg(target_os = "macos")]
if setattr_in.crtime & FATTR_CRTIME > 0 {
set_attr.ctime = fsai2ts!(setattr_in.crtime, setattr_in.crtimensec);
}

#[cfg(target_os = "macos")]
if setattr_in.chgtime & FATTR_CHGTIME > 0 {
set_attr.ctime = fsai2ts!(setattr_in.chgtime, setattr_in.chgtimensec);
}

#[cfg(target_os = "macos")]
if setattr_in.bkuptime & FATTR_BKUPTIME > 0 {
set_attr.ctime = fsai2ts!(setattr_in.bkuptime, setattr_in.bkuptimensec);
}

#[cfg(target_os = "macos")]
if setattr_in.flags & FATTR_FLAGS > 0 {
set_attr.flags = Some(setattr_in.flags);
}

set_attr
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/mount_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use std::os::unix::io::RawFd;

#[cfg(target_os = "freebsd")]
use nix::mount::Nmount;
#[cfg(target_os = "macos")]
use nix::mount::mount;
use nix::unistd;

/// mount options.
Expand Down
6 changes: 3 additions & 3 deletions src/raw/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,11 @@ pub struct fuse_setattr_in {
pub gid: u32,
pub unused5: u32,
#[cfg(target_os = "macos")]
pub bkuptime: u64,
pub bkuptime: u32,
#[cfg(target_os = "macos")]
pub chgtime: u64,
pub chgtime: u32,
#[cfg(target_os = "macos")]
pub crtime: u64,
pub crtime: u32,
#[cfg(target_os = "macos")]
pub bkuptimensec: u32,
#[cfg(target_os = "macos")]
Expand Down
6 changes: 3 additions & 3 deletions src/raw/connection/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use std::io;
use std::io::ErrorKind;
#[cfg(target_os = "linux")]
use std::io::Write;
use std::io::{IoSlice, IoSliceMut, Read};
use std::io::{IoSlice, IoSliceMut};
#[cfg(target_os = "linux")]
use std::mem::ManuallyDrop;
use std::ops::{Deref, DerefMut};
#[cfg(any(
Expand All @@ -19,10 +20,9 @@ use std::ops::{Deref, DerefMut};
target_os = "macos",
))]
use std::os::fd::OwnedFd;
use std::os::fd::{AsFd, BorrowedFd, FromRawFd};
use std::os::fd::{AsFd, BorrowedFd};
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::AsRawFd;
#[cfg(all(target_os = "linux", feature = "unprivileged"))]
use std::os::unix::io::RawFd;
use std::pin::pin;
Expand Down
35 changes: 35 additions & 0 deletions src/raw/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,41 @@ impl<FS: Filesystem + Send + Sync + 'static> Session<FS> {
reply_flags |= FUSE_NO_OPENDIR_SUPPORT;
}

#[cfg(target_os = "macos")]
if init_in.flags & FUSE_ALLOCATE > 0 {
debug!("enable FUSE_ALLOCATE");

reply_flags |= FUSE_ALLOCATE;
}

#[cfg(target_os = "macos")]
if init_in.flags & FUSE_EXCHANGE_DATA > 0 {
debug!("enable FUSE_EXCHANGE_DATA");

reply_flags |= FUSE_EXCHANGE_DATA;
}

#[cfg(target_os = "macos")]
if init_in.flags & FUSE_CASE_INSENSITIVE > 0 {
debug!("enable FUSE_CASE_INSENSITIVE");

reply_flags |= FUSE_CASE_INSENSITIVE;
}

#[cfg(target_os = "macos")]
if init_in.flags & FUSE_VOL_RENAME > 0 {
debug!("enable FUSE_VOL_RENAME");

reply_flags |= FUSE_VOL_RENAME;
}

#[cfg(target_os = "macos")]
if init_in.flags & FUSE_XTIMES > 0 {
debug!("enable FUSE_XTIMES");

reply_flags |= FUSE_XTIMES;
}

// TODO: pass init_in to init, so the file system will know which flags are in use.
let reply = match fs.init(request).await {
Err(err) => {
Expand Down

0 comments on commit 9d6f88b

Please sign in to comment.