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
This commit is contained in:
Warner Losh 2017-03-03 20:23:10 +00:00
parent 4a110fbfa7
commit 1644567051
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=314619
2 changed files with 27 additions and 3 deletions

View File

@ -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

View File

@ -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;
@ -195,6 +196,20 @@ bindump(uint8_t *data, size_t datalen)
write(1, data, 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)
{
@ -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;