From: Ruiyu Ni Date: Thu, 22 Aug 2013 05:44:23 +0000 (+0000) Subject: Do not lock the volume when the volume maps to a file instead of a physical disk. X-Git-Tag: edk2-stable201903~12318 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=04492de53f40bb756b521d2a35744b38e08bc2a5;hp=de49225db86a2209fc09afb1baade3db1542b0cb 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 Reviewed-by: Eric Dong git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14588 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c index 1e12dd5204..12924e659f 100644 --- a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c +++ b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c @@ -1,6 +1,6 @@ /**@file -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
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) {