Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Sep 2020 18:20:41 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r366164 - head/usr.sbin/efivar
Message-ID:  <202009251820.08PIKf7o098510@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Fri Sep 25 18:20:41 2020
New Revision: 366164
URL: https://svnweb.freebsd.org/changeset/base/366164

Log:
  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.

Modified:
  head/usr.sbin/efivar/efiutil.c

Modified: head/usr.sbin/efivar/efiutil.c
==============================================================================
--- head/usr.sbin/efivar/efiutil.c	Fri Sep 25 17:14:35 2020	(r366163)
+++ head/usr.sbin/efivar/efiutil.c	Fri Sep 25 18:20:41 2020	(r366164)
@@ -160,23 +160,27 @@ efi_print_load_option(uint8_t *data, size_t datalen, i
 	// 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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009251820.08PIKf7o098510>