summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2013-01-22 17:06:28 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2013-01-22 17:06:28 +0000
commitcdae92a55c4e92dd3d4caea3c634741a0c168ef5 (patch)
treedc4379715e888e782d1c71b03af83c5466e43f53
parent27ebf0630af26a85a667b724d2ea986f6868b749 (diff)
downloadFreeBSD-src-cdae92a55c4e92dd3d4caea3c634741a0c168ef5.zip
FreeBSD-src-cdae92a55c4e92dd3d4caea3c634741a0c168ef5.tar.gz
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.
-rw-r--r--usr.sbin/bsdinstall/partedit/part_wizard.c6
-rw-r--r--usr.sbin/bsdinstall/partedit/partedit.c6
-rw-r--r--usr.sbin/bsdinstall/partedit/scripted.c22
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 1a81c01e..a304fb8 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 296d45c..eff87fe 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 bfe0922..4ac3482 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);
}
OpenPOWER on IntegriCloud