Skip to content

du: don't panic if file doesn't exist#12020

Closed
ajanicij wants to merge 3 commits into
uutils:mainfrom
ajanicij:ajanicij/du-exclude-no-such-file
Closed

du: don't panic if file doesn't exist#12020
ajanicij wants to merge 3 commits into
uutils:mainfrom
ajanicij:ajanicij/du-exclude-no-such-file

Conversation

@ajanicij

Copy link
Copy Markdown
Contributor

This PR solves a problem that file opening error causes panic in du.

Technical details

Running du with a nonexistent file causes a panic:

> du -X /proc/self/mem

thread 'main' (653) panicked at src/uu/du/src/du.rs:763:20:
Could not parse line: Os { code: 5, kind: Uncategorized, message: "Input/output error" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fish: Job 1, 'du -X /proc/self/mem' terminated by signal SIGABRT (Abort)

The problem is that line

let file = File::open(filename).expect("no such file");

causes a panic. (Also, the message no such file is incorrect; File::open can fail for other reasons; for example,
if we pass a directory name instead of a file.)

@oech3

oech3 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Sorry. But #11996

@github-actions

github-actions Bot commented Apr 26, 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)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
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)

@ajanicij

Copy link
Copy Markdown
Contributor Author

:-)
I was too slow. 11996 was there first. Closing this PR.

@ajanicij ajanicij closed this Apr 26, 2026
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.

3 participants