diff options
author | asami <asami@FreeBSD.org> | 1996-07-24 23:45:24 +0000 |
---|---|---|
committer | asami <asami@FreeBSD.org> | 1996-07-24 23:45:24 +0000 |
commit | 7918737d5b4b5519b6675ed4e6afaad8eae01276 (patch) | |
tree | aab62ab0e5485550e1c587a687099e8c067d44c5 /sys/geom/geom_ccd.c | |
parent | b7d408a490ea27345f164a90626cb6996314d1e9 (diff) | |
download | FreeBSD-src-7918737d5b4b5519b6675ed4e6afaad8eae01276.zip FreeBSD-src-7918737d5b4b5519b6675ed4e6afaad8eae01276.tar.gz |
Fail when odd number of disks are specified with mirror flag. Memory
leak fixes. Miscellaneous cleanup.
Partially submitted by: Matt White <mwhite+@CMU.EDU>
Diffstat (limited to 'sys/geom/geom_ccd.c')
-rw-r--r-- | sys/geom/geom_ccd.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index 662bd8c..ce52aa5 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -1,4 +1,4 @@ -/* $Id: ccd.c,v 1.14 1996/07/21 09:28:03 phk Exp $ */ +/* $Id: ccd.c,v 1.15 1996/07/23 21:51:13 phk Exp $ */ /* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */ @@ -208,10 +208,6 @@ static void ccdmakedisklabel __P((struct ccd_softc *)); static int ccdlock __P((struct ccd_softc *)); static void ccdunlock __P((struct ccd_softc *)); -#ifdef CCD_DEBUG -static void loopdelay __P((void)); -#endif - #ifdef DEBUG static void printiinfo __P((struct ccdiinfo *)); #endif @@ -335,6 +331,10 @@ ccdinit(ccd, cpaths, p) printf("ccd%d: can't copy path, error = %d\n", ccd->ccd_unit, error); #endif + while (ci > cs->sc_cinfo) { + ci--; + free(ci->ci_path, M_DEVBUF); + } free(cs->sc_cinfo, M_DEVBUF); return (error); } @@ -351,7 +351,10 @@ ccdinit(ccd, cpaths, p) ccd->ccd_unit, ci->ci_path, "error", error); #endif - free(ci->ci_path, M_DEVBUF); + while (ci >= cs->sc_cinfo) { + free(ci->ci_path, M_DEVBUF); + ci--; + } free(cs->sc_cinfo, M_DEVBUF); return (error); } @@ -367,7 +370,10 @@ ccdinit(ccd, cpaths, p) printf("ccd%d: %s: ioctl failed, error = %d\n", ccd->ccd_unit, ci->ci_path, error); #endif - free(ci->ci_path, M_DEVBUF); + while (ci >= cs->sc_cinfo) { + free(ci->ci_path, M_DEVBUF); + ci--; + } free(cs->sc_cinfo, M_DEVBUF); return (error); } @@ -382,7 +388,10 @@ ccdinit(ccd, cpaths, p) printf("ccd%d: %s: incorrect partition type\n", ccd->ccd_unit, ci->ci_path); #endif - free(ci->ci_path, M_DEVBUF); + while (ci >= cs->sc_cinfo) { + free(ci->ci_path, M_DEVBUF); + ci--; + } free(cs->sc_cinfo, M_DEVBUF); return (EFTYPE); } @@ -405,7 +414,10 @@ ccdinit(ccd, cpaths, p) printf("ccd%d: %s: size == 0\n", ccd->ccd_unit, ci->ci_path); #endif - free(ci->ci_path, M_DEVBUF); + while (ci >= cs->sc_cinfo) { + free(ci->ci_path, M_DEVBUF); + ci--; + } free(cs->sc_cinfo, M_DEVBUF); return (ENODEV); } @@ -427,7 +439,10 @@ ccdinit(ccd, cpaths, p) printf("ccd%d: interleave must be at least %d\n", ccd->ccd_unit, (maxsecsize / DEV_BSIZE)); #endif - free(ci->ci_path, M_DEVBUF); + while (ci >= cs->sc_cinfo) { + free(ci->ci_path, M_DEVBUF); + ci--; + } free(cs->sc_cinfo, M_DEVBUF); return (EINVAL); } @@ -441,10 +456,18 @@ ccdinit(ccd, cpaths, p) ci < &cs->sc_cinfo[cs->sc_nccdisks]; ci++) ci->ci_size = minsize; if (ccd->ccd_flags & CCDF_MIRROR) { + /* + * Check to see if an even number of components + * have been specified. + */ if (cs->sc_nccdisks % 2) { - cs->sc_nccdisks--; - printf("ccd%d: mirroring requires even number of disks; using %d\n", - ccd->ccd_unit, cs->sc_nccdisks); + printf("ccd%d: mirroring requires an even number of disks\n", ccd->ccd_unit ); + while (ci > cs->sc_cinfo) { + ci--; + free(ci->ci_path, M_DEVBUF); + } + free(cs->sc_cinfo, M_DEVBUF); + return (EINVAL); } cs->sc_size = (cs->sc_nccdisks/2) * minsize; } @@ -1008,21 +1031,6 @@ ccdiodone(cbp) splx(s); } - -#ifdef CCD_DEBUG -static void -loopdelay() -{ - int i, j, k, l; - printf("I'm now gonna wait for fifteen seconds\n"); - printf("Press Ctl-Alt-Esc NOW!\n"); - for (i = 0; i < 1000; i++) - for (j = 0; j < 1000; j++) - for (k = 0; k < 100; k++) - l = i * j * k; -} -#endif - int ccdioctl(dev, cmd, data, flag, p) dev_t dev; |