diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-04-01 16:11:50 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-04-01 16:19:46 +0100 |
| commit | f68cedf202c1fc6c39243136a4d766bc1d67cc80 (patch) | |
| tree | d9b2bccaaa19437aafe4e95ed56bfdebf2730b98 /util/libreboot-utils/lib/file.c | |
| parent | 5b465d3af6d61c3a1dc69d727948bef470b7be46 (diff) | |
libreboot-utils/file: never retry file rw on zero
even with a timer, it's possible that on a buggy system,
we may keep writing even though the outcome is zero. if
a system comes back with zero bytes written, that is a
fatal bug and we should stop.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib/file.c')
| -rw-r--r-- | util/libreboot-utils/lib/file.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/util/libreboot-utils/lib/file.c b/util/libreboot-utils/lib/file.c index d44d8cf9..741e6793 100644 --- a/util/libreboot-utils/lib/file.c +++ b/util/libreboot-utils/lib/file.c @@ -146,7 +146,7 @@ err_fsync_dir: ssize_t rw_file_exact(int fd, unsigned char *mem, size_t nrw, - off_t off, int rw_type, size_t max_retries) + off_t off, int rw_type) { int saved_errno = errno; ssize_t rval = 0; @@ -154,7 +154,6 @@ rw_file_exact(int fd, unsigned char *mem, size_t nrw, size_t nrw_cur; off_t off_cur; void *mem_cur; - size_t retries_on_zero = 0; errno = 0; if (io_args(fd, mem, nrw, off, rw_type) == -1) @@ -178,17 +177,8 @@ rw_file_exact(int fd, unsigned char *mem, size_t nrw, off_cur = off + (off_t)rc; - if ((rval = rw(fd, mem_cur, nrw_cur, off_cur, rw_type)) < 0) - goto err_rw_file_exact; - - if (rval == 0) { - if (retries_on_zero++ < max_retries) - continue; - + if ((rval = rw(fd, mem_cur, nrw_cur, off_cur, rw_type)) <= 0) goto err_rw_file_exact; - } - - retries_on_zero = 0; } if (if_err((size_t)rc != nrw, EIO) || |
