Skip to content

chmod: preserve metadata errors for overlong paths - #15499

Merged
sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/chmod-stat-error-context-12828
Oct 23, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/chmod-stat-error-context-12828

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

Preserve metadata errors for operands and --reference files so overlong paths report File name too long. Add regressions for recursive operation and continued processing.

Closes #12828.

Comment thread src/uu/chmod/src/chmod.rs
enum ChmodError {
#[error("{}", translate!("chmod-error-cannot-stat", "file" => _0.quote()))]
CannotStat(PathBuf),
#[error("{}", translate!("perms-cannot-access", "file" => _0.quote(), "error" => strip_errno(_1)))]

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.

for --reference GNU says "failed to get attributes of 'x': ...", not "cannot access"
could you please keep a separate variant for the reference file?

Comment thread src/uu/chmod/src/chmod.rs
#[error("{}", translate!("chmod-error-cannot-stat", "file" => _0.quote()))]
CannotStat(PathBuf),
#[error("{}", translate!("perms-cannot-access", "file" => _0.quote(), "error" => strip_errno(_1)))]
CannotStat(PathBuf, std::io::Error),

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.

chmod-error-cannot-stat is now unused, please remove it from the ftl files too

.arg("700")
.arg(&path)
.arg("valid")
.fails_with_code(1);

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 check the whole message ("cannot access ...: File name too long"), not only the errno

@limadog9
limadog9 force-pushed the fix/chmod-stat-error-context-12828 branch 2 times, most recently from 1c1e0c8 to 44f3193 Compare October 19, 2026 11:36
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/follow-symlink is no longer failing!

Comment thread src/uu/chmod/locales/en-US.ftl Outdated
chmod-verbose-mode-retained = mode of {$file} retained as {$mode_octal} ({$mode_display})
chmod-verbose-failed-change = failed to change mode of file {$file} from {$old_mode} ({$old_mode_display}) to {$new_mode} ({$new_mode_display})
chmod-verbose-mode-changed = mode of {$file} changed from {$old_mode} ({$old_mode_display}) to {$new_mode} ({$new_mode_display})
chmod-error-reference-stat = failed to get attributes of { $file }: { $error }

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.

could you please move it next to the other chmod-error-* keys? (same in fr-FR.ftl)

Preserve metadata errors for operands and --reference files so overlong paths report File name too long. Add regressions for recursive operation and continued processing.

Closes uutils#12828.
@limadog9
limadog9 force-pushed the fix/chmod-stat-error-context-12828 branch from 44f3193 to 9625395 Compare October 19, 2026 19:39
@sylvestre
sylvestre merged commit 17c3ef9 into uutils:main Oct 23, 2026
99 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

sylvestre added a commit to sylvestre/coreutils-1 that referenced this pull request Oct 25, 2026
* tests/chmod/partial-fail.sh: Ensure ENAMETOOLONG is reported for an
operand and for --reference, and that later operands are still
processed, with and without -R.
uutils/coreutils#15499
hubot pushed a commit to coreutils/coreutils that referenced this pull request Oct 25, 2026
* tests/chmod/partial-fail.sh: Ensure ENAMETOOLONG is reported for an
operand and for --reference, and that later operands are still
processed, with and without -R.
uutils/coreutils#15499

Link: #396
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.

bug(chmod): when a file is a larger, the utility reports incorrect error messages

2 participants