From 04492de53f40bb756b521d2a35744b38e08bc2a5 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Thu, 22 Aug 2013 05:44:23 +0000 Subject: [PATCH] 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 --- Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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) { -- 2.39.2