Skip to content

fix(operations): place a copy where the mount refuses links with EACCES - #1945

Merged
l0gicgate merged 3 commits into
lgse:mainfrom
Thejus-M:fix/1941-place-copies-where-links-are-refused-with-eacces
Oct 31, 2026
Merged

l0gicgate merged 3 commits into
lgse:mainfrom
Thejus-M:fix/1941-place-copies-where-links-are-refused-with-eacces

Conversation

@Thejus-M

Copy link
Copy Markdown
Contributor

Description

Copying a file into a mount that refuses link() with EACCES always failed with
Could not copy <name>: Permission denied, and nothing was created at the destination.
A KDE Connect SFTP mount of an Android phone is one such mount: its server implements no
hardlink or symlink extension, and sshfs reports the refusal as EACCES rather than
EPERM or EOPNOTSUPP. Since renameat2(RENAME_NOREPLACE) also fails there (EINVAL,
already learned as unsupported), the hard link was the only remaining publish rung, so the
whole copy aborted even though plain writes, rename(), chmod and the rest all work.

placement.rs classified EPERM and the is_unsupported errnos but let EACCES fall
through to PlaceError::Io, and probe turned it into Ok(None), so the mount never
learned anything and every paste repeated the failing link().

This treats EACCES the way EPERM is already treated at the link rung, at the symlink
rung, and in the capability probe, so the mount is learned once and the copy falls back to
the exclusive-creation path that works there. exchange_through already pairs
Errno::ACCESS with Errno::PERM, so this follows the existing convention.

Visual evidence

N/A — no user-visible surface changed. The only difference is that a copy onto such a mount
now completes instead of showing the "Permission denied" error dialog.

How to test

  1. Pair an Android phone with KDE Connect and open its filesystem, so kdeconnectd mounts it
    with sshfs at /run/user/<uid>/<device-id>.
  2. In Strata, open /run/user/<uid>/<device-id>/storage/emulated/0/Download.
  3. Copy any local file and paste it there.

Expected result: the file is copied. Before this change the paste failed with
Could not copy <name>: Permission denied and created nothing.

Without a phone, the added regression test covers it: the quirks harness refuses every link
with EACCES, and placing a file must reach the reserved-file rung and record
hard_links: Some(false) for the mount.

Related issue

Closes #1941

@github-actions github-actions Bot added the fix label Oct 30, 2026
@wmfeht

wmfeht commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Review: no bugs found. The change treats EACCES like EPERM on the link rung, the symlink rung and the probe, as described. Without the fix, the new test gets Io(EACCES) from the link rung, so it catches the regression.

Behaviour change: a real "permission denied" now takes a different route (low)

This only applies on mounts without RENAME_NOREPLACE (sshfs, vboxsf and similar) when the destination folder really can't be written to. There, a link refused with EACCES now goes on to the later rungs:

  • the probe can't create its file, so hard_links stays None;
  • recreate_symlink returns Unsupported for a regular file;
  • allows_reserved_name turns down the reserved-file rung because hard_links is still None.

So place now returns PlaceError::Unsupported where it used to return Io(EACCES).

  • Moves: local_operations.rs (the Err(PlaceError::CrossDevice | PlaceError::Unsupported) arm of the in-mount move) turns this into Moved::Copy. A move into an unwritable folder now tries a copy-and-delete, which should then fail on its own EACCES. The move still fails, but by a longer path. I haven't checked that the final error dialog still says "Permission denied".
  • Copies: not affected in practice, since the staged file already sits in the destination folder.
  • Folder renames: deferred_close::retry_folder_rename only covers folders and place_directory didn't change, so the Io(EACCES) retry is unaffected.

Accepting this seems reasonable. Mentioning it in the PR body would make it clear it's intended.

Test coverage gaps (minor)

  • Symlink rung: the new EACCES arms in recreate_symlink have no test. Adding symlinks: Support::Rejected(Errno::ACCESS) and a symlink source would cover both arms.
  • Existing destination: the exists(fs, to)? → Exists path after an EACCES link isn't covered. the_ladder_never_replaces_an_existing_destination already has a links: Support::Rejected(Errno::PERM) set. Adding a Rejected(Errno::ACCESS) set there would check that a destination created just before the link rung is never replaced, extending an existing setup rather than adding a new test.
  • More faithful fixture (optional): the new test starts from without_flags(Errno::INVAL). Building it from Quirks { links: Support::Rejected(Errno::ACCESS), ..Quirks::sshfs() } would match the KDE Connect mount more closely, including collisions_as_eperm and single_link_count, which matter on the reserved-file rung.

I didn't run the tests locally.

wmfeht
wmfeht previously approved these changes Oct 30, 2026
…fused

A link refused with EACCES now runs the capability probe, but a folder that
cannot be written refuses the probe's file as well. Report that denial as
before instead of falling through to Unsupported, which turned a refused
move into a copy that failed later on the same error.

Cover the symlink rung's EACCES arms and the existing-destination check
alongside the EPERM set, and build the refusing mount from the sshfs preset.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review pass: merged main (e7f3d068d) into the branch and pushed one follow-up commit, 0f2a3e901.

What changed and why

  • place_non_directory: the EPERM | EACCES arm now returns the link's own errno when the probe itself is refused with EACCES. This addresses the behaviour change noted in the review above: on a mount without RENAME_NOREPLACE, an unwritable destination folder refuses both the link and the probe's file, so without this the ladder ended in Unsupported and an in-mount move turned into a copy that failed later on the same denial. With it, the move reports Permission denied directly, as before this PR. The KDE Connect case is unaffected: there the probe's file is created, only the link is refused, and hard_links is learned as Some(false).
  • Tests, following the coverage suggestions above:
    • the new placement test is table-driven over a file and a symlink, with symlinks: Rejected(EACCES), so both EACCES arms of recreate_symlink are exercised; it is built from Quirks::sshfs().
    • the_ladder_never_replaces_an_existing_destination gains a links: Rejected(EACCES) quirk set for the exists → Exists path.
    • eacces_from_a_folder_that_refuses_the_probe_is_reported covers the probe-denial return.
    • Mutation check: reverting the symlink arms fails the first test with Io(EACCES); reverting the probe-denial return fails the third with Unsupported.

Local verification: cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, and ./scripts/test-headless.py --lib adapters::local_operations (751 passed, 0 failed). No UI surface changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy into a KDE Connect (sshfs) mount always fails: link() returns EACCES, which placement.rs does not classify

3 participants