Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jan 2014 20:06:15 +0000 (UTC)
From:      Lars Engels <lme@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r260492 - head/sbin/geom/class/part
Message-ID:  <201401092006.s09K6F4t000315@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lme (ports committer)
Date: Thu Jan  9 20:06:14 2014
New Revision: 260492
URL: http://svnweb.freebsd.org/changeset/base/260492

Log:
  Check if the given argument to 'gpart add' is actually a geom device and
  give a hint to use 'gpart create' before trying to add a partition.
  
  Approved by:	pjd

Modified:
  head/sbin/geom/class/part/geom_part.c   (contents, props changed)

Modified: head/sbin/geom/class/part/geom_part.c
==============================================================================
--- head/sbin/geom/class/part/geom_part.c	Thu Jan  9 18:53:21 2014	(r260491)
+++ head/sbin/geom/class/part/geom_part.c	Thu Jan  9 20:06:14 2014	(r260492)
@@ -454,8 +454,19 @@ gpart_autofill(struct gctl_req *req)
 	if (s == NULL)
 		abort();
 	gp = find_geom(cp, s);
-	if (gp == NULL)
-		errx(EXIT_FAILURE, "No such geom: %s.", s);
+	if (gp == NULL) {
+		if (g_device_path(s) == NULL) {
+			errx(EXIT_FAILURE, "No such geom %s.", s);
+		} else {
+			/*
+			 * We don't free memory allocated by g_device_path() as
+			 * we are about to exit.
+			 */
+			errx(EXIT_FAILURE,
+			    "No partitioning scheme found on geom %s. Create one first using 'gpart create'.",
+			    s);
+		}
+	}
 	pp = LIST_FIRST(&gp->lg_consumer)->lg_provider;
 	if (pp == NULL)
 		errx(EXIT_FAILURE, "Provider for geom %s not found.", s);



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