Skip to content

uucore: report unreadable files under --ignore-missing - #15844

Open
tirdesh wants to merge 1 commit into
uutils:mainfrom
tirdesh:uucore-ignore-missing-unreadable
Open

tirdesh wants to merge 1 commit into
uutils:mainfrom
tirdesh:uucore-ignore-missing-unreadable

Conversation

@tirdesh

@tirdesh tirdesh commented Oct 25, 2026

Copy link
Copy Markdown

Closes #15767

md5sum -c --ignore-missing skipped a listed file that exists but cannot be opened, printed nothing about it, and exited 0. Only genuinely absent files should be ignored.

The error arm of get_file_to_check turned every File::open failure into LineCheckError::FileNotFound without looking at the error kind, so EACCES or ENOTDIR was treated like ENOENT and dropped by --ignore-missing. It now matches on err.kind(): NotFound keeps the old path, anything else is printed, counted through failed_open() and returned as CantOpenFile. That variant already existed and was already counted into failed_open_file.

process_checksum_file also skipped the final failed_open_file check whenever --ignore-missing was set. Ignored missing files never reach that counter, so the guard only exempted files that really could not be read, and I dropped it.

Reproduced on macOS with a readable file and a mode-000 file, both listed in CHECKSUMS:

$ coreutils md5sum --check --ignore-missing CHECKSUMS; echo $?
readable.txt: OK
0

and after the change:

readable.txt: OK
md5sum: unreadable.txt: Permission denied
unreadable.txt: FAILED open or read
md5sum: WARNING: 1 listed file could not be read
1

A file that is really missing is still ignored and still exits 0.

The code is shared, so cksum, b2sum and the sha*sum tools are covered too. I added test_check_ignore_missing_unopenable_file next to test_check_failed_to_read in tests/by-util/test_cksum.rs; it uses an ENOTDIR path rather than mode 000 so that it also holds when the tests run as root, and the branch taken is the same either way. It fails on main, printing only f: OK. cargo fmt --check and clippy -D warnings are clean. I have only tested this on macOS.

--ignore-missing dropped every file whose open failed, not only the ones
that were absent, so a file that exists but cannot be read was skipped
without a word and the run exited 0.

Classify the error in get_file_to_check: only NotFound stays on the
missing path, anything else is printed, counted through failed_open and
returned as CantOpenFile. Drop the matching !ignore_missing guard on the
final failed_open_file check, which ignored missing files never reach.

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.

checksum: --ignore-missing treats unreadable files as missing, exits 0

1 participant