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>
master
Leah Rowe 2025-01-27 04:47:49 +00:00
parent b44c311db7
commit 5c9edb8ffe
1 changed files with 9 additions and 1 deletions

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);
}