REFACTOR: Fixed MOST name inconsistencies.

This commit is contained in:
2017-12-20 17:15:26 +00:00
parent 542520f5cd
commit a4650c61aa
428 changed files with 16205 additions and 16320 deletions

View File

@@ -38,17 +38,17 @@ using DiscImageChef.Devices;
namespace DiscImageChef.Core.Devices.Scanning
{
public static class ATA
public static class Ata
{
public static ScanResults Scan(string MHDDLogPath, string IBGLogPath, string devicePath, Device dev)
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
{
ScanResults results = new ScanResults();
bool aborted;
MHDDLog mhddLog;
IBGLog ibgLog;
MhddLog mhddLog;
IbgLog ibgLog;
byte[] cmdBuf;
bool sense;
results.blocks = 0;
results.Blocks = 0;
ushort currentProfile = 0x0001;
Decoders.ATA.AtaErrorRegistersCHS errorChs;
uint timeout = 5;
@@ -62,7 +62,7 @@ namespace DiscImageChef.Core.Devices.Scanning
// Initializate reader
Reader ataReader = new Reader(dev, timeout, cmdBuf);
// Fill reader blocks
results.blocks = ataReader.GetDeviceBlocks();
results.Blocks = ataReader.GetDeviceBlocks();
if(ataReader.FindReadCommand())
{
DicConsole.ErrorWriteLine(ataReader.ErrorMessage);
@@ -94,24 +94,24 @@ namespace DiscImageChef.Core.Devices.Scanning
results.D = 0; // >=50ms, <150ms
results.E = 0; // >=150ms, <500ms
results.F = 0; // >=500ms
results.errored = 0;
results.Errored = 0;
DateTime start;
DateTime end;
results.processingTime = 0;
results.ProcessingTime = 0;
double currentSpeed = 0;
results.maxSpeed = double.MinValue;
results.minSpeed = double.MaxValue;
results.unreadableSectors = new List<ulong>();
results.seekMax = double.MinValue;
results.seekMin = double.MaxValue;
results.seekTotal = 0;
const int seekTimes = 1000;
results.MaxSpeed = double.MinValue;
results.MinSpeed = double.MaxValue;
results.UnreadableSectors = new List<ulong>();
results.SeekMax = double.MinValue;
results.SeekMin = double.MaxValue;
results.SeekTotal = 0;
const int SEEK_TIMES = 1000;
double seekCur = 0;
Random rnd = new Random();
uint seekPos = (uint)rnd.Next((int)results.blocks);
uint seekPos = (uint)rnd.Next((int)results.Blocks);
ushort seekCy = (ushort)rnd.Next(cylinders);
byte seekHd = (byte)rnd.Next(heads);
byte seekSc = (byte)rnd.Next(sectors);
@@ -119,26 +119,26 @@ namespace DiscImageChef.Core.Devices.Scanning
aborted = false;
System.Console.CancelKeyPress += (sender, e) => { e.Cancel = aborted = true; };
if(ataReader.IsLBA)
if(ataReader.IsLba)
{
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MHDDLog(MHDDLogPath, dev, results.blocks, blockSize, blocksToRead);
ibgLog = new IBGLog(IBGLogPath, currentProfile);
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile);
start = DateTime.UtcNow;
for(ulong i = 0; i < results.blocks; i += blocksToRead)
for(ulong i = 0; i < results.Blocks; i += blocksToRead)
{
if(aborted) break;
if((results.blocks - i) < blocksToRead) blocksToRead = (byte)(results.blocks - i);
if((results.Blocks - i) < blocksToRead) blocksToRead = (byte)(results.Blocks - i);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(currentSpeed > results.maxSpeed && currentSpeed != 0) results.maxSpeed = currentSpeed;
if(currentSpeed < results.minSpeed && currentSpeed != 0) results.minSpeed = currentSpeed;
if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed && currentSpeed != 0) results.MinSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks,
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks,
currentSpeed);
bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration);
@@ -157,8 +157,8 @@ namespace DiscImageChef.Core.Devices.Scanning
}
else
{
results.errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.unreadableSectors.Add(b);
results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(duration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, duration);
@@ -176,60 +176,60 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine();
mhddLog.Close();
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.blocks + 1)) / 1024) /
(results.processingTime / 1000), devicePath);
ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.Blocks + 1)) / 1024) /
(results.ProcessingTime / 1000), devicePath);
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
if(ataReader.CanSeekLBA)
if(ataReader.CanSeekLba)
{
for(int i = 0; i < seekTimes; i++)
for(int i = 0; i < SEEK_TIMES; i++)
{
if(aborted) break;
seekPos = (uint)rnd.Next((int)results.blocks);
seekPos = (uint)rnd.Next((int)results.Blocks);
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
ataReader.Seek(seekPos, out seekCur);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(seekCur > results.seekMax && seekCur != 0) results.seekMax = seekCur;
if(seekCur < results.seekMin && seekCur != 0) results.seekMin = seekCur;
if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur;
if(seekCur < results.SeekMin && seekCur != 0) results.SeekMin = seekCur;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
results.seekTotal += seekCur;
results.SeekTotal += seekCur;
GC.Collect();
}
}
}
else
{
mhddLog = new MHDDLog(MHDDLogPath, dev, results.blocks, blockSize, blocksToRead);
ibgLog = new IBGLog(IBGLogPath, currentProfile);
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile);
ulong currentBlock = 0;
results.blocks = (ulong)(cylinders * heads * sectors);
results.Blocks = (ulong)(cylinders * heads * sectors);
start = DateTime.UtcNow;
for(ushort Cy = 0; Cy < cylinders; Cy++)
for(ushort cy = 0; cy < cylinders; cy++)
{
for(byte Hd = 0; Hd < heads; Hd++)
for(byte hd = 0; hd < heads; hd++)
{
for(byte Sc = 1; Sc < sectors; Sc++)
for(byte sc = 1; sc < sectors; sc++)
{
if(aborted) break;
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(currentSpeed > results.maxSpeed && currentSpeed != 0)
results.maxSpeed = currentSpeed;
if(currentSpeed < results.minSpeed && currentSpeed != 0)
results.minSpeed = currentSpeed;
if(currentSpeed > results.MaxSpeed && currentSpeed != 0)
results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed && currentSpeed != 0)
results.MinSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", Cy, Hd,
Sc, currentSpeed);
DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", cy, hd,
sc, currentSpeed);
bool error = ataReader.ReadCHS(out cmdBuf, Cy, Hd, Sc, out duration);
bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration);
if(!error)
{
@@ -245,8 +245,8 @@ namespace DiscImageChef.Core.Devices.Scanning
}
else
{
results.errored += blocksToRead;
results.unreadableSectors.Add(currentBlock);
results.Errored += blocksToRead;
results.UnreadableSectors.Add(currentBlock);
if(duration < 500) mhddLog.Write(currentBlock, 65535);
else mhddLog.Write(currentBlock, duration);
@@ -267,14 +267,14 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine();
mhddLog.Close();
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.blocks + 1)) / 1024) /
(results.processingTime / 1000), devicePath);
ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.Blocks + 1)) / 1024) /
(results.ProcessingTime / 1000), devicePath);
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
if(ataReader.CanSeek)
{
for(int i = 0; i < seekTimes; i++)
for(int i = 0; i < SEEK_TIMES; i++)
{
if(aborted) break;
@@ -285,14 +285,14 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.Write("\rSeeking to cylinder {0}, head {1}, sector {2}...\t\t", seekCy, seekHd,
seekSc);
ataReader.SeekCHS(seekCy, seekHd, seekSc, out seekCur);
ataReader.SeekChs(seekCy, seekHd, seekSc, out seekCur);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(seekCur > results.seekMax && seekCur != 0) results.seekMax = seekCur;
if(seekCur < results.seekMin && seekCur != 0) results.seekMin = seekCur;
if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur;
if(seekCur < results.SeekMin && seekCur != 0) results.SeekMin = seekCur;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
results.seekTotal += seekCur;
results.SeekTotal += seekCur;
GC.Collect();
}
}
@@ -300,13 +300,13 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine();
results.processingTime /= 1000;
results.totalTime = (end - start).TotalSeconds;
results.ProcessingTime /= 1000;
results.TotalTime = (end - start).TotalSeconds;
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
results.avgSpeed = (((double)blockSize * (double)(results.blocks + 1)) / 1048576) /
results.processingTime;
results.AvgSpeed = (((double)blockSize * (double)(results.Blocks + 1)) / 1048576) /
results.ProcessingTime;
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
results.seekTimes = seekTimes;
results.SeekTimes = SEEK_TIMES;
return results;
}

