util/nvmutil: Show bytes written in writeGbe

This will be useful for future debugging, and future
work on optimisations.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-01-27 04:47:49 +00:00
parent b2d6393ed5
commit d666f67ebe

View File

@@ -420,16 +420,24 @@ writeGbe(void)
if ((!gbeFileChanged) || (flags == O_RDONLY))
return;
size_t tbw = 0; /* total bytes written */
for (int p = 0; p < 2; p++) {
if ((!nvmPartChanged[p]))
continue;
swap(p); /* swap bytes on big-endian host CPUs */
err_if(pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize)
== -1);
tbw += nf;
}
if ((!tbw) && (gbeFileChanged))
fprintf(stderr, "No changes needed on file '%s'\n", filename);
else if (tbw)
printf("%ld bytes written to file '%s'\n", tbw, filename);
errno = 0;
err_if(close(fd) == -1);
}