From b70b9ce914c5624549ab42cc68d8c703f5d90512 Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Sat, 31 Jan 2015 20:35:26 -0500 Subject: [PATCH] f3probe: improve I/O error handling --- libdevs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libdevs.c b/libdevs.c index 8e9d04a..e9d9f34 100644 --- a/libdevs.c +++ b/libdevs.c @@ -320,7 +320,10 @@ static int read_all(int fd, char *buf, int count) int done = 0; do { 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. */ done += rc; } while (done < count);