Introduce g_provider_by_name() function, and use it.
This commit is contained in:
parent
3a3fcd72dd
commit
d6c5e71627
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=115850
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user