diff --git a/libparsec/crates/platform_mountpoint/src/unix/filesystem.rs b/libparsec/crates/platform_mountpoint/src/unix/filesystem.rs index ff4bc626d87..ef44073d35c 100644 --- a/libparsec/crates/platform_mountpoint/src/unix/filesystem.rs +++ b/libparsec/crates/platform_mountpoint/src/unix/filesystem.rs @@ -444,20 +444,11 @@ impl fuser::Filesystem for Filesystem { .get_path_or_panic(ino); let ops = self.ops.clone(); self.tokio_handle.spawn(async move { - match ops.stat_entry(&path).await { - Ok(stat) => reply - .manual() - .attr(&TTL, &entry_stat_to_file_attr(stat, ino, uid, gid)), - Err(err) => match err { - WorkspaceStatEntryError::EntryNotFound => reply.manual().error(libc::ENOENT), - WorkspaceStatEntryError::Offline => reply.manual().error(libc::EHOSTUNREACH), - WorkspaceStatEntryError::NoRealmAccess => reply.manual().error(libc::EPERM), - WorkspaceStatEntryError::Stopped - | WorkspaceStatEntryError::InvalidKeysBundle(_) - | WorkspaceStatEntryError::InvalidCertificate(_) - | WorkspaceStatEntryError::InvalidManifest(_) - | WorkspaceStatEntryError::Internal(_) => reply.manual().error(libc::EIO), - }, + let res = getattr_from_path(&ops, path, ino, uid, gid).await; + + match res { + Ok(stat) => reply.manual().attr(&TTL, &stat), + Err(errno) => reply.manual().error(errno), } }); } @@ -1033,6 +1024,7 @@ impl fuser::Filesystem for Filesystem { return; } else { + // FIXME: Currently I'm only returning the file attributes without truncating the file // Truncate file by path let path = { @@ -1121,7 +1113,23 @@ impl fuser::Filesystem for Filesystem { // TODO: support atime/utime change ? - reply.manual().error(libc::ENOSYS); + // Nothing to set, just return the file attr + + let path = { + let inodes_guard = self.inodes.lock().expect("mutex is poisoned"); + inodes_guard.get_path_or_panic(ino) + }; + + let ops = self.ops.clone(); + + self.tokio_handle.spawn(async move { + let res = getattr_from_path(&ops, path, ino, uid, gid).await; + + match res { + Ok(attr) => reply.manual().attr(&TTL, &attr), + Err(errno) => reply.manual().error(errno), + } + }); } fn read( @@ -1636,3 +1644,31 @@ impl fuser::Filesystem for Filesystem { // TODO: Fuser exposes a `copy_file_range` method for FUSE >= 7.28. This // would speed up file copy a lot by reusing the same blocks ! } + +async fn getattr_from_path( + ops: &WorkspaceOps, + path: FsPath, + ino: u64, + uid: u32, + gid: u32, +) -> Result { + match ops + .stat_entry(&path) + .await + .map(|stat| entry_stat_to_file_attr(stat, ino, uid, gid)) + .inspect(|stat| log::trace!("File stat for {ino}: {stat:?}")) + .inspect_err(|e| log::trace!("File stat for {ino} result in error: {e:?}")) + { + Ok(stat) => Ok(stat), + Err(err) => match err { + WorkspaceStatEntryError::EntryNotFound => Err(libc::ENOENT), + WorkspaceStatEntryError::Offline => Err(libc::EHOSTUNREACH), + WorkspaceStatEntryError::NoRealmAccess => Err(libc::EPERM), + WorkspaceStatEntryError::Stopped + | WorkspaceStatEntryError::InvalidKeysBundle(_) + | WorkspaceStatEntryError::InvalidCertificate(_) + | WorkspaceStatEntryError::InvalidManifest(_) + | WorkspaceStatEntryError::Internal(_) => Err(libc::EIO), + }, + } +} diff --git a/newsfragments/8976.bugfix.rst b/newsfragments/8976.bugfix.rst new file mode 100644 index 00000000000..70e8915054b --- /dev/null +++ b/newsfragments/8976.bugfix.rst @@ -0,0 +1 @@ +Fix an issue when creating a new file from the mountpoint on macOS diff --git a/newsfragments/8991.bugfix.rst b/newsfragments/8991.bugfix.rst new file mode 100644 index 00000000000..6d6ecdd3a00 --- /dev/null +++ b/newsfragments/8991.bugfix.rst @@ -0,0 +1 @@ +Fix an issue when modifying a file using TextEdit on macOS