Index: head/sys/geom/label/g_label.c =================================================================== --- head/sys/geom/label/g_label.c (revision 221305) +++ head/sys/geom/label/g_label.c (working copy) @@ -361,8 +361,6 @@ g_label_ctl_create(struct gctl_req *req, struct g_ gctl_error(req, "No 'arg%d' argument", 1); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { G_LABEL_DEBUG(1, "Provider %s is invalid.", name); Index: head/sys/geom/raid/g_raid.c =================================================================== --- head/sys/geom/raid/g_raid.c (revision 221305) +++ head/sys/geom/raid/g_raid.c (working copy) @@ -592,8 +592,6 @@ g_raid_open_consumer(struct g_raid_softc *sc, cons g_topology_assert(); - if (strncmp(name, "/dev/", 5) == 0) - name += 5; pp = g_provider_by_name(name); if (pp == NULL) return (NULL); Index: head/sys/geom/cache/g_cache.c =================================================================== --- head/sys/geom/cache/g_cache.c (revision 221305) +++ head/sys/geom/cache/g_cache.c (working copy) @@ -778,8 +778,6 @@ g_cache_ctl_create(struct gctl_req *req, struct g_ gctl_error(req, "No 'arg1' argument"); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { G_CACHE_DEBUG(1, "Provider %s is invalid.", name); Index: head/sys/geom/mirror/g_mirror_ctl.c =================================================================== --- head/sys/geom/mirror/g_mirror_ctl.c (revision 221305) +++ head/sys/geom/mirror/g_mirror_ctl.c (working copy) @@ -453,8 +453,6 @@ g_mirror_ctl_insert(struct gctl_req *req, struct g gctl_error(req, "Provider %s already inserted.", name); continue; } - if (strncmp(name, "/dev/", 5) == 0) - name += 5; pp = g_provider_by_name(name); if (pp == NULL) { gctl_error(req, "Unknown provider %s.", name); Index: head/sys/geom/mountver/g_mountver.c =================================================================== --- head/sys/geom/mountver/g_mountver.c (revision 221305) +++ head/sys/geom/mountver/g_mountver.c (working copy) @@ -387,8 +387,6 @@ g_mountver_ctl_create(struct gctl_req *req, struct gctl_error(req, "No 'arg%d' argument", i); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { G_MOUNTVER_DEBUG(1, "Provider %s is invalid.", name); Index: head/sys/geom/nop/g_nop.c =================================================================== --- head/sys/geom/nop/g_nop.c (revision 221305) +++ head/sys/geom/nop/g_nop.c (working copy) @@ -341,8 +341,6 @@ g_nop_ctl_create(struct gctl_req *req, struct g_cl gctl_error(req, "No 'arg%d' argument", i); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { G_NOP_DEBUG(1, "Provider %s is invalid.", name); @@ -411,8 +409,6 @@ g_nop_ctl_configure(struct gctl_req *req, struct g gctl_error(req, "No 'arg%d' argument", i); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL || pp->geom->class != mp) { G_NOP_DEBUG(1, "Provider %s is invalid.", name); @@ -518,8 +514,6 @@ g_nop_ctl_reset(struct gctl_req *req, struct g_cla gctl_error(req, "No 'arg%d' argument", i); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL || pp->geom->class != mp) { G_NOP_DEBUG(1, "Provider %s is invalid.", name); Index: head/sys/geom/raid3/g_raid3_ctl.c =================================================================== --- head/sys/geom/raid3/g_raid3_ctl.c (revision 221305) +++ head/sys/geom/raid3/g_raid3_ctl.c (working copy) @@ -430,8 +430,6 @@ g_raid3_ctl_insert(struct gctl_req *req, struct g_ gctl_error(req, "No '%s' argument.", "no"); return; } - if (strncmp(name, "/dev/", 5) == 0) - name += 5; g_topology_lock(); pp = g_provider_by_name(name); if (pp == NULL) { Index: head/sys/geom/geom_subr.c =================================================================== --- head/sys/geom/geom_subr.c (revision 221305) +++ head/sys/geom/geom_subr.c (working copy) @@ -47,6 +47,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include +#include #include #include #include @@ -599,6 +603,30 @@ g_error_provider(struct g_provider *pp, int error) pp->error = error; } +static struct g_provider * +g_provider_by_devname(char const *name) +{ + struct g_provider *pp; + struct nameidata nd; + int error, vfslocked; + + pp = NULL; + NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, name, curthread); + error = namei(&nd); + vfslocked = NDHASGIANT(&nd); + if (error == 0) { + if (nd.ni_vp->v_type == VBLK || nd.ni_vp->v_type == VCHR) + pp = g_dev_getprovider(nd.ni_vp->v_rdev); + NDFREE(&nd, 0); + } + VFS_UNLOCK_GIANT(vfslocked); + return (pp); +} + +#ifndef _PATH_DEV +#define _PATH_DEV "/dev/" +#endif + struct g_provider * g_provider_by_name(char const *arg) { @@ -606,6 +634,12 @@ g_provider_by_name(char const *arg) struct g_geom *gp; struct g_provider *pp; + if (strncmp(arg, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) { + pp = g_provider_by_devname(arg); + if (pp != NULL) + return (pp); + arg += sizeof(_PATH_DEV) - 1; + } LIST_FOREACH(cp, &g_classes, class) { LIST_FOREACH(gp, &cp->geom, geom) { LIST_FOREACH(pp, &gp->provider, provider) { Index: head/sys/geom/part/g_part.c =================================================================== --- head/sys/geom/part/g_part.c (revision 221305) +++ head/sys/geom/part/g_part.c (working copy) @@ -340,8 +340,6 @@ g_part_parm_provider(struct gctl_req *req, const c pname = gctl_get_asciiparam(req, name); if (pname == NULL) return (ENOATTR); - if (strncmp(pname, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) - pname += sizeof(_PATH_DEV) - 1; pp = g_provider_by_name(pname); if (pp == NULL) { gctl_error(req, "%d %s '%s'", EINVAL, name, pname); Index: head/sys/geom/stripe/g_stripe.c =================================================================== --- head/sys/geom/stripe/g_stripe.c (revision 221305) +++ head/sys/geom/stripe/g_stripe.c (working copy) @@ -1059,8 +1059,6 @@ g_stripe_ctl_create(struct gctl_req *req, struct g gctl_error(req, "No 'arg%u' argument.", no); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { G_STRIPE_DEBUG(1, "Disk %s is invalid.", name); @@ -1085,8 +1083,6 @@ g_stripe_ctl_create(struct gctl_req *req, struct g gctl_error(req, "No 'arg%u' argument.", no); continue; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); KASSERT(pp != NULL, ("Provider %s disappear?!", name)); if (g_stripe_add_disk(sc, pp, no - 1) != 0) { Index: head/sys/geom/multipath/g_multipath.c =================================================================== --- head/sys/geom/multipath/g_multipath.c (revision 221305) +++ head/sys/geom/multipath/g_multipath.c (working copy) @@ -610,7 +610,6 @@ g_multipath_ctl_add(struct gctl_req *req, struct g struct g_consumer *cp; struct g_provider *pp, *pp0; const char *name, *mpname; - static const char devpf[6] = "/dev/"; g_topology_assert(); @@ -630,8 +629,6 @@ g_multipath_ctl_add(struct gctl_req *req, struct g gctl_error(req, "No 'arg1' argument"); return; } - if (strncmp(name, devpf, 5) == 0) - name += 5; pp = g_provider_by_name(name); if (pp == NULL) { gctl_error(req, "Provider %s is invalid", name); Index: head/sys/geom/concat/g_concat.c =================================================================== --- head/sys/geom/concat/g_concat.c (revision 221305) +++ head/sys/geom/concat/g_concat.c (working copy) @@ -778,8 +778,6 @@ g_concat_ctl_create(struct gctl_req *req, struct g gctl_error(req, "No 'arg%u' argument.", no); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { G_CONCAT_DEBUG(1, "Disk %s is invalid.", name); @@ -804,8 +802,6 @@ g_concat_ctl_create(struct gctl_req *req, struct g gctl_error(req, "No 'arg%d' argument.", no); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); KASSERT(pp != NULL, ("Provider %s disappear?!", name)); if (g_concat_add_disk(sc, pp, no - 1) != 0) { Index: head/sys/geom/virstor/g_virstor.c =================================================================== --- head/sys/geom/virstor/g_virstor.c (revision 221305) +++ head/sys/geom/virstor/g_virstor.c (working copy) @@ -318,9 +318,6 @@ virstor_ctl_add(struct gctl_req *req, struct g_cla g_topology_unlock(); return; } - if (strncmp(prov_name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) - prov_name += sizeof(_PATH_DEV) - 1; - pp = g_provider_by_name(prov_name); if (pp == NULL) { /* This is the most common error so be verbose about it */ Index: head/sys/geom/eli/g_eli_ctl.c =================================================================== --- head/sys/geom/eli/g_eli_ctl.c (revision 221305) +++ head/sys/geom/eli/g_eli_ctl.c (working copy) @@ -90,8 +90,6 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_cl gctl_error(req, "No 'arg%u' argument.", 0); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { gctl_error(req, "Provider %s is invalid.", name); @@ -335,8 +333,6 @@ g_eli_ctl_onetime(struct gctl_req *req, struct g_c gctl_error(req, "No 'arg%u' argument.", 0); return; } - if (strncmp(name, "/dev/", strlen("/dev/")) == 0) - name += strlen("/dev/"); pp = g_provider_by_name(name); if (pp == NULL) { gctl_error(req, "Provider %s is invalid.", name);