Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jan 2011 03:57:25 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r217042 - user/nwhitehorn/bsdinstall/partedit
Message-ID:  <201101060357.p063vPHc001231@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Thu Jan  6 03:57:25 2011
New Revision: 217042
URL: http://svn.freebsd.org/changeset/base/217042

Log:
  Use the newly-available "modified" attribute in gpart to determine if we
  have to do anything. This avoids an unnecessary warning due to an EPERM
  trying to commit/undo changes on an unmodified geom.

Modified:
  user/nwhitehorn/bsdinstall/partedit/gpart_ops.c

Modified: user/nwhitehorn/bsdinstall/partedit/gpart_ops.c
==============================================================================
--- user/nwhitehorn/bsdinstall/partedit/gpart_ops.c	Thu Jan  6 03:56:01 2011	(r217041)
+++ user/nwhitehorn/bsdinstall/partedit/gpart_ops.c	Thu Jan  6 03:57:25 2011	(r217042)
@@ -744,9 +744,11 @@ void
 gpart_revert_all(struct gmesh *mesh)
 {
 	struct gclass *classp;
+	struct gconfig *gc;
 	struct ggeom *gp;
 	struct gctl_req *r;
 	const char *errstr;
+	const char *modified;
 
 	LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
 		if (strcmp(classp->lg_name, "PART") == 0)
@@ -759,6 +761,18 @@ gpart_revert_all(struct gmesh *mesh)
 	}
 
 	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+		modified = "true"; /* XXX: If we don't know (kernel too old),
+				    * assume there are modifications. */
+		LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+			if (strcmp(gc->lg_name, "modified") == 0) {
+				modified = gc->lg_val;
+				break;
+			}
+		}
+
+		if (strcmp(modified, "false") == 0)
+			continue;
+
 		r = gctl_get_handle();
 		gctl_ro_param(r, "class", -1, "PART");
 		gctl_ro_param(r, "arg0", -1, gp->lg_name);
@@ -772,51 +786,17 @@ gpart_revert_all(struct gmesh *mesh)
 }
 
 void
-gpart_revert(struct gprovider *pp)
-{
-	struct gctl_req *r;
-	struct ggeom *geom;
-	struct gconsumer *cp;
-	const char *errstr;
-
-	/*
-	 * Find the PART geom we are manipulating. This may be a consumer of
-	 * this provider, or its parent. Check the consumer case first.
-	 */
-	geom = NULL;
-	LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers)
-		if (strcmp(cp->lg_geom->lg_class->lg_name, "PART") == 0) {
-			geom = cp->lg_geom;
-			break;
-		}
-
-	if (geom == NULL && strcmp(pp->lg_geom->lg_class->lg_name, "PART") == 0)
-		geom = pp->lg_geom;
-
-	if (geom == NULL) /* Things that aren't gpart we can't have changed */
-		return;
-
-	r = gctl_get_handle();
-	gctl_ro_param(r, "class", -1, "PART");
-	gctl_ro_param(r, "arg0", -1, geom->lg_name);
-	gctl_ro_param(r, "verb", -1, "undo");
-
-	errstr = gctl_issue(r);
-	if (errstr != NULL && errstr[0] != '\0') 
-		gpart_show_error("Error", NULL, errstr);
-	gctl_free(r);
-}
-
-void
 gpart_commit(struct gmesh *mesh)
 {
 	struct partition_metadata *md;
 	struct gclass *classp;
 	struct ggeom *gp;
+	struct gconfig *gc;
 	struct gconsumer *cp;
 	struct gprovider *pp;
 	struct gctl_req *r;
 	const char *errstr;
+	const char *modified;
 
 	LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
 		if (strcmp(classp->lg_name, "PART") == 0)
@@ -829,6 +809,16 @@ gpart_commit(struct gmesh *mesh)
 	}
 
 	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
+		LIST_FOREACH(gc, &gp->lg_config, lg_config) {
+			if (strcmp(gc->lg_name, "modified") == 0) {
+				modified = gc->lg_val;
+				break;
+			}
+		}
+
+		if (strcmp(modified, "false") == 0)
+			continue;
+
 		/* Add bootcode if necessary, before the commit */
 		md = get_part_metadata(gp->lg_name, 0);
 		if (md != NULL && md->bootcode)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101060357.p063vPHc001231>