diff options
author | lme <lme@FreeBSD.org> | 2014-01-09 20:06:14 +0000 |
---|---|---|
committer | lme <lme@FreeBSD.org> | 2014-01-09 20:06:14 +0000 |
commit | f2d18bc0418edfc20b30d94bb2d21f10ce30a2ec (patch) | |
tree | 70246e3400fa5c85a0fee9110b6c84a7c631753b /sbin/geom | |
parent | 74292e1d7ac4b53694acf36c0a12c1488843e018 (diff) | |
download | FreeBSD-src-f2d18bc0418edfc20b30d94bb2d21f10ce30a2ec.zip FreeBSD-src-f2d18bc0418edfc20b30d94bb2d21f10ce30a2ec.tar.gz |
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
Diffstat (limited to 'sbin/geom')
-rw-r--r-- | sbin/geom/class/part/geom_part.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 604e659..ee4b2a9 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); |