Skip to content

Commit

Permalink
VolumeVerifier: Show underdump warnings for WBFS/CISO too
Browse files Browse the repository at this point in the history
  • Loading branch information
JosJuice committed Jun 29, 2019
1 parent 0dfff81 commit 8179e26
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
56 changes: 33 additions & 23 deletions Source/Core/DiscIO/VolumeVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,24 +382,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 @@ -457,7 +441,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 @@ -496,20 +480,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 @@ -749,10 +733,10 @@ void VolumeVerifier::Process()

while (m_block_index < m_blocks.size() && m_blocks[m_block_index].offset < m_progress)
{
const u64 offset = m_blocks[m_block_index].offset;
if (!m_volume.CheckBlockIntegrity(m_blocks[m_block_index].block_index,
m_blocks[m_block_index].partition))
{
const u64 offset = m_blocks[m_block_index].offset;
if (m_scrubber.CanBlockBeScrubbed(offset))
{
WARN_LOG(DISCIO, "Integrity check failed for unused block at 0x%" PRIx64, offset);
Expand All @@ -764,6 +748,11 @@ void VolumeVerifier::Process()
m_block_errors[m_blocks[m_block_index].partition]++;
}
}
else
{
m_biggest_verified_offset =
std::max(m_biggest_verified_offset, offset + VolumeWii::BLOCK_TOTAL_SIZE);
}
m_block_index++;
}
}
Expand Down Expand Up @@ -831,6 +820,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 @@ -99,8 +99,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();
bool CheckContentIntegrity(const IOS::ES::Content& content);
Expand All @@ -127,6 +127,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 8179e26

Please sign in to comment.