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:
Brendan Jackman 2014-05-08 15:04:16 +00:00 committed by oliviermartin
parent 35d3b52ddd
commit dcaf7c9012
1 changed files with 1 additions and 24 deletions

View File

@ -389,12 +389,8 @@ SetFileInfo (
)
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
UINT8 *DataBuffer;
UINTN BlockSize;
Status = EFI_SUCCESS;
BlockIo = Instance->BlockIo;
Status = EFI_SUCCESS;
// 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
@ -417,25 +413,6 @@ SetFileInfo (
if (EFI_ERROR (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;
}