summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-06 18:55:31 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-06 18:55:31 +0000
commit0698c6ada44a8b4896d6ef12e0028b38cf9f8bbf (patch)
treea00e5263e9e02318b567c967763a7f08e04d496c
parent397fc78e58892c7d193809a3d75440492a8051be (diff)
util/nvmutil: warn about partial gbe file writes
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 1a235e01..7cad5055 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -759,11 +759,16 @@ write_gbe(void)
static void
write_gbe_part(size_t p)
{
- if (pwrite(fd, gbe_mem_offset(p, "pwrite"),
- GBE_PART_SIZE, gbe_file_offset(p, "pwrite")) != GBE_PART_SIZE) {
- err(ECANCELED,
- "Can't write %d b to '%s' p%d", GBE_PART_SIZE, fname, p);
- }
+ ssize_t rval = pwrite(fd, gbe_mem_offset(p, "pwrite"),
+ GBE_PART_SIZE, gbe_file_offset(p, "pwrite"));
+
+ if (rval == -1)
+ err(ECANCELED, "Can't write %zx b to '%s' p%zx",
+ GBE_PART_SIZE, fname, p);
+
+ if (rval != GBE_PART_SIZE)
+ err(ECANCELED, "CORRUPTED WRITE (%zx b) to file '%s' p%zx",
+ rval, fname, p);
}
/*