Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2012 07:42:54 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r230565 - stable/8/sys/geom/part
Message-ID:  <201201260742.q0Q7gsJk070721@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Thu Jan 26 07:42:54 2012
New Revision: 230565
URL: http://svn.freebsd.org/changeset/base/230565

Log:
  MFC r215118:
    Move code for search of existing geom into g_part_find_geom
    function and use this function instead of g_part_parm_geom
    in g_part_ctl_create.

Modified:
  stable/8/sys/geom/part/g_part.c
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/geom/part/g_part.c
==============================================================================
--- stable/8/sys/geom/part/g_part.c	Thu Jan 26 07:03:30 2012	(r230564)
+++ stable/8/sys/geom/part/g_part.c	Thu Jan 26 07:42:54 2012	(r230565)
@@ -299,6 +299,17 @@ g_part_new_provider(struct g_geom *gp, s
 	g_error_provider(entry->gpe_pp, 0);
 }
 
+static struct g_geom*
+g_part_find_geom(const char *name)
+{
+	struct g_geom *gp;
+	LIST_FOREACH(gp, &g_part_class.geom, geom) {
+		if (!strcmp(name, gp->name))
+			break;
+	}
+	return (gp);
+}
+
 static int
 g_part_parm_geom(const char *name, struct g_geom **v)
 {
@@ -306,10 +317,7 @@ g_part_parm_geom(const char *name, struc
 
 	if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
 		name += strlen(_PATH_DEV);
-	LIST_FOREACH(gp, &g_part_class.geom, geom) {
-		if (!strcmp(name, gp->name))
-			break;
-	}
+	gp = g_part_find_geom(name);
 	if (gp == NULL)
 		return (EINVAL);
 	*v = gp;
@@ -682,8 +690,8 @@ g_part_ctl_create(struct gctl_req *req, 
 	g_topology_assert();
 
 	/* Check that there isn't already a g_part geom on the provider. */
-	error = g_part_parm_geom(pp->name, &gp);
-	if (!error) {
+	gp = g_part_find_geom(pp->name);
+	if (gp != NULL) {
 		null = gp->softc;
 		if (null->gpt_scheme != &g_part_null_scheme) {
 			gctl_error(req, "%d geom '%s'", EEXIST, pp->name);



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