mirror of https://github.com/acidanthera/audk.git
Add a lock to protect the critical region in Service APIs for gEfiBlockIoProtocolGuid and gEfiSimpleFileSystemProtocolGuid Protocol to prevent re-entrance of the same API from from different TPL level. In UEFI 2.1 spec, it is state that the service API for this Protocol is callable at EFI_TPL_CALLBACK level.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2450 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
ac10bddd8e
commit
1a682c8c37
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006 - 2007, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -851,25 +851,33 @@ WinNtBlockIoReadBlocks (
|
||||||
BOOL Flag;
|
BOOL Flag;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
DWORD BytesRead;
|
DWORD BytesRead;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtReadBlocks");
|
Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtReadBlocks");
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);
|
Flag = Private->WinNtThunk->ReadFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesRead, NULL);
|
||||||
if (!Flag || (BytesRead != BufferSize)) {
|
if (!Flag || (BytesRead != BufferSize)) {
|
||||||
DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
|
DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
|
||||||
return WinNtBlockIoError (Private);
|
Status = WinNtBlockIoError (Private);
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we wrote then media is present.
|
// If we wrote then media is present.
|
||||||
//
|
//
|
||||||
This->Media->MediaPresent = TRUE;
|
This->Media->MediaPresent = TRUE;
|
||||||
return EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
Done:
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
|
@ -911,18 +919,22 @@ WinNtBlockIoWriteBlocks (
|
||||||
UINTN BytesWritten;
|
UINTN BytesWritten;
|
||||||
BOOL Flag;
|
BOOL Flag;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtWriteBlocks");
|
Status = WinNtBlockIoReadWriteCommon (Private, MediaId, Lba, BufferSize, Buffer, "WinNtWriteBlocks");
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
Flag = Private->WinNtThunk->WriteFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesWritten, NULL);
|
Flag = Private->WinNtThunk->WriteFile (Private->NtHandle, Buffer, (DWORD) BufferSize, (LPDWORD) &BytesWritten, NULL);
|
||||||
if (!Flag || (BytesWritten != BufferSize)) {
|
if (!Flag || (BytesWritten != BufferSize)) {
|
||||||
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
|
DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed. (%d)\n", Private->WinNtThunk->GetLastError ()));
|
||||||
return WinNtBlockIoError (Private);
|
Status = WinNtBlockIoError (Private);
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -930,7 +942,12 @@ WinNtBlockIoWriteBlocks (
|
||||||
//
|
//
|
||||||
This->Media->MediaPresent = TRUE;
|
This->Media->MediaPresent = TRUE;
|
||||||
This->Media->ReadOnly = FALSE;
|
This->Media->ReadOnly = FALSE;
|
||||||
return EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
Done:
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
return Status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
|
@ -981,6 +998,9 @@ WinNtBlockIoResetBlock (
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
WIN_NT_BLOCK_IO_PRIVATE *Private;
|
WIN_NT_BLOCK_IO_PRIVATE *Private;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
Private = WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
|
@ -989,6 +1009,8 @@ WinNtBlockIoResetBlock (
|
||||||
Private->NtHandle = INVALID_HANDLE_VALUE;
|
Private->NtHandle = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006 - 2007, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -478,11 +478,14 @@ Returns:
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
|
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
|
||||||
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL || Root == NULL) {
|
if (This == NULL || Root == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);
|
Private = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
PrivateFile = NULL;
|
PrivateFile = NULL;
|
||||||
|
@ -557,6 +560,8 @@ Done:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,9 +667,6 @@ Returns:
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
|
PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
|
||||||
NewPrivateFile = NULL;
|
NewPrivateFile = NULL;
|
||||||
|
@ -1112,11 +1114,14 @@ Returns:
|
||||||
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
|
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
|
||||||
{
|
{
|
||||||
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
if (PrivateFile->LHandle != INVALID_HANDLE_VALUE) {
|
if (PrivateFile->LHandle != INVALID_HANDLE_VALUE) {
|
||||||
|
@ -1139,6 +1144,9 @@ Returns:
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (PrivateFile);
|
gBS->FreePool (PrivateFile);
|
||||||
|
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1168,11 +1176,14 @@ Returns:
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
Status = EFI_WARN_DELETE_FAILURE;
|
Status = EFI_WARN_DELETE_FAILURE;
|
||||||
|
@ -1204,6 +1215,8 @@ Returns:
|
||||||
gBS->FreePool (PrivateFile->FileName);
|
gBS->FreePool (PrivateFile->FileName);
|
||||||
gBS->FreePool (PrivateFile);
|
gBS->FreePool (PrivateFile);
|
||||||
|
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1297,21 +1310,26 @@ Returns:
|
||||||
UINT64 Pos;
|
UINT64 Pos;
|
||||||
UINT64 FileSize;
|
UINT64 FileSize;
|
||||||
UINTN FileInfoSize;
|
UINTN FileInfoSize;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL || BufferSize == NULL || Buffer == NULL) {
|
if (This == NULL || BufferSize == NULL || Buffer == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {
|
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PrivateFile->IsDirectoryPath) {
|
if (!PrivateFile->IsDirectoryPath) {
|
||||||
|
|
||||||
if (This->GetPosition (This, &Pos) != EFI_SUCCESS) {
|
if (This->GetPosition (This, &Pos) != EFI_SUCCESS) {
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInfoSize = SIZE_OF_EFI_FILE_SYSTEM_INFO;
|
FileInfoSize = SIZE_OF_EFI_FILE_SYSTEM_INFO;
|
||||||
|
@ -1344,7 +1362,8 @@ Returns:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSize = FileInfo->FileSize;
|
FileSize = FileInfo->FileSize;
|
||||||
|
@ -1354,19 +1373,22 @@ Returns:
|
||||||
if (Pos >= FileSize) {
|
if (Pos >= FileSize) {
|
||||||
*BufferSize = 0;
|
*BufferSize = 0;
|
||||||
if (Pos == FileSize) {
|
if (Pos == FileSize) {
|
||||||
return EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
goto Done;
|
||||||
} else {
|
} else {
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PrivateFile->WinNtThunk->ReadFile (
|
Status = PrivateFile->WinNtThunk->ReadFile (
|
||||||
PrivateFile->LHandle,
|
PrivateFile->LHandle,
|
||||||
Buffer,
|
Buffer,
|
||||||
*BufferSize,
|
*BufferSize,
|
||||||
BufferSize,
|
BufferSize,
|
||||||
NULL
|
NULL
|
||||||
) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
|
) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1374,7 +1396,8 @@ Returns:
|
||||||
//
|
//
|
||||||
if (!PrivateFile->IsValidFindBuf) {
|
if (!PrivateFile->IsValidFindBuf) {
|
||||||
*BufferSize = 0;
|
*BufferSize = 0;
|
||||||
return EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size = SIZE_OF_EFI_FILE_INFO;
|
Size = SIZE_OF_EFI_FILE_INFO;
|
||||||
|
@ -1454,6 +1477,8 @@ Returns:
|
||||||
|
|
||||||
*BufferSize = ResultSize;
|
*BufferSize = ResultSize;
|
||||||
|
|
||||||
|
Done:
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1501,26 +1526,33 @@ Returns:
|
||||||
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
|
// TODO: EFI_INVALID_PARAMETER - add return value to function comment
|
||||||
{
|
{
|
||||||
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL || BufferSize == NULL || Buffer == NULL) {
|
if (This == NULL || BufferSize == NULL || Buffer == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {
|
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrivateFile->IsDirectoryPath) {
|
if (PrivateFile->IsDirectoryPath) {
|
||||||
return EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrivateFile->IsOpenedByRead) {
|
if (PrivateFile->IsOpenedByRead) {
|
||||||
return EFI_ACCESS_DENIED;
|
Status = EFI_ACCESS_DENIED;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PrivateFile->WinNtThunk->WriteFile (
|
Status = PrivateFile->WinNtThunk->WriteFile (
|
||||||
PrivateFile->LHandle,
|
PrivateFile->LHandle,
|
||||||
Buffer,
|
Buffer,
|
||||||
*BufferSize,
|
*BufferSize,
|
||||||
|
@ -1528,6 +1560,10 @@ Returns:
|
||||||
NULL
|
NULL
|
||||||
) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
|
) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
|
||||||
|
|
||||||
|
Done:
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
return Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// bugbug: need to access windows error reporting
|
// bugbug: need to access windows error reporting
|
||||||
//
|
//
|
||||||
|
@ -1565,16 +1601,20 @@ Returns:
|
||||||
UINT32 PosLow;
|
UINT32 PosLow;
|
||||||
UINT32 PosHigh;
|
UINT32 PosHigh;
|
||||||
CHAR16 *FileName;
|
CHAR16 *FileName;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
if (PrivateFile->IsDirectoryPath) {
|
if (PrivateFile->IsDirectoryPath) {
|
||||||
if (Position != 0) {
|
if (Position != 0) {
|
||||||
return EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->AllocatePool (
|
Status = gBS->AllocatePool (
|
||||||
|
@ -1584,7 +1624,7 @@ Returns:
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrCpy (FileName, PrivateFile->FileName);
|
StrCpy (FileName, PrivateFile->FileName);
|
||||||
|
@ -1617,6 +1657,8 @@ Returns:
|
||||||
Status = (PosLow == 0xFFFFFFFF) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
|
Status = (PosLow == 0xFFFFFFFF) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Done:
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,11 +1693,13 @@ Returns:
|
||||||
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
||||||
INT32 PositionHigh;
|
INT32 PositionHigh;
|
||||||
UINT64 PosHigh64;
|
UINT64 PosHigh64;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL || Position == NULL) {
|
if (This == NULL || Position == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
PositionHigh = 0;
|
PositionHigh = 0;
|
||||||
|
@ -1663,7 +1707,8 @@ Returns:
|
||||||
|
|
||||||
if (PrivateFile->IsDirectoryPath) {
|
if (PrivateFile->IsDirectoryPath) {
|
||||||
|
|
||||||
return EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
|
goto Done;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -1685,6 +1730,7 @@ Returns:
|
||||||
}
|
}
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1868,11 +1914,14 @@ Returns:
|
||||||
BOOL NtStatus;
|
BOOL NtStatus;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
|
WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE *PrivateRoot;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL || InformationType == NULL || BufferSize == NULL) {
|
if (This == NULL || InformationType == NULL || BufferSize == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
|
PrivateRoot = WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
|
||||||
|
|
||||||
|
@ -1885,7 +1934,8 @@ Returns:
|
||||||
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
|
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
|
||||||
if (*BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {
|
if (*BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {
|
||||||
*BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
|
*BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
|
||||||
return EFI_BUFFER_TOO_SMALL;
|
Status = EFI_BUFFER_TOO_SMALL;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *) Buffer;
|
FileSystemInfoBuffer = (EFI_FILE_SYSTEM_INFO *) Buffer;
|
||||||
|
@ -1903,7 +1953,7 @@ Returns:
|
||||||
&DriveName
|
&DriveName
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrCpy (DriveName, PrivateFile->FilePath);
|
StrCpy (DriveName, PrivateFile->FilePath);
|
||||||
|
@ -1966,7 +2016,8 @@ Returns:
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (!NtStatus) {
|
if (!NtStatus) {
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1978,7 +2029,8 @@ Returns:
|
||||||
if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
|
if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
|
||||||
if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
|
if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
|
||||||
*BufferSize = StrSize (PrivateRoot->VolumeLabel);
|
*BufferSize = StrSize (PrivateRoot->VolumeLabel);
|
||||||
return EFI_BUFFER_TOO_SMALL;
|
Status = EFI_BUFFER_TOO_SMALL;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrCpy ((CHAR16 *) Buffer, PrivateRoot->VolumeLabel);
|
StrCpy ((CHAR16 *) Buffer, PrivateRoot->VolumeLabel);
|
||||||
|
@ -1986,6 +2038,8 @@ Returns:
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Done:
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2063,6 +2117,7 @@ Returns:
|
||||||
FILETIME NewLastWriteFileTime;
|
FILETIME NewLastWriteFileTime;
|
||||||
WIN32_FIND_DATA FindBuf;
|
WIN32_FIND_DATA FindBuf;
|
||||||
EFI_FILE_SYSTEM_INFO *NewFileSystemInfo;
|
EFI_FILE_SYSTEM_INFO *NewFileSystemInfo;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check for invalid parameters.
|
// Check for invalid parameters.
|
||||||
|
@ -2071,6 +2126,8 @@ Returns:
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialise locals.
|
// Initialise locals.
|
||||||
//
|
//
|
||||||
|
@ -2087,7 +2144,8 @@ Returns:
|
||||||
//
|
//
|
||||||
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
|
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
|
||||||
if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {
|
if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer;
|
NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer;
|
||||||
|
@ -2107,7 +2165,8 @@ Returns:
|
||||||
|
|
||||||
StrCpy (PrivateRoot->VolumeLabel, NewFileSystemInfo->VolumeLabel);
|
StrCpy (PrivateRoot->VolumeLabel, NewFileSystemInfo->VolumeLabel);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2115,20 +2174,24 @@ Returns:
|
||||||
//
|
//
|
||||||
if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
|
if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
|
||||||
if (BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
|
if (BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrCpy (PrivateRoot->VolumeLabel, (CHAR16 *) Buffer);
|
StrCpy (PrivateRoot->VolumeLabel, (CHAR16 *) Buffer);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CompareGuid (InformationType, &gEfiFileInfoGuid)) {
|
if (!CompareGuid (InformationType, &gEfiFileInfoGuid)) {
|
||||||
return EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BufferSize < SIZE_OF_EFI_FILE_INFO) {
|
if (BufferSize < SIZE_OF_EFI_FILE_INFO) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2144,7 +2207,8 @@ Returns:
|
||||||
(NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
|
(NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
|
||||||
(sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF)
|
(sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF)
|
||||||
) {
|
) {
|
||||||
return EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2573,6 +2637,7 @@ Done:
|
||||||
gBS->FreePool (NewFileName);
|
gBS->FreePool (NewFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2612,35 +2677,47 @@ Returns:
|
||||||
{
|
{
|
||||||
BY_HANDLE_FILE_INFORMATION FileInfo;
|
BY_HANDLE_FILE_INFORMATION FileInfo;
|
||||||
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
WIN_NT_EFI_FILE_PRIVATE *PrivateFile;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_TPL OldTpl;
|
||||||
|
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OldTpl = gBS->RaiseTPL (EFI_TPL_CALLBACK);
|
||||||
|
|
||||||
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
PrivateFile = WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
|
||||||
|
|
||||||
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {
|
if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {
|
||||||
return EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrivateFile->IsDirectoryPath) {
|
if (PrivateFile->IsDirectoryPath) {
|
||||||
return EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrivateFile->IsOpenedByRead) {
|
if (PrivateFile->IsOpenedByRead) {
|
||||||
return EFI_ACCESS_DENIED;
|
Status = EFI_ACCESS_DENIED;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivateFile->WinNtThunk->GetFileInformationByHandle (PrivateFile->LHandle, &FileInfo);
|
PrivateFile->WinNtThunk->GetFileInformationByHandle (PrivateFile->LHandle, &FileInfo);
|
||||||
|
|
||||||
if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
|
if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
|
||||||
return EFI_ACCESS_DENIED;
|
Status = EFI_ACCESS_DENIED;
|
||||||
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PrivateFile->WinNtThunk->FlushFileBuffers (PrivateFile->LHandle) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
|
Status = PrivateFile->WinNtThunk->FlushFileBuffers (PrivateFile->LHandle) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
|
||||||
|
|
||||||
|
Done:
|
||||||
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
return Status;
|
||||||
//
|
//
|
||||||
// bugbug: - Use Windows error reporting.
|
// bugbug: - Use Windows error reporting.
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue