Skip to content

chown, chgrp: keep -h separate from -H/-L traversal - #15127

Draft
abendrothj wants to merge 6 commits into
uutils:mainfrom
abendrothj:chown-h-with-dereference
Draft

abendrothj wants to merge 6 commits into
uutils:mainfrom
abendrothj:chown-h-with-dereference

Conversation

@abendrothj

@abendrothj abendrothj commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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

With -h, -H and -L were also used to decide whether to change links, so -RHh/-RLh didn't descend through the operand link, and -RLh changed link targets instead of the links.

Traversal now follows -H/-L, and whether a link or its target is changed follows -h. When a link is changed, an owner or group that wasn't given stays unchanged instead of being copied from the target. A symlink operand is now judged for --from and reported by -v by its target, and so is one met in the tree under -L. As with GNU 9.12, a link that can't be followed fails with "cannot access", a link to a directory that can't be read is left alone, and a dangling link is judged and changed as itself. The -v text still differs from GNU as on main (unrequested IDs printed, operand before descendants).

Tests: test_chown_h_judges_symlink_operand_on_its_target, test_chown_big_l_with_h_judges_from_on_link_target, test_chown_h_changes_symlink_operand_itself, test_chown_h_keeps_unchanged_group_of_symlink_operand, test_chown_h_changes_dangling_symlink_operand, test_chown_h_fails_on_symlink_loop_operand, test_chown_h_leaves_link_to_unreadable_dir, test_chown_big_l_with_h_changes_symlinks_in_tree.

Closes #15116

Copilot AI balanced review requested due to automatic review settings October 6, 2026 07:28

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.

@codspeed

codspeed Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 67 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

✅ 115 untouched benchmarks
⏩ 360 skipped benchmarks1


Comparing abendrothj:chown-h-with-dereference (9944c37) with main (bbef561)

Open in CodSpeed

Footnotes

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

@abendrothj
abendrothj force-pushed the chown-h-with-dereference branch 2 times, most recently from 5409d04 to 98a54f0 Compare October 12, 2026 11:38
@abendrothj
abendrothj force-pushed the chown-h-with-dereference branch 2 times, most recently from 58cd990 to 2b552a4 Compare November 7, 2026 07:21
The error itself stays on stderr, as in GNU. On Linux, files below a -R
operand now get the line too.
On Linux the file is held with O_PATH, rechecked and changed through
that descriptor, so a rename after the check no longer redirects it.
On Linux it was skipped without a message; it is now changed by name,
or held with O_PATH under --from. -R still leaves it alone, as in GNU.
--from and -v used the link's owner, not the target that is changed.
A link whose target cannot be stat'd is now reported and left alone.
A dangling link under -H or -L, or an unreadable -R operand, got no
"failed to change" line from -v.
-R -H/-L -h now descend through a symlinked operand, and -R -L -h
changes the links in the tree rather than their targets, as in GNU.
@abendrothj
abendrothj force-pushed the chown-h-with-dereference branch from 2b552a4 to 9944c37 Compare November 8, 2026 23: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.

chown, chgrp: -h with -R -H/-L doesn't descend into a symlinked directory operand

2 participants