Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Apr 2015 10:10:39 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r281304 - in stable/9: lib/libgeom sbin/geom/class/part sys/geom/part
Message-ID:  <201504091010.t39AAdSn012499@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Apr  9 10:10:38 2015
New Revision: 281304
URL: https://svnweb.freebsd.org/changeset/base/281304

Log:
  MFC r280687: Make GEOM_PART work in presence of previous withered self.

Modified:
  stable/9/lib/libgeom/geom_xml2tree.c
  stable/9/sbin/geom/class/part/geom_part.c
  stable/9/sys/geom/part/g_part.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/lib/   (props changed)
  stable/9/lib/libgeom/   (props changed)
  stable/9/sbin/   (props changed)
  stable/9/sbin/geom/   (props changed)
  stable/9/sbin/geom/class/part/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/lib/libgeom/geom_xml2tree.c
==============================================================================
--- stable/9/lib/libgeom/geom_xml2tree.c	Thu Apr  9 10:10:05 2015	(r281303)
+++ stable/9/lib/libgeom/geom_xml2tree.c	Thu Apr  9 10:10:38 2015	(r281304)
@@ -186,6 +186,7 @@ static void
 EndElement(void *userData, const char *name)
 {
 	struct mystate *mt;
+	struct gconf *c;
 	struct gconfig *gc;
 	char *p;
 
@@ -259,7 +260,14 @@ EndElement(void *userData, const char *n
 		return;
 	}
 
-	if (mt->config != NULL) {
+	if (mt->config != NULL || (!strcmp(name, "wither") &&
+	    (mt->provider != NULL || mt->geom != NULL))) {
+		if (mt->config != NULL)
+			c = mt->config;
+		else if (mt->provider != NULL)
+			c = &mt->provider->lg_config;
+		else
+			c = &mt->geom->lg_config;
 		gc = calloc(1, sizeof *gc);
 		if (gc == NULL) {
 			mt->error = errno;
@@ -270,14 +278,15 @@ EndElement(void *userData, const char *n
 		}
 		gc->lg_name = strdup(name);
 		if (gc->lg_name == NULL) {
+			free(gc);
 			mt->error = errno;
 			XML_StopParser(mt->parser, 0);
 			warn("Cannot allocate memory during processing of '%s' "
 			    "element", name);
 			return;
 		}
-		gc->lg_val = p;
-		LIST_INSERT_HEAD(mt->config, gc, lg_config);
+		gc->lg_val = p ? p : strdup("1");
+		LIST_INSERT_HEAD(c, gc, lg_config);
 		return;
 	}
 

Modified: stable/9/sbin/geom/class/part/geom_part.c
==============================================================================
--- stable/9/sbin/geom/class/part/geom_part.c	Thu Apr  9 10:10:05 2015	(r281303)
+++ stable/9/sbin/geom/class/part/geom_part.c	Thu Apr  9 10:10:38 2015	(r281304)
@@ -207,15 +207,20 @@ find_class(struct gmesh *mesh, const cha
 static struct ggeom *
 find_geom(struct gclass *classp, const char *name)
 {
-	struct ggeom *gp;
+	struct ggeom *gp, *wgp;
 
 	if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
 		name += sizeof(_PATH_DEV) - 1;
+	wgp = NULL;
 	LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
-		if (strcmp(gp->lg_name, name) == 0)
+		if (strcmp(gp->lg_name, name) != 0)
+			continue;
+		if (find_geomcfg(gp, "wither") == NULL)
 			return (gp);
+		else
+			wgp = gp;
 	}
-	return (NULL);
+	return (wgp);
 }
 
 static const char *
@@ -598,6 +603,8 @@ gpart_show_geom(struct ggeom *gp, const 
 	off_t length, secsz;
 	int idx, wblocks, wname, wmax;
 
+	if (find_geomcfg(gp, "wither"))
+		return;
 	scheme = find_geomcfg(gp, "scheme");
 	if (scheme == NULL)
 		errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name);

Modified: stable/9/sys/geom/part/g_part.c
==============================================================================
--- stable/9/sys/geom/part/g_part.c	Thu Apr  9 10:10:05 2015	(r281303)
+++ stable/9/sys/geom/part/g_part.c	Thu Apr  9 10:10:38 2015	(r281304)
@@ -439,7 +439,8 @@ g_part_find_geom(const char *name)
 {
 	struct g_geom *gp;
 	LIST_FOREACH(gp, &g_part_class.geom, geom) {
-		if (!strcmp(name, gp->name))
+		if ((gp->flags & G_GEOM_WITHER) == 0 &&
+		    strcmp(name, gp->name) == 0)
 			break;
 	}
 	return (gp);
@@ -461,10 +462,6 @@ g_part_parm_geom(struct gctl_req *req, c
 		gctl_error(req, "%d %s '%s'", EINVAL, name, gname);
 		return (EINVAL);
 	}
-	if ((gp->flags & G_GEOM_WITHER) != 0) {
-		gctl_error(req, "%d %s", ENXIO, gname);
-		return (ENXIO);
-	}
 	*v = gp;
 	return (0);
 }



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