Skip to content

chmod: fix EROFS showing as Permission denied - #12200

Merged
RenjiSann merged 4 commits into
uutils:mainfrom
gabrielhnf:fix-chmod-erofs-error-message
Oct 26, 2026
Merged

RenjiSann merged 4 commits into
uutils:mainfrom
gabrielhnf:fix-chmod-erofs-error-message

Conversation

@gabrielhnf

Copy link
Copy Markdown
Contributor

Fixes #12196

Problem

When running chmod -R on a read-only filesystem, uutils was reporting:

chmod: cannot access 'file': Permission denied

Instead of the correct:

chmod: changing permissions of 'file': Read-only file system

Cause

safe_chmod_file was hardcoding ChmodError::PermissionDenied regardless of the actual error returned by the OS, discarding the real error kind.

Fix

Map ErrorKind::ReadOnlyFilesystem to a new ChmodError::ReadOnlyFileSystem variant with the correct message, consistent with GNU coreutils behavior.

@github-actions

github-actions Bot commented May 9, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)

@sylvestre

Copy link
Copy Markdown
Contributor

looks good but could you please add a test to make sure we don't regress

@gabrielhnf

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion! Also planning a follow-up PR to fix another problem regarding error reporting, should that include tests as well?

@gabrielhnf
gabrielhnf force-pushed the fix-chmod-erofs-error-message branch from 68eb7ed to d003ce2 Compare October 23, 2026 17:19
@gabrielhnf

Copy link
Copy Markdown
Contributor Author

I've rebased the PR and added a regression test using a read-only filesystem. It exercises the recursive chmod -R path and checks that the correct EROFS error message is reported.

The Android CI failure appears unrelated to this PR, as it failed during emulator setup due to a Termux package download error (HTTP 522), before the tests ran.

@gabrielhnf
gabrielhnf force-pushed the fix-chmod-erofs-error-message branch from d003ce2 to 6845941 Compare October 25, 2026 01:16
@RenjiSann

Copy link
Copy Markdown
Collaborator

Thank you for your PR !

@RenjiSann
RenjiSann merged commit 081f2cd into uutils:main Oct 26, 2026
98 checks passed
@xtqqczze

Copy link
Copy Markdown
Collaborator

@gabrielhnf In the future, please rebase to keep the commit history clean, avoiding separate commits for fixes. This helps keep git blame useful.

@gabrielhnf

Copy link
Copy Markdown
Contributor Author

Ah, got it. My bad, I'll keep that in mind for future PRs. Thanks for pointing it out!

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 -R: cannot access ...: Permission denied when gnuchmod gives Read-only file system

4 participants