CCD_DPRINTF(CCDB_FOLLOW, ("ccdopen(%x, %x)\n", dev, flags));
ccdopen(dev_t dev, int flags, int fmt, struct proc *p){	int unit = ccdunit(dev);	struct ccd_softc *cs;	struct disklabel *lp;	int error = 0, part, pmask;#ifdef DEBUG	if (ccddebug & CCDB_FOLLOW)		printf("ccdopen(%x, %x)\n", dev, flags);#endif	if (unit >= numccd)		return (ENXIO);	cs = &ccd_softc[unit];	if ((error = ccdlock(cs)) != 0)		return (error);	lp = cs->sc_dkdev.dk_label;	part = DISKPART(dev);	pmask = (1 << part);	/*	 * If we're initialized, check to see if there are any other	 * open partitions.  If not, then it's safe to update	 * the in-core disklabel.	 */	if ((cs->sc_flags & CCDF_INITED) && (cs->sc_dkdev.dk_openmask == 0))		ccdgetdisklabel(dev, cs, lp, cs->sc_dkdev.dk_cpulabel, 0);	/* Check that the partition exists. */	if (part != RAW_PART) {		if (((cs->sc_flags & CCDF_INITED) == 0) ||		    ((part >= lp->d_npartitions) ||		    (lp->d_partitions[part].p_fstype == FS_UNUSED))) {			error = ENXIO;			goto done;		}	}	/* Prevent our unit from being unconfigured while open. */	switch (fmt) {	case S_IFCHR:		cs->sc_dkdev.dk_copenmask |= pmask;		break;	case S_IFBLK:		cs->sc_dkdev.dk_bopenmask |= pmask;		break;	}	cs->sc_dkdev.dk_openmask =	    cs->sc_dkdev.dk_copenmask | cs->sc_dkdev.dk_bopenmask; done:	ccdunlock(cs);	return (error);}