Skip to content

du: propagate errors from --exclude-from instead of panicking#11996

Merged
cakebaker merged 5 commits into
uutils:mainfrom
rossilor95:du-exclude-from-error-propagation
Apr 27, 2026
Merged

du: propagate errors from --exclude-from instead of panicking#11996
cakebaker merged 5 commits into
uutils:mainfrom
rossilor95:du-exclude-from-error-propagation

Conversation

@rossilor95
Copy link
Copy Markdown
Contributor

Fixes #11924
Fixes #11925

du -X <file> panicked on two failure modes when reading the
--exclude-from file:

  1. Missing file (du -X with a nonexistent file panics #11924):
    $ du -X nonexistent-file
    thread 'main' panicked at src/uu/du/src/du.rs:759:37: no such file: Os { code: 2, kind: NotFound, ... } Aborted (core dumped)
    GNU du prints a clean error and exits non-zero.

  2. Per-line I/O error (du -X /proc/self/mem panics #11925), e.g. a pseudo-file that fails on read:
    $ du -X /proc/self/mem
    thread 'main' panicked at src/uu/du/src/du.rs:763:20: Could not parse line: Os { code: 5, kind: Uncategorized, ... }

Both now exit with code 1 and print to stderr (du: No such file or directory, du: Input/output error, du: Permission denied — message follows the OS error kind).

The call site was also switched from .flat_map(file_as_vec) to a
.map(...).collect::<UResult<_>>()? chain, because flat_map over a
Result-returning function silently drops Err (zero items) — hiding
any I/O failure instead of reporting it.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 25, 2026

GNU testsuite comparison:

Congrats! The gnu test tests/unexpand/bounded-memory is now passing!
Skip an intermittent issue tests/pr/bounded-memory (was skipped on 'main', now failing)

@cakebaker
Copy link
Copy Markdown
Contributor

Can you please add a test to ensure we don't regress in the future? Thanks.

@rossilor95
Copy link
Copy Markdown
Contributor Author

Can you please add a test to ensure we don't regress in the future? Thanks.

Sure! Done

@xtqqczze

This comment was marked as resolved.

@rossilor95
Copy link
Copy Markdown
Contributor Author

rossilor95 commented Apr 26, 2026

    thread 'test_du::test_du_exclude_from_read_error' panicked at tests/by-util/test_du.rs:1535:10:
    'du: Input/output error
    ' does not contain 'du: /proc/self/mem: Input/output error'

Sorry, my bad: forgot to double check the error message 😅 It's fixed now

@cakebaker cakebaker merged commit a8ca919 into uutils:main Apr 27, 2026
169 checks passed
@cakebaker
Copy link
Copy Markdown
Contributor

Thanks!

@rossilor95 rossilor95 deleted the du-exclude-from-error-propagation branch May 13, 2026 19:10
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.

du -X /proc/self/mem panics du -X with a nonexistent file panics

3 participants