git: 0a09fd56501c - stable/12 - geom(8): list geoms with /dev/ prefix

Robert Wing rew at FreeBSD.org
Mon Jan 11 21:14:45 UTC 2021


The branch stable/12 has been updated by rew:

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

commit 0a09fd56501c2508c9d2797302544d55112d767f
Author:     Robert Wing <rew at FreeBSD.org>
AuthorDate: 2020-12-12 07:22:38 +0000
Commit:     Robert Wing <rew at FreeBSD.org>
CommitDate: 2021-01-11 20:54:22 +0000

    geom(8): list geoms with /dev/ prefix
    
    Allow geom(8) to list geoms with the '/dev/' prefix.
    
    `geom part show` accepts the '/dev/' prefix but `geom part list` does not.
    
    Modify find_geom() in sbin/geom/core/geom.c to be consistent with the behavior
    of find_geom() in lib/geom/part/geom_part.c.
    
    PR:             188213
    Reported by:    Ronald F. Guilmette <rfg at tristatelogic.com>
    Reviewed by:    imp, kevans
    Approved by:    kevans (mentor)
    Differential Revision:  https://reviews.freebsd.org/D27556
    
    (cherry picked from commit f200cc255f8e90b1905d94d0506a22f5dcd467c0)
---
 sbin/geom/core/geom.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c
index e6d6d789908f..58b33a067700 100644
--- a/sbin/geom/core/geom.c
+++ b/sbin/geom/core/geom.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <ctype.h>
 #include <err.h>
 #include <errno.h>
+#include <paths.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -862,6 +863,9 @@ find_geom(struct gclass *classp, const char *name)
 {
 	struct ggeom *gp;
 
+	if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
+		name += sizeof(_PATH_DEV) - 1;
+
 	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
 		if (strcmp(gp->lg_name, name) == 0)
 			return (gp);


More information about the dev-commits-src-all mailing list