kboot: Fix zfs bootonce protocol

This wasn't updated when the other copies were updated. Make it
identical to efi code. We should likely refactor this (with userboot),
but they are all not quite identical.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2024-02-20 20:26:08 -07:00
parent 9a5aaa97cb
commit 65ee8f90b7

View file

@ -567,40 +567,35 @@ hostdisk_zfs_probe(void)
/* This likely shoud move to libsa/zfs/zfs.c and be used by at least EFI booting */ /* This likely shoud move to libsa/zfs/zfs.c and be used by at least EFI booting */
static bool static bool
probe_zfs_currdev(uint64_t pool_guid, uint64_t root_guid, bool setcurrdev) probe_zfs_currdev(uint64_t pool_guid)
{ {
char *devname; char *devname;
struct zfs_devdesc currdev; struct zfs_devdesc currdev;
bool bootable; char buf[VDEV_PAD_SIZE];
currdev.dd.d_dev = &zfs_dev; currdev.dd.d_dev = &zfs_dev;
currdev.dd.d_unit = 0; currdev.dd.d_unit = 0;
currdev.pool_guid = pool_guid; currdev.pool_guid = pool_guid;
currdev.root_guid = root_guid; currdev.root_guid = 0;
devname = devformat(&currdev.dd); devname = devformat(&currdev.dd);
if (setcurrdev) printf("Setting currdev to %s\n", devname);
set_currdev(devname); set_currdev(devname);
init_zfs_boot_options(devname);
bootable = sanity_check_currdev(); if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf, sizeof(buf)) == 0) {
if (bootable) { printf("zfs bootonce: %s\n", buf);
char buf[VDEV_PAD_SIZE]; set_currdev(buf);
setenv("zfs-bootonce", buf, 1);
if (zfs_get_bootonce(&currdev, OS_BOOTONCE, buf, sizeof(buf)) == 0) {
printf("zfs bootonce: %s\n", buf);
if (setcurrdev)
set_currdev(buf);
setenv("zfs-bootonce", buf, 1);
}
(void)zfs_attach_nvstore(&currdev);
init_zfs_boot_options(devname);
} }
return (bootable); (void)zfs_attach_nvstore(&currdev);
return (sanity_check_currdev());
} }
static bool static bool
hostdisk_zfs_try_default(hdinfo_t *hd) hostdisk_zfs_try_default(hdinfo_t *hd)
{ {
return (probe_zfs_currdev(hd->hd_zfs_uuid, 0, true)); return (probe_zfs_currdev(hd->hd_zfs_uuid));
} }
bool bool