View File

@@ -35,9 +35,9 @@ using DiscImageChef.Devices;
namespace DiscImageChef.Core.Devices.Scanning
{
public static class NVMe
public static class Nvme
{
public static ScanResults Scan(string MHDDLogPath, string IBGLogPath, string devicePath, Device dev)
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
{
throw new NotImplementedException("NVMe devices not yet supported.");
}

View File

@@ -38,19 +38,19 @@ using DiscImageChef.Devices;
namespace DiscImageChef.Core.Devices.Scanning
{
public static class SCSI
public static class Scsi
{
public static ScanResults Scan(string MHDDLogPath, string IBGLogPath, string devicePath, Device dev)
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
{
ScanResults results = new ScanResults();
bool aborted;
MHDDLog mhddLog;
IBGLog ibgLog;
MhddLog mhddLog;
IbgLog ibgLog;
byte[] cmdBuf;
byte[] senseBuf;
bool sense = false;
double duration;
results.blocks = 0;
results.Blocks = 0;
uint blockSize = 0;
ushort currentProfile = 0x0001;
@@ -139,15 +139,15 @@ namespace DiscImageChef.Core.Devices.Scanning
Reader scsiReader = null;
if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.DirectAccess ||
dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice ||
dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice ||
dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice ||
dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice ||
dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice)
if(dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.DirectAccess ||
dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice ||
dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice ||
dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice ||
dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice ||
dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice)
{
scsiReader = new Reader(dev, dev.Timeout, null, false);
results.blocks = scsiReader.GetDeviceBlocks();
results.Blocks = scsiReader.GetDeviceBlocks();
if(scsiReader.FindReadCommand())
{
DicConsole.ErrorWriteLine("Unable to read medium.");
@@ -156,24 +156,24 @@ namespace DiscImageChef.Core.Devices.Scanning
blockSize = scsiReader.LogicalBlockSize;
if(results.blocks != 0 && blockSize != 0)
if(results.Blocks != 0 && blockSize != 0)
{
results.blocks++;
results.Blocks++;
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)",
results.blocks, blockSize, results.blocks * (ulong)blockSize);
results.Blocks, blockSize, results.Blocks * (ulong)blockSize);
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
}
}
if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess)
if(dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess)
{
DicConsole.WriteLine("Scanning will never be supported on SCSI Streaming Devices.");
DicConsole.WriteLine("It has no sense to do it, and it will put too much strain on the tape.");
return results;
}
if(results.blocks == 0)
if(results.Blocks == 0)
{
DicConsole.ErrorWriteLine("Unable to read medium or empty medium present...");
return results;
@@ -182,7 +182,7 @@ namespace DiscImageChef.Core.Devices.Scanning
bool compactDisc = true;
Decoders.CD.FullTOC.CDFullTOC? toc = null;
if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice)
if(dev.ScsiType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice)
{
sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout,
out duration);
@@ -227,15 +227,15 @@ namespace DiscImageChef.Core.Devices.Scanning
results.D = 0; // >=50ms, <150ms
results.E = 0; // >=150ms, <500ms
results.F = 0; // >=500ms
results.errored = 0;
results.Errored = 0;
DateTime start;
DateTime end;
results.processingTime = 0;
results.totalTime = 0;
results.ProcessingTime = 0;
results.TotalTime = 0;
double currentSpeed = 0;
results.maxSpeed = double.MinValue;
results.minSpeed = double.MaxValue;
results.unreadableSectors = new List<ulong>();
results.MaxSpeed = double.MinValue;
results.MinSpeed = double.MaxValue;
results.UnreadableSectors = new List<ulong>();
aborted = false;
System.Console.CancelKeyPress += (sender, e) => { e.Cancel = aborted = true; };
@@ -279,30 +279,30 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MHDDLog(MHDDLogPath, dev, results.blocks, blockSize, blocksToRead);
ibgLog = new IBGLog(IBGLogPath, currentProfile);
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile);
for(ulong i = 0; i < results.blocks; i += blocksToRead)
for(ulong i = 0; i < results.Blocks; i += blocksToRead)
{
if(aborted) break;
double cmdDuration = 0;
if((results.blocks - i) < blocksToRead) blocksToRead = (uint)(results.blocks - i);
if((results.Blocks - i) < blocksToRead) blocksToRead = (uint)(results.Blocks - i);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(currentSpeed > results.maxSpeed && currentSpeed != 0) results.maxSpeed = currentSpeed;
if(currentSpeed < results.minSpeed && currentSpeed != 0) results.minSpeed = currentSpeed;
if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed && currentSpeed != 0) results.MinSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks, currentSpeed);
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks, currentSpeed);
if(readcd)
{
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)i, 2352, blocksToRead,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out cmdDuration);
results.processingTime += cmdDuration;
results.ProcessingTime += cmdDuration;
}
if(!sense)
@@ -332,8 +332,8 @@ namespace DiscImageChef.Core.Devices.Scanning
// are in a track where subchannel indicates data)
(senseDecoded.Value.ASC != 0x64 || senseDecoded.Value.ASCQ != 0x00))
{
results.errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.unreadableSectors.Add(b);
results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, cmdDuration);
@@ -343,8 +343,8 @@ namespace DiscImageChef.Core.Devices.Scanning
}
else
{
results.errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.unreadableSectors.Add(b);
results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, cmdDuration);
@@ -363,9 +363,9 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine();
mhddLog.Close();
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.blocks + 1)) / 1024) /
(results.processingTime / 1000), devicePath);
ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.Blocks + 1)) / 1024) /
(results.ProcessingTime / 1000), devicePath);
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
}
else
@@ -374,26 +374,26 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MHDDLog(MHDDLogPath, dev, results.blocks, blockSize, blocksToRead);
ibgLog = new IBGLog(IBGLogPath, currentProfile);
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile);
for(ulong i = 0; i < results.blocks; i += blocksToRead)
for(ulong i = 0; i < results.Blocks; i += blocksToRead)
{
if(aborted) break;
double cmdDuration = 0;
if((results.blocks - i) < blocksToRead) blocksToRead = (uint)(results.blocks - i);
if((results.Blocks - i) < blocksToRead) blocksToRead = (uint)(results.Blocks - i);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(currentSpeed > results.maxSpeed && currentSpeed != 0) results.maxSpeed = currentSpeed;
if(currentSpeed < results.minSpeed && currentSpeed != 0) results.minSpeed = currentSpeed;
if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed && currentSpeed != 0) results.MinSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks, currentSpeed);
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks, currentSpeed);
sense = scsiReader.ReadBlocks(out readBuffer, i, blocksToRead, out cmdDuration);
results.processingTime += cmdDuration;
results.ProcessingTime += cmdDuration;
if(!sense && !dev.Error)
{
@@ -410,8 +410,8 @@ namespace DiscImageChef.Core.Devices.Scanning
// TODO: Separate errors on kind of errors.
else
{
results.errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.unreadableSectors.Add(b);
results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(cmdDuration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, cmdDuration);
@@ -427,28 +427,28 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine();
mhddLog.Close();
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.blocks + 1)) / 1024) /
(results.processingTime / 1000), devicePath);
ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.Blocks + 1)) / 1024) /
(results.ProcessingTime / 1000), devicePath);
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
}
results.seekMax = double.MinValue;
results.seekMin = double.MaxValue;
results.seekTotal = 0;
const int seekTimes = 1000;
results.SeekMax = double.MinValue;
results.SeekMin = double.MaxValue;
results.SeekTotal = 0;
const int SEEK_TIMES = 1000;
double seekCur = 0;
Random rnd = new Random();
uint seekPos = (uint)rnd.Next((int)results.blocks);
uint seekPos = (uint)rnd.Next((int)results.Blocks);
for(int i = 0; i < seekTimes; i++)
for(int i = 0; i < SEEK_TIMES; i++)
{
if(aborted) break;
seekPos = (uint)rnd.Next((int)results.blocks);
seekPos = (uint)rnd.Next((int)results.Blocks);
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
@@ -456,22 +456,22 @@ namespace DiscImageChef.Core.Devices.Scanning
else scsiReader.ReadBlock(out readBuffer, seekPos, out seekCur);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(seekCur > results.seekMax && seekCur != 0) results.seekMax = seekCur;
if(seekCur < results.seekMin && seekCur != 0) results.seekMin = seekCur;
if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur;
if(seekCur < results.SeekMin && seekCur != 0) results.SeekMin = seekCur;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
results.seekTotal += seekCur;
results.SeekTotal += seekCur;
GC.Collect();
}
DicConsole.WriteLine();
results.processingTime /= 1000;
results.totalTime = (end - start).TotalSeconds;
results.ProcessingTime /= 1000;
results.TotalTime = (end - start).TotalSeconds;
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
results.avgSpeed = (((double)blockSize * (double)(results.blocks + 1)) / 1048576) / results.processingTime;
results.AvgSpeed = (((double)blockSize * (double)(results.Blocks + 1)) / 1048576) / results.ProcessingTime;
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
results.seekTimes = seekTimes;
results.SeekTimes = SEEK_TIMES;
return results;
}

View File

@@ -36,23 +36,23 @@ namespace DiscImageChef.Core.Devices.Scanning
{
public struct ScanResults
{
public double totalTime;
public double processingTime;
public double avgSpeed;
public double maxSpeed;
public double minSpeed;
public double TotalTime;
public double ProcessingTime;
public double AvgSpeed;
public double MaxSpeed;
public double MinSpeed;
public ulong A;
public ulong B;
public ulong C;
public ulong D;
public ulong E;
public ulong F;
public List<ulong> unreadableSectors;
public double seekMax;
public double seekMin;
public double seekTotal;
public int seekTimes;
public ulong blocks;
public ulong errored;
public List<ulong> UnreadableSectors;
public double SeekMax;
public double SeekMin;
public double SeekTotal;
public int SeekTimes;
public ulong Blocks;
public ulong Errored;
}
}

View File

@@ -41,15 +41,15 @@ namespace DiscImageChef.Core.Devices.Scanning
{
public static class SecureDigital
{
public static ScanResults Scan(string MHDDLogPath, string IBGLogPath, string devicePath, Device dev)
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
{
ScanResults results = new ScanResults();
bool aborted;
MHDDLog mhddLog;
IBGLog ibgLog;
MhddLog mhddLog;
IbgLog ibgLog;
byte[] cmdBuf;
bool sense;
results.blocks = 0;
results.Blocks = 0;
uint[] response;
uint timeout = 5;
double duration = 0;
@@ -63,24 +63,24 @@ namespace DiscImageChef.Core.Devices.Scanning
ExtendedCSD ecsd = new ExtendedCSD();
CSD csd = new CSD();
sense = dev.ReadExtendedCSD(out cmdBuf, out response, timeout, out duration);
sense = dev.ReadExtendedCsd(out cmdBuf, out response, timeout, out duration);
if(!sense)
{
ecsd = Decoders.MMC.Decoders.DecodeExtendedCSD(cmdBuf);
blocksToRead = ecsd.OptimalReadSize;
results.blocks = ecsd.SectorCount;
results.Blocks = ecsd.SectorCount;
blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512);
// Supposing it's high-capacity MMC if it has Extended CSD...
byteAddressed = false;
}
if(sense || results.blocks == 0)
if(sense || results.Blocks == 0)
{
sense = dev.ReadCSD(out cmdBuf, out response, timeout, out duration);
sense = dev.ReadCsd(out cmdBuf, out response, timeout, out duration);
if(!sense)
{
csd = Decoders.MMC.Decoders.DecodeCSD(cmdBuf);
results.blocks = (ulong)((csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2));
results.Blocks = (ulong)((csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2));
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
}
}
@@ -89,11 +89,11 @@ namespace DiscImageChef.Core.Devices.Scanning
{
Decoders.SecureDigital.CSD csd = new Decoders.SecureDigital.CSD();
sense = dev.ReadCSD(out cmdBuf, out response, timeout, out duration);
sense = dev.ReadCsd(out cmdBuf, out response, timeout, out duration);
if(!sense)
{
csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
results.blocks = (ulong)(csd.Structure == 0
results.Blocks = (ulong)(csd.Structure == 0
? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2)
: (csd.Size + 1) * 1024);
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
@@ -102,7 +102,7 @@ namespace DiscImageChef.Core.Devices.Scanning
}
}
if(results.blocks == 0)
if(results.Blocks == 0)
{
DicConsole.ErrorWriteLine("Unable to get device size.");
return results;
@@ -133,46 +133,46 @@ namespace DiscImageChef.Core.Devices.Scanning
results.D = 0; // >=50ms, <150ms
results.E = 0; // >=150ms, <500ms
results.F = 0; // >=500ms
results.errored = 0;
results.Errored = 0;
DateTime start;
DateTime end;
results.processingTime = 0;
results.ProcessingTime = 0;
double currentSpeed = 0;
results.maxSpeed = double.MinValue;
results.minSpeed = double.MaxValue;
results.unreadableSectors = new List<ulong>();
results.seekMax = double.MinValue;
results.seekMin = double.MaxValue;
results.seekTotal = 0;
const int seekTimes = 1000;
results.MaxSpeed = double.MinValue;
results.MinSpeed = double.MaxValue;
results.UnreadableSectors = new List<ulong>();
results.SeekMax = double.MinValue;
results.SeekMin = double.MaxValue;
results.SeekTotal = 0;
const int SEEK_TIMES = 1000;
double seekCur = 0;
Random rnd = new Random();
uint seekPos = (uint)rnd.Next((int)results.blocks);
uint seekPos = (uint)rnd.Next((int)results.Blocks);
aborted = false;
System.Console.CancelKeyPress += (sender, e) => { e.Cancel = aborted = true; };
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
mhddLog = new MHDDLog(MHDDLogPath, dev, results.blocks, blockSize, blocksToRead);
ibgLog = new IBGLog(IBGLogPath, currentProfile);
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(ibgLogPath, currentProfile);
start = DateTime.UtcNow;
for(ulong i = 0; i < results.blocks; i += blocksToRead)
for(ulong i = 0; i < results.Blocks; i += blocksToRead)
{
if(aborted) break;
if((results.blocks - i) < blocksToRead) blocksToRead = (byte)(results.blocks - i);
if((results.Blocks - i) < blocksToRead) blocksToRead = (byte)(results.Blocks - i);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(currentSpeed > results.maxSpeed && currentSpeed != 0) results.maxSpeed = currentSpeed;
if(currentSpeed < results.minSpeed && currentSpeed != 0) results.minSpeed = currentSpeed;
if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed && currentSpeed != 0) results.MinSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks, currentSpeed);
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.Blocks, currentSpeed);
bool error = dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, byteAddressed,
timeout, out duration);
@@ -191,8 +191,8 @@ namespace DiscImageChef.Core.Devices.Scanning
}
else
{
results.errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.unreadableSectors.Add(b);
results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
if(duration < 500) mhddLog.Write(i, 65535);
else mhddLog.Write(i, duration);
@@ -210,16 +210,16 @@ namespace DiscImageChef.Core.Devices.Scanning
DicConsole.WriteLine();
mhddLog.Close();
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.blocks + 1)) / 1024) / (results.processingTime / 1000),
ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
(((double)blockSize * (double)(results.Blocks + 1)) / 1024) / (results.ProcessingTime / 1000),
devicePath);
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
for(int i = 0; i < seekTimes; i++)
for(int i = 0; i < SEEK_TIMES; i++)
{
if(aborted) break;
seekPos = (uint)rnd.Next((int)results.blocks);
seekPos = (uint)rnd.Next((int)results.Blocks);
DicConsole.Write("\rSeeking to sector {0}...\t\t", seekPos);
@@ -227,22 +227,22 @@ namespace DiscImageChef.Core.Devices.Scanning
out seekCur);
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(seekCur > results.seekMax && seekCur != 0) results.seekMax = seekCur;
if(seekCur < results.seekMin && seekCur != 0) results.seekMin = seekCur;
if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur;
if(seekCur < results.SeekMin && seekCur != 0) results.SeekMin = seekCur;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
results.seekTotal += seekCur;
results.SeekTotal += seekCur;
GC.Collect();
}
DicConsole.WriteLine();
results.processingTime /= 1000;
results.totalTime = (end - start).TotalSeconds;
results.ProcessingTime /= 1000;
results.TotalTime = (end - start).TotalSeconds;
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
results.avgSpeed = (((double)blockSize * (double)(results.blocks + 1)) / 1048576) / results.processingTime;
results.AvgSpeed = (((double)blockSize * (double)(results.Blocks + 1)) / 1048576) / results.ProcessingTime;
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
results.seekTimes = seekTimes;
results.SeekTimes = SEEK_TIMES;
return results;
}