Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mountpoint issues on macOS #9351

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ eventsource-stream = { version = "0.2.3", default-features = false }
flate2 = { version = "1.0.34", features = ["rust_backend"], default-features = false }
flume = { version = "0.11.1", default-features = false }
fnmatch-regex = { version = "0.2.1", default-features = false }
fuser = { version = "0.15.0", default-features = false }
fuser = { version = "0.15.1", default-features = false }
futures = { version = "0.3.31", default-features = false }
generic-array = { version = "0.14.7", default-features = false }
getrandom = { package = "getrandom", version = "0.2.15", default-features = false }
Expand Down Expand Up @@ -177,7 +177,7 @@ rpassword = { version = "7.3.1", default-features = false }
rsa = { version = "0.8.2", default-features = false }
rstest = { version = "0.18.2", default-features = false }
rstest_reuse = { version = "0.6.0", default-features = false }
ruzstd = { version = "0.7.2", default-features = true }
ruzstd = { version = "0.7.3", default-features = true }
sentry = { version = "0.34.0", default-features = false }
sentry-log = { version = "0.34.0", default-features = false }
serde = { version = "1.0.214", default-features = false }
Expand Down
8 changes: 8 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ We are not affected since sqlx is used on the client side to store the files' da
Before being stored in SQLite, that data is splitted into chunk and encoded, so we are below the overflow limit of 4GB.
"""

[[advisories.ignore]]
FirelightFlagboy marked this conversation as resolved.
Show resolved Hide resolved
id = "RUSTSEC-2024-0398"
reason = """
We do not distribute the same secret 500-1500 times.
https://github.com/Scille/parsec-cloud/issues/8990
"""

# If this is true, then cargo deny will use the git executable to fetch advisory database.
# If this is false, then it uses a built-in git library.
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.
Expand Down
69 changes: 54 additions & 15 deletions libparsec/crates/platform_mountpoint/src/unix/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
});
}
Expand Down Expand Up @@ -1033,6 +1024,7 @@ impl fuser::Filesystem for Filesystem {

return;
} else {
// FIXME: Currently I'm only returning the file attributes without truncating the file
FirelightFlagboy marked this conversation as resolved.
Show resolved Hide resolved
// Truncate file by path

let path = {
Expand Down Expand Up @@ -1121,7 +1113,26 @@ impl fuser::Filesystem for Filesystem {

// TODO: support atime/utime change ?
FirelightFlagboy marked this conversation as resolved.
Show resolved Hide resolved

reply.manual().error(libc::ENOSYS);
// Nothing to set, just return the file attr
FirelightFlagboy marked this conversation as resolved.
Show resolved Hide resolved
// Seems benign but it's important for `setattr` to return the file attributes even if
// nothing changed.
// Previously we where returning an error and that caused the issues #8976 and #8991

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(
Expand Down Expand Up @@ -1636,3 +1647,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<fuser::FileAttr, i32> {
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),
},
}
}
1 change: 1 addition & 0 deletions newsfragments/8976.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue when creating a new file from the mountpoint on macOS
1 change: 1 addition & 0 deletions newsfragments/8991.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue when modifying a file using TextEdit on macOS
1 change: 1 addition & 0 deletions newsfragments/9173.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a panic when copying a file using the mountpoint on macOS
Loading