Skip to content

Commit

Permalink
[efi] Make our virtual file system case insensitive
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Aug 27, 2014
1 parent 3357a8e commit 2cb95c9
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/interface/efi/efi_file.c
Expand Up @@ -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>
Expand Down Expand Up @@ -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
*
Expand All @@ -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;

Expand All @@ -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;
}

Expand Down

0 comments on commit 2cb95c9

Please sign in to comment.