On 26/09, Andreas Dilger wrote: > I think the proper behavior here is to return the bytes actually read, then > retry the rest of the read. If there is a permanent error then it can be > returned from the next read. It doesn't make sense to return an error > if you don't have to...
That's the intent, this should only return an error if read() actually fails. full_read only returns bytes < count if read() failed or there was a zero byte read i.e EOF. One point this can be improved on is to restrict further the errnos we return an error from, excluding EAGAIN, EINTR etc. The only way I can see this erroneously returning an error with this patch is if a) full_read makes an X number of successful reads, then b) safe_read makes a read call that is interrupted via EINTR, then c) a subsequent read returns 0. Resulting with count < bytes and errno != 0. However, this is probably a bit overkill. Either way I'd be happy to update the patch with whatever you decide.