/* Write zero pool from the WritePos to the end of OFile. */
EFI_STATUS FatWriteZeroPool(IN FAT_OFILE *OFile, IN UINTN WritePos)
/* Write zero pool from the WritePos to the end of OFile. */
EFI_STATUS FatWriteZeroPool(IN FAT_OFILE *OFile, IN UINTN WritePos)
{
  EFI_STATUS  Status;
  VOID        *ZeroBuffer;
  UINTN       AppendedSize;
  UINTN       BufferSize;
  UINTN       WriteSize;
  AppendedSize = OFile->FileSize - WritePos;
  BufferSize   = AppendedSize;
  if (AppendedSize > FAT_MAX_ALLOCATE_SIZE) {
    BufferSize = FAT_MAX_ALLOCATE_SIZE;
  }
  ZeroBuffer = AllocateZeroPool (BufferSize);
  if (ZeroBuffer == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }
  do {
    WriteSize     = AppendedSize > BufferSize ? BufferSize : (UINTN)AppendedSize;
    AppendedSize -= WriteSize;
    Status        = FatAccessOFile (OFile, WriteData, WritePos, &WriteSize, ZeroBuffer, NULL);
    if (EFI_ERROR (Status)) {
      break;
    }
    WritePos += WriteSize;
  } while (AppendedSize > 0);
  FreePool (ZeroBuffer);
  return Status;
}