svn commit: r245796 - head/usr.sbin/bsdinstall/partedit

Nathan Whitehorn nwhitehorn at FreeBSD.org
Tue Jan 22 17:06:29 UTC 2013


Author: nwhitehorn
Date: Tue Jan 22 17:06:28 2013
New Revision: 245796
URL: http://svnweb.freebsd.org/changeset/base/245796

Log:
  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.

Modified:
  head/usr.sbin/bsdinstall/partedit/part_wizard.c
  head/usr.sbin/bsdinstall/partedit/partedit.c
  head/usr.sbin/bsdinstall/partedit/scripted.c

Modified: head/usr.sbin/bsdinstall/partedit/part_wizard.c
==============================================================================
--- head/usr.sbin/bsdinstall/partedit/part_wizard.c	Tue Jan 22 17:05:26 2013	(r245795)
+++ head/usr.sbin/bsdinstall/partedit/part_wizard.c	Tue Jan 22 17:06:28 2013	(r245796)
@@ -167,12 +167,6 @@ provider_for_name(struct gmesh *mesh, co
 	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;

Modified: head/usr.sbin/bsdinstall/partedit/partedit.c
==============================================================================
--- head/usr.sbin/bsdinstall/partedit/partedit.c	Tue Jan 22 17:05:26 2013	(r245795)
+++ head/usr.sbin/bsdinstall/partedit/partedit.c	Tue Jan 22 17:06:28 2013	(r245796)
@@ -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.";

Modified: head/usr.sbin/bsdinstall/partedit/scripted.c
==============================================================================
--- head/usr.sbin/bsdinstall/partedit/scripted.c	Tue Jan 22 17:05:26 2013	(r245795)
+++ head/usr.sbin/bsdinstall/partedit/scripted.c	Tue Jan 22 17:06:28 2013	(r245796)
@@ -45,12 +45,6 @@ provider_for_name(struct gmesh *mesh, co
 	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 *sche
 		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 **a
 		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);
 }


More information about the svn-src-all mailing list