u-root
u-root copied to clipboard
uio package lazy reader reports a close error even when it does not report an open error
The uio package lazy reader function can get an open error, should the program hand it a pathname of a file that can't be opened. It won't report it because it's a lazy open; it will be seen by the app as a read error, since the open occurs on first read. When the app tries to close the file, it can get a close error -- because the file in this case is not open. But the app did not get an open error. Getting a close error on a readonly file, when the open did not fail, is confusing.
The uio package lazy read function should not return close errors; or, at least, it could track when an open failed and in that case it can ignore the close error.
If the open() returns an error, lr.r should be nil.
What you're describing is only ever possible if you give the lazy reader an open function that returns both a non-nil object and an error at the same time.
func open() {
return foostruct{}, fmt.Errorf("...")
}
Where have you seen such an open function
seen in the wild in our cpio command. It's in my closed pr.
Do you have a log or anything? Reading the code, I cannot imagine this is possible.