svn commit: r314619 - head/usr.sbin/efivar
Warner Losh
imp at FreeBSD.org
Fri Mar 3 20:23:11 UTC 2017
Author: imp
Date: Fri Mar 3 20:23:10 2017
New Revision: 314619
URL: https://svnweb.freebsd.org/changeset/base/314619
Log:
Implement --guid/-g to print the known GUIDs as human readable. The
list of known GUIDs can be found with --list-guids.
Sponsored by: Netflix
Modified:
head/usr.sbin/efivar/efivar.8
head/usr.sbin/efivar/efivar.c
Modified: head/usr.sbin/efivar/efivar.8
==============================================================================
--- head/usr.sbin/efivar/efivar.8 Fri Mar 3 20:23:05 2017 (r314618)
+++ head/usr.sbin/efivar/efivar.8 Fri Mar 3 20:23:10 2017 (r314619)
@@ -41,6 +41,7 @@
.Op Fl -binary
.Op Fl -delete
.Op Fl -fromfile Ar file
+.Op Fl -guid
.Op Fl -hex
.Op Fl -list-guids
.Op Fl -list
@@ -116,6 +117,10 @@ flags.
No
.Ar value
may be specified.
+.It Fl g Fl -guid
+flag is specified, guids are converted to names if they are known (and
+show up in
+.Fl -list-guids ).
.It Fl H Fl -hex
List variable data as a hex dump.
.It Fl L Fl -list-guids
@@ -151,6 +156,7 @@ Set the specified
to
.Ar value .
This is not yet implemented.
+If the
.Sh COMPATIBILITY
The
.Nm
Modified: head/usr.sbin/efivar/efivar.c
==============================================================================
--- head/usr.sbin/efivar/efivar.c Fri Mar 3 20:23:05 2017 (r314618)
+++ head/usr.sbin/efivar/efivar.c Fri Mar 3 20:23:10 2017 (r314619)
@@ -46,6 +46,7 @@ static struct option longopts[] = {
{ "binary", no_argument, NULL, 'b' },
{ "delete", no_argument, NULL, 'D' },
{ "fromfile", required_argument, NULL, 'f' },
+ { "guid", no_argument, NULL, 'g' },
{ "hex", no_argument, NULL, 'H' },
{ "list-guids", no_argument, NULL, 'L' },
{ "list", no_argument, NULL, 'l' },
@@ -59,7 +60,7 @@ static struct option longopts[] = {
};
-static int aflag, Aflag, bflag, dflag, Dflag, Hflag, Nflag,
+static int aflag, Aflag, bflag, dflag, Dflag, gflag, Hflag, Nflag,
lflag, Lflag, Rflag, wflag, pflag;
static char *varname;
static u_long attrib = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
@@ -196,6 +197,20 @@ bindump(uint8_t *data, size_t datalen)
}
static void
+pretty_guid(efi_guid_t *guid, char **gname)
+{
+ char *pretty = NULL;
+
+ if (gflag)
+ efi_guid_to_name(guid, &pretty);
+
+ if (pretty == NULL)
+ efi_guid_to_str(guid, gname);
+ else
+ *gname = pretty;
+}
+
+static void
print_var(efi_guid_t *guid, char *name)
{
uint32_t att;
@@ -204,7 +219,7 @@ print_var(efi_guid_t *guid, char *name)
char *gname;
int rv;
- efi_guid_to_str(guid, &gname);
+ pretty_guid(guid, &gname);
if (pflag) {
rv = efi_get_variable(*guid, name, &data, &datalen, &att);
@@ -267,7 +282,7 @@ parse_args(int argc, char **argv)
{
int ch, i;
- while ((ch = getopt_long(argc, argv, "aAbdDf:HlLNn:pRt:w",
+ while ((ch = getopt_long(argc, argv, "aAbdDf:gHlLNn:pRt:w",
longopts, NULL)) != -1) {
switch (ch) {
case 'a':
@@ -285,6 +300,9 @@ parse_args(int argc, char **argv)
case 'D':
Dflag++;
break;
+ case 'g':
+ gflag++;
+ break;
case 'H':
Hflag++;
break;
More information about the svn-src-head
mailing list