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>
This commit is contained in:
Leah Rowe
2026-04-01 16:11:50 +01:00
parent 5b465d3af6
commit f68cedf202
4 changed files with 8 additions and 23 deletions
+4 -5
View File
@@ -109,7 +109,7 @@ read_file(void)
/* read main file
*/
_r = rw_file_exact(f->gbe_fd, f->buf, f->gbe_file_size,
0, IO_PREAD, MAX_ZERO_RW_RETRY);
0, IO_PREAD);
if (_r < 0)
exitf("%s: read failed", f->fname);
@@ -117,7 +117,7 @@ read_file(void)
/* copy to tmpfile
*/
_r = rw_file_exact(f->tmp_fd, f->buf, f->gbe_file_size,
0, IO_PWRITE, MAX_ZERO_RW_RETRY);
0, IO_PWRITE);
if (_r < 0)
exitf("%s: %s: copy failed",
@@ -140,7 +140,7 @@ read_file(void)
exitf("%s: fsync (tmpfile copy)", f->tname);
_r = rw_file_exact(f->tmp_fd, f->bufcmp, f->gbe_file_size,
0, IO_PREAD, MAX_ZERO_RW_RETRY);
0, IO_PREAD);
if (_r < 0)
exitf("%s: read failed (cmp)", f->tname);
@@ -556,8 +556,7 @@ rw_gbe_file_exact(int fd, unsigned char *mem, size_t nrw,
if (nrw > (size_t)GBE_PART_SIZE)
goto err_rw_gbe_file_exact;
r = rw_file_exact(fd, mem, nrw, off, rw_type,
MAX_ZERO_RW_RETRY);
r = rw_file_exact(fd, mem, nrw, off, rw_type);
return rw_over_nrw(r, nrw);