mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
MFC change 196278:
Emit a proper error message instead of dumping core when 1) GEOM_PART does not exist in the kernel, and 2) the GEOM in question does not exist. Additionally abort in case of programming errors that result in neither the class nor geom not being present in the gctl request. Approved by: re (kib)
This commit is contained in:
parent
336b627671
commit
75f5a2286d
1 changed files with 14 additions and 2 deletions
|
|
@ -274,8 +274,18 @@ gpart_autofill(struct gctl_req *req)
|
|||
error = geom_gettree(&mesh);
|
||||
if (error)
|
||||
return (error);
|
||||
cp = find_class(&mesh, gctl_get_ascii(req, "class"));
|
||||
gp = find_geom(cp, gctl_get_ascii(req, "geom"));
|
||||
s = gctl_get_ascii(req, "class");
|
||||
if (s == NULL)
|
||||
abort();
|
||||
cp = find_class(&mesh, s);
|
||||
if (cp == NULL)
|
||||
errx(EXIT_FAILURE, "Class %s not found.", s);
|
||||
s = gctl_get_ascii(req, "geom");
|
||||
if (s == NULL)
|
||||
abort();
|
||||
gp = find_geom(cp, s);
|
||||
if (gp == NULL)
|
||||
errx(EXIT_FAILURE, "No such geom: %s.", s);
|
||||
first = atoll(find_geomcfg(gp, "first"));
|
||||
last = atoll(find_geomcfg(gp, "last"));
|
||||
grade = ~0ULL;
|
||||
|
|
@ -536,6 +546,8 @@ gpart_write_partcode(struct gctl_req *req, int idx, void *code, ssize_t size)
|
|||
errx(EXIT_FAILURE, "Class %s not found.", s);
|
||||
}
|
||||
s = gctl_get_ascii(req, "geom");
|
||||
if (s == NULL)
|
||||
abort();
|
||||
gp = find_geom(classp, s);
|
||||
if (gp == NULL)
|
||||
errx(EXIT_FAILURE, "No such geom: %s.", s);
|
||||
|
|
|
|||
Loading…
Reference in a new issue