f3probe: improve I/O error handling

This commit is contained in:
Michel Machado 2015-01-31 20:35:26 -05:00
parent 7c0306ca6f
commit b70b9ce914

View File

@ -320,7 +320,10 @@ static int read_all(int fd, char *buf, int count)
int done = 0; int done = 0;
do { do {
ssize_t rc = read(fd, buf + done, count - done); ssize_t rc = read(fd, buf + done, count - done);
assert(rc >= 0); /* Did the read() went right? */ if (rc < 0) {
assert(errno == EIO);
return errno;
}
assert(rc != 0); /* We should never hit the end of the file. */ assert(rc != 0); /* We should never hit the end of the file. */
done += rc; done += rc;
} while (done < count); } while (done < count);