From nobody Thu May 1 18:06:45 2025 X-Original-To: dev-commits-src-main@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 4ZpMSk3K6Lz5vW6x; Thu, 01 May 2025 18:06:46 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZpMSj4KT8z4C9s; Thu, 01 May 2025 18:06:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746122805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=13UUDb/acrYJKK6SQiO2f9yl7qWUsUxA7vlnmmfQrhs=; b=iiYPmJVWecoiVrs5g85ploUiDXpP9aG4tSJPfxAqVn8kWwc087bxjhcdGhCRTBgQobdbd8 rJfJ9+ClGtJOiKkGQs7eW0TgU95YFAN69PKnSnbZf76yeTUgdTmgRp65atS+C4XAa2DIzH 5q9N2ITIa23d1/FSlFT/14Ar/Z6pMJ3FBvEJLXFP4s8t0XM3leTIgJ7WC3pnjH5+r8Bdrm jsnDwVZz1y7a4j8p1Q8xPudW0JnQFQwD3Q9WUOKzz6hKOd3cZlVPwBehfudzgAL0mx8zfn YMV5FTH1ozedq1aL0pg+i21xpLGRfkvvybHYYzUJ2KXaKMyR0wyJTs3A5M4lfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746122805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=13UUDb/acrYJKK6SQiO2f9yl7qWUsUxA7vlnmmfQrhs=; b=Aua3voOm46yoFn5jOVW5dEDlNewlHAWEgw3LOiV7ffzevWnSoNNhw3oRr9Ty/k9P5SFBwq GCE4A1D/CfDzTXaRR8QcDn6r0/ItqpPomkfYQ+USbqt7fLqq3Dt0Axetir3ir0Op+SpR1I 3IwpubaTCZ+C5fW0ipKlAAeIFuHgDXgqVTEjB/TBp/8e3kYgQh5djyRVWmVqlamwB8y1y3 t3X7ldnvxGfRGp2cxiuVOoB4pSLA975Fh6e7Z0JNd2z0n+zNeVhl7XUKY9DOGivGR5gBJQ LgISB0Df91cpTtfk/sv4J1XcNcwwV0DzKxlERFTPSP2Mm/IBAHrMnfilckdqOA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746122805; a=rsa-sha256; cv=none; b=yHZHuTAgJVeSX0SC+YfIwpRrYPp+kmIWI8/TqhpeJNhIBIVzkTyfTfxG49bBDlmqqaypVA eNLEQxYHwU+mGAxsVvXGcZ7XpxTelZmpUHIhl8oxhfNrEh7Kb6T2VLb/bo3IAaMu43tR0w cQjZIUV1b2FlYaVUL+E0vBlqWCjtQvvtb82I01bEmJvP+CA71brb8DoEM06yC4JuzDsiyi CB+gcGwn4CnAbectJkE8XOnG9SnfmYJVm6rjfLDzXb5b0hw6cC3fJohcDbB8+0vWYcWdIS Ypwx14UM5EA12t2P6CSTL3RUtmkOafF/fRkWzG+ipVfWb6CQwMevwztjPzUsww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZpMSj3tMXzfTn; Thu, 01 May 2025 18:06:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 541I6j4R066793; Thu, 1 May 2025 18:06:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 541I6jm0066790; Thu, 1 May 2025 18:06:45 GMT (envelope-from git) Date: Thu, 1 May 2025 18:06:45 GMT Message-Id: <202505011806.541I6jm0066790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 8d136fb027ba - main - efivar: Use struct guid_table instead of uuid_table List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8d136fb027ba2b12794d0501422def5d4e375643 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8d136fb027ba2b12794d0501422def5d4e375643 commit 8d136fb027ba2b12794d0501422def5d4e375643 Author: Warner Losh AuthorDate: 2025-05-01 17:54:02 +0000 Commit: Warner Losh CommitDate: 2025-05-01 17:55:14 +0000 efivar: Use struct guid_table instead of uuid_table uuid_table was the linux name. When libefivar was started, I tried to make it compatible with Linux. However, that's no longer relevant: (a) little to no Linux code was subsequently ported and (b) Linux compat has eroded. This erodes it a bit more to cope with the uuid_t -> efi_guid_t changes. This also moves a couple of functions around to reduce copying and updates consumers for the visible parts of this change. Sponsored by: Netflix Reviewed by: tsoome, kib Differential Revision: https://reviews.freebsd.org/D50060 --- lib/libefivar/efivar.c | 41 +++++++++++++++++++---------------------- lib/libefivar/efivar.h | 4 ++-- usr.sbin/efivar/efivar.c | 2 +- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/lib/libefivar/efivar.c b/lib/libefivar/efivar.c index 03efb3c5226a..a7cf13055bfe 100644 --- a/lib/libefivar/efivar.c +++ b/lib/libefivar/efivar.c @@ -42,7 +42,7 @@ static int efi_fd = -2; const efi_guid_t efi_guid_empty = Z; -static struct uuid_table guid_tbl [] = +static struct guid_table guid_tbl [] = { { "00000000-0000-0000-0000-000000000000", "zero", Z }, { "093e0fae-a6c4-4f50-9f1b-d41e2b89c19a", "sha512", Z }, @@ -76,31 +76,39 @@ static struct uuid_table guid_tbl [] = { "e2b36190-879b-4a3d-ad8d-f2e7bba32784", "rsa2048_sha256", Z }, { "ff3e5307-9fd0-48c9-85f1-8ad56c701e01", "sha384", Z }, { "f46ee6f4-4785-43a3-923d-7f786c3c8479", "lenovo_startup_interrupt", Z }, - { "ffffffff-ffff-ffff-ffff-ffffffffffff", "zzignore-this-guid", Z }, }; +int +efi_str_to_guid(const char *s, efi_guid_t *guid) +{ + uint32_t status; + + /* knows efi_guid_t is binary compatible with uuid_t */ + uuid_from_string(s, (uuid_t *)guid, &status); + + return (status == uuid_s_ok ? 0 : -1); +} + static void efi_guid_tbl_compile(void) { size_t i; - uint32_t status; static bool done = false; + struct guid_table *ent; if (done) return; for (i = 0; i < nitems(guid_tbl); i++) { - uuid_from_string(guid_tbl[i].uuid_str, (uuid_t *)&guid_tbl[i].guid, - &status); - /* all f's is a bad version, so ignore that error */ - if (status != uuid_s_ok && status != uuid_s_bad_version) - fprintf(stderr, "Can't convert %s to a uuid for %s: %d\n", - guid_tbl[i].uuid_str, guid_tbl[i].name, (int)status); + ent = &guid_tbl[i]; + if (efi_str_to_guid(ent->uuid_str, &ent->guid) != 0) + fprintf(stderr, "Can't convert %s to a guid for %s\n", + ent->uuid_str, ent->name); } done = true; } int -efi_known_guid(struct uuid_table **tbl) +efi_known_guid(struct guid_table **tbl) { *tbl = guid_tbl; @@ -327,7 +335,7 @@ efi_guid_to_str(const efi_guid_t *guid, char **sp) { uint32_t status; - /* knows efi_guid_t is a typedef of uuid_t */ + /* knows efi_guid_t is binary compatible with uuid_t */ uuid_to_string((const uuid_t *)guid, sp, &status); return (status == uuid_s_ok ? 0 : -1); @@ -373,17 +381,6 @@ errout: return rv; } -int -efi_str_to_guid(const char *s, efi_guid_t *guid) -{ - uint32_t status; - - /* knows efi_guid_t is a typedef of uuid_t */ - uuid_from_string(s, (uuid_t *)guid, &status); - - return (status == uuid_s_ok ? 0 : -1); -} - int efi_variables_supported(void) { diff --git a/lib/libefivar/efivar.h b/lib/libefivar/efivar.h index 980f261e9edc..e159f4cccd3d 100644 --- a/lib/libefivar/efivar.h +++ b/lib/libefivar/efivar.h @@ -80,14 +80,14 @@ int efi_str_to_guid(const char *s, efi_guid_t *guid); int efi_variables_supported(void); /* FreeBSD extensions */ -struct uuid_table +struct guid_table { const char *uuid_str; const char *name; efi_guid_t guid; }; -int efi_known_guid(struct uuid_table **); +int efi_known_guid(struct guid_table **); extern const efi_guid_t efi_guid_empty; diff --git a/usr.sbin/efivar/efivar.c b/usr.sbin/efivar/efivar.c index a87c73abef36..c40ff1ea010f 100644 --- a/usr.sbin/efivar/efivar.c +++ b/usr.sbin/efivar/efivar.c @@ -298,7 +298,7 @@ print_variables(void) static void print_known_guid(void) { - struct uuid_table *tbl; + struct guid_table *tbl; int i, n; n = efi_known_guid(&tbl);