Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4bc2ba

Browse files
FirelightFlagboytouilleMan
andcommittedJan 21, 2025
Fix mountpoint issues on macOS (#9351)
* [rust] update `fuser` to `0.15.1` Fix #9173 * Make `setattr` always return file attr even if no attr where changed Fix #8976, fix #8991 Co-authored-by: Emmanuel Leblond <[email protected]> * [rust] Update `ruzstd` to `0.7.3` * Ignore `RUSTSEC-2024-0398` Related to #8990 --------- Co-authored-by: Emmanuel Leblond <[email protected]>
1 parent 12f41ff commit d4bc2ba

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed
 

‎libparsec/crates/platform_mountpoint/src/unix/filesystem.rs

+54-15
Original file line numberDiff line numberDiff line change
@@ -444,20 +444,11 @@ impl fuser::Filesystem for Filesystem {
444444
.get_path_or_panic(ino);
445445
let ops = self.ops.clone();
446446
self.tokio_handle.spawn(async move {
447-
match ops.stat_entry(&path).await {
448-
Ok(stat) => reply
449-
.manual()
450-
.attr(&TTL, &entry_stat_to_file_attr(stat, ino, uid, gid)),
451-
Err(err) => match err {
452-
WorkspaceStatEntryError::EntryNotFound => reply.manual().error(libc::ENOENT),
453-
WorkspaceStatEntryError::Offline => reply.manual().error(libc::EHOSTUNREACH),
454-
WorkspaceStatEntryError::NoRealmAccess => reply.manual().error(libc::EPERM),
455-
WorkspaceStatEntryError::Stopped
456-
| WorkspaceStatEntryError::InvalidKeysBundle(_)
457-
| WorkspaceStatEntryError::InvalidCertificate(_)
458-
| WorkspaceStatEntryError::InvalidManifest(_)
459-
| WorkspaceStatEntryError::Internal(_) => reply.manual().error(libc::EIO),
460-
},
447+
let res = getattr_from_path(&ops, path, ino, uid, gid).await;
448+
449+
match res {
450+
Ok(stat) => reply.manual().attr(&TTL, &stat),
451+
Err(errno) => reply.manual().error(errno),
461452
}
462453
});
463454
}
@@ -1033,6 +1024,7 @@ impl fuser::Filesystem for Filesystem {
10331024

10341025
return;
10351026
} else {
1027+
// FIXME: Currently I'm only returning the file attributes without truncating the file
10361028
// Truncate file by path
10371029

10381030
let path = {
@@ -1121,7 +1113,26 @@ impl fuser::Filesystem for Filesystem {
11211113

11221114
// TODO: support atime/utime change ?
11231115

1124-
reply.manual().error(libc::ENOSYS);
1116+
// Nothing to set, just return the file attr
1117+
// Seems benign but it's important for `setattr` to return the file attributes even if
1118+
// nothing changed.
1119+
// Previously we where returning an error and that caused the issues #8976 and #8991
1120+
1121+
let path = {
1122+
let inodes_guard = self.inodes.lock().expect("Mutex is poisoned");
1123+
inodes_guard.get_path_or_panic(ino)
1124+
};
1125+
1126+
let ops = self.ops.clone();
1127+
1128+
self.tokio_handle.spawn(async move {
1129+
let res = getattr_from_path(&ops, path, ino, uid, gid).await;
1130+
1131+
match res {
1132+
Ok(attr) => reply.manual().attr(&TTL, &attr),
1133+
Err(errno) => reply.manual().error(errno),
1134+
}
1135+
});
11251136
}
11261137

11271138
fn read(
@@ -1636,3 +1647,31 @@ impl fuser::Filesystem for Filesystem {
16361647
// TODO: Fuser exposes a `copy_file_range` method for FUSE >= 7.28. This
16371648
// would speed up file copy a lot by reusing the same blocks !
16381649
}
1650+
1651+
async fn getattr_from_path(
1652+
ops: &WorkspaceOps,
1653+
path: FsPath,
1654+
ino: u64,
1655+
uid: u32,
1656+
gid: u32,
1657+
) -> Result<fuser::FileAttr, i32> {
1658+
match ops
1659+
.stat_entry(&path)
1660+
.await
1661+
.map(|stat| entry_stat_to_file_attr(stat, ino, uid, gid))
1662+
.inspect(|stat| log::trace!("File stat for {ino}: {stat:?}"))
1663+
.inspect_err(|e| log::trace!("File stat for {ino} result in error: {e:?}"))
1664+
{
1665+
Ok(stat) => Ok(stat),
1666+
Err(err) => match err {
1667+
WorkspaceStatEntryError::EntryNotFound => Err(libc::ENOENT),
1668+
WorkspaceStatEntryError::Offline => Err(libc::EHOSTUNREACH),
1669+
WorkspaceStatEntryError::NoRealmAccess => Err(libc::EPERM),
1670+
WorkspaceStatEntryError::Stopped
1671+
| WorkspaceStatEntryError::InvalidKeysBundle(_)
1672+
| WorkspaceStatEntryError::InvalidCertificate(_)
1673+
| WorkspaceStatEntryError::InvalidManifest(_)
1674+
| WorkspaceStatEntryError::Internal(_) => Err(libc::EIO),
1675+
},
1676+
}
1677+
}

‎newsfragments/8976.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix an issue when creating a new file from the mountpoint on macOS

‎newsfragments/8991.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix an issue when modifying a file using TextEdit on macOS

‎newsfragments/9173.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a panic when copying a file using the mountpoint on macOS

0 commit comments

Comments
 (0)
Please sign in to comment.