Repo: https://github.com/lersek/edk2.git
Branch: open_file_by_devpath_tiano_1008_v2
This is version 2 of the patch set that was originally posted at:
https://lists.01.org/pipermail/edk2-devel/2018-July/027253.html
for <https://bugzilla.tianocore.org/show_bug.cgi?id=1008>.
Changes are noted on every patch.
The cumulative code difference is very small (not counting the
FrameworkUefiLib copy of the function), so I'm including it here for
easier review:
> diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h
> index 2468bf2aee80..f950f1c9c648 100644
> --- a/MdePkg/Include/Library/UefiLib.h
> +++ b/MdePkg/Include/Library/UefiLib.h
> @@ -1554,9 +1554,11 @@ EfiLocateProtocolBuffer (
> traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.
>
> @param[in,out] FilePath On input, the device path to the file or directory
> - to open or create. On output, FilePath points one
> - past the last node in the original device path that
> - has been successfully processed. FilePath is set on
> + to open or create. The caller is responsible for
> + ensuring that the device path pointed-to by FilePath
> + is well-formed. On output, FilePath points one past
> + the last node in the original device path that has
> + been successfully processed. FilePath is set on
> output even if EfiOpenFileByDevicePath() returns an
> error.
>
> diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c
> index d3e290178cd9..7bcac5613768 100644
> --- a/MdePkg/Library/UefiLib/UefiLib.c
> +++ b/MdePkg/Library/UefiLib/UefiLib.c
> @@ -1751,9 +1751,11 @@ EfiLocateProtocolBuffer (
> traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.
>
> @param[in,out] FilePath On input, the device path to the file or directory
> - to open or create. On output, FilePath points one
> - past the last node in the original device path that
> - has been successfully processed. FilePath is set on
> + to open or create. The caller is responsible for
> + ensuring that the device path pointed-to by FilePath
> + is well-formed. On output, FilePath points one past
> + the last node in the original device path that has
> + been successfully processed. FilePath is set on
> output even if EfiOpenFileByDevicePath() returns an
> error.
>
> @@ -1808,6 +1810,10 @@ EfiOpenFileByDevicePath (
> EFI_HANDLE FileSystemHandle;
> EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem;
> EFI_FILE_PROTOCOL *LastFile;
> + FILEPATH_DEVICE_PATH *FilePathNode;
> + CHAR16 *AlignedPathName;
> + CHAR16 *PathName;
> + EFI_FILE_PROTOCOL *NextFile;
>
> if (File == NULL) {
> return EFI_INVALID_PARAMETER;
> @@ -1854,15 +1860,6 @@ EfiOpenFileByDevicePath (
> // Traverse the device path nodes relative to the filesystem.
> //
> while (!IsDevicePathEnd (*FilePath)) {
> - //
> - // Keep local variables that relate to the current device path node tightly
> - // scoped.
> - //
> - FILEPATH_DEVICE_PATH *FilePathNode;
> - CHAR16 *AlignedPathName;
> - CHAR16 *PathName;
> - EFI_FILE_PROTOCOL *NextFile;
> -
> if (DevicePathType (*FilePath) != MEDIA_DEVICE_PATH ||
> DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP) {
> Status = EFI_INVALID_PARAMETER;
> @@ -1942,6 +1939,10 @@ EfiOpenFileByDevicePath (
> CloseLastFile:
> LastFile->Close (LastFile);
>
> + //
> + // We are on the error path; we must have set an error Status for returning
> + // to the caller.
> + //
> ASSERT (EFI_ERROR (Status));
> return Status;
> }
> diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
> index 312a92d7461a..aef85c470143 100644
> --- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
> +++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
> @@ -163,7 +163,7 @@ UpdatePage(
>
> gSecureBootPrivateData->FileContext->FileName = FileName;
>
> - EfiOpenFileByDevicePath(
> + EfiOpenFileByDevicePath (
> &FilePath,
> &gSecureBootPrivateData->FileContext->FHandle,
> EFI_FILE_MODE_READ,
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Roman Bacik <roman.bacik@broadcom.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Thanks,
Laszlo
Laszlo Ersek (7):
MdePkg/UefiLib: introduce EfiOpenFileByDevicePath()
IntelFrameworkPkg/FrameworkUefiLib: introduce
EfiOpenFileByDevicePath()
MdeModulePkg/RamDiskDxe: replace OpenFileByDevicePath() with UefiLib
API
NetworkPkg/TlsAuthConfigDxe: replace OpenFileByDevicePath() with
UefiLib API
SecurityPkg/SecureBootConfigDxe: replace OpenFileByDevicePath() with
UefiLib API
ShellPkg/UefiShellLib: drop DeviceHandle param of
ShellOpenFileByDevicePath()
ShellPkg/UefiShellLib: rebase ShellOpenFileByDevicePath() to UefiLib
API
IntelFrameworkPkg/Library/FrameworkUefiLib/FrameworkUefiLib.inf | 1 +
IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c | 227 ++++++++++++++++++++
MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf | 1 -
MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskFileExplorer.c | 140 ------------
MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c | 2 +-
MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.h | 39 ----
MdePkg/Include/Library/UefiLib.h | 88 ++++++++
MdePkg/Library/UefiLib/UefiLib.c | 227 ++++++++++++++++++++
MdePkg/Library/UefiLib/UefiLib.inf | 1 +
NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf | 1 -
NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c | 141 +-----------
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf | 1 -
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c | 151 +------------
ShellPkg/Include/Library/ShellLib.h | 2 -
ShellPkg/Library/UefiShellLib/UefiShellLib.c | 118 +---------
ShellPkg/Library/UefiShellLib/UefiShellLib.inf | 3 +-
16 files changed, 552 insertions(+), 591 deletions(-)
--
2.14.1.3.gb7cf6e02401b
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel