Skip to content

Commit 0467065

Browse files
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 9184b25 commit 0467065

File tree

7 files changed

+71
-21
lines changed

7 files changed

+71
-21
lines changed

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ eventsource-stream = { version = "0.2.3", default-features = false }
133133
flate2 = { version = "1.0.34", features = ["rust_backend"], default-features = false }
134134
flume = { version = "0.11.1", default-features = false }
135135
fnmatch-regex = { version = "0.2.1", default-features = false }
136-
fuser = { version = "0.15.0", default-features = false }
136+
fuser = { version = "0.15.1", default-features = false }
137137
futures = { version = "0.3.31", default-features = false }
138138
generic-array = { version = "0.14.7", default-features = false }
139139
getrandom = { package = "getrandom", version = "0.2.15", default-features = false }
@@ -177,7 +177,7 @@ rpassword = { version = "7.3.1", default-features = false }
177177
rsa = { version = "0.8.2", default-features = false }
178178
rstest = { version = "0.18.2", default-features = false }
179179
rstest_reuse = { version = "0.6.0", default-features = false }
180-
ruzstd = { version = "0.7.2", default-features = true }
180+
ruzstd = { version = "0.7.3", default-features = true }
181181
sentry = { version = "0.34.0", default-features = false }
182182
sentry-log = { version = "0.34.0", default-features = false }
183183
serde = { version = "1.0.214", default-features = false }

deny.toml

+8
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ We are not affected since sqlx is used on the client side to store the files' da
9393
Before being stored in SQLite, that data is splitted into chunk and encoded, so we are below the overflow limit of 4GB.
9494
"""
9595

96+
[[advisories.ignore]]
97+
id = "RUSTSEC-2024-0398"
98+
reason = """
99+
We do not distribute the same secret 500-1500 times.
100+
101+
https://github.com/Scille/parsec-cloud/issues/8990
102+
"""
103+
96104
# If this is true, then cargo deny will use the git executable to fetch advisory database.
97105
# If this is false, then it uses a built-in git library.
98106
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.

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)