diff options
author | Nathan Whitehorn <nwhitehorn@FreeBSD.org> | 2013-01-22 17:06:28 +0000 |
---|---|---|
committer | Nathan Whitehorn <nwhitehorn@FreeBSD.org> | 2013-01-22 17:06:28 +0000 |
commit | f0ddc92d2741e1d2d252e0f785c8cd31421a9d9d (patch) | |
tree | dc4379715e888e782d1c71b03af83c5466e43f53 /usr.sbin/bsdinstall/partedit | |
parent | f89d608184e3d277a2ae2779c9db315669e57b9d (diff) | |
download | src-f0ddc92d2741e1d2d252e0f785c8cd31421a9d9d.tar.gz src-f0ddc92d2741e1d2d252e0f785c8cd31421a9d9d.zip |
Improve error handling and remove an unnecessary check on geom provider
type. GEOM provider names can't duplicate (or shouldn't -- devfs will either
break or only use the first one if they do) so using the first provider
by that name is a sufficient check. This also lets the scripted partitioner
install onto gmirror and geli and such things.
Notes
Notes:
svn path=/head/; revision=245796
Diffstat (limited to 'usr.sbin/bsdinstall/partedit')
-rw-r--r-- | usr.sbin/bsdinstall/partedit/part_wizard.c | 6 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit.c | 6 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/scripted.c | 22 |
3 files changed, 17 insertions, 17 deletions
diff --git a/usr.sbin/bsdinstall/partedit/part_wizard.c b/usr.sbin/bsdinstall/partedit/part_wizard.c index 1a81c01e119f..a304fb83039c 100644 --- a/usr.sbin/bsdinstall/partedit/part_wizard.c +++ b/usr.sbin/bsdinstall/partedit/part_wizard.c @@ -167,12 +167,6 @@ provider_for_name(struct gmesh *mesh, const char *name) struct ggeom *gp; LIST_FOREACH(classp, &mesh->lg_class, lg_class) { - if (strcmp(classp->lg_name, "DISK") != 0 && - strcmp(classp->lg_name, "PART") != 0 && - strcmp(classp->lg_name, "RAID") != 0 && - strcmp(classp->lg_name, "MD") != 0) - continue; - LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { if (LIST_EMPTY(&gp->lg_provider)) continue; diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c index 296d45cef66a..eff87feaef54 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.c +++ b/usr.sbin/bsdinstall/partedit/partedit.c @@ -97,8 +97,12 @@ main(int argc, const char **argv) "the Finish button."; part_wizard(); } else if (strcmp(basename(argv[0]), "scriptedpart") == 0) { - scripted_editor(argc, argv); + error = scripted_editor(argc, argv); prompt = NULL; + if (error != 0) { + end_dialog(); + return (error); + } } else { prompt = "Create partitions for FreeBSD. No changes will be " "made until you select Finish."; diff --git a/usr.sbin/bsdinstall/partedit/scripted.c b/usr.sbin/bsdinstall/partedit/scripted.c index bfe092201bd9..4ac34824b090 100644 --- a/usr.sbin/bsdinstall/partedit/scripted.c +++ b/usr.sbin/bsdinstall/partedit/scripted.c @@ -45,12 +45,6 @@ provider_for_name(struct gmesh *mesh, const char *name) struct ggeom *gp; LIST_FOREACH(classp, &mesh->lg_class, lg_class) { - if (strcmp(classp->lg_name, "DISK") != 0 && - strcmp(classp->lg_name, "PART") != 0 && - strcmp(classp->lg_name, "RAID") != 0 && - strcmp(classp->lg_name, "MD") != 0) - continue; - LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { if (LIST_EMPTY(&gp->lg_provider)) continue; @@ -81,6 +75,11 @@ part_config(char *disk, const char *scheme, char *config) scheme = default_scheme(); error = geom_gettree(&mesh); + if (provider_for_name(&mesh, disk) == NULL) { + fprintf(stderr, "GEOM provider %s not found\n", disk); + geom_deletetree(&mesh); + return (-1); + } /* Remove any existing partitioning and create new scheme */ LIST_FOREACH(classp, &mesh.lg_class, lg_class) @@ -183,7 +182,7 @@ int parse_disk_config(char *input) } while (input != NULL && *input != 0); if (disk != NULL) - part_config(disk, scheme, partconfig); + return (part_config(disk, scheme, partconfig)); return (0); } @@ -192,7 +191,7 @@ int scripted_editor(int argc, const char **argv) { char *token; - int i, len = 0; + int i, error = 0, len = 0; for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1; @@ -203,8 +202,11 @@ scripted_editor(int argc, const char **argv) strcat(input, argv[i]); } - while ((token = strsep(&input, ";")) != NULL) - parse_disk_config(token); + while ((token = strsep(&input, ";")) != NULL) { + error = parse_disk_config(token); + if (error != 0) + return (error); + } return (0); } |