1 /* virt-efivars editor.
2 * Copyright (C) 2015 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #define GUID_FORMAT "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x"
33 efi_guid_t *guid = NULL;
37 while ((r = efi_get_next_variable_name (&guid, &name)) > 0)
38 printf (GUID_FORMAT "-%s\n",
39 guid->a, guid->b, guid->c, bswap_16 (guid->d),
40 guid->e[0], guid->e[1], guid->e[2], guid->e[3],
41 guid->e[4], guid->e[5], name);
44 perror ("efi_get_next_variable_name");
52 uint8_t data[] = "rwmjtestdata";
54 if (efi_set_variable (efi_guid_redhat, "RWMJTest",
56 EFI_VARIABLE_BOOTSERVICE_ACCESS |
57 EFI_VARIABLE_RUNTIME_ACCESS |
58 EFI_VARIABLE_NON_VOLATILE) < 0) {
59 perror ("efi_set_variable");
65 main (int argc, char *argv[])
67 printf ("*** editor running ***\n");
69 if (!efi_variables_supported ()) {
70 fprintf (stderr, "UEFI variables are not supported!\n");
78 printf ("*** editor finished ***\n");