]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwboot: Handle EINTR in kwboot_write()
authorPali Rohár <pali@kernel.org>
Tue, 25 Jan 2022 17:13:10 +0000 (18:13 +0100)
committerStefan Roese <sr@denx.de>
Mon, 31 Jan 2022 09:23:38 +0000 (10:23 +0100)
The write() syscall may be interrupted. Handle EINTR and retry it.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
tools/kwboot.c

index de433c1b0440d82ec165cd3edfc33fb251c7e408..8b748f0fddf50763e10a87926cb41ed23fe3d9eb 100644 (file)
@@ -292,13 +292,15 @@ static int blk_rsp_timeo = KWBOOT_BLK_RSP_TIMEO;
 static ssize_t
 kwboot_write(int fd, const char *buf, size_t len)
 {
-       size_t tot = 0;
+       ssize_t tot = 0;
 
        while (tot < len) {
                ssize_t wr = write(fd, buf + tot, len - tot);
 
-               if (wr < 0)
-                       return -1;
+               if (wr < 0 && errno == EINTR)
+                       continue;
+               else if (wr < 0)
+                       return wr;
 
                tot += wr;
        }