git: 217a0796fb0b - stable/13 - GEOM: Fix regression after 7f16b501e25.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Wed, 11 May 2022 01:44:25 UTC
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=217a0796fb0b8f43efef5a371e98aab36e3a68f7

commit 217a0796fb0b8f43efef5a371e98aab36e3a68f7
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-03-16 03:58:09 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-05-11 01:20:25 +0000

    GEOM: Fix regression after 7f16b501e25.
    
    find_geom() in some classes trim leading "/dev/" from geom names.
    Lack of that in geom_gettree_geom() broke some existing scripts.
    
    PR:             262554
    MFC after:      2 months
    
    (cherry picked from commit bd0f3d34fa20686bac9a418d3a37a3f59c25ab19)
---
 lib/libgeom/geom_xml2tree.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c
index a6da0e6d163f..52d21790101e 100644
--- a/lib/libgeom/geom_xml2tree.c
+++ b/lib/libgeom/geom_xml2tree.c
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
+#include <paths.h>
 #include <fcntl.h>
 #include <ctype.h>
 #include <sys/stat.h>
@@ -481,6 +482,8 @@ geom_gettree_geom(struct gmesh *gmp, const char *c, const char *g, int parents)
 	char *p;
 	int error;
 
+	if (g != NULL && strncmp(g, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
+		g += sizeof(_PATH_DEV) - 1;
 	p = geom_getxml_geom(c, g, parents);
 	if (p == NULL)
 		return (errno);