diff options
| author | Warner Losh <imp@FreeBSD.org> | 2023-05-01 15:26:31 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2023-05-01 21:02:52 +0000 |
| commit | 91ac713b646de667ac149be7dfe06adba4ce55cc (patch) | |
| tree | 1b38f9e61f354afdd5cd28650b7ce5a266b91d6f /stand | |
| parent | 5f2e84015da7a664bba0af7727349c9c3f6902ba (diff) | |
Diffstat (limited to 'stand')
| -rw-r--r-- | stand/efi/boot1/boot1.c | 20 | ||||
| -rw-r--r-- | stand/efi/boot1/boot_module.h | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/stand/efi/boot1/boot1.c b/stand/efi/boot1/boot1.c index 088821ecd1f8..2f9801c8ea92 100644 --- a/stand/efi/boot1/boot1.c +++ b/stand/efi/boot1/boot1.c @@ -96,6 +96,26 @@ try_boot(const boot_module_t *mod, dev_info_t *dev, void *loaderbuf, size_t load buf = NULL; } + /* + * See if there's any env variables the module wants to set. If so, + * append it to any config present. + */ + if (mod->extra_env != NULL) { + const char *env = mod->extra_env(); + if (env != NULL) { + size_t newlen = cmdsize + strlen(env) + 1; + + cmd = realloc(cmd, newlen); + if (cmd == NULL) + goto errout; + if (cmdsize > 0) + strlcat(cmd, " ", newlen); + strlcat(cmd, env, newlen); + cmdsize = strlen(cmd); + free(__DECONST(char *, env)); + } + } + if ((status = BS->LoadImage(TRUE, IH, efi_devpath_last_node(dev->devpath), loaderbuf, loadersize, &loaderhandle)) != EFI_SUCCESS) { printf("Failed to load image provided by %s, size: %zu, (%lu)\n", diff --git a/stand/efi/boot1/boot_module.h b/stand/efi/boot1/boot_module.h index 99046fb53577..4ecfa4c72a83 100644 --- a/stand/efi/boot1/boot_module.h +++ b/stand/efi/boot1/boot_module.h @@ -94,6 +94,9 @@ typedef struct boot_module_t /* valid devices as found by probe. */ dev_info_t *(*devices)(void); + + /* return any environment variables to pass to next stage */ + const char *(*extra_env)(void); } boot_module_t; extern const boot_module_t *boot_modules[]; |
