diff options
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c index b0e7dc302e..c6137aca1f 100644 --- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c +++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c @@ -483,6 +483,10 @@ FvSimpleFileSystemOpen ( FV_FILESYSTEM_FILE *NewFile;
FV_FILESYSTEM_FILE_INFO *FvFileInfo;
LIST_ENTRY *FvFileInfoLink;
+ EFI_STATUS Status;
+ UINTN FileNameLength;
+ UINTN NewFileNameLength;
+ CHAR16 *FileNameWithExtension;
//
// Check for a valid mode
@@ -531,26 +535,60 @@ FvSimpleFileSystemOpen ( //
// Do a linear search for a file in the FV with a matching filename
//
+ Status = EFI_NOT_FOUND;
+ FvFileInfo = NULL;
for (FvFileInfoLink = GetFirstNode (&Instance->FileInfoHead);
!IsNull (&Instance->FileInfoHead, FvFileInfoLink);
FvFileInfoLink = GetNextNode (&Instance->FileInfoHead, FvFileInfoLink)) {
FvFileInfo = FVFS_FILE_INFO_FROM_LINK (FvFileInfoLink);
if (mUnicodeCollation->StriColl (mUnicodeCollation, &FvFileInfo->FileInfo.FileName[0], FileName) == 0) {
- NewFile = AllocateZeroPool (sizeof (FV_FILESYSTEM_FILE));
- if (NewFile == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
- NewFile->Signature = FVFS_FILE_SIGNATURE;
- NewFile->Instance = Instance;
- NewFile->FvFileInfo = FvFileInfo;
- CopyMem (&NewFile->FileProtocol, &mFileSystemTemplate, sizeof (mFileSystemTemplate));
- InitializeListHead (&NewFile->Link);
- InsertHeadList (&Instance->FileHead, &NewFile->Link);
+ // If the file has not been found check if the filename exists with an extension
+ // in case there was no extension present.
+ // FvFileSystem adds a 'virtual' extension '.EFI' to EFI applications and drivers
+ // present in the Firmware Volume
+ if (Status == EFI_NOT_FOUND) {
+ FileNameLength = StrLen (FileName);
+
+ // Does the filename already contain the '.EFI' extension?
+ if (mUnicodeCollation->StriColl (mUnicodeCollation, FileName + FileNameLength - 4, L".efi") != 0) {
+ // No, there was no extension. So add one and search again for the file
+ // NewFileNameLength = FileNameLength + 1 + 4 = (Number of non-null character) + (file extension) + (a null character)
+ NewFileNameLength = FileNameLength + 1 + 4;
+ FileNameWithExtension = AllocateCopyPool (NewFileNameLength * 2, FileName);
+ StrCatS (FileNameWithExtension, NewFileNameLength, L".EFI");
+
+ for (FvFileInfoLink = GetFirstNode (&Instance->FileInfoHead);
+ !IsNull (&Instance->FileInfoHead, FvFileInfoLink);
+ FvFileInfoLink = GetNextNode (&Instance->FileInfoHead, FvFileInfoLink)) {
+ FvFileInfo = FVFS_FILE_INFO_FROM_LINK (FvFileInfoLink);
+ if (mUnicodeCollation->StriColl (mUnicodeCollation, &FvFileInfo->FileInfo.FileName[0], FileNameWithExtension) == 0) {
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ }
+ }
- *NewHandle = &NewFile->FileProtocol;
- return EFI_SUCCESS;
+ if (!EFI_ERROR (Status)) {
+ NewFile = AllocateZeroPool (sizeof (FV_FILESYSTEM_FILE));
+ if (NewFile == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
+
+ NewFile->Signature = FVFS_FILE_SIGNATURE;
+ NewFile->Instance = Instance;
+ NewFile->FvFileInfo = FvFileInfo;
+ CopyMem (&NewFile->FileProtocol, &mFileSystemTemplate, sizeof (mFileSystemTemplate));
+ InitializeListHead (&NewFile->Link);
+ InsertHeadList (&Instance->FileHead, &NewFile->Link);
+
+ *NewHandle = &NewFile->FileProtocol;
+ return EFI_SUCCESS;
}
return EFI_NOT_FOUND;
|