mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
ArmPlatformPkg/BootMonFs: Don't write file header to media until Flush
This prevents writing to a garbage location if the file has not been flushed before, as its BlockStart and BlockEnd are not set. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brendan Jackman <brendan.jackman@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15514 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
35d3b52ddd
commit
dcaf7c9012
@ -389,12 +389,8 @@ SetFileInfo (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
|
||||||
UINT8 *DataBuffer;
|
|
||||||
UINTN BlockSize;
|
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
BlockIo = Instance->BlockIo;
|
|
||||||
|
|
||||||
// Note that a call to this function on a file opened read-only is only
|
// Note that a call to this function on a file opened read-only is only
|
||||||
// invalid if it actually changes fields, so we don't immediately fail if the
|
// invalid if it actually changes fields, so we don't immediately fail if the
|
||||||
@ -417,25 +413,6 @@ SetFileInfo (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Update the last block
|
|
||||||
//
|
|
||||||
BlockSize = BlockIo->Media->BlockSize;
|
|
||||||
DataBuffer = AllocatePool (BlockSize);
|
|
||||||
if (DataBuffer == NULL) {
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
Status = BlockIo->ReadBlocks (BlockIo, Instance->Media->MediaId,
|
|
||||||
File->HwDescription.BlockEnd, BlockSize, DataBuffer);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
FreePool (DataBuffer);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
CopyMem (DataBuffer + BlockSize - sizeof (File->HwDescription), &File->HwDescription, sizeof (File->HwDescription));
|
|
||||||
Status = BlockIo->WriteBlocks (BlockIo, Instance->Media->MediaId,
|
|
||||||
File->HwDescription.BlockEnd, BlockSize, DataBuffer);
|
|
||||||
FreePool (DataBuffer);
|
|
||||||
}
|
}
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user