From owner-svn-src-all@freebsd.org Fri Sep 25 18:20:42 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 020013FFB2D; Fri, 25 Sep 2020 18:20:42 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BygFj60qnz4MCY; Fri, 25 Sep 2020 18:20:41 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B29BF1715A; Fri, 25 Sep 2020 18:20:41 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08PIKfqq098511; Fri, 25 Sep 2020 18:20:41 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08PIKf7o098510; Fri, 25 Sep 2020 18:20:41 GMT (envelope-from imp@FreeBSD.org) Message-Id: <202009251820.08PIKf7o098510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 25 Sep 2020 18:20:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366164 - head/usr.sbin/efivar X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/usr.sbin/efivar X-SVN-Commit-Revision: 366164 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2020 18:20:42 -0000 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)