From b815763cf274674af027dc3e8beeb7e8b17c1408 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 28 Mar 2003 02:39:08 +0000 Subject: In ccdsize(), check for CCDF_INITED before doing the ccdopen(). Adapted from NetBSD. --- sys/dev/ccd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c index b92d96a3ce0..e87d6a7f30a 100644 --- a/sys/dev/ccd.c +++ b/sys/dev/ccd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ccd.c,v 1.50 2002/11/10 21:23:09 miod Exp $ */ +/* $OpenBSD: ccd.c,v 1.51 2003/03/28 02:39:07 millert Exp $ */ /* $NetBSD: ccd.c,v 1.33 1996/05/05 04:21:14 thorpej Exp $ */ /*- @@ -1456,17 +1456,20 @@ ccdsize(dev) dev_t dev; { struct ccd_softc *cs; - int part, size; + int part, size, unit; - if (ccdopen(dev, 0, S_IFBLK, curproc)) + unit = ccdunit(dev); + if (unit >= numccd) return (-1); - cs = &ccd_softc[ccdunit(dev)]; - part = DISKPART(dev); - + cs = &ccd_softc[unit]; if ((cs->sc_flags & CCDF_INITED) == 0) return (-1); + if (ccdopen(dev, 0, S_IFBLK, curproc)) + return (-1); + + part = DISKPART(dev); if (cs->sc_dkdev.dk_label->d_partitions[part].p_fstype != FS_SWAP) size = -1; else -- cgit v1.2.3