From 4f3be6b8d94a388ce7ae239c785ea447d0adbf48 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 13 Jan 2023 14:20:56 -0700 Subject: [PATCH] kboot: Fetch hostfs_root and bootdev from the environment Fetch bootdev from the environment variable (so it should be set on the command line). Default to 'zfs:' which will in the future look for the first zpool that we can boot from. Prior versions of kboot would set this from the second argument on the command line. Fetch hostfs_root from the environment (defaulting to '/'). Prior versions of kboot would set this from the first arg on the command line. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D38010 --- stand/kboot/main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/stand/kboot/main.c b/stand/kboot/main.c index d333737e164a..9a0f8b8baf69 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -172,6 +172,9 @@ main(int argc, const char **argv) heapbase = host_getmem(heapsize); setheap(heapbase, heapbase + heapsize); + /* Parse the command line args -- ignoring for now the console selection */ + parse_args(argc, argv); + /* * Set up console. */ @@ -180,8 +183,20 @@ main(int argc, const char **argv) /* Initialize all the devices */ devinit(); - /* Parse the command line args -- ignoring for now the console selection */ - parse_args(argc, argv); + bootdev = getenv("bootdev"); + 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) { + /* + * Pseudo device that says go find the right ZFS pool. + */ + printf("WARNING: bare 'zfs:' for boot device not yet implemented\n"); + } +#endif printf("Boot device: %s with hostfs_root %s\n", bootdev, hostfs_root);