Skip to content

chown, chgrp: say "cannot read directory" for a directory that does not open - #15171

Open
NdekoCode wants to merge 3 commits into
uutils:mainfrom
NdekoCode:chown-cannot-read-directory
Open

NdekoCode wants to merge 3 commits into
uutils:mainfrom
NdekoCode:chown-cannot-read-directory

Conversation

@NdekoCode

Copy link
Copy Markdown
Contributor

Under -R, a directory that could not be opened for reading was reported as cannot access 'd/a': Permission denied, where GNU 9.12 says cannot read directory 'd/a': Permission denied. The same wording was already used when a directory opened but could not be listed. The walkdir path used off Linux also printed these diagnostics with -f, which hides them in GNU.

Both traversal paths now report a directory that does not open, or that opens but cannot be listed, as cannot read directory, through one shared message, and -f keeps both quiet. The two Linux tests that pinned the old wording are updated, and a test for each utility covers the message and -f. The chgrp and chown suites pass on Linux and macOS.

Closes #15154 (the chmod half is in #15166).

Comment thread src/uucore/src/lib/features/perms.rs Outdated
Comment thread src/uucore/src/lib/features/perms.rs Outdated
Comment thread src/uucore/src/lib/features/perms.rs Outdated
Comment thread tests/by-util/test_chgrp.rs Outdated
@NdekoCode
NdekoCode requested a review from sylvestre October 7, 2026 22:09
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)

@codspeed

codspeed Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.44%

⚠️ 124 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 1 benchmark has no flamegraph

The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 2 regressed benchmarks
✅ 397 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory cp_recursive_deep_tree[(120, 4)] 532.6 KB 699.2 KB -23.82%
❌ ⚠️ CPU Simulation mv_single_file 146.9 ms 151.5 ms -3.04%
⚡ ⚠️ CPU Simulation du_deep_tree[(100, 3)] 1.9 ms 1.9 ms +4.43%
⚡ ⚠️ CPU Simulation sort_long_line[10000] 1.1 ms 1 ms +3.67%

Tip

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


Comparing NdekoCode:chown-cannot-read-directory (3649b1e) with main (ae34722)2

Open in CodSpeed

Footnotes

  1. 70 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 (198c615) during the generation of this report, so ae34722 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@sylvestre

Copy link
Copy Markdown
Contributor

Please don't rebase unlike you have a good reason.
Rebading all your pr isn't helpful :/

@NdekoCode

Copy link
Copy Markdown
Contributor Author

The failing Tests (unix) job is the OpenBSD one, and Android fails the same test: both take the walkdir path, which never yields the operand itself under min_depth(1), so its own read error still said "cannot access". last_dir now starts from the operand, and the unused PathBuf import went with it. Linux was already right (checked as non-root in Docker).

…ot open

A directory that could not be opened for reading under -R was reported
as "cannot access", where GNU says "cannot read directory". The
walkdir path used off Linux also printed its diagnostics with -f, which
is meant to hide them.

Report a directory that does not open, or that opens but cannot be
listed, as "cannot read directory", on both traversal paths, and keep
-f quiet on both.
walkdir never yields the root under min_depth(1), so a read error on
the operand itself still came out as "cannot access" on the walkdir
path (macOS, the BSDs). Start last_dir from the root, and drop the
PathBuf import that the Linux build did not use.
@NdekoCode
NdekoCode force-pushed the chown-cannot-read-directory branch from 099397b to 3649b1e Compare October 20, 2026 19:33
@NdekoCode

Copy link
Copy Markdown
Contributor Author

@sylvestre could you check again ?

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.

chmod, chgrp: -R says "cannot access" for a directory it can't read

2 participants