From 8242dca57beb79790cb3570f2dca37ba6d0fc5a3 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 17 Jan 2023 11:02:51 +0000 Subject: util/nvmutil: limit bytes written per command Massive reduction in number of bytes written, if copy/swap commands are not used. --- util/nvmutil/nvmutil.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'util') 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); } -- cgit v1.2.1