public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Andrew Fish <afish@apple.com>
Subject: Re: [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content
Date: Wed, 29 Aug 2018 01:51:36 +0000	[thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A0931E3CD9A@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20180827075330.269224-6-ruiyu.ni@intel.com>

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, August 27, 2018 3:53 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A; Andrew Fish
> Subject: [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content
> 
> The patch changes the behavior to not zero out file content
> when the file size is not multiple of block size.
> Instead, it just provides access to the contents that are
> multiple of block size and leaves the remaining content (less than
> block size) untouched.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> ---
>  EmulatorPkg/Win/Host/WinBlockIo.c | 28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/EmulatorPkg/Win/Host/WinBlockIo.c
> b/EmulatorPkg/Win/Host/WinBlockIo.c
> index 14491a6e90..7df7d42c7c 100644
> --- a/EmulatorPkg/Win/Host/WinBlockIo.c
> +++ b/EmulatorPkg/Win/Host/WinBlockIo.c
> @@ -90,6 +90,7 @@ WinNtBlockIoOpenDevice (
>  {
>    EFI_STATUS            Status;
>    UINT64                FileSize;
> +  UINT64                EndOfFile;
> 
>    //
>    // If the device is already opened, close it
> @@ -112,7 +113,7 @@ WinNtBlockIoOpenDevice (
>    );
> 
>    if (Private->NtHandle == INVALID_HANDLE_VALUE) {
> -    DEBUG ((EFI_D_INFO, "OpenBlock: Could not open %S, %x\n", Private-
> >FileName, GetLastError ()));
> +    DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %S, %x\n", Private-
> >FileName, GetLastError ()));
>      Media->MediaPresent = FALSE;
>      Status = EFI_NO_MEDIA;
>      goto Done;
> @@ -124,14 +125,35 @@ WinNtBlockIoOpenDevice (
>    Status = SetFilePointer64 (Private, 0, &FileSize, FILE_END);
> 
>    if (EFI_ERROR (Status)) {
> -    DEBUG ((EFI_D_ERROR, "OpenBlock: Could not get filesize of %s\n", Private-
> >FileName));
> +    DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %s\n",
> Private->FileName));
>      Status = EFI_UNSUPPORTED;
>      goto Done;
>    }
> 
>    Media->LastBlock = DivU64x32 (FileSize, (UINT32)Private->BlockSize) - 1;
> 
> -  DEBUG ((EFI_D_INIT, "OpenBlock: opened %S\n", Private->FileName));
> +  EndOfFile = MultU64x32 (Media->LastBlock + 1, (UINT32)Private->BlockSize);
> +

Hi Ray,

The below logic seems actually zeroing out the file content if the file
size is not a multiple of block size. Could you help to double confirm
this one?

Best Regards,
Hao Wu

> +  if (FileSize != EndOfFile) {
> +    //
> +    // file is not the proper size, change it
> +    //
> +    DEBUG ((EFI_D_INIT, "PlOpenBlock: Initializing block device: %hs\n",
> Private->FileName));
> +
> +    //
> +    // first set it to 0
> +    //
> +    SetFilePointer64 (Private, 0, NULL, FILE_BEGIN);
> +    SetEndOfFile (Private->NtHandle);
> +
> +    //
> +    // then set it to the needed file size (OS will zero fill it)
> +    //
> +    SetFilePointer64 (Private, EndOfFile, NULL, FILE_BEGIN);
> +    SetEndOfFile (Private->NtHandle);
> +  }
> +
> +  DEBUG ((EFI_D_INIT, "PlOpenBlock: opened %S\n", Private->FileName));
>    Status = EFI_SUCCESS;
> 
>  Done:
> --
> 2.16.1.windows.1



  reply	other threads:[~2018-08-29  1:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-27  7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
2018-08-27  7:53 ` [PATCH 01/10] EmulatorPkg/EmuGopDxe: Fix TxtInEx.SetState SCT conformance failure Ruiyu Ni
2018-08-27  7:53 ` [PATCH 02/10] EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode Ruiyu Ni
2018-08-27  7:53 ` [PATCH 03/10] EmulatorPkg/Win: Use FrameBufferBltLib for BLT operation Ruiyu Ni
2018-08-27  7:53 ` [PATCH 04/10] EmulatorPkg/Win: ReadKeyStrokeEx() always returns correct KeyState Ruiyu Ni
2018-08-27  7:53 ` [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content Ruiyu Ni
2018-08-29  1:51   ` Wu, Hao A [this message]
2018-08-27  7:53 ` [PATCH 06/10] EmulatorPkg/Win: Enable 64bit (SEC, PEI, DXE all run at 64bit) Ruiyu Ni
2018-08-27  7:53 ` [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size Ruiyu Ni
2018-08-29  1:54   ` Wu, Hao A
2018-08-29  2:53     ` Ni, Ruiyu
2018-08-27  7:53 ` [PATCH 08/10] EmulatorPkg/Win: Add VS2017 project file Ruiyu Ni
2018-08-27  7:53 ` [PATCH 09/10] EmulatorPkg: Use MdeModulePkg/Bds module Ruiyu Ni
2018-08-27  7:53 ` [PATCH 10/10] EmulatorPkg: IoThunk->Close() is called too early, may causing hang Ruiyu Ni
2018-08-29  1:58 ` [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Wu, Hao A
2018-08-29  3:41   ` Ni, Ruiyu

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=B80AF82E9BFB8E4FBD8C89DA810C6A0931E3CD9A@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