svn commit: r227222 - in stable/9/usr.sbin/bsdinstall: partedit scripts

Nathan Whitehorn nwhitehorn at FreeBSD.org
Sun Nov 6 16:37:50 UTC 2011


Author: nwhitehorn
Date: Sun Nov  6 16:37:50 2011
New Revision: 227222
URL: http://svn.freebsd.org/changeset/base/227222

Log:
  MFC r226666,226739,226741:
  Avoid showing the user some spurious error messages from GEOM [1] and do
  provide error messages instead of silent failure if there are no disks
  or no network interfaces in the system [2].
  
  PR:		bin/161926 [1], bin/161926 [2]
  Approved by:	re (kib)

Modified:
  stable/9/usr.sbin/bsdinstall/partedit/gpart_ops.c
  stable/9/usr.sbin/bsdinstall/partedit/partedit.c
  stable/9/usr.sbin/bsdinstall/scripts/netconfig
Directory Properties:
  stable/9/usr.sbin/bsdinstall/   (props changed)

Modified: stable/9/usr.sbin/bsdinstall/partedit/gpart_ops.c
==============================================================================
--- stable/9/usr.sbin/bsdinstall/partedit/gpart_ops.c	Sun Nov  6 16:37:15 2011	(r227221)
+++ stable/9/usr.sbin/bsdinstall/partedit/gpart_ops.c	Sun Nov  6 16:37:50 2011	(r227222)
@@ -392,8 +392,14 @@ gpart_destroy(struct ggeom *lg_geom)
 	gctl_ro_param(r, "force", sizeof(force), &force);
 	gctl_ro_param(r, "verb", -1, "destroy");
 	errstr = gctl_issue(r);
-	if (errstr != NULL && errstr[0] != '\0') 
-		gpart_show_error("Error", NULL, errstr);
+	if (errstr != NULL && errstr[0] != '\0') {
+		/*
+		 * Check if we reverted away the existence of the geom
+		 * altogether. Show all other errors to the user.
+		 */
+		if (strtol(errstr, NULL, 0) != EINVAL)
+			gpart_show_error("Error", NULL, errstr);
+	}
 	gctl_free(r);
 
 	/* And any metadata associated with the partition scheme itself */
@@ -450,6 +456,10 @@ gpart_edit(struct gprovider *pp)
 				return;
 			}
 
+			/* If this is a nested partition, edit as usual */
+			if (strcmp(pp->lg_geom->lg_class->lg_name, "PART") == 0)
+				break;
+
 			/* Destroy the geom and all sub-partitions */
 			gpart_destroy(cp->lg_geom);
 
@@ -507,7 +517,7 @@ editpart:
 	choice = dlg_form("Edit Partition", "", 0, 0, 0, nitems, items, &junk);
 
 	if (choice) /* Cancel pressed */
-		return;
+		goto endedit;
 
 	/* Check if the label has a / in it */
 	if (strchr(items[3].text, '/') != NULL) {
@@ -538,6 +548,13 @@ editpart:
 	    items[2].text, (strcmp(oldtype, items[0].text) != 0) ?
 	    newfs : NULL);
 
+endedit:
+	if (strcmp(oldtype, items[0].text) != 0 && cp != NULL)
+		gpart_destroy(cp->lg_geom);
+	if (strcmp(oldtype, items[0].text) != 0 && strcmp(items[0].text,
+	    "freebsd") == 0)
+		gpart_partition(pp->lg_name, "BSD");
+
 	for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)
 		if (items[i].text_free)
 			free(items[i].text);

Modified: stable/9/usr.sbin/bsdinstall/partedit/partedit.c
==============================================================================
--- stable/9/usr.sbin/bsdinstall/partedit/partedit.c	Sun Nov  6 16:37:15 2011	(r227221)
+++ stable/9/usr.sbin/bsdinstall/partedit/partedit.c	Sun Nov  6 16:37:50 2011	(r227222)
@@ -70,7 +70,7 @@ main(int argc, const char **argv)
 {
 	struct partition_metadata *md;
 	const char *prompt;
-	struct partedit_item *items;
+	struct partedit_item *items = NULL;
 	struct gmesh mesh;
 	int i, op, nitems, nscroll;
 	int error;
@@ -99,12 +99,21 @@ main(int argc, const char **argv)
 
 	/* Show the part editor either immediately, or to confirm wizard */
 	while (1) {
-		error = geom_gettree(&mesh);
-		items = read_geom_mesh(&mesh, &nitems);
-		get_mount_points(items, nitems);
 		dlg_clear();
 		dlg_put_backtitle();
 
+		error = geom_gettree(&mesh);
+		if (error == 0)
+			items = read_geom_mesh(&mesh, &nitems);
+		if (error || items == NULL) {
+			dialog_msgbox("Error", "No disks found. If you need to "
+			    "install a kernel driver, choose Shell at the "
+			    "installation menu.", 0, 0, TRUE);
+			break;
+		}
+			
+		get_mount_points(items, nitems);
+
 		if (i >= nitems)
 			i = nitems - 1;
 		op = diskeditor_show("Partition Editor", prompt,

Modified: stable/9/usr.sbin/bsdinstall/scripts/netconfig
==============================================================================
--- stable/9/usr.sbin/bsdinstall/scripts/netconfig	Sun Nov  6 16:37:15 2011	(r227221)
+++ stable/9/usr.sbin/bsdinstall/scripts/netconfig	Sun Nov  6 16:37:50 2011	(r227222)
@@ -49,6 +49,13 @@ for IF in `ifconfig -l`; do
 	DIALOG_TAGS="$DIALOG_TAGS $IF \"$DESC\""
 done
 
+if [ -z "$INTERFACES" ]; then
+	dialog --backtitle 'FreeBSD Installer' \
+	    --title 'Network Configuration Error' \
+	    --msgbox 'No network interfaces present to configure.' 0 0
+	exit 1
+fi
+
 exec 3>&1
 INTERFACE=`echo $DIALOG_TAGS | xargs dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&3`
 if [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi


More information about the svn-src-all mailing list