mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Fixed MOST name inconsistencies.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user