diff options
author | Leah Rowe <leah@libreboot.org> | 2023-01-17 11:02:51 +0000 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-01-17 11:03:55 +0000 |
commit | 8242dca57beb79790cb3570f2dca37ba6d0fc5a3 (patch) | |
tree | 9d4ee56e58df2794118c8156912a8591c4088b96 /util/nvmutil/nvmutil.c | |
parent | e398331b3804b7e7e8c61f6845e18beec7b23578 (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/nvmutil/nvmutil.c')
-rw-r--r-- | util/nvmutil/nvmutil.c | 8 |
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); } |