From owner-svn-src-all@freebsd.org Thu Mar 9 00:31:37 2017 Return-Path: Delivered-To: svn-src-all@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 8DA84D01B68; Thu, 9 Mar 2017 00:31:37 +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 64C40C82; Thu, 9 Mar 2017 00:31:37 +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 v290VaOu041113; Thu, 9 Mar 2017 00:31:36 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v290Vaw7041111; Thu, 9 Mar 2017 00:31:36 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201703090031.v290Vaw7041111@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 9 Mar 2017 00:31:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314927 - 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-all@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 09 Mar 2017 00:31:37 -0000 Author: imp Date: Thu Mar 9 00:31:36 2017 New Revision: 314927 URL: https://svnweb.freebsd.org/changeset/base/314927 Log: Finish implementing -d/--device/--device-path flag to print variable as if it were a device path. Remove language about a=b syntax on the command line. This will not be implemented due to its limited usefulness. UEFI variables are binary blobs, on the whole, and a simple work around exists for strings. Clarify that the new value of the variable is taken from stdin. Update manual with history. 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 Thu Mar 9 00:31:31 2017 (r314926) +++ head/usr.sbin/efivar/efivar.8 Thu Mar 9 00:31:36 2017 (r314927) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2003 Netflix, Inc +.\" Copyright (c) 2017 Netflix, Inc .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 29, 2016 +.Dd March 4, 2017 .Dt EFIVAR 8 .Os .Sh NAME @@ -40,6 +40,7 @@ .Op Fl -attributes .Op Fl -binary .Op Fl -delete +.Op Fl -device-path .Op Fl -fromfile Ar file .Op Fl -guid .Op Fl -hex @@ -51,7 +52,6 @@ .Op Fl -print-decimal .Op Fl -raw-guid .Op Fl -write -.Ar name Ns Op = Ns Ar value .Sh DESCRIPTION This program manages .Dq Unified Extensible Firmware Interface @@ -117,6 +117,9 @@ flags. No .Ar value may be specified. +.It Fl d Fl -device Fl -device-path +Interpret the variables printed as UEFI device paths and print the +UEFI standard string representation. .It Fl g Fl -guid flag is specified, guids are converted to names if they are known (and show up in @@ -138,33 +141,45 @@ flag is also listed, their values will b Do not display the variable name. .It Fl p Fl -print Print the value of the variable. -.It Fl d Fl -print-decimal -Treat the value of the variable as a number and print it as a -decimal. -This is currently unimplemented. .It Fl R Fl -raw-guid Do not substitute well known names for GUID numeric values in output. .It Fl w Fl -write -Write (replace) the variable specified with the value specified. +Write (replace) the variable specified with the value specified from +standard input. +No command line option to do this is available since UEFI variables +are binary structures rather than strings. +.Xr echo 1 +.Fl n +can be used to specify simple strings. .It Ar name Display the .Ar name environment variable. -.It Ar name Ns = Ns Ar value -Set the specified -.Ar name -to -.Ar value . -This is not yet implemented. -If the .Sh COMPATIBILITY The .Nm program is intended to be compatible (strict superset) with a progam of the same name included in the Red Hat libefivar package. +.Pp +Except the +.Fl d +and +.Fl -print-decimal +flags are not implmenented and never will be. +The +.Fl d +flag is a short-hand for +.Fl -device-path . .Sh SEE ALSO Appendix A of the UEFI specification has the format for GUIDs. All GUIDs .Dq Globally Unique Identifiers have the format described in RFC 4122. .El +.Pp +.Xr efivar 8 +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 12.0 . Modified: head/usr.sbin/efivar/efivar.c ============================================================================== --- head/usr.sbin/efivar/efivar.c Thu Mar 9 00:31:31 2017 (r314926) +++ head/usr.sbin/efivar/efivar.c Thu Mar 9 00:31:36 2017 (r314927) @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -201,8 +202,13 @@ bindump(uint8_t *data, size_t datalen) static void devpath_dump(uint8_t *data, size_t datalen) { + char buffer[1024]; - fprintf(stderr, "junk %p %zu\n", data, datalen); + efidp_format_device_path(buffer, sizeof(buffer), + (const_efidp)data, datalen); + if (!Nflag) + printf(": "); + printf("%s\n", buffer); } static void