From a8adf664b7a663bb38c487e0bd42901586d57a7e Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Fri, 23 May 2008 00:51:34 +0000 Subject: Make rd act more like a 'normal' disk device, allowing the elimination of 'fakerootdev' hackery. This allows us to bring back miod@'s r1.70 subr_disk.c change to avoid the GENERIC dance when rootdev has been initialized. This in turn re-enables raidframe root devices. Add a nice panic if rootdev can't be initialized, displaying the name of the device that didn't work rather than just blowing up by de-referencing NULL. ok deraadt@ --- sys/kern/subr_disk.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) (limited to 'sys/kern/subr_disk.c') diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 1b2879c5386..92a267e9c1d 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.73 2008/04/07 23:10:24 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.74 2008/05/23 00:51:33 krw Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -981,10 +981,6 @@ bufq_default_get(struct bufq *bq) return (bp); } -#ifdef RAMDISK_HOOKS -static struct device fakerdrootdev = { DV_DISK, {}, NULL, 0, "rd0", NULL }; -#endif - struct device * getdisk(char *str, int len, int defpart, dev_t *devp) { @@ -992,9 +988,6 @@ getdisk(char *str, int len, int defpart, dev_t *devp) if ((dv = parsedisk(str, len, defpart, devp)) == NULL) { printf("use one of: exit"); -#ifdef RAMDISK_HOOKS - printf(" %s[a-p]", fakerdrootdev.dv_xname); -#endif TAILQ_FOREACH(dv, &alldevs, dv_list) { if (dv->dv_class == DV_DISK) printf(" %s[a-p]", dv->dv_xname); @@ -1024,20 +1017,11 @@ parsedisk(char *str, int len, int defpart, dev_t *devp) } else part = defpart; -#ifdef RAMDISK_HOOKS - if (strncmp(str, fakerdrootdev.dv_xname, len) == 0) { - dv = &fakerdrootdev; - goto gotdisk; - } -#endif TAILQ_FOREACH(dv, &alldevs, dv_list) { if (dv->dv_class == DV_DISK && strncmp(str, dv->dv_xname, len) == 0 && dv->dv_xname[len] == '\0') { -#ifdef RAMDISK_HOOKS -gotdisk: -#endif majdev = findblkmajor(dv); if (majdev < 0) panic("parsedisk"); @@ -1070,12 +1054,6 @@ setroot(struct device *bootdv, int part, int exitflags) extern char *nfsbootdevname; #endif -#ifdef RAMDISK_HOOKS - bootdv = &fakerdrootdev; - mountroot = NULL; - part = 0; -#endif - /* * If `swap generic' and we couldn't determine boot device, * ask the user. @@ -1171,10 +1149,9 @@ gotswap: rootdv = bootdv; rootdev = dumpdev = swapdev = NODEV; #endif - } else if (mountroot == NULL) { + } else if (mountroot == NULL && rootdev == NODEV) { /* - * `swap generic' or RAMDISK_HOOKS -- use the - * device we were told to + * `swap generic' */ rootdv = bootdv; majdev = findblkmajor(rootdv); @@ -1204,6 +1181,8 @@ gotswap: snprintf(buf, sizeof buf, "%s%d%c", findblkname(majdev), unit, 'a' + part); rootdv = parsedisk(buf, strlen(buf), 0, &nrootdev); + if (rootdv == NULL) + panic("root device (%s) not found", buf); } if (rootdv && rootdv == bootdv && rootdv->dv_class == DV_IFNET) -- cgit v1.2.3