aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2023-05-01 15:27:14 +0000
committerWarner Losh <imp@FreeBSD.org>2023-05-01 21:02:53 +0000
commit43f7eeff0d45769e1deaf0a6879bc807fdafaf4c (patch)
tree3c272e0784a642bac663869213f2edb8ef433e69 /stand
parentb765cfa380a47de2b77cbf8a6249e226b0de2275 (diff)
downloadsrc-43f7eeff0d45769e1deaf0a6879bc807fdafaf4c.tar.gz
src-43f7eeff0d45769e1deaf0a6879bc807fdafaf4c.zip
Diffstat (limited to 'stand')
-rw-r--r--stand/efi/boot1/zfs_module.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/stand/efi/boot1/zfs_module.c b/stand/efi/boot1/zfs_module.c
index 7aaca72e30f1..234b50084839 100644
--- a/stand/efi/boot1/zfs_module.c
+++ b/stand/efi/boot1/zfs_module.c
@@ -40,6 +40,8 @@
static dev_info_t *devices;
+static char zfs_bootonce[VDEV_PAD_SIZE];
+
uint64_t
ldi_get_size(void *priv)
{
@@ -165,6 +167,16 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize)
return (EFI_NOT_FOUND);
}
+ /*
+ * OK. We've found a filesystem. Any attempt to use it should clear the
+ * 'once' flag. Prior to now, we'd not be able to clear it anyway. We
+ * don't care if we can't find the files to boot, or if there's a
+ * problem with it: we've tried to use it once we're able to mount the
+ * ZFS dataset.
+ */
+ *zfs_bootonce = '\0';
+ zfs_get_bootonce_spa(spa, OS_BOOTONCE, zfs_bootonce, sizeof(zfs_bootonce));
+
if ((err = zfs_lookup(&zmount, filepath, &dn)) != 0) {
if (err == ENOENT) {
DPRINTF("Failed to find '%s' on pool '%s' (%d)\n",
@@ -220,6 +232,18 @@ status(void)
printf("\n");
}
+static const char *
+extra_env(void)
+{
+ char *rv = NULL; /* So we return NULL if asprintf fails */
+
+ if (*zfs_bootonce == '\0')
+ return NULL;
+ asprintf(&rv, "zfs-bootonce=%s", zfs_bootonce);
+ return (rv);
+}
+
+
static void
init(void)
{
@@ -241,5 +265,6 @@ const boot_module_t zfs_module =
.probe = probe,
.load = load,
.status = status,
- .devices = _devices
+ .devices = _devices,
+ .extra_env = extra_env,
};