]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Add error table entry for local filesystem EFI_NOT_FOUND error
authorMichael Brown <mcb30@ipxe.org>
Fri, 29 Mar 2024 12:41:32 +0000 (12:41 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 29 Mar 2024 14:46:13 +0000 (14:46 +0000)
Add an abbreviated "Not found" error message for an EFI_NOT_FOUND
error encountered when attempting to open a file on a local
filesystem, so that any automatic attempt to download a non-existent
autoexec.ipxe script produces only a minimal error message.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_local.c

index 00cc1147f913b04bd256e3771f31ebca922ba2f7..ec6d93a1d67aee7dabd1cbb773d6cfb9491626ae 100644 (file)
@@ -35,6 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/uri.h>
 #include <ipxe/iobuf.h>
 #include <ipxe/process.h>
+#include <ipxe/errortab.h>
 #include <ipxe/efi/efi.h>
 #include <ipxe/efi/efi_strings.h>
 #include <ipxe/efi/efi_path.h>
@@ -48,6 +49,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  *
  */
 
+/* Disambiguate the various error causes */
+#define EINFO_EEFI_OPEN                                                        \
+       __einfo_uniqify ( EINFO_EPLATFORM, 0x01, "Could not open" )
+#define EINFO_EEFI_OPEN_NOT_FOUND                                      \
+       __einfo_platformify ( EINFO_EEFI_OPEN, EFI_NOT_FOUND,           \
+                             "Not found" )
+#define EEFI_OPEN_NOT_FOUND                                            \
+       __einfo_error ( EINFO_EEFI_OPEN_NOT_FOUND )
+#define EEFI_OPEN( efirc ) EPLATFORM ( EINFO_EEFI_OPEN, efirc,         \
+                                      EEFI_OPEN_NOT_FOUND )
+
 /** Download blocksize */
 #define EFI_LOCAL_BLKSIZE 4096
 
@@ -75,6 +87,11 @@ struct efi_local {
        size_t len;
 };
 
+/** Human-readable error messages */
+struct errortab efi_local_errors[] __errortab = {
+       __einfo_errortab ( EINFO_EEFI_OPEN_NOT_FOUND ),
+};
+
 /**
  * Free local file
  *
@@ -339,7 +356,7 @@ static int efi_local_open_resolved ( struct efi_local *local,
        /* Open file */
        if ( ( efirc = local->root->Open ( local->root, &file, name,
                                           EFI_FILE_MODE_READ, 0 ) ) != 0 ) {
-               rc = -EEFI ( efirc );
+               rc = -EEFI_OPEN ( efirc );
                DBGC ( local, "LOCAL %p could not open \"%s\": %s\n",
                       local, resolved, strerror ( rc ) );
                return rc;