gctl_get_geom: Skip validation of g_class.

The caller from kernel is expected to provide an valid g_class
pointer, instead of traversing the global g_class list, just
use that pointer directly instead.

Reviewed by:		mav
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D25811
This commit is contained in:
Xin LI 2020-07-26 22:30:55 +00:00
parent 178d88fa39
commit a450ecfdbd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363585
2 changed files with 6 additions and 11 deletions

View File

@ -434,7 +434,7 @@ void *gctl_get_paraml(struct gctl_req *req, const char *param, int len);
void *gctl_get_paraml_opt(struct gctl_req *req, const char *param, int len);
int gctl_error(struct gctl_req *req, const char *fmt, ...) __printflike(2, 3);
struct g_class *gctl_get_class(struct gctl_req *req, char const *arg);
struct g_geom *gctl_get_geom(struct gctl_req *req, struct g_class *mpr, char const *arg);
struct g_geom *gctl_get_geom(struct gctl_req *req, struct g_class *mp, char const *arg);
struct g_provider *gctl_get_provider(struct gctl_req *req, char const *arg);
#endif /* _GEOM_GEOM_H_ */

View File

@ -409,25 +409,20 @@ gctl_get_class(struct gctl_req *req, char const *arg)
}
struct g_geom *
gctl_get_geom(struct gctl_req *req, struct g_class *mpr, char const *arg)
gctl_get_geom(struct gctl_req *req, struct g_class *mp, char const *arg)
{
char const *p;
struct g_class *mp;
struct g_geom *gp;
MPASS(mp != NULL);
p = gctl_get_asciiparam(req, arg);
if (p == NULL) {
gctl_error(req, "Missing %s argument", arg);
return (NULL);
}
LIST_FOREACH(mp, &g_classes, class) {
if (mpr != NULL && mpr != mp)
continue;
LIST_FOREACH(gp, &mp->geom, geom) {
if (!strcmp(p, gp->name))
return (gp);
}
}
LIST_FOREACH(gp, &mp->geom, geom)
if (!strcmp(p, gp->name))
return (gp);
gctl_error(req, "Geom not found: \"%s\"", p);
return (NULL);
}