aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2023-03-02 17:55:06 +0000
committerWarner Losh <imp@FreeBSD.org>2023-03-02 18:12:09 +0000
commit3a616b10d8f7bb0f1af7d6a971bdfbabdfecd896 (patch)
treea3bc66a3f3117fac29e35a2dddb4e945e16948d0
parent6c47abb63bd55db0f5234ed1c3c107a103e6fb85 (diff)
downloadsrc-3a616b10d8f7bb0f1af7d6a971bdfbabdfecd896.tar.gz
src-3a616b10d8f7bb0f1af7d6a971bdfbabdfecd896.zip
kboot: Better default boot device
Provide a better message when we can't find a boot device. Sponsored by: Netflix
-rw-r--r--stand/kboot/main.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/stand/kboot/main.c b/stand/kboot/main.c
index 1cc4c0531772..e01507323bad 100644
--- a/stand/kboot/main.c
+++ b/stand/kboot/main.c
@@ -232,23 +232,22 @@ main(int argc, const char **argv)
bootdev = getenv("bootdev");
if (bootdev == NULL)
bootdev = hostdisk_gen_probe();
- if (bootdev == NULL)
- bootdev="zfs:";
hostfs_root = getenv("hostfs_root");
if (hostfs_root == NULL)
hostfs_root = "/";
#if defined(LOADER_ZFS_SUPPORT)
- if (strcmp(bootdev, "zfs:") == 0) {
+ if (bootdev == NULL || strcmp(bootdev, "zfs:") == 0) {
/*
* Pseudo device that says go find the right ZFS pool. This will be
* the first pool that we find that passes the sanity checks (eg looks
* like it might be vbootable) and sets currdev to the right thing based
* on active BEs, etc
*/
- hostdisk_zfs_find_default();
- } else
+ if (hostdisk_zfs_find_default())
+ bootdev = getenv("currdev");
+ }
#endif
- {
+ if (bootdev != NULL) {
/*
* Otherwise, honor what's on the command line. If we've been
* given a specific ZFS partition, then we'll honor it w/o BE
@@ -256,6 +255,8 @@ main(int argc, const char **argv)
* boot than the default one in the pool.
*/
set_currdev(bootdev);
+ } else {
+ panic("Bootdev is still NULL");
}
printf("Boot device: %s with hostfs_root %s\n", bootdev, hostfs_root);