Revision: 17903
http://sourceforge.net/p/edk2/code/17903
Author: oliviermartin
Date: 2015-07-09 10:34:27 +0000 (Thu, 09 Jul 2015)
Log Message:
-----------
MdeModulePkg/FvSimpleFileSystemDxe: Support file opening with no '.efi'
FvSimpleFileSystem adds '.efi' to the EFI application and drivers
filenames even through this extension is not present in the real
filename of the EFI module.
In the current behaviour, it would not be possible to open an EFI
application using FvSimpleFileSystem if the extension has been omitted
in the given filename.
It can be create some confusion if someone wants to try to
open a file with the real application name (eg: 'Shell').
This patch adds support to try again to look for the file with the
extension if it had failed to find it without the extension.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <[email protected]>
Reviewed-by: Feng Tian <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
Modified:
trunk/edk2/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
===================================================================
---
trunk/edk2/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
2015-07-09 08:55:23 UTC (rev 17902)
+++
trunk/edk2/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
2015-07-09 10:34:27 UTC (rev 17903)
@@ -483,6 +483,10 @@
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,28 +535,62 @@
//
// 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);
- *NewHandle = &NewFile->FileProtocol;
- return EFI_SUCCESS;
+ // 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;
+ }
+ }
}
}
+ 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;
}
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits