From owner-svn-src-all@FreeBSD.ORG Thu Nov 11 12:13:41 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 889C5106566B; Thu, 11 Nov 2010 12:13:41 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 772008FC1C; Thu, 11 Nov 2010 12:13:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oABCDfsC066985; Thu, 11 Nov 2010 12:13:41 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oABCDfXf066983; Thu, 11 Nov 2010 12:13:41 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201011111213.oABCDfXf066983@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 11 Nov 2010 12:13:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215118 - head/sys/geom/part X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2010 12:13:41 -0000 Author: ae Date: Thu Nov 11 12:13:41 2010 New Revision: 215118 URL: http://svn.freebsd.org/changeset/base/215118 Log: Fix regression introduced in r215088: gpart(8) reports "arg0 'provider': Invalid argument" after creating new partition table. 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. Approved by: kib (mentor) Modified: head/sys/geom/part/g_part.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Thu Nov 11 11:54:01 2010 (r215117) +++ head/sys/geom/part/g_part.c Thu Nov 11 12:13:41 2010 (r215118) @@ -296,6 +296,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(struct gctl_req *req, const char *name, struct g_geom **v) { @@ -307,10 +318,7 @@ g_part_parm_geom(struct gctl_req *req, c return (ENOATTR); if (strncmp(gname, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) gname += sizeof(_PATH_DEV) - 1; - LIST_FOREACH(gp, &g_part_class.geom, geom) { - if (!strcmp(gname, gp->name)) - break; - } + gp = g_part_find_geom(gname); if (gp == NULL) { gctl_error(req, "%d %s '%s'", EINVAL, name, gname); return (EINVAL); @@ -748,8 +756,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(req, "arg0", &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);