init_usec = time_usec();
- /* Ask Shim to leave its protocol around, so that the stub can use it to validate PEs.
- * By default, Shim uninstalls its protocol when calling StartImage(). */
- shim_retain_protocol();
-
err = BS->HandleProtocol(image, MAKE_GUID_PTR(EFI_LOADED_IMAGE_PROTOCOL), (void **) &loaded_image);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error getting a LoadedImageProtocol handle: %m");
+ err = discover_root_dir(loaded_image, &root_dir);
+ if (err != EFI_SUCCESS) {
+ log_error_status(err, "Unable to open root directory: %m");
+
+ /* If opening the root directory fails this typically means someone is trying to boot our
+ * systemd-boot EFI PE binary as network boot NBP. That cannot work however, since we
+ * wouldn't find any menu entries. Provide a helpful message what to try instead. */
+
+ if (err == EFI_UNSUPPORTED)
+ log_info("| Note that invoking systemd-boot directly as UEFI network boot NBP is not\n"
+ "| supported. Instead of booting the systemd-boot PE binary (i.e. an .efi file)\n"
+ "| via the network, use an EFI GPT disk image (i.e. a file with .img suffix)\n"
+ "| containing systemd-boot instead.");
+
+ return err;
+ }
+
+ /* Ask Shim to leave its protocol around, so that the stub can use it to validate PEs.
+ * By default, Shim uninstalls its protocol when calling StartImage(). */
+ shim_retain_protocol();
+
export_common_variables(loaded_image);
export_loader_variables(loaded_image, init_usec);
- err = discover_root_dir(loaded_image, &root_dir);
- if (err != EFI_SUCCESS)
- return log_error_status(err, "Unable to open root directory: %m");
-
(void) load_drivers(image, loaded_image, root_dir);
_cleanup_free_ char16_t *loaded_image_path = NULL;