summaryrefslogtreecommitdiffstats
path: root/sbin/geom/class/stripe
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-08-28 02:49:28 +0000
committerpjd <pjd@FreeBSD.org>2004-08-28 02:49:28 +0000
commit826fb4fba8df15bfbfbb5075087aa35372540736 (patch)
tree5f5d5728811c879c4991aa8e1a9a8fa98ac39a59 /sbin/geom/class/stripe
parent354291a750d1a58a6e98021df5ed843ba60dc8af (diff)
downloadFreeBSD-src-826fb4fba8df15bfbfbb5075087aa35372540736.zip
FreeBSD-src-826fb4fba8df15bfbfbb5075087aa35372540736.tar.gz
Warn the user if we are not going to use the whole provider's space.
Diffstat (limited to 'sbin/geom/class/stripe')
-rw-r--r--sbin/geom/class/stripe/geom_stripe.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/sbin/geom/class/stripe/geom_stripe.c b/sbin/geom/class/stripe/geom_stripe.c
index 9c47ef4..0f23ad1 100644
--- a/sbin/geom/class/stripe/geom_stripe.c
+++ b/sbin/geom/class/stripe/geom_stripe.c
@@ -127,10 +127,11 @@ stripe_label(struct gctl_req *req)
{
struct g_stripe_metadata md;
intmax_t *stripesizep;
+ off_t compsize, msize;
u_char sector[512];
+ unsigned i, ssize;
const char *name;
char param[16];
- unsigned i;
int *hardcode, *nargs, error;
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
@@ -151,10 +152,22 @@ stripe_label(struct gctl_req *req)
/*
* Clear last sector first to spoil all components if device exists.
*/
+ compsize = 0;
for (i = 1; i < (unsigned)*nargs; i++) {
snprintf(param, sizeof(param), "arg%u", i);
name = gctl_get_asciiparam(req, param);
+ msize = g_get_mediasize(name);
+ ssize = g_get_sectorsize(name);
+ if (msize == 0 || ssize == 0) {
+ gctl_error(req, "Can't get informations about %s: %s.",
+ name, strerror(errno));
+ return;
+ }
+ msize -= ssize;
+ if (compsize == 0 || (compsize > 0 && msize < compsize))
+ compsize = msize;
+
error = g_metadata_clear(name, NULL);
if (error != 0) {
gctl_error(req, "Can't store metadata on %s: %s.", name,
@@ -187,6 +200,13 @@ stripe_label(struct gctl_req *req)
snprintf(param, sizeof(param), "arg%u", i);
name = gctl_get_asciiparam(req, param);
+ msize = g_get_mediasize(name) - g_get_sectorsize(name);
+ if (compsize < msize) {
+ fprintf(stderr,
+ "warning: %s: only %jd bytes from %jd bytes used.\n",
+ name, (intmax_t)compsize, (intmax_t)msize);
+ }
+
md.md_no = i - 1;
if (!*hardcode)
bzero(md.md_provider, sizeof(md.md_provider));
OpenPOWER on IntegriCloud