diff --git a/lib/libefivar/efivar-dp-xlate.c b/lib/libefivar/efivar-dp-xlate.c --- a/lib/libefivar/efivar-dp-xlate.c +++ b/lib/libefivar/efivar-dp-xlate.c @@ -76,7 +76,7 @@ { struct gclass *classp; struct ggeom *gp; - struct gprovider *pp; + struct gprovider *pp, *ppl; const char *val; /* @@ -88,7 +88,6 @@ } if (classp == NULL) return (NULL); - /* * Each geom will have a number of providers, search each * one of them for the efimedia that matches. @@ -100,11 +99,31 @@ if (val == NULL) continue; if (strcasecmp(efimedia, val) == 0) - return (pp); + goto partition_found; } } - return (NULL); +partition_found: + /* + * Having found the "efimedia" partition, check if there is a glabel on + * it and preferentially return the glabel. + */ + LIST_FOREACH(classp, &mesh->lg_class, lg_class) { + if (strcasecmp(classp->lg_name, G_LABEL) == 0) { + LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { + if (strcmp(gp->lg_name, pp->lg_name) == 0) { + LIST_FOREACH(ppl, &gp->lg_provider, + lg_provider) + { + pp = ppl; + break; + } + } + } + } + } + /* XXX Additional geom classes require class-specific code */ + return (pp); } static struct gprovider *