Add a warning when we are not going to use whole provider's space. --- ../../../sbin/geom/class/stripe/geom_stripe.c Mon Aug 9 13:29:41 2004 +++ sbin/geom/class/stripe/geom_stripe.c Sat Aug 28 04:49:28 2004 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sbin/geom/class/stripe/geom_stripe.c,v 1.6 2004/08/09 11:29:41 pjd Exp $"); +__FBSDID("$FreeBSD: src/sbin/geom/class/stripe/geom_stripe.c,v 1.7 2004/08/28 02:49:28 pjd Exp $"); #include #include @@ -127,10 +127,11 @@ { 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 @@ /* * 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, @@ -186,6 +199,13 @@ 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) - 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)