From: Samanta Navarro Date: Fri, 13 Jan 2023 11:50:40 +0000 (+0000) Subject: lib/blkdev: handle interrupted read call X-Git-Tag: v2.39-rc1~160^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d5cd07bebbbbec93c4c0bd6e247c1189ec3e3aa;p=thirdparty%2Futil-linux.git lib/blkdev: handle interrupted read call The read call may fail if it is interrupted by a signal. Do not assume that we have reached the end of the underlying block device because of this. Use read_all which retries in these cases. Signed-off-by: Samanta Navarro --- diff --git a/lib/blkdev.c b/lib/blkdev.c index cc1eea3a62..954de454e6 100644 --- a/lib/blkdev.c +++ b/lib/blkdev.c @@ -31,6 +31,7 @@ # define EBADFD 77 /* File descriptor in bad state */ #endif +#include "all-io.h" #include "blkdev.h" #include "c.h" #include "linux_version.h" @@ -43,7 +44,7 @@ blkdev_valid_offset (int fd, off_t offset) { if (lseek (fd, offset, 0) < 0) return 0; - if (read (fd, &ch, 1) < 1) + if (read_all (fd, &ch, 1) < 1) return 0; return 1; }