Skip to content

Commit

Permalink
Log the specific sectors that failed validation
Browse files Browse the repository at this point in the history
  • Loading branch information
TalAloni committed Nov 18, 2017
1 parent 8c3b52c commit 00d4ec3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions HardDiskValidator/DiskTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ private BlockStatus PerformVerifyTest(long sectorIndex, long sectorCount)
GC.Collect();
GC.WaitForPendingFinalizers();

byte[] pattern = GetTestPattern(sectorIndex + sectorOffset, sectorsToRead, Disk.BytesPerSector);
byte[] buffer;
try
{
Expand All @@ -292,11 +291,18 @@ private BlockStatus PerformVerifyTest(long sectorIndex, long sectorCount)
return BlockStatus.Untested;
}

if (!ByteUtils.AreByteArraysEqual(pattern, buffer))
BlockStatus status = BlockStatus.OK;
for (int position = 0; position < sectorsToRead; position++)
{
AddToLog("Verification mismatch at sectors {0:###,###,###,###,##0}-{1:###,###,###,###,##0}", sectorIndex, sectorIndex + sectorsToRead - 1);
return BlockStatus.Damaged;
byte[] pattern = GetTestPattern(sectorIndex + sectorOffset + position, Disk.BytesPerSector);
byte[] sectorBytes = ByteReader.ReadBytes(buffer, position * Disk.BytesPerSector, Disk.BytesPerSector);
if (!ByteUtils.AreByteArraysEqual(pattern, sectorBytes))
{
status = BlockStatus.Damaged;
AddToLog("Verification mismatch at sector {0:###,###,###,###,###}", sectorIndex + sectorOffset + position);
}
}
return status;
}

return BlockStatus.OK;
Expand Down

0 comments on commit 00d4ec3

Please sign in to comment.