aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/efivar/efiutil.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2020-09-25 18:20:41 +0000
committerWarner Losh <imp@FreeBSD.org>2020-09-25 18:20:41 +0000
commit66c613905f4e07e4110f463f7d51ec97f3659943 (patch)
treebf4363b2cda528bdc0a7246e2e60c659815f9db4 /usr.sbin/efivar/efiutil.c
parent6d5ca5199c509904a202dc2c4f9fba24471d8151 (diff)
downloadsrc-66c613905f4e07e4110f463f7d51ec97f3659943.tar.gz
src-66c613905f4e07e4110f463f7d51ec97f3659943.zip
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.
Notes
Notes: svn path=/head/; revision=366164
Diffstat (limited to 'usr.sbin/efivar/efiutil.c')
-rw-r--r--usr.sbin/efivar/efiutil.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/usr.sbin/efivar/efiutil.c b/usr.sbin/efivar/efiutil.c
index d1def125160c..838e56334066 100644
--- a/usr.sbin/efivar/efiutil.c
+++ b/usr.sbin/efivar/efiutil.c
@@ -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)