public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: Laszlo Ersek <lersek@redhat.com>,
	edk2-devel-01 <edk2-devel@lists.01.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Ni, Ruiyu" <ruiyu.ni@intel.com>
Subject: Re: [PATCH 1/4] MdePkg/UefiLib: don't special-case EFI_FILE_MODE_CREATE in OpenMode
Date: Fri, 17 Aug 2018 20:35:00 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E2E52C8@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20180817143534.28393-2-lersek@redhat.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Laszlo Ersek [mailto:lersek@redhat.com]
> Sent: Friday, August 17, 2018 7:36 AM
> To: edk2-devel-01 <edk2-devel@lists.01.org>
> Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [PATCH 1/4] MdePkg/UefiLib: don't special-case EFI_FILE_MODE_CREATE in OpenMode
> 
> While reviewing the patch that would land as 768b611136d0
> ("MdePkg/UefiLib: introduce EfiOpenFileByDevicePath()", 2018-08-16), Ray
> pointed out that distinguishing EFI_FILE_MODE_CREATE was wasteful. Per
> spec, if the file to create exists, then EFI_FILE_MODE_CREATE is ignored
> by EFI_FILE_PROTOCOL.Open(), and the existent file is opened.
> 
> Therefore we don't need an attempt to "open-but-not-create" first, and a
> fallback to "open-and-create-too" second -- that behavior is internal to
> EFI_FILE_PROTOCOL.Open(). Remove the special-casing of
> EFI_FILE_MODE_CREATE.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Suggested-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1074
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> 
> Notes:
>     Tested with MdeModulePkg/RamDiskDxe: created a virtual disk from an ISO
>     file, using the HII form; browsed the disk contents from the UEFI shell.
> 
>  MdePkg/Include/Library/UefiLib.h | 19 ++--------
>  MdePkg/Library/UefiLib/UefiLib.c | 40 +++-----------------
>  2 files changed, 9 insertions(+), 50 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h
> index f950f1c9c648..f80067f11103 100644
> --- a/MdePkg/Include/Library/UefiLib.h
> +++ b/MdePkg/Include/Library/UefiLib.h
> @@ -1533,12 +1533,7 @@ EfiLocateProtocolBuffer (
> 
>    On the remaining device path, the longest initial sequence of
>    FILEPATH_DEVICE_PATH nodes is node-wise traversed with
> -  EFI_FILE_PROTOCOL.Open(). For the pathname fragment specified by each
> -  traversed FILEPATH_DEVICE_PATH node, EfiOpenFileByDevicePath() first masks
> -  EFI_FILE_MODE_CREATE out of OpenMode, and passes 0 for Attributes. If
> -  EFI_FILE_PROTOCOL.Open() fails, and OpenMode includes EFI_FILE_MODE_CREATE,
> -  then the operation is retried with the caller's OpenMode and Attributes
> -  unmodified.
> +  EFI_FILE_PROTOCOL.Open().
> 
>    (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes
>    includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single
> @@ -1570,18 +1565,10 @@ EfiLocateProtocolBuffer (
>                             the last node in FilePath.
> 
>    @param[in] OpenMode      The OpenMode parameter to pass to
> -                           EFI_FILE_PROTOCOL.Open(). For each
> -                           FILEPATH_DEVICE_PATH node in FilePath,
> -                           EfiOpenFileByDevicePath() first opens the specified
> -                           pathname fragment with EFI_FILE_MODE_CREATE masked
> -                           out of OpenMode and with Attributes set to 0, and
> -                           only retries the operation with EFI_FILE_MODE_CREATE
> -                           unmasked and Attributes propagated if the first open
> -                           attempt fails.
> +                           EFI_FILE_PROTOCOL.Open().
> 
>    @param[in] Attributes    The Attributes parameter to pass to
> -                           EFI_FILE_PROTOCOL.Open(), when EFI_FILE_MODE_CREATE
> -                           is propagated unmasked in OpenMode.
> +                           EFI_FILE_PROTOCOL.Open().
> 
>    @retval EFI_SUCCESS            The file or directory has been opened or
>                                   created.
> diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c
> index 7bcac5613768..39d0ce2b21b3 100644
> --- a/MdePkg/Library/UefiLib/UefiLib.c
> +++ b/MdePkg/Library/UefiLib/UefiLib.c
> @@ -1730,12 +1730,7 @@ EfiLocateProtocolBuffer (
> 
>    On the remaining device path, the longest initial sequence of
>    FILEPATH_DEVICE_PATH nodes is node-wise traversed with
> -  EFI_FILE_PROTOCOL.Open(). For the pathname fragment specified by each
> -  traversed FILEPATH_DEVICE_PATH node, EfiOpenFileByDevicePath() first masks
> -  EFI_FILE_MODE_CREATE out of OpenMode, and passes 0 for Attributes. If
> -  EFI_FILE_PROTOCOL.Open() fails, and OpenMode includes EFI_FILE_MODE_CREATE,
> -  then the operation is retried with the caller's OpenMode and Attributes
> -  unmodified.
> +  EFI_FILE_PROTOCOL.Open().
> 
>    (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes
>    includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single
> @@ -1767,18 +1762,10 @@ EfiLocateProtocolBuffer (
>                             the last node in FilePath.
> 
>    @param[in] OpenMode      The OpenMode parameter to pass to
> -                           EFI_FILE_PROTOCOL.Open(). For each
> -                           FILEPATH_DEVICE_PATH node in FilePath,
> -                           EfiOpenFileByDevicePath() first opens the specified
> -                           pathname fragment with EFI_FILE_MODE_CREATE masked
> -                           out of OpenMode and with Attributes set to 0, and
> -                           only retries the operation with EFI_FILE_MODE_CREATE
> -                           unmasked and Attributes propagated if the first open
> -                           attempt fails.
> +                           EFI_FILE_PROTOCOL.Open().
> 
>    @param[in] Attributes    The Attributes parameter to pass to
> -                           EFI_FILE_PROTOCOL.Open(), when EFI_FILE_MODE_CREATE
> -                           is propagated unmasked in OpenMode.
> +                           EFI_FILE_PROTOCOL.Open().
> 
>    @retval EFI_SUCCESS            The file or directory has been opened or
>                                   created.
> @@ -1889,31 +1876,16 @@ EfiOpenFileByDevicePath (
>      }
> 
>      //
> -    // Open the next pathname fragment with EFI_FILE_MODE_CREATE masked out and
> -    // with Attributes set to 0.
> +    // Open or create the file corresponding to the next pathname fragment.
>      //
>      Status = LastFile->Open (
>                           LastFile,
>                           &NextFile,
>                           PathName,
> -                         OpenMode & ~(UINT64)EFI_FILE_MODE_CREATE,
> -                         0
> +                         OpenMode,
> +                         Attributes
>                           );
> 
> -    //
> -    // Retry with EFI_FILE_MODE_CREATE and the original Attributes if the first
> -    // attempt failed, and the caller specified EFI_FILE_MODE_CREATE.
> -    //
> -    if (EFI_ERROR (Status) && (OpenMode & EFI_FILE_MODE_CREATE) != 0) {
> -      Status = LastFile->Open (
> -                           LastFile,
> -                           &NextFile,
> -                           PathName,
> -                           OpenMode,
> -                           Attributes
> -                           );
> -    }
> -
>      //
>      // Release any AlignedPathName on both error and success paths; PathName is
>      // no longer needed.
> --
> 2.14.1.3.gb7cf6e02401b
> 



  reply	other threads:[~2018-08-17 20:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17 14:35 [PATCH 0/4] {Mde, IntelFramework, Network, UefiCpu}Pkg: roundup for BZs 1074, 1090, 1092 Laszlo Ersek
2018-08-17 14:35 ` [PATCH 1/4] MdePkg/UefiLib: don't special-case EFI_FILE_MODE_CREATE in OpenMode Laszlo Ersek
2018-08-17 20:35   ` Gao, Liming [this message]
2018-08-17 14:35 ` [PATCH 2/4] IntelFrameworkPkg/FrameworkUefiLib: don't special-case EFI_FILE_MODE_CREATE Laszlo Ersek
2018-08-17 20:35   ` Gao, Liming
2018-08-17 14:35 ` [PATCH 3/4] NetworkPkg/TlsAuthConfigDxe: fix TlsCaCertificate attributes retrieval Laszlo Ersek
2018-08-20  6:29   ` Li, Songpeng
2018-08-21 13:30     ` Laszlo Ersek
2018-08-22  0:36     ` Wu, Jiaxin
2018-08-22  0:31   ` Fu, Siyuan
2018-08-17 14:35 ` [PATCH 4/4] UefiCpuPkg/PiSmmCpuDxeSmm: clear exec file mode bits on "PiSmmCpuDxeSmm.c" Laszlo Ersek
2018-08-20  1:31   ` Zeng, Star
2018-08-22  8:41 ` [PATCH 0/4] {Mde, IntelFramework, Network, UefiCpu}Pkg: roundup for BZs 1074, 1090, 1092 Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E2E52C8@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox