util/nvmutil: limit bytes written per command
Massive reduction in number of bytes written, if copy/swap commands are not used.fsdg20230625
parent
e398331b38
commit
8242dca57b
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue