Skip to content

cp: report inaccessible symlink targets correctly - #15445

Open
limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/cp-inaccessible-symlink-target
Open

limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/cp-inaccessible-symlink-target

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

Preserve target lookup errors instead of treating every failed lookup as a missing target. Operations that replace the symlink itself may proceed without accessing its target.

Closes #9463.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

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

@limadog9
limadog9 force-pushed the fix/cp-inaccessible-symlink-target branch 2 times, most recently from ee8f378 to 60262c6 Compare October 17, 2026 14:55
Comment thread src/uu/cp/src/cp.rs Outdated
{
return Err(CpError::IoErrContext(
error,
format!("cannot stat {}", dest.quote()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use translate!() for this message

Comment thread src/uu/cp/src/cp.rs
let target_missing = match dest.try_exists() {
Ok(exists) => !exists,
Err(error)
if options.backup == BackupMode::None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this skips the error with --backup and -l/-s, could you please add a test for those too?

Comment thread tests/by-util/test_cp.rs Outdated
at.write("good/README", "file2");

at.symlink_file("foo", "tmp/README");
at.relative_symlink_file("../foo", "tmp/README");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why switch these older tests to relative_symlink_file? seems unrelated to the fix

@limadog9
limadog9 force-pushed the fix/cp-inaccessible-symlink-target branch 2 times, most recently from d18b513 to 0b3d133 Compare November 15, 2026 04:43
@sylvestre
sylvestre force-pushed the fix/cp-inaccessible-symlink-target branch from 0b3d133 to c3f3e16 Compare November 16, 2026 03:14
@limadog9
limadog9 force-pushed the fix/cp-inaccessible-symlink-target branch 4 times, most recently from 15e53d8 to e706c8b Compare November 23, 2026 01:05
@codspeed

codspeed Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 17.6%

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 1 improved benchmark
✅ 10 untouched benchmarks
⏩ 472 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory cp_recursive_deep_tree[(120, 4)] 788.5 KB 670.5 KB +17.6%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing limadog9:fix/cp-inaccessible-symlink-target (e706c8b) with main (8b16a3d)

Open in CodSpeed

Footnotes

  1. 472 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Preserve target lookup errors instead of treating every failed lookup as a missing target. Operations that replace the symlink itself may proceed without accessing its target.

Closes uutils#9463.
@sylvestre
sylvestre force-pushed the fix/cp-inaccessible-symlink-target branch from e706c8b to b29e6f9 Compare November 23, 2026 20:26

This branch has not been deployed

No deployments
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.

cp: Symlink to dir contained in dir with permission 0 is considered as dangling

2 participants