Tweak output of the loader variable

When the DEVICE_PATH is <= 4 that means it's effectively empty. I have
a laptop that has a BIOS that likes to generate these:

8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot2001
0000: 01 00 00 00 04 00 45 00 46 00 49 00 20 00 55 00
0010: 53 00 42 00 20 00 44 00 65 00 76 00 69 00 63 00
0020: 65 00 00 00 7f ff 04 00 52 43

which now decodes as
8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot2001
* EFI USB Device
Empty path
Option:
0000: 52 43

which matches my hand-decode.

Add an extra newline after Option: to make it look nice.

I suspect that these entries really should be VenHw entries instead,
but my ability to change that is NIL, so cope with them as best we can.

efibootmgr(8)'s output is fine and doesn't need adjusting.
This commit is contained in:
Warner Losh 2020-09-25 18:20:41 +00:00
parent 6d5ca5199c
commit 66c613905f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366164

View file

@ -160,23 +160,27 @@ efi_print_load_option(uint8_t *data, size_t datalen, int Aflag, int bflag, int u
// We got to here, everything is good
printf("%c ", attr & LOAD_OPTION_ACTIVE ? '*' : ' ');
ucs2_to_utf8(descr, &str);
printf("%s", str);
printf("%s\n", str);
free(str);
while (dp < edp && SIZE(dp, edp) > sizeof(efidp_header)) {
efidp_format_device_path(buf, sizeof(buf), dp, SIZE(dp, edp));
rv = efivar_device_path_to_unix_path(dp, &dev, &relpath, &abspath);
dp = (efidp)((char *)dp + efidp_size(dp));
printf(" %s\n", buf);
if (rv == 0) {
printf(" %*s:%s\n", len + (int)strlen(dev), dev, relpath);
free(dev);
free(relpath);
free(abspath);
if (fplen <= 4) {
printf("Empty path\n");
} else {
while (dp < edp && SIZE(dp, edp) > sizeof(efidp_header)) {
efidp_format_device_path(buf, sizeof(buf), dp, SIZE(dp, edp));
rv = efivar_device_path_to_unix_path(dp, &dev, &relpath, &abspath);
dp = (efidp)((char *)dp + efidp_size(dp));
printf(" %s\n", buf);
if (rv == 0) {
printf(" %*s:%s\n", len + (int)strlen(dev), dev, relpath);
free(dev);
free(relpath);
free(abspath);
}
}
}
if (optlen == 0)
return;
printf("Options: ");
printf("Option:\n");
if (Aflag)
asciidump(opt, optlen);
else if (bflag)