util/nvmutil: don't call writeGbeFile if O_RDONLY

This replaces a check in the function for O_RDONLY, and
fixes the bug where the "dump" command triggers such error.

Signed-off-by: Leah Rowe <leah@libreboot.org>
fsdg20230625
Leah Rowe 2023-06-01 14:07:20 +01:00
parent 99258a38ae
commit bdccd7cb0c
1 changed files with 2 additions and 3 deletions

View File

@ -50,7 +50,8 @@ main(int argc, char *argv[])
cmd_setmac(strMac); /* nvm gbe.bin setmac */
else if (cmd != NULL)
(*cmd)(); /* all other commands except setmac */
writeGbeFile(FILENAME);
if ((gbeFileModified) && (flags != O_RDONLY))
writeGbeFile(FILENAME);
err_if((errno != 0) && (cmd != &cmd_dump));
return errno;
@ -253,8 +254,6 @@ xorswap_buf(int partnum)
void
writeGbeFile(const char *filename)
{
if (flags == O_RDONLY)
err(ERR(), "Write aborted due to read-only mode: %s", filename);
if (gbeFileModified)
errno = 0;
for (int p = 0; p < 2; p++) {