mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 08:40:14 +02:00
util/nvmutil: only write parts that are modified
Old behaviour: always write both gbe sections. New behaviour: only write back what was changed.
This commit is contained in:
+13
-12
@@ -439,21 +439,22 @@ writeGbeFile(int *fd, const char *filename)
|
|||||||
int partnum;
|
int partnum;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (pwrite((*fd), (uint8_t *) gbe[0], SIZE_4KB, 0) != SIZE_4KB)
|
for (partnum = 0; partnum < 2; partnum++) {
|
||||||
err(errno, "%s", filename);
|
if (nvmPartModified[partnum]) {
|
||||||
if (pwrite((*fd), (uint8_t *) gbe[1], SIZE_4KB, SIZE_4KB) != SIZE_4KB)
|
printf("Part %d modified\n", partnum);
|
||||||
err(errno, "%s", filename);
|
} else {
|
||||||
|
fprintf (stderr,
|
||||||
|
"Part %d NOT modified\n", partnum);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pwrite((*fd), (uint8_t *) gbe[partnum], SIZE_4KB,
|
||||||
|
partnum << 12) != SIZE_4KB)
|
||||||
|
err(errno, "%s", filename);
|
||||||
|
}
|
||||||
if (close((*fd)))
|
if (close((*fd)))
|
||||||
err(errno, "%s", filename);
|
err(errno, "%s", filename);
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
err(errno, "%s", filename);
|
err(errno, "%s", filename);
|
||||||
|
|
||||||
for (partnum = 0; partnum < 2; partnum++) {
|
printf("File `%s` successfully re-written.\n", filename);
|
||||||
if (nvmPartModified[partnum])
|
|
||||||
printf("Part %d modified\n", partnum);
|
|
||||||
else
|
|
||||||
fprintf (stderr,
|
|
||||||
"Part %d NOT modified\n", partnum);
|
|
||||||
}
|
|
||||||
printf("File `%s` successfully modified\n", filename);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user