Skip to content

Conversation

@mattsu2020
Copy link
Contributor

Summary

  • ensure ln -f only reports SameFile when the source and destination resolve to the identical path
  • allow recreating hard links inside a directory when the existing entry already points to the source but has the same inode
  • keep conservative behaviour when canonicalization fails so we still avoid clobbering truly identical files

Testing

  • cargo test --test tests test_ln

fixes #8830

Improved the `link` function in `ln.rs` to use canonical path resolution for accurate same-file detection when forcing overwrites, preventing incorrect errors for equivalent paths. Added tests to verify behavior for self-linking and hard link relinking scenarios.
@github-actions
Copy link

github-actions bot commented Oct 7, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

Co-authored-by: Sylvestre Ledru <[email protected]>
@github-actions
Copy link

github-actions bot commented Oct 7, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@mattsu2020 mattsu2020 requested a review from sylvestre October 10, 2025 11:09
@sylvestre sylvestre merged commit 1c29075 into uutils:main Oct 10, 2025
103 checks passed
@sylvestre
Copy link
Contributor

great, thanks

@mattsu2020 mattsu2020 deleted the ln_fix2 branch October 10, 2025 11:32
Misakait pushed a commit to Misakait/coreutils that referenced this pull request Oct 15, 2025
…tils#8838)

* fix(ln): enhance same-file detection with canonical paths

Improved the `link` function in `ln.rs` to use canonical path resolution for accurate same-file detection when forcing overwrites, preventing incorrect errors for equivalent paths. Added tests to verify behavior for self-linking and hard link relinking scenarios.

Co-authored-by: Sylvestre Ledru <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ln -f: ln: 'file' and 'dir/file' are the same file

2 participants