summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-01-17 11:02:51 +0000
committerLeah Rowe <leah@libreboot.org>2023-01-17 11:03:55 +0000
commit8242dca57beb79790cb3570f2dca37ba6d0fc5a3 (patch)
tree9d4ee56e58df2794118c8156912a8591c4088b96 /util
parente398331b3804b7e7e8c61f6845e18beec7b23578 (diff)
util/nvmutil: limit bytes written per command
Massive reduction in number of bytes written, if copy/swap commands are not used.
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index cf8c63d4..8681ed55 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -437,9 +437,14 @@ void
writeGbeFile(int *fd, const char *filename)
{
int p;
+ int tw = 0;
int nw = SIZE_4KB;
errno = 0;
+ /* if copy/swap not performed, write only the nvm part */
+ if ((gbe[0] != gbe[1]) && (gbe[0] < gbe[1]))
+ nw = 128;
+
for (p = 0; p < 2; p++) {
if (nvmPartModified[p]) {
printf("Part %d modified\n", p);
@@ -450,11 +455,12 @@ writeGbeFile(int *fd, const char *filename)
}
if (pwrite((*fd), (uint8_t *) gbe[p], nw, p << 12) != nw)
err(errno, "%s", filename);
+ tw += nw;
}
if (close((*fd)))
err(errno, "%s", filename);
if (errno != 0)
err(errno, "%s", filename);
- printf("File `%s` successfully re-written.\n", filename);
+ printf("%d bytes written to file: `%s`\n", tw, filename);
}