diff options
author | phk <phk@FreeBSD.org> | 2003-06-04 18:17:52 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-06-04 18:17:52 +0000 |
commit | e23e34a19802782b58aaba1063a789cc198f2e82 (patch) | |
tree | 5626e124f018746fcb1f3cd7775457d4272b04d5 /sys/geom | |
parent | 9e9ac1e55e5c653a1a2a32556d8ddbcd3213e9ed (diff) | |
download | FreeBSD-src-e23e34a19802782b58aaba1063a789cc198f2e82.zip FreeBSD-src-e23e34a19802782b58aaba1063a789cc198f2e82.tar.gz |
Introduce g_provider_by_name() function, and use it.
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom.h | 1 | ||||
-rw-r--r-- | sys/geom/geom_ctl.c | 13 | ||||
-rw-r--r-- | sys/geom/geom_subr.c | 17 |
3 files changed, 21 insertions, 10 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 5dc6925..70579b0 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -204,6 +204,7 @@ void g_destroy_geom(struct g_geom *pp); void g_destroy_provider(struct g_provider *pp); void g_detach(struct g_consumer *cp); void g_error_provider(struct g_provider *pp, int error); +struct g_provider *g_provider_by_name(char const *arg); int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); #define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) int g_handleattr(struct bio *bp, const char *attribute, void *val, int len); diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index 76491b8..c113076 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -406,21 +406,14 @@ struct g_provider * gctl_get_provider(struct gctl_req *req, char const *arg) { char const *p; - struct g_class *cp; - struct g_geom *gp; struct g_provider *pp; p = gctl_get_asciiparam(req, arg); if (p == NULL) return (NULL); - LIST_FOREACH(cp, &g_classes, class) { - LIST_FOREACH(gp, &cp->geom, geom) { - LIST_FOREACH(pp, &gp->provider, provider) { - if (!strcmp(p, pp->name)) - return (pp); - } - } - } + pp = g_provider_by_name(p); + if (pp != NULL) + return (pp); gctl_error(req, "Provider not found"); return (NULL); } diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index 00bdfcb..84978c9 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -380,6 +380,23 @@ g_error_provider(struct g_provider *pp, int error) pp->error = error; } +struct g_provider * +g_provider_by_name(char const *arg) +{ + struct g_class *cp; + struct g_geom *gp; + struct g_provider *pp; + + LIST_FOREACH(cp, &g_classes, class) { + LIST_FOREACH(gp, &cp->geom, geom) { + LIST_FOREACH(pp, &gp->provider, provider) { + if (!strcmp(arg, pp->name)) + return (pp); + } + } + } + return (NULL); +} void g_destroy_provider(struct g_provider *pp) |