-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move is_removable_media_path() to a shared location.
We need to use is_removable_media_path(), and potentially other helpers, from Mok as well as shim. This moves it to a file just for Device Path utility functions to make that simpler. Signed-off-by: Peter Jones <[email protected]>
- Loading branch information
Showing
5 changed files
with
61 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: BSD-2-Clause-Patent | ||
/* | ||
* dp.c - device path helpers | ||
* Copyright Peter Jones <[email protected]> | ||
*/ | ||
|
||
#include "shim.h" | ||
|
||
int | ||
is_removable_media_path(EFI_LOADED_IMAGE *li) | ||
{ | ||
unsigned int pathlen = 0; | ||
CHAR16 *bootpath = NULL; | ||
int ret = 0; | ||
|
||
bootpath = DevicePathToStr(li->FilePath); | ||
|
||
/* Check the beginning of the string and the end, to avoid | ||
* caring about which arch this is. */ | ||
/* I really don't know why, but sometimes bootpath gives us | ||
* L"\\EFI\\BOOT\\/BOOTX64.EFI". So just handle that here... | ||
*/ | ||
if (StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\BOOT", 14) && | ||
StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\/BOOT", 15) && | ||
StrnCaseCmp(bootpath, L"EFI\\BOOT\\BOOT", 13) && | ||
StrnCaseCmp(bootpath, L"EFI\\BOOT\\/BOOT", 14)) | ||
goto error; | ||
|
||
pathlen = StrLen(bootpath); | ||
if (pathlen < 5 || StrCaseCmp(bootpath + pathlen - 4, L".EFI")) | ||
goto error; | ||
|
||
ret = 1; | ||
|
||
error: | ||
if (bootpath) | ||
FreePool(bootpath); | ||
|
||
return ret; | ||
} | ||
|
||
|
||
// vim:fenc=utf-8:tw=75:noet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: BSD-2-Clause-Patent | ||
/* | ||
* dp.h - device path helper functions | ||
* Copyright Peter Jones <[email protected]> | ||
*/ | ||
|
||
#ifndef DP_H_ | ||
#define DP_H_ | ||
|
||
int | ||
is_removable_media_path(EFI_LOADED_IMAGE *li); | ||
|
||
#endif /* !DP_H_ */ | ||
// vim:fenc=utf-8:tw=75:noet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters