fix: report read error for device files with -files0-from - #809
Conversation
Previously, using -files0-from on character or block device files that return EOF immediately (e.g., /dev/vhost-net) would succeed silently and exit with code 0. GNU find treats this as a read error. This commit adds a check after reading the file: if the file is a character or block device and the read returns zero bytes, we emit a "read error" message and exit with non-zero status, matching GNU find.
Merging this PR will improve performance by 11.96%
Performance Changes
Tip Curious why this is faster? Comment Comparing |
|
Commit 48e6dfe has test result changes: bfs testsuite: |
50de4b8 to
5f72426
Compare
|
Commit 50de4b8 has test result changes: bfs testsuite: |
|
Commit 5f72426 has test result changes: bfs testsuite: |
5f72426 to
5a98655
Compare
|
Commit 5a98655 has test result changes: bfs testsuite: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #809 +/- ##
==========================================
- Coverage 91.93% 91.88% -0.05%
==========================================
Files 35 35
Lines 7251 7262 +11
Branches 378 380 +2
==========================================
+ Hits 6666 6673 +7
- Misses 443 445 +2
- Partials 142 144 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit d5dbc2d has test result changes: bfs testsuite: |
Fixes #780
Problem
When using
-files0-fromwith a character or block device file that returns EOF immediately (e.g./dev/vhost-net,/dev/vhost-vsock), the current implementation reads zero bytes and exits successfully with code0. GNU find, however, detects a read error and fails with a non‑zero exit code and an appropriate error message.Solution
After reading the file, we now check the file type via its metadata. If the file is a character or block device and the read count is zero, we explicitly treat it as a read error and return a
Box<dyn Error>with a descriptive message.