/*
- * Let bootcode augment "rootspec".
+ * Let bootcode augment "rootspec", ensure that
+ * rootdev is invalid to avoid confusion.
*/
- if (rootspec == NULL)
+ if (rootspec == NULL) {
rootspec = bootspec;
+ rootdev = NODEV;
+ }
/*
* force boot device to md0
@@ -448,9 +451,9 @@ setroot_ask(device_t bootdv, int bootpar
/*
* configure
- * dev_t rootdev
+ * device_t root_device
+ * dev_t rootdev (for disks)
*
- * return device_t or NULL if not found
*/
static void
setroot_root(device_t bootdv, int bootpartition)
@@ -459,6 +462,7 @@ setroot_root(device_t bootdv, int bootpa
int majdev;
const char *rootdevname;
char buf[128];
+ dev_t nrootdev;
if (rootspec == NULL) {
@@ -490,20 +494,17 @@ setroot_root(device_t bootdv, int bootpa
*/
/*
- * If it's a network interface, we can bail out
- * early.
+ * If rootspec can be parsed, just use it.
*/
- rootdv = finddevice(rootspec);
- if (rootdv != NULL && device_class(rootdv) == DV_IFNET)
- goto haveroot;
-
- if (rootdv != NULL && device_class(rootdv) == DV_DISK &&
- !DEV_USES_PARTITIONS(rootdv) &&
- (majdev = devsw_name2blk(device_xname(rootdv), NULL, 0)) >= 0) {
- rootdev = makedev(majdev, device_unit(rootdv));
+ rootdv = parsedisk(rootspec, strlen(rootspec), 0, &nrootdev);
+ if (rootdv != NULL) {
+ rootdev = nrootdev;
goto haveroot;
}
+ /*
+ * Fall back to rootdev, compute rootdv for it
+ */
rootdevname = devsw_blk2name(major(rootdev));
if (rootdevname == NULL) {
printf("unknown device major 0x%llx\n",
@@ -647,11 +648,22 @@ finddevice(const char *name)
}
static device_t
-getdisk(char *str, int len, int defpart, dev_t *devp, int isdump)
+getdisk(const char *str, int len, int defpart, dev_t *devp, int isdump)
{
device_t dv;
deviter_t di;