Do not lock the volume when the volume maps to a file instead of a physical disk.

Otherwise WriteBlocks() on the volume which maps to a file will fail.

Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14588 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ruiyu Ni 2013-08-22 05:44:23 +00:00 committed by niruiyu
parent de49225db8
commit 04492de53f
1 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/**@file
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -990,11 +990,15 @@ WinNtBlockIoWriteBlocks (
// According the Windows requirement, first need to lock the volume before
// write to it.
//
Locked = Private->WinNtThunk->DeviceIoControl (Private->NtHandle, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &BytesReturned, NULL);
if (Locked == 0) {
DEBUG ((EFI_D_INIT, "ReadBlocks: Lock volume failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
Status = WinNtBlockIoError (Private);
goto Done;
if (Private->DeviceType == EfiWinNtPhysicalDisks) {
Locked = Private->WinNtThunk->DeviceIoControl (Private->NtHandle, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &BytesReturned, NULL);
if (Locked == 0) {
DEBUG ((EFI_D_INIT, "ReadBlocks: Lock volume failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
Status = WinNtBlockIoError (Private);
goto Done;
}
} else {
Locked = 0;
}
Flag = Private->WinNtThunk->WriteFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesWritten, NULL);
if (Locked != 0) {