소스 검색

[efi] Make our virtual file system case insensitive

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 년 전
부모
커밋
2cb95c9028
1개의 변경된 파일24개의 추가작업 그리고 4개의 파일을 삭제
  1. 24
    4
      src/interface/efi/efi_file.c

+ 24
- 4
src/interface/efi/efi_file.c 파일 보기

@@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
30 30
 #include <stdlib.h>
31 31
 #include <stdio.h>
32 32
 #include <string.h>
33
+#include <strings.h>
33 34
 #include <errno.h>
34 35
 #include <wchar.h>
35 36
 #include <ipxe/image.h>
@@ -74,6 +75,27 @@ static const char * efi_file_name ( struct efi_file *file ) {
74 75
 	return ( file->image ? file->image->name : "<root>" );
75 76
 }
76 77
 
78
+/**
79
+ * Find EFI file image
80
+ *
81
+ * @v wname		Filename
82
+ * @ret image		Image, or NULL
83
+ */
84
+static struct image * efi_file_find ( const CHAR16 *wname ) {
85
+	char name[ wcslen ( wname ) + 1 /* NUL */ ];
86
+	struct image *image;
87
+
88
+	/* Find image */
89
+	snprintf ( name, sizeof ( name ), "%ls", wname );
90
+	list_for_each_entry ( image, &images, list ) {
91
+		if ( strcasecmp ( image->name, name ) == 0 )
92
+			return image;
93
+	}
94
+
95
+	return NULL;
96
+
97
+}
98
+
77 99
 /**
78 100
  * Open file
79 101
  *
@@ -89,7 +111,6 @@ efi_file_open ( EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new,
89 111
 		CHAR16 *wname, UINT64 mode __unused,
90 112
 		UINT64 attributes __unused ) {
91 113
 	struct efi_file *file = container_of ( this, struct efi_file, file );
92
-	char name[ wcslen ( wname ) + 1 /* NUL */ ];
93 114
 	struct efi_file *new_file;
94 115
 	struct image *image;
95 116
 
@@ -113,10 +134,9 @@ efi_file_open ( EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new,
113 134
 	}
114 135
 
115 136
 	/* Identify image */
116
-	snprintf ( name, sizeof ( name ), "%ls", wname );
117
-	image = find_image ( name );
137
+	image = efi_file_find ( wname );
118 138
 	if ( ! image ) {
119
-		DBGC ( file, "EFIFILE \"%s\" does not exist\n", name );
139
+		DBGC ( file, "EFIFILE \"%ls\" does not exist\n", wname );
120 140
 		return EFI_NOT_FOUND;
121 141
 	}
122 142
 

Loading…
취소
저장