diff options
| author | oster <oster@NetBSD.org> | 2007-03-09 15:57:34 +0000 |
|---|---|---|
| committer | oster <oster@NetBSD.org> | 2007-03-09 15:57:34 +0000 |
| commit | fb3988281d780f34b730875e0a0601dddc6064bb (patch) | |
| tree | 46a474af80c12a28cd414080a0b03f638a34e65e /sys/dev/raidframe | |
| parent | f6c868150987d254ad76979b1cafa62b267fece9 (diff) | |
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.
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_netbsdkintf.c | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 2da9ba2844c..4e5a3bc3ebd 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -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; + } } } |
