]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Make our virtual file system case insensitive
authorMichael Brown <mcb30@ipxe.org>
Wed, 27 Aug 2014 02:13:43 +0000 (03:13 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 27 Aug 2014 02:13:43 +0000 (03:13 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_file.c

index 258a3ba0a61c0f2ddf100d8ffc1d3215c6c0288e..2ef3c57347cd3df3aa6b364d62fdaa3563049fca 100644 (file)
@@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 #include <errno.h>
 #include <wchar.h>
 #include <ipxe/image.h>
@@ -74,6 +75,27 @@ static const char * efi_file_name ( struct efi_file *file ) {
        return ( file->image ? file->image->name : "<root>" );
 }
 
+/**
+ * Find EFI file image
+ *
+ * @v wname            Filename
+ * @ret image          Image, or NULL
+ */
+static struct image * efi_file_find ( const CHAR16 *wname ) {
+       char name[ wcslen ( wname ) + 1 /* NUL */ ];
+       struct image *image;
+
+       /* Find image */
+       snprintf ( name, sizeof ( name ), "%ls", wname );
+       list_for_each_entry ( image, &images, list ) {
+               if ( strcasecmp ( image->name, name ) == 0 )
+                       return image;
+       }
+
+       return NULL;
+
+}
+
 /**
  * Open file
  *
@@ -89,7 +111,6 @@ efi_file_open ( EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new,
                CHAR16 *wname, UINT64 mode __unused,
                UINT64 attributes __unused ) {
        struct efi_file *file = container_of ( this, struct efi_file, file );
-       char name[ wcslen ( wname ) + 1 /* NUL */ ];
        struct efi_file *new_file;
        struct image *image;
 
@@ -113,10 +134,9 @@ efi_file_open ( EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new,
        }
 
        /* Identify image */
-       snprintf ( name, sizeof ( name ), "%ls", wname );
-       image = find_image ( name );
+       image = efi_file_find ( wname );
        if ( ! image ) {
-               DBGC ( file, "EFIFILE \"%s\" does not exist\n", name );
+               DBGC ( file, "EFIFILE \"%ls\" does not exist\n", wname );
                return EFI_NOT_FOUND;
        }