From ba1dcabf6d88390910affcb448cd2a85115c371b Mon Sep 17 00:00:00 2001 From: Lars Engels Date: Thu, 9 Jan 2014 20:06:14 +0000 Subject: [PATCH] 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 --- sbin/geom/class/part/geom_part.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 604e65970a27..ee4b2a939f82 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -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);