head: distinguish read and write errors in copy loop#12265
Open
gabrielhnf wants to merge 3 commits into
Open
Conversation
|
GNU testsuite comparison: |
d05aa2c to
f525520
Compare
Contributor
|
Oh Ok. I should split last loop. |
Contributor
|
CI's log is not useful form me to investivage what utils is missing import. How did you determine the probrematic commit? |
Contributor
|
main is passing OpenBSD CI. So it looks network error. |
Author
|
Noticed rustix missing in the logs and connected it to the commit since it was the most recent merge introducing that dependency. If main is passing then you're right, likely a transient network error. Sorry for getting ahead of myself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12234
Problem
When running
headon a file that fails during reading (e.g./proc/self/mem), uutils was reporting:Instead of the correct:
Cause
io::copymerges read and write errors into a single return value with no way to distinguish them. Since all errors were mapped through wrap_in_stdout_error, a read failure was incorrectly attributed to stdout.Fix
Replaced
io::copywith a manual read/write loop and introduced a PrintError enum to tag errors at the source as either ReadError or WriteError. This distinction is preserved all the way up to uu_head, where read errors get the filename attached and write errors are reported against stdout.Note
print_n_byteshas the same issue viasend_n_bytes. Fixing it would require introducing a similar distinction inside that function, which felt out of scope for this PR and thus was left for a separate issue.Some code paths in
print_but_last_n_bytes,print_but_last_n_lines, and the seekable file path inhead_backwards_on_seekable_filestill map all errors to PrintError::WriteError as a pragmatic compromise. These paths do not exhibit the bug reported in this issue. Left for a separate issue.