from the UEFI shell. It is entirely read-only.\r
\r
Copyright (c) 2014, ARM Limited. All rights reserved.\r
-Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
FV_FILESYSTEM_FILE *NewFile;\r
FV_FILESYSTEM_FILE_INFO *FvFileInfo;\r
LIST_ENTRY *FvFileInfoLink;\r
+ EFI_STATUS Status;\r
+ UINTN FileNameLength;\r
+ UINTN NewFileNameLength;\r
+ CHAR16 *FileNameWithExtension;\r
\r
//\r
// Check for a valid mode\r
//\r
// Do a linear search for a file in the FV with a matching filename\r
//\r
+ Status = EFI_NOT_FOUND;\r
+ FvFileInfo = NULL;\r
for (FvFileInfoLink = GetFirstNode (&Instance->FileInfoHead);\r
!IsNull (&Instance->FileInfoHead, FvFileInfoLink);\r
FvFileInfoLink = GetNextNode (&Instance->FileInfoHead, FvFileInfoLink)) {\r
FvFileInfo = FVFS_FILE_INFO_FROM_LINK (FvFileInfoLink);\r
if (mUnicodeCollation->StriColl (mUnicodeCollation, &FvFileInfo->FileInfo.FileName[0], FileName) == 0) {\r
- NewFile = AllocateZeroPool (sizeof (FV_FILESYSTEM_FILE));\r
- if (NewFile == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
+ Status = EFI_SUCCESS;\r
+ break;\r
+ }\r
+ }\r
\r
- NewFile->Signature = FVFS_FILE_SIGNATURE;\r
- NewFile->Instance = Instance;\r
- NewFile->FvFileInfo = FvFileInfo;\r
- CopyMem (&NewFile->FileProtocol, &mFileSystemTemplate, sizeof (mFileSystemTemplate));\r
- InitializeListHead (&NewFile->Link);\r
- InsertHeadList (&Instance->FileHead, &NewFile->Link);\r
+ // If the file has not been found check if the filename exists with an extension\r
+ // in case there was no extension present.\r
+ // FvFileSystem adds a 'virtual' extension '.EFI' to EFI applications and drivers\r
+ // present in the Firmware Volume\r
+ if (Status == EFI_NOT_FOUND) {\r
+ FileNameLength = StrLen (FileName);\r
+\r
+ // Does the filename already contain the '.EFI' extension?\r
+ if (mUnicodeCollation->StriColl (mUnicodeCollation, FileName + FileNameLength - 4, L".efi") != 0) {\r
+ // No, there was no extension. So add one and search again for the file\r
+ // NewFileNameLength = FileNameLength + 1 + 4 = (Number of non-null character) + (file extension) + (a null character)\r
+ NewFileNameLength = FileNameLength + 1 + 4;\r
+ FileNameWithExtension = AllocateCopyPool (NewFileNameLength * 2, FileName);\r
+ StrCatS (FileNameWithExtension, NewFileNameLength, L".EFI");\r
+\r
+ for (FvFileInfoLink = GetFirstNode (&Instance->FileInfoHead);\r
+ !IsNull (&Instance->FileInfoHead, FvFileInfoLink);\r
+ FvFileInfoLink = GetNextNode (&Instance->FileInfoHead, FvFileInfoLink)) {\r
+ FvFileInfo = FVFS_FILE_INFO_FROM_LINK (FvFileInfoLink);\r
+ if (mUnicodeCollation->StriColl (mUnicodeCollation, &FvFileInfo->FileInfo.FileName[0], FileNameWithExtension) == 0) {\r
+ Status = EFI_SUCCESS;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
\r
- *NewHandle = &NewFile->FileProtocol;\r
- return EFI_SUCCESS;\r
+ if (!EFI_ERROR (Status)) {\r
+ NewFile = AllocateZeroPool (sizeof (FV_FILESYSTEM_FILE));\r
+ if (NewFile == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
+ NewFile->Signature = FVFS_FILE_SIGNATURE;\r
+ NewFile->Instance = Instance;\r
+ NewFile->FvFileInfo = FvFileInfo;\r
+ CopyMem (&NewFile->FileProtocol, &mFileSystemTemplate, sizeof (mFileSystemTemplate));\r
+ InitializeListHead (&NewFile->Link);\r
+ InsertHeadList (&Instance->FileHead, &NewFile->Link);\r
+\r
+ *NewHandle = &NewFile->FileProtocol;\r
+ return EFI_SUCCESS;\r
}\r
\r
return EFI_NOT_FOUND;\r
FsInfoOut = (EFI_FILE_SYSTEM_INFO *) Buffer;\r
\r
CopyMem (FsInfoOut, &mFsInfoTemplate, sizeof (EFI_FILE_SYSTEM_INFO));\r
- Status = StrnCpyS (FsInfoOut->VolumeLabel, (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_INFO, VolumeLabel)) / sizeof (CHAR16), Instance->VolumeLabel, StrLen (Instance->VolumeLabel));\r
+ Status = StrnCpyS ( FsInfoOut->VolumeLabel, \r
+ (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_INFO, VolumeLabel)) / sizeof (CHAR16), \r
+ Instance->VolumeLabel, \r
+ StrLen (Instance->VolumeLabel)\r
+ );\r
ASSERT_EFI_ERROR (Status);\r
FsInfoOut->Size = Size;\r
return Status;\r
}\r
\r
FsVolumeLabel = (EFI_FILE_SYSTEM_VOLUME_LABEL*) Buffer;\r
- Status = StrnCpyS (FsVolumeLabel->VolumeLabel, (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_VOLUME_LABEL, VolumeLabel)) / sizeof (CHAR16), Instance->VolumeLabel, StrLen (Instance->VolumeLabel));\r
+ Status = StrnCpyS (FsVolumeLabel->VolumeLabel, \r
+ (*BufferSize - OFFSET_OF (EFI_FILE_SYSTEM_VOLUME_LABEL, VolumeLabel)) / sizeof (CHAR16),\r
+ Instance->VolumeLabel, \r
+ StrLen (Instance->VolumeLabel)\r
+ );\r
ASSERT_EFI_ERROR (Status);\r
return Status;\r
} else {\r