From 0c8a9da21e91dfdca9973aa793206b4d4ed3177d Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sun, 26 Sep 2004 17:15:42 +0000 Subject: [PATCH] Don't allow to specify wrong stripe size. Reported by: obrien --- sbin/geom/class/stripe/geom_stripe.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sbin/geom/class/stripe/geom_stripe.c b/sbin/geom/class/stripe/geom_stripe.c index 0f23ad1354ae..251630f35d73 100644 --- a/sbin/geom/class/stripe/geom_stripe.c +++ b/sbin/geom/class/stripe/geom_stripe.c @@ -129,7 +129,7 @@ stripe_label(struct gctl_req *req) intmax_t *stripesizep; off_t compsize, msize; u_char sector[512]; - unsigned i, ssize; + unsigned i, ssize, secsize; const char *name; char param[16]; int *hardcode, *nargs, error; @@ -153,6 +153,7 @@ stripe_label(struct gctl_req *req) * Clear last sector first to spoil all components if device exists. */ compsize = 0; + secsize = 0; for (i = 1; i < (unsigned)*nargs; i++) { snprintf(param, sizeof(param), "arg%u", i); name = gctl_get_asciiparam(req, param); @@ -167,6 +168,10 @@ stripe_label(struct gctl_req *req) msize -= ssize; if (compsize == 0 || (compsize > 0 && msize < compsize)) compsize = msize; + if (secsize == 0) + secsize = ssize; + else + secsize = g_lcm(secsize, ssize); error = g_metadata_clear(name, NULL); if (error != 0) { @@ -191,6 +196,11 @@ stripe_label(struct gctl_req *req) gctl_error(req, "No '%s' argument.", "stripesize"); return; } + if ((*stripesizep % secsize) != 0) { + gctl_error(req, "Stripesize should be multiple of %u.", + secsize); + return; + } md.md_stripesize = *stripesizep; /*