From nobody Tue Apr 28 20:59:08 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g4t8d6z56z6c5S9 for ; Tue, 28 Apr 2026 20:59:13 +0000 (UTC) (envelope-from git@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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g4t8d5jplz3PSp for ; Tue, 28 Apr 2026 20:59:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777409953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9bwawPfmwp15kFjjht4kkF3+cAQ7/Mx3Lawu5WOBwRA=; b=o0zveuFvygrWCQLGQs6Jgpq2R77FT1hP53jWnKmV/4UzLk2qQlD/H8SS7YN85+XqEM8F/O Ipicy44z7imI5/FYPlE5ONupnSEeiD5WLvoUJ92DhWSfvV3tA5UQVEYGfpdeMdZVdkxXpJ 0DQT9GBZQpECTWiF31FjyghOz4V5KMteZljLserSJPRI8pj2IleSoULDkXnMoNrf3BIwHM 5TTlJ2hS+/d5AAMJIYpeAPjARNjic1gicl7waSN3uJWb3GiW4+K2KZvJPC60HV5ZK4782Z rAMd/288OC+c8DXybk+8VzCHy6PTGvNqJZDNOfQAwr52o7qdqyye71rD+9Iprw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777409953; a=rsa-sha256; cv=none; b=py7yM9jPfCKJ+Q1NvUR9cy9D9Uk2OQEaR3/9oxhIoGHvpkiMdxMa2ZsqXIDFtBAf+YFkms xrZkpNeyjbxciRRgPqjpMhYpQtCjMomCxMUkEowgXNZ7jToenQqthirBOU0WFULBQXysbS laZlgTiv7ZvP7nlpoms1SKkR0GCLT6DT0CbQZzhb9nFswcZCKewWu1zt7x3Ti8LzvXLB+T m3hlv3yeBVxqpceC+UBI5rBi7YjBhNRspIaQVpA3u+r7fT3tF56WltRE+CjPgTFmO0CVAZ XEBhz885vnJrXEmsndc6nQojYR6qGirRWrzrkpdzQO34tMuNnmf4i+rla5HgAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777409953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9bwawPfmwp15kFjjht4kkF3+cAQ7/Mx3Lawu5WOBwRA=; b=OBtv6qlsQMfsFWGSrVoHLam3d/zr9WAmm62L160xGJJE8ooKq4wzqRtHTYky40wHADaqai rQNu7mnZuXXuxCRozCy8CBnIyGXk4wGU3bI/b411yiIXjheklGuGvQpNWfVgbO7RUuO9Yw zImOUZiB42Zkp3MLfd4XiAeTP7RFfWhL51UKs0DyVd8pwd24DFwB3Qbbngy6WPCM/YfeCB 6U7UX/hkbRkJe4+t3isJFFS/w95DtsMNbbWNoWmu6BBmPpNv0iVS2qvCcqETvop2xFRrzV KSVrX/XtiuLBf9XQVhyLUSBBTuFNvKk6luzy5MHwRxfkVDUydab/6Xh4tfEx7w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g4t8d50tdz18wb for ; Tue, 28 Apr 2026 20:59:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3c305 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 28 Apr 2026 20:59:08 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: =?utf-8?Q?St=C3=A9pha?=ne Rochoy From: Pouria Mousavizadeh Tehrani Subject: git: 48363f39f141 - main - efivar: Move dump functions into libefivar List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pouria X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 48363f39f1417df3e39da53f219596f8501c9452 Auto-Submitted: auto-generated Date: Tue, 28 Apr 2026 20:59:08 +0000 Message-Id: <69f11f9c.3c305.57a589ae@gitrepo.freebsd.org> The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=48363f39f1417df3e39da53f219596f8501c9452 commit 48363f39f1417df3e39da53f219596f8501c9452 Author: Stéphane Rochoy AuthorDate: 2026-04-24 12:10:19 +0000 Commit: Pouria Mousavizadeh Tehrani CommitDate: 2026-04-28 20:58:54 +0000 efivar: Move dump functions into libefivar To allow their use by efibootmgr. Signed-off-by: stephane.rochoy@stormshield.eu Reviewed by: imp Sponsored by: Stormshield Pull-Request: https://github.com/freebsd/freebsd-src/pull/2167 --- lib/libefivar/Makefile | 1 + {usr.sbin/efivar => lib/libefivar}/efiutil.c | 33 ++++++++++++++------------ lib/libefivar/efivar.h | 10 ++++++++ usr.sbin/efibootmgr/Makefile | 7 +++--- usr.sbin/efibootmgr/efibootmgr.c | 1 - usr.sbin/efivar/Makefile | 2 +- usr.sbin/efivar/efiutil.h | 35 ---------------------------- usr.sbin/efivar/efivar.c | 9 ++++--- 8 files changed, 37 insertions(+), 61 deletions(-) diff --git a/lib/libefivar/Makefile b/lib/libefivar/Makefile index bc31ee6c47e3..339ba9d18a5e 100644 --- a/lib/libefivar/Makefile +++ b/lib/libefivar/Makefile @@ -35,6 +35,7 @@ LIB= efivar SRCS= efivar.c efichar.c efivar-dp-format.c \ efivar-dp-parse.c \ efivar-dp-xlate.c \ + efiutil.c \ uefi-guid.c uefi-dputil.c INCS= efivar.h efivar-dp.h SHLIB_MAJOR= 1 diff --git a/usr.sbin/efivar/efiutil.c b/lib/libefivar/efiutil.c similarity index 88% rename from usr.sbin/efivar/efiutil.c rename to lib/libefivar/efiutil.c index fc2a309a81ef..a6dce1981101 100644 --- a/usr.sbin/efivar/efiutil.c +++ b/lib/libefivar/efiutil.c @@ -35,16 +35,15 @@ #include #include #include -#include "efiutil.h" #include "efichar.h" #include /* * Dump the data as ASCII data, which is a pretty - * printed form + * printed form. */ void -asciidump(uint8_t *data, size_t datalen) +efi_asciidump(uint8_t *data, size_t datalen, int indent) { size_t i; int len; @@ -55,14 +54,14 @@ asciidump(uint8_t *data, size_t datalen) len++; if (len > 80) { len = 0; - printf("\n"); + printf("\n%*s", indent, ""); } printf("%c", data[i]); } else { len +=3; if (len > 80) { len = 0; - printf("\n"); + printf("\n%*s", indent, ""); } printf("%%%02x", data[i]); } @@ -71,7 +70,7 @@ asciidump(uint8_t *data, size_t datalen) } void -utf8dump(uint8_t *data, size_t datalen) +efi_utf8dump(uint8_t *data, size_t datalen, int indent) { char *utf8 = NULL; efi_char *ucs2; @@ -84,21 +83,25 @@ utf8dump(uint8_t *data, size_t datalen) memcpy(ucs2, data, datalen); ucs2[datalen / sizeof(efi_char)] = 0; ucs2_to_utf8(ucs2, &utf8); - printf("%s\n", utf8); + printf("%*s%s\n", indent, "", utf8); free(utf8); free(ucs2); } void -hexdump(uint8_t *data, size_t datalen) +efi_hexdump(uint8_t *data, size_t datalen, int indent) { size_t i; - for (i = 0; i < datalen; i++) { + if (datalen == 0) + return; + + printf("0000: %02x ", data[0]); + for (i = 1; i < datalen; i++) { if (i % 16 == 0) { if (i != 0) printf("\n"); - printf("%04x: ", (int)i); + printf("%*s%04x: ", indent, "", (int)i); } printf("%02x ", data[i]); } @@ -106,7 +109,7 @@ hexdump(uint8_t *data, size_t datalen) } void -bindump(uint8_t *data, size_t datalen) +efi_bindump(uint8_t *data, size_t datalen) { write(1, data, datalen); } @@ -180,11 +183,11 @@ efi_print_load_option(uint8_t *data, size_t datalen, int Aflag, int bflag, int u return; printf("Option:\n"); if (Aflag) - asciidump(opt, optlen); + efi_asciidump(opt, optlen, 0); else if (bflag) - bindump(opt, optlen); + efi_bindump(opt, optlen); else if (uflag) - utf8dump(opt, optlen); + efi_utf8dump(opt, optlen, 0); else - hexdump(opt, optlen); + efi_hexdump(opt, optlen, 0); } diff --git a/lib/libefivar/efivar.h b/lib/libefivar/efivar.h index 238b23a8b2b8..563715d96ed0 100644 --- a/lib/libefivar/efivar.h +++ b/lib/libefivar/efivar.h @@ -79,6 +79,16 @@ int efi_set_variable(efi_guid_t guid, const char *name, int efi_str_to_guid(const char *s, efi_guid_t *guid); int efi_variables_supported(void); +/* + * different routines to dump data. + */ + +void efi_asciidump(uint8_t *data, size_t datalen, int indent); +void efi_bindump(uint8_t *data, size_t datalen); +void efi_print_load_option(uint8_t *, size_t, int, int, int); +void efi_hexdump(uint8_t *data, size_t datalen, int indent); +void efi_utf8dump(uint8_t *data, size_t datalen, int indent); + /* FreeBSD extensions */ struct guid_table { diff --git a/usr.sbin/efibootmgr/Makefile b/usr.sbin/efibootmgr/Makefile index d976656a99c9..6f0a2a1dddbb 100644 --- a/usr.sbin/efibootmgr/Makefile +++ b/usr.sbin/efibootmgr/Makefile @@ -1,14 +1,13 @@ EFIBOOT=${SRCTOP}/stand/efi EFIINCL=${SRCTOP}/stand/efi/include -EFIVAR=${SRCTOP}/usr.sbin/efivar -.PATH: ${EFIBOOT}/libefi ${EFIVAR} -CFLAGS+= -I${EFIVAR} -I${EFIINCL} +.PATH: ${EFIBOOT}/libefi +CFLAGS+= -I${EFIINCL} PACKAGE= efi-tools PROG=efibootmgr MAN= efibootmgr.8 -SRCS= efichar.c efiutil.c efibootmgr.c +SRCS= efichar.c efibootmgr.c LIBADD= efivar geom diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c index b919130d9c11..1b572b613e05 100644 --- a/usr.sbin/efibootmgr/efibootmgr.c +++ b/usr.sbin/efibootmgr/efibootmgr.c @@ -50,7 +50,6 @@ #include #include -#include #include #include diff --git a/usr.sbin/efivar/Makefile b/usr.sbin/efivar/Makefile index dd655f6b953d..4d71ec7d4dc4 100644 --- a/usr.sbin/efivar/Makefile +++ b/usr.sbin/efivar/Makefile @@ -5,7 +5,7 @@ MAN= efivar.8 LIBADD= efivar geom -SRCS= efivar.c efiutil.c +SRCS= efivar.c EFIBOOT=${SRCTOP}/stand/efi CFLAGS+= -I${EFIBOOT}/include diff --git a/usr.sbin/efivar/efiutil.h b/usr.sbin/efivar/efiutil.h deleted file mode 100644 index c9fcb99ec1eb..000000000000 --- a/usr.sbin/efivar/efiutil.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2017 Netflix, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * different routines to dump data. - */ - -void asciidump(uint8_t *data, size_t datalen); -void bindump(uint8_t *data, size_t datalen); -void efi_print_load_option(uint8_t *, size_t, int, int, int); -void hexdump(uint8_t *data, size_t datalen); -void utf8dump(uint8_t *data, size_t datalen); - diff --git a/usr.sbin/efivar/efivar.c b/usr.sbin/efivar/efivar.c index c40ff1ea010f..6d252959e7de 100644 --- a/usr.sbin/efivar/efivar.c +++ b/usr.sbin/efivar/efivar.c @@ -38,7 +38,6 @@ #include #include #include -#include "efiutil.h" #include "efichar.h" /* options descriptor */ @@ -254,15 +253,15 @@ print_var(efi_guid_t *guid, char *name) if (load_opt_flag) efi_print_load_option(data, datalen, Aflag, bflag, uflag); else if (Aflag) - asciidump(data, datalen); + efi_asciidump(data, datalen, 0); else if (uflag) - utf8dump(data, datalen); + efi_utf8dump(data, datalen, 0); else if (bflag) - bindump(data, datalen); + efi_bindump(data, datalen); else if (dflag) devpath_dump(data, datalen); else - hexdump(data, datalen); + efi_hexdump(data, datalen, 0); } else { printf("%s-%s", gname, name); }