printf("RAID autoconfigure\n");
db1_printf(("RAID autoconfigure\n"));
rf_auto_config_set(cset,unit)	RF_ConfigSet_t *cset;	int *unit;{	RF_Raid_t *raidPtr;	RF_Config_t *config;	int raidID;	int retcode;	printf("RAID autoconfigure\n");	retcode = 0;	*unit = -1;	/* 1. Create a config structure */	config = (RF_Config_t *)malloc(sizeof(RF_Config_t),				       M_RAIDFRAME,				       M_NOWAIT);	if (config==NULL) {		printf("Out of mem!?!?\n");				/* XXX do something more intelligent here. */		return(1);	}	memset(config, 0, sizeof(RF_Config_t));	/* XXX raidID needs to be set correctly.. */	/* 	   2. Figure out what RAID ID this one is supposed to live at 	   See if we can get the same RAID dev that it was configured	   on last time.. 	*/	raidID = cset->ac->clabel->last_unit;	if ((raidID < 0) || (raidID >= numraid)) {		/* let's not wander off into lala land. */		raidID = numraid - 1;	}	if (raidPtrs[raidID]->valid != 0) {		/* 		   Nope... Go looking for an alternative...  		   Start high so we don't immediately use raid0 if that's		   not taken. 		*/		for(raidID = numraid - 1; raidID >= 0; raidID--) {			if (raidPtrs[raidID]->valid == 0) {				/* can use this one! */				break;			}		}	}	if (raidID < 0) {		/* punt... */		printf("Unable to auto configure this set!\n");		printf("(Out of RAID devs!)\n");		return(1);	}	printf("Configuring raid%d:\n",raidID);	raidPtr = raidPtrs[raidID];	/* XXX all this stuff should be done SOMEWHERE ELSE! */	raidPtr->raidid = raidID;	raidPtr->openings = RAIDOUTSTANDING;	/* 3. Build the configuration structure */	rf_create_configuration(cset->ac, config, raidPtr);	/* 4. Do the configuration */	retcode = rf_Configure(raidPtr, config, cset->ac);		if (retcode == 0) {		raidinit(raidPtrs[raidID]);		rf_markalldirty(raidPtrs[raidID]);		raidPtrs[raidID]->autoconfigure = 1; /* XXX do this here? */		if (cset->ac->clabel->root_partition==1) {			/* everything configured just fine.  Make a note			   that this set is eligible to be root. */			cset->rootable = 1;			/* XXX do this here? */			raidPtrs[raidID]->root_partition = 1; 		}	}	/* 5. Cleanup */	free(config, M_RAIDFRAME);		*unit = raidID;	return(retcode);}