diff options
author | pjd <pjd@FreeBSD.org> | 2004-09-26 17:15:42 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2004-09-26 17:15:42 +0000 |
commit | 22b46382874a4577b392848cfd6bcbc31f907c34 (patch) | |
tree | 71923732b28eeb70cf420eb4a4a366d89d5efb5f /sbin/geom/class | |
parent | f00a812528fdcca55aa02731d0db2ffb6f80708d (diff) | |
download | FreeBSD-src-22b46382874a4577b392848cfd6bcbc31f907c34.zip FreeBSD-src-22b46382874a4577b392848cfd6bcbc31f907c34.tar.gz |
Don't allow to specify wrong stripe size.
Reported by: obrien
Diffstat (limited to 'sbin/geom/class')
-rw-r--r-- | sbin/geom/class/stripe/geom_stripe.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sbin/geom/class/stripe/geom_stripe.c b/sbin/geom/class/stripe/geom_stripe.c index 0f23ad1..251630f 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; /* |