summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2024-03-19 16:13:59 +0100
committerMichael Brown2024-03-19 16:13:59 +0100
commit390bce9516ce3a4adf599762b6c965813332595e (patch)
tree33d9193fe547c3e44116b9cf5c7ee6c38c1d3fd6
parent[efi] Add efi_path_uri() to parse a URI from an EFI device path (diff)
downloadipxe-390bce9516ce3a4adf599762b6c965813332595e.tar.gz
ipxe-390bce9516ce3a4adf599762b6c965813332595e.tar.xz
ipxe-390bce9516ce3a4adf599762b6c965813332595e.zip
[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.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c
index 26116068..f6395b65 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 */