Skip to content

fix: report read error for device files with -files0-from - #809

Open
Xylphy wants to merge 3 commits into
uutils:mainfrom
Xylphy:fix-files0-from-device-error
Open

fix: report read error for device files with -files0-from#809
Xylphy wants to merge 3 commits into
uutils:mainfrom
Xylphy:fix-files0-from-device-error

Conversation

@Xylphy

@Xylphy Xylphy commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #780

Problem
When using -files0-from with 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 code 0. 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.

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.
@Xylphy
Xylphy marked this pull request as draft August 4, 2026 14:54
@codspeed-hq

codspeed-hq Bot commented Aug 4, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 11.96%

⚡ 1 improved benchmark
✅ 19 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
printf 36.8 ms 32.9 ms +11.96%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Xylphy:fix-files0-from-device-error (d5dbc2d) with main (d19ce8b)

Open in CodSpeed

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Commit 48e6dfe has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 266 / FAILED: 41 / SKIPPED: 6

Changes from main branch:
  TOTAL: +1
  PASSED: +1
  FAILED: +0

New test failures (1):
  - gnu/files0_from_ok

Test improvements (1):
  + gnu/okdir_path_empty

@Xylphy
Xylphy force-pushed the fix-files0-from-device-error branch from 50de4b8 to 5f72426 Compare August 4, 2026 15:15
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Commit 50de4b8 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 312 / PASSED: 266 / FAILED: 40 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 266 / FAILED: 41 / SKIPPED: 6

Changes from main branch:
  TOTAL: -1
  PASSED: +0
  FAILED: -1

Test improvements (1):
  + gnu/okdir_path_empty

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Commit 5f72426 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 266 / FAILED: 42 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 266 / FAILED: 41 / SKIPPED: 6

Changes from main branch:
  TOTAL: +1
  PASSED: +0
  FAILED: +1

New test failures (1):
  - gnu/files0_from_ok

@Xylphy
Xylphy force-pushed the fix-files0-from-device-error branch from 5f72426 to 5a98655 Compare August 4, 2026 15:23
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Commit 5a98655 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 266 / FAILED: 41 / SKIPPED: 6

Changes from main branch:
  TOTAL: +1
  PASSED: +1
  FAILED: +0

New test failures (1):
  - gnu/okdir_path_relative

Test improvements (1):
  + gnu/okdir_path_empty

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.88%. Comparing base (d19ce8b) to head (d5dbc2d).

Files with missing lines Patch % Lines
src/find/matchers/mod.rs 63.63% 2 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Commit d5dbc2d has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 266 / FAILED: 42 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 266 / FAILED: 41 / SKIPPED: 6

Changes from main branch:
  TOTAL: +1
  PASSED: +0
  FAILED: +1

New test failures (1):
  - gnu/files0_from_ok

@Xylphy
Xylphy marked this pull request as ready for review August 4, 2026 16:02
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(find): when -files0-from is /dev/vhost-net or /dev/vhost-vsock it silences errors

1 participant