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
This commit is contained in:
Warner Losh 2023-01-13 14:20:56 -07:00
parent 42e37d8caf
commit 4f3be6b8d9

View File

@ -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);