diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-04-21 13:39:29 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-04-21 13:39:29 +0100 |
| commit | 7f4f07fc4039353ee499d76bb53b6c742adb6428 (patch) | |
| tree | 69da1a8915bd9e28535eed9d6875c41002134987 /util/nvmutil/nvmutil.c | |
| parent | 4b5aca8ff89bf46538a59bb55512dedeedbf1cbb (diff) | |
use old nvmutil for now, in lbmk
i'm trying to make nvmutil work on openbsd. the new code
in lbutils is a bit buggy, likely somewhere in mkhtemp.
i'm still debugging it.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c new file mode 100644 index 00000000..670b7110 --- /dev/null +++ b/util/nvmutil/nvmutil.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: MIT + * Copyright (c) 2022-2026 Leah Rowe <leah@libreboot.org> + * + * This tool lets you modify Intel GbE NVM (Gigabit Ethernet + * Non-Volatile Memory) images, e.g. change the MAC address. + * These images configure your Intel Gigabit Ethernet adapter. + */ + +#include <sys/types.h> +#include <sys/stat.h> + +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stddef.h> +#include <stdlib.h> + +#include "include/common.h" + +int +main(int argc, char *argv[]) +{ + struct xstate *x = xstatus(argc, argv); + struct commands *cmd = &x->cmd[x->i]; + struct xfile *f = &x->f; + + unsigned long c; + + if (cmd->run == NULL) + err(errno, "Command not set"); + + cmd->run(); + + for (c = 0; c < items(x->cmd); c++) + x->cmd[c].run = cmd_helper_err; + + if ((cmd->flags & O_ACCMODE) == O_RDWR) + write_to_gbe_bin(); + + if (exit_cleanup() == -1) + err(EIO, "%s: close", f->fname); + + if (f->io_err_gbe_bin) + err(EIO, "%s: error writing final file"); + + if (f->tname != NULL) + free(f->tname); + + return EXIT_SUCCESS; +} |
