diff options
author | Michael Brown <mcb30@ipxe.org> | 2024-03-19 15:13:59 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2024-03-19 15:13:59 +0000 |
commit | 390bce9516ce3a4adf599762b6c965813332595e (patch) | |
tree | 33d9193fe547c3e44116b9cf5c7ee6c38c1d3fd6 | |
parent | 1a84facf12b07a5e5375822015b56cf320821055 (diff) | |
download | ipxe-390bce9516ce3a4adf599762b6c965813332595e.tar.gz |
[efi] Set current working URI from our own device path URI, if present
When booted via HTTP, our loaded image's device path will include the
URI from which we were downloaded. Set this as the current working
URI, so that an embedded script may perform subsequent downloads
relative to the iPXE binary, or construct explicit relative paths via
the ${cwduri} setting.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | src/interface/efi/efiprefix.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c index 261160681..f6395b65b 100644 --- a/src/interface/efi/efiprefix.c +++ b/src/interface/efi/efiprefix.c @@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <stdlib.h> #include <errno.h> #include <ipxe/device.h> +#include <ipxe/uri.h> #include <ipxe/init.h> #include <ipxe/efi/efi.h> #include <ipxe/efi/efi_driver.h> @@ -30,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/efi/efi_autoexec.h> #include <ipxe/efi/efi_cachedhcp.h> #include <ipxe/efi/efi_watchdog.h> +#include <ipxe/efi/efi_path.h> #include <ipxe/efi/efi_veto.h> /** @@ -80,6 +82,12 @@ static void efi_init_application ( void ) { EFI_HANDLE device = efi_loaded_image->DeviceHandle; EFI_DEVICE_PATH_PROTOCOL *devpath = efi_loaded_image_path; EFI_DEVICE_PATH_PROTOCOL *filepath = efi_loaded_image->FilePath; + struct uri *uri; + + /* Set current working URI from device path, if present */ + uri = efi_path_uri ( devpath ); + if ( uri ) + churi ( uri ); /* Identify autoboot device, if any */ efi_set_autoboot_ll_addr ( device, devpath ); @@ -89,6 +97,9 @@ static void efi_init_application ( void ) { /* Load autoexec script, if any */ efi_autoexec_load ( device, filepath ); + + /* Drop temporary reference to URI */ + uri_put ( uri ); } /** EFI application initialisation function */ |