Skip to content

Commit

Permalink
Merge pull request dolphin-emu#8204 from JosJuice/volumeverifier-unde…
Browse files Browse the repository at this point in the history
…rdump-wbfs

VolumeVerifier: Show underdump warnings for WBFS/CISO too
  • Loading branch information
stenzek authored Aug 9, 2019
2 parents 428ae5a + 8c8bab3 commit b88e561
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
58 changes: 34 additions & 24 deletions Source/Core/DiscIO/VolumeVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,24 +383,8 @@ void VolumeVerifier::CheckDiscSize()
if (!IsDisc(m_volume.GetVolumeType()))
return;

const u64 biggest_offset = GetBiggestUsedOffset();
if (biggest_offset > m_volume.GetSize())
{
const bool second_layer_missing =
biggest_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
std::string text =
second_layer_missing ?
Common::GetStringT(
"This disc image is too small and lacks some data. The problem is most likely that "
"this is a dual-layer disc that has been dumped as a single-layer disc.") :
Common::GetStringT(
"This disc image is too small and lacks some data. If your dumping program saved "
"the disc image as several parts, you need to merge them into one file.");
AddProblem(Severity::High, std::move(text));
return;
}

if (ShouldBeDualLayer() && biggest_offset <= SL_DVD_R_SIZE)
m_biggest_referenced_offset = GetBiggestReferencedOffset();
if (ShouldBeDualLayer() && m_biggest_referenced_offset <= SL_DVD_R_SIZE)
{
AddProblem(Severity::Medium,
Common::GetStringT(
Expand Down Expand Up @@ -458,7 +442,7 @@ void VolumeVerifier::CheckDiscSize()
}
}

u64 VolumeVerifier::GetBiggestUsedOffset() const
u64 VolumeVerifier::GetBiggestReferencedOffset() const
{
std::vector<Partition> partitions = m_volume.GetPartitions();
if (partitions.empty())
Expand Down Expand Up @@ -497,20 +481,20 @@ u64 VolumeVerifier::GetBiggestUsedOffset() const
if (fs)
{
const u64 offset =
m_volume.PartitionOffsetToRawOffset(GetBiggestUsedOffset(fs->GetRoot()), partition);
m_volume.PartitionOffsetToRawOffset(GetBiggestReferencedOffset(fs->GetRoot()), partition);
biggest_offset = std::max(biggest_offset, offset);
}
}
return biggest_offset;
}

u64 VolumeVerifier::GetBiggestUsedOffset(const FileInfo& file_info) const
u64 VolumeVerifier::GetBiggestReferencedOffset(const FileInfo& file_info) const
{
if (file_info.IsDirectory())
{
u64 biggest_offset = 0;
for (const FileInfo& f : file_info)
biggest_offset = std::max(biggest_offset, GetBiggestUsedOffset(f));
biggest_offset = std::max(biggest_offset, GetBiggestReferencedOffset(f));
return biggest_offset;
}
else
Expand Down Expand Up @@ -821,9 +805,14 @@ void VolumeVerifier::Process()
m_blocks[block_index].partition);
}

if (!success)
const u64 offset = m_blocks[block_index].offset;
if (success)
{
m_biggest_verified_offset =
std::max(m_biggest_verified_offset, offset + VolumeWii::BLOCK_TOTAL_SIZE);
}
else
{
const u64 offset = m_blocks[block_index].offset;
if (m_scrubber.CanBlockBeScrubbed(offset))
{
WARN_LOG(DISCIO, "Integrity check failed for unused block at 0x%" PRIx64, offset);
Expand Down Expand Up @@ -894,6 +883,27 @@ void VolumeVerifier::Finish()
}
}

if (IsDisc(m_volume.GetVolumeType()) &&
(m_volume.IsSizeAccurate() || m_volume.SupportsIntegrityCheck()))
{
u64 volume_size = m_volume.IsSizeAccurate() ? m_volume.GetSize() : m_biggest_verified_offset;
if (m_biggest_referenced_offset > volume_size)
{
const bool second_layer_missing =
m_biggest_referenced_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
std::string text =
second_layer_missing ?
Common::GetStringT("This disc image is too small and lacks some data. The problem is "
"most likely that this is a dual-layer disc that has been dumped "
"as a single-layer disc.") :
Common::GetStringT("This disc image is too small and lacks some data. If your "
"dumping program saved the disc image as several parts, you need "
"to merge them into one file.");
AddProblem(Severity::High, std::move(text));
return;
}
}

for (auto [partition, blocks] : m_block_errors)
{
if (blocks > 0)
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/DiscIO/VolumeVerifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class VolumeVerifier final
bool ShouldHaveMasterpiecePartitions() const;
bool ShouldBeDualLayer() const;
void CheckDiscSize();
u64 GetBiggestUsedOffset() const;
u64 GetBiggestUsedOffset(const FileInfo& file_info) const;
u64 GetBiggestReferencedOffset() const;
u64 GetBiggestReferencedOffset(const FileInfo& file_info) const;
void CheckMisc();
void SetUpHashing();
void WaitForAsyncOperations() const;
Expand Down Expand Up @@ -134,6 +134,9 @@ class VolumeVerifier final
std::map<Partition, size_t> m_block_errors;
std::map<Partition, size_t> m_unused_block_errors;

u64 m_biggest_referenced_offset = 0;
u64 m_biggest_verified_offset = 0;

bool m_started = false;
bool m_done = false;
u64 m_progress = 0;
Expand Down

0 comments on commit b88e561

Please sign in to comment.