Skip to content

ln: create links through the open target directory - #15524

Open
abendrothj wants to merge 3 commits into
uutils:mainfrom
abendrothj:ln-target-dir-anchor
Open

abendrothj wants to merge 3 commits into
uutils:mainfrom
abendrothj:ln-target-dir-anchor

Conversation

@abendrothj

@abendrothj abendrothj commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Based on #15122; only the last commit is new here.

Closes #15523

With a target directory, ln checked it once and then created each link and renamed each backup by joining the directory's path, so a rename of that path in between sent the remaining links elsewhere.

ln now opens the target directory once and does everything relative to it: the existence and directory checks, choosing a backup name, the backup rename, and creating or replacing the link. ., .. and / as sources resolve as before. A directory that can't be opened, and an empty source name, still go by path, so their errors stay as they were. The -r link text and the same-file checks still use the path. uucore's DirAnchor becomes public, and backup_control::get_backup_path_with_exists checks numbered backup names in the same directory.

One message changes: with -fn, several sources and a target that is a symlink to a directory, the second source now gets "will not overwrite just-created" instead of "Not a directory". GNU refuses that command outright, while main replaces the symlink with the first link; that's for a separate fix.

Checked against GNU 9.12 with the target renamed while ln waits at an -i prompt, with and without --backup: links and backups stay in the original directory, as in GNU. test_target_dir_renamed_during_prompt covers six cases and fails without the change on macOS and Linux. test_unsearchable_target_dir, test_empty_source_into_target_dir, test_target_dir_backup_source_without_basename and two tests for write/search-only target directories cover what stays as it was.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:06

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/env/printenv is no longer failing!

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 9%

2 warnings, 1 note

⚠️ 120 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 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 374 untouched benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation mv_force_overwrite 128.1 ms 156.8 ms -18.26%
❌ CPU Simulation ls_recursive_wide_tree[(10000, 1000)] 66.8 ms 75 ms -10.89%
⚡ CPU Simulation du_wide_tree[(5000, 500)] 15.9 ms 15.4 ms +3.47%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing abendrothj:ln-target-dir-anchor (3e02400) with main (bbef561)2

Open in CodSpeed

Footnotes

  1. 98 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. ↩

  2. No successful run was found on main (89bd968) during the generation of this report, so bbef561 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Comment thread src/uu/ln/src/ln.rs Resolved
Comment thread src/uu/ln/src/ln.rs Resolved
Comment thread src/uu/ln/src/ln.rs Resolved
Copilot AI balanced review requested due to automatic review settings October 20, 2026 00:48
@abendrothj
abendrothj force-pushed the ln-target-dir-anchor branch from 71a3e69 to f6794f9 Compare October 20, 2026 00:48

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@xtqqczze

This comment was marked as resolved.

@abendrothj
abendrothj force-pushed the ln-target-dir-anchor branch from f6794f9 to eb937fb Compare October 22, 2026 06:44
Copilot AI balanced review requested due to automatic review settings October 22, 2026 06:44

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@xtqqczze

Copy link
Copy Markdown
Collaborator

Comment thread src/uu/ln/src/ln.rs Resolved
Copilot AI balanced review requested due to automatic review settings October 23, 2026 08:09
@abendrothj
abendrothj force-pushed the ln-target-dir-anchor branch from eb937fb to f36e668 Compare October 23, 2026 08:09

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.32 MB (+72 KB, +0.05%)

Significant per-binary changes:
  printenv     1.09 MB ->    1.15 MB  (+60 KB, +5.36%)

@sylvestre
sylvestre force-pushed the ln-target-dir-anchor branch from f36e668 to c30e23a Compare October 25, 2026 09:31
Copilot AI balanced review requested due to automatic review settings October 25, 2026 09:31

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@abendrothj
abendrothj force-pushed the ln-target-dir-anchor branch from c30e23a to fa04a96 Compare November 2, 2026 23:05
Copilot AI balanced review requested due to automatic review settings November 2, 2026 23:05

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@xtqqczze

xtqqczze commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Check failures tracked by #16147.

@sylvestre

Copy link
Copy Markdown
Contributor

a bunch of jobs are failing

@xtqqczze

xtqqczze commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

needs to be rebased for CI

@abendrothj
abendrothj force-pushed the ln-target-dir-anchor branch from fa04a96 to 92c0e62 Compare November 7, 2026 06:33
Copilot AI balanced review requested due to automatic review settings November 7, 2026 06:33

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

For ln -f/-sf, cp -lf/-sf and mv's cross-device symlink. Without O_PATH
or O_SEARCH (OpenBSD, Hurd) it falls back to the directory's path.
ln and mv's cross-device move use it next. The no-unique-temp-name
error is now translated.
Links and backups stay in the directory if it is renamed meanwhile.
@sylvestre
sylvestre force-pushed the ln-target-dir-anchor branch from 92c0e62 to 3e02400 Compare November 8, 2026 16:01
Copilot AI balanced review requested due to automatic review settings November 8, 2026 16:01

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

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.

ln -t: a renamed target directory redirects the remaining links

4 participants