From nobody Thu May 01 18:06:38 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 4ZpMSb3bSRz5vW6S; Thu, 01 May 2025 18:06:39 +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 4ZpMSZ6b0kz4BGR; Thu, 01 May 2025 18:06:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746122798; 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=RvkFchIhziPQKTzbLlZF7ZrRvJxMaiql9pav34AtXLs=; b=W/aenCr2ibBpWMJnflAJiBGKTJ2Oj6oJ4UYZ7SSf1kXFjaVGBzR1mmwgLuf4Fmcyn9WfdM wi3YG96EtFZO2jRMq4CJTNXwBYY0btdD7u4fi7UZ8EVcvE9UdEoUJBwFbm5EIbXbwYn3+J hszK2RB+NANSi4ry9tQMsPiCYwEKi2k4cu3rzWpCqmzNBIguptrwPTtrESAiLsmpuubONP FmMdzqh3Q10ZSlWhrx6C8/aOArTqDeSAHJKHjrlWOAM9aQwJMKPoQyQQGdpsaUuCzK0Wd9 7ilpJX3YIIg9hSZT1ihImN2cP6dhMrP2ovXb2j7WiokwzI+0zBScKmE7aai1KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746122798; 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=RvkFchIhziPQKTzbLlZF7ZrRvJxMaiql9pav34AtXLs=; b=ymLy36ZuXJVZt6ENWeYoQuOO4+ggGBF0ZQ7Llb6L9Xfc//K4XNpiIgJ9IsDNZ+dGuCxrZX 7D2pztngxSEk5bVPlLYG2jqfCxRG6KekYryqidnz9LNOGDVEmMq1tte8MCIr4lcbUrejs6 Bs/HKK7QW0sDUJl/W4hxcq+T1dAWKkaKKjxJUxaSYXLb8X1B3kaU16YUVdjqglsAoDD6w6 zS5Gk77jI1OcB7QrVsKrQLYXQNetwyTOCIMB67rbK+jAhzRESkNhusYTKyHqRK7VUXscSp 6aCCXq3Xu6mRAhVToHEcpaEI2kOrL8IJmTilEj+96YKFZ46UsBVU6w5tH3FfmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746122798; a=rsa-sha256; cv=none; b=r8SXJgXYySBSsLJ+LBpDdFQuIiIaZaROMofThRPmRDFeMJBEkewnEzfDKcNB8L3Pl8x9+a JJvk0iYtNSlH/LAubyaxSiEUeqwqs8L07meYpmlr46UN6KqEcD+V7UO0DPA+1iBmLlqtsw OewKlxH5mh96DL/DqbYpooZQaMrabefIyYYxTtAUChqH/F9rrh40iGr7Ru54uKNYO4dgYW 9P4z8HoJfLH29Bed23A7oVhsVGv/abv+vG5Z1k/NyCMjRfEQSWVfqIvg5dEJpXmp7rUKCo 6I+CVd251ljeogmxNvDI83SzgHzbu/MPweEOZlxaxxnjC+1Bg+DgOj3FmrqWSQ== 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 4ZpMSZ5Yhczfk8; Thu, 01 May 2025 18:06:38 +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 541I6cwb066569; Thu, 1 May 2025 18:06:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 541I6crp066566; Thu, 1 May 2025 18:06:38 GMT (envelope-from git) Date: Thu, 1 May 2025 18:06:38 GMT Message-Id: <202505011806.541I6crp066566@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: 9d218a7be088 - main - efitable: Don't assume EFI GUID are uuid_t 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: 9d218a7be088c6b5ef250a945d532f3ae59c6a1a Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9d218a7be088c6b5ef250a945d532f3ae59c6a1a commit 9d218a7be088c6b5ef250a945d532f3ae59c6a1a Author: Warner Losh AuthorDate: 2025-05-01 17:53:19 +0000 Commit: Warner Losh CommitDate: 2025-05-01 17:53:19 +0000 efitable: Don't assume EFI GUID are uuid_t To share code better with EDK2, we need to align our interfaces with its definition of EFI_GUID. This structure is the same size as our uuid_t, but has different elements. The EFI standard uses a string notaiton that are compatible with the uuid_* routines, however. So we use those routies to parse, but need to b careful to cast as appropriate. Becuas the ABI is the same, this is safe, though perhaps suboptimal. These changes make efitable API neutral. Sponsored by: Netflix Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D50036 --- usr.sbin/efitable/efitable.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/usr.sbin/efitable/efitable.c b/usr.sbin/efitable/efitable.c index 81d8bb999c58..f283d467b01d 100644 --- a/usr.sbin/efitable/efitable.c +++ b/usr.sbin/efitable/efitable.c @@ -46,17 +46,19 @@ static void efi_table_print_esrt(const void *data); static void efi_table_print_prop(const void *data); static void usage(void) __dead2; +typedef uuid_t efi_guid_t; /* Typedef for future efi_guid_t */ + struct efi_table_op { char name[TABLE_MAX_LEN]; void (*parse) (const void *); - struct uuid uuid; + efi_guid_t guid; }; static const struct efi_table_op efi_table_ops[] = { { .name = "esrt", .parse = efi_table_print_esrt, - .uuid = EFI_TABLE_ESRT }, + .guid = EFI_TABLE_ESRT }, { .name = "prop", .parse = efi_table_print_prop, - .uuid = EFI_PROPERTIES_TABLE } + .guid = EFI_PROPERTIES_TABLE } }; int @@ -81,14 +83,23 @@ main(int argc, char **argv) if (argc < 0) exit(EXIT_FAILURE); - while ((ch = getopt_long(argc, argv, "u:t:", longopts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "g:t:u:", longopts, NULL)) != -1) { switch (ch) { + case 'g': case 'u': { char *uuid_str = optarg; struct uuid uuid; uint32_t status; + /* + * Note: we use the uuid parsing routine to parse the + * guid strings. However, EFI defines a slightly + * different structure to access them. We unify on + * using a structure that's compatible with EDK2 + * EFI_GUID structure. + */ + uuid_set = 1; uuid_from_string(uuid_str, &uuid, &status); @@ -96,7 +107,7 @@ main(int argc, char **argv) xo_errx(EX_DATAERR, "invalid UUID"); for (size_t n = 0; n < nitems(efi_table_ops); n++) { - if (!memcmp(&uuid, &efi_table_ops[n].uuid, + if (!memcmp(&uuid, &efi_table_ops[n].guid, sizeof(uuid))) { efi_idx = n; got_table = true; @@ -140,7 +151,7 @@ main(int argc, char **argv) if (efi_fd < 0) xo_err(EX_OSFILE, "/dev/efi"); - table.uuid = efi_table_ops[efi_idx].uuid; + memcpy(&table.uuid, &efi_table_ops[efi_idx].guid, sizeof(struct uuid)); if (ioctl(efi_fd, EFIIOC_GET_TABLE, &table) == -1) xo_err(EX_OSERR, "EFIIOC_GET_TABLE (len == 0)"); @@ -181,7 +192,7 @@ efi_table_print_esrt(const void *data) uint32_t status; char *uuid; - uuid_to_string(&e->fw_class, &uuid, &status); + uuid_to_string((const uuid_t *)&e->fw_class, &uuid, &status); if (status != uuid_s_ok) { xo_errx(EX_DATAERR, "uuid_to_string error"); } @@ -232,6 +243,6 @@ efi_table_print_prop(const void *data) static void usage(void) { - xo_error("usage: efitable [-d uuid | -t name] [--libxo]\n"); + xo_error("usage: efitable [-g guid | -t name] [--libxo]\n"); exit(EX_USAGE); }