In the case of multiple RAID sets that are marked as root, attempt to

use the RAID set that contains the component used for booting.  Thanks
to manu@ for the main part of this.
This commit is contained in:
oster 2007-03-09 15:57:34 +00:00
parent f6c8681509
commit fb3988281d
1 changed files with 46 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_netbsdkintf.c,v 1.225 2007/03/04 06:02:38 christos Exp $ */
/* $NetBSD: rf_netbsdkintf.c,v 1.226 2007/03/09 15:57:34 oster Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@ -146,7 +146,7 @@
***********************************************************/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.225 2007/03/04 06:02:38 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.226 2007/03/09 15:57:34 oster Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@ -451,7 +451,9 @@ rf_buildroothack(RF_ConfigSet_t *config_sets)
int retcode;
int raidID;
int rootID;
int col;
int num_root;
char *devname;
rootID = 0;
num_root = 0;
@ -500,8 +502,48 @@ rf_buildroothack(RF_ConfigSet_t *config_sets)
if (num_root == 1) {
booted_device = raid_softc[rootID].sc_dev;
} else if (num_root > 1) {
/* we can't guess.. require the user to answer... */
boothowto |= RB_ASKNAME;
/*
* Maybe the MD code can help. If it cannot, then
* setroot() will discover that we have no
* booted_device and will ask the user if nothing was
* hardwired in the kernel config file
*/
if (booted_device == NULL)
cpu_rootconf();
if (booted_device == NULL)
return;
num_root = 0;
for (raidID = 0; raidID < numraid; raidID++) {
if (raidPtrs[raidID]->valid == 0)
continue;
if (raidPtrs[raidID]->root_partition == 0)
continue;
for (col = 0; col < raidPtrs[raidID]->numCol; col++) {
devname = raidPtrs[raidID]->Disks[col].devname;
devname += sizeof("/dev/") - 1;
if (strncmp(devname, booted_device->dv_xname,
strlen(booted_device->dv_xname)) != 0)
continue;
#ifdef DEBUG
printf("raid%d includes boot device %s\n",
raidID, devname);
#endif
num_root++;
rootID = raidID;
}
}
if (num_root == 1) {
booted_device = raid_softc[rootID].sc_dev;
} else {
/* we can't guess.. require the user to answer... */
boothowto |= RB_ASKNAME;
}
}
}