git: 0c479a5c47db - releng/13.2 - efivar: Try harder to find label's efimedia

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 19 Feb 2023 06:48:24 UTC
The branch releng/13.2 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=0c479a5c47dbbba7b6ff3a867e0981749e3262a5

commit 0c479a5c47dbbba7b6ff3a867e0981749e3262a5
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-02-16 16:36:03 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-19 06:46:46 +0000

    efivar: Try harder to find label's efimedia
    
    If there's no efimedia attribute on the provider, and the provider's a
    glabel, then find the 'parent' geom. In this case, the provider's name
    is label-type/name, but the geom's label will that of the underlying
    device (eg ada0p1). If it is, recurisvely call find_geom_efimedia with
    the geom's name, which shuold have the efimedia attribute.
    
    Sponsored by:           Netflix
    Reviewed by:            corvink, manu, asomers
    Differential Revision:  https://reviews.freebsd.org/D38614
    Approved by:            re@ (cperciva)
    
    (cherry picked from commit ccf2121d59ac51e1a0287d75262d48018d09cad6)
    (cherry picked from commit 9ad4c0468f1924cf7bdb9830bb781de9ca095c61)
---
 lib/libefivar/efivar-dp-xlate.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/libefivar/efivar-dp-xlate.c b/lib/libefivar/efivar-dp-xlate.c
index 1b30d1dfb143..effc8a2de475 100644
--- a/lib/libefivar/efivar-dp-xlate.c
+++ b/lib/libefivar/efivar-dp-xlate.c
@@ -527,6 +527,15 @@ find_geom_efimedia(struct gmesh *mesh, const char *dev)
 	if (pp == NULL)
 		return (NULL);
 	efimedia = geom_pp_attr(mesh, pp, "efimedia");
+
+	/*
+	 * If this device doesn't hav an efimedia attribute, see if it is a
+	 * glabel node, and if so look for the underlying provider to get the
+	 * efimedia attribute from.
+	 */
+	if (efimedia == NULL &&
+	    strcmp(pp->lg_geom->lg_class->lg_name, G_LABEL) == 0)
+		efimedia = find_geom_efimedia(mesh, pp->lg_geom->lg_name);
 	if (efimedia == NULL)
 		return (NULL);
 	return strdup(efimedia);