From bdccd7cb0c632a07e6d9feea4964ebbc18a48cd3 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 1 Jun 2023 14:07:20 +0100 Subject: 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 --- util/nvmutil/nvmutil.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 1e2b2b56..d9b79e61 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -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++) { -- cgit v1.2.1