From owner-svn-src-head@freebsd.org Fri Mar 3 20:23:11 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9710FCF7248; Fri, 3 Mar 2017 20:23:11 +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 mx1.freebsd.org (Postfix) with ESMTPS id 598DD1F36; Fri, 3 Mar 2017 20:23:11 +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 v23KNAmp063246; Fri, 3 Mar 2017 20:23:10 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v23KNABN063244; Fri, 3 Mar 2017 20:23:10 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201703032023.v23KNABN063244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 3 Mar 2017 20:23:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314619 - head/usr.sbin/efivar X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Mar 2017 20:23:11 -0000 Author: imp Date: Fri Mar 3 20:23:10 2017 New Revision: 314619 URL: https://svnweb.freebsd.org/changeset/base/314619 Log: 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 Modified: head/usr.sbin/efivar/efivar.8 head/usr.sbin/efivar/efivar.c Modified: head/usr.sbin/efivar/efivar.8 ============================================================================== --- head/usr.sbin/efivar/efivar.8 Fri Mar 3 20:23:05 2017 (r314618) +++ head/usr.sbin/efivar/efivar.8 Fri Mar 3 20:23:10 2017 (r314619) @@ -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 Modified: head/usr.sbin/efivar/efivar.c ============================================================================== --- head/usr.sbin/efivar/efivar.c Fri Mar 3 20:23:05 2017 (r314618) +++ head/usr.sbin/efivar/efivar.c Fri Mar 3 20:23:10 2017 (r314619) @@ -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; @@ -196,6 +197,20 @@ bindump(uint8_t *data, size_t 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) { uint32_t att; @@ -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;