* commandline:

* DiscImageChef.Settings/Settings.cs:
	* DiscImageChef.Settings/docs/README.txt:
	* DiscImageChef.Settings/packages.config:
	* DiscImageChef.Settings/docs/LICENSE.txt:
	* DiscImageChef.Settings/docs/ChangeLog.txt:
	* DiscImageChef.Settings/docs/mono/index.xml:
	* DiscImageChef.Settings/docs/html/index.html:
	* DiscImageChef.Settings/Properties/AssemblyInfo.cs:
	* DiscImageChef.Settings/DiscImageChef.Settings.csproj:
	* DiscImageChef.Settings/docs/mono/ns-Claunia.PropertyList.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/UID.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/UID.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSSet.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/index.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSSet.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDate.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSData.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDate.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSData.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSArray.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSNumber.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSString.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSObject.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSArray.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSNumber.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSString.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSObject.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/NSDictionary.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/NSDictionary.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListParser.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/XmlPropertyListParser.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/XmlPropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/ASCIIPropertyListParser.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/ASCIIPropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListParser.xml:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/BinaryPropertyListWriter.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListWriter.html:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/BinaryPropertyListParser.html:
	* DiscImageChef.Settings/docs/mono/Claunia.PropertyList/PropertyListFormatException.xml:
	* DiscImageChef.Settings/docs/html/Claunia.PropertyList/PropertyListFormatException.html:
	  Added supports for settings

	* DiscImageChef/Commands/Configure.cs:
	  Added support for settings.

	* DiscImageChef/Core/Statistics.cs:
	* DiscImageChef/Commands/Verify.cs:
	* DiscImageChef/Commands/Entropy.cs:
	* DiscImageChef/Commands/Formats.cs:
	* DiscImageChef/Commands/PrintHex.cs:
	* DiscImageChef/Commands/MediaInfo.cs:
	* DiscImageChef/Commands/Statistics.cs:
	  Added statistics.

	* DiscImageChef.Decoders/SCSI/Inquiry.cs:
	  Corrected bug on inquiry decoding.

	* DiscImageChef.Decoders/SCSI/Modes.cs:
	  Corrected bug on decoding mode page 2Ah without write
	  performance descriptors.
	Corrected bug when there is a vendor page 0 in mode sense
	  decoding.

	* DiscImageChef.Devices/Device/Constructor.cs:
	  Corrected detecting USB or FireWire attached CD/DVD/BD and
	  tape drives.
	Try ATA identify on USB or FireWire that don't have SCSI
	  INQUIRY.

	* DiscImageChef.DiscImages/CDRWin.cs:
	  Corrected CD-ROM XA vs CD-ROM detection.

	* DiscImageChef.Partitions/AppleMap.cs:
	  Corrected big endian working.
	Added debug output.

	* DiscImageChef.sln:
	  Added supports for settings.

	* DiscImageChef/Commands/Decode.cs:
	* DiscImageChef/Commands/Analyze.cs:
	* DiscImageChef/Commands/Compare.cs:
	* DiscImageChef/Commands/Checksum.cs:
	* DiscImageChef/Commands/Benchmark.cs:
	* DiscImageChef/Commands/DeviceInfo.cs:
	* DiscImageChef/Commands/CreateSidecar.cs:
	  Added statistics.

	* DiscImageChef/Commands/DeviceReport.cs:
	  Added statistics.
	Correct handling empty inquiry string fields.
	Suppose it is not removable, til proved wrong.
	Corrected MODE SENSE (6/10) detection and calling order.
	If device is MMC type but reports neither mode page 2Ah
	  neither GET CONFIGURATION, try all CDs (old drives work like
	  that).
	Try reading Lead-In and Lead-Out in Audio CD using Audio READ
	  CD commands.
	Corrected READ LONG information handling, some drives return
	  2s-complement in 32 bit. Upper 16 bits are ignored.
	Added support for DVD raw block (37856 bytes).
	Check READ LONG up to 36 times the cooked block size. That
	  should be enough to detect huge blocked media (like DVD and
	  BD) without taking ages.
	If READ LONG size had to be bruteforced, and debug is
	  activated, save the result.

	* DiscImageChef/Commands/DumpMedia.cs:
	  Added statistics.
	Corrected READ LONG information handling, some drives return
	  2s-complement in 32 bit. Upper 16 bits are ignored.
	Start trying with 64 blocks at a time. Some drives report to
	  be able to read 255 at a time, but they really don't, they
	  take a lot longer to read.

	* DiscImageChef/Commands/MediaScan.cs:
	  Added statistics.
	Start trying with 64 blocks at a time. Some drives report to
	  be able to read 255 at a time, but they really don't, they
	  take a lot longer to read.

	* DiscImageChef/DiscImageChef.csproj:
	  Added support for settings.
	Added statistics.

	* DiscImageChef/Main.cs:
	* DiscImageChef/Options.cs:
	  Added support for settings.
	Added statistics.
This commit is contained in:
2016-02-03 18:58:11 +00:00
parent bb69a1b8d9
commit d777061105
75 changed files with 21603 additions and 100 deletions

View File

@@ -1,3 +1,71 @@
2016-02-03 Natalia Portillo <claunia@claunia.com>
* Commands/Configure.cs:
Added support for settings.
* Core/Statistics.cs:
* Commands/Verify.cs:
* Commands/Entropy.cs:
* Commands/Formats.cs:
* Commands/PrintHex.cs:
* Commands/MediaInfo.cs:
* Commands/Statistics.cs:
Added statistics.
* Commands/Decode.cs:
* Commands/Analyze.cs:
* Commands/Compare.cs:
* Commands/Checksum.cs:
* Commands/Benchmark.cs:
* Commands/DeviceInfo.cs:
* Commands/CreateSidecar.cs:
Added statistics.
* Commands/DeviceReport.cs:
Added statistics.
Correct handling empty inquiry string fields.
Suppose it is not removable, til proved wrong.
Corrected MODE SENSE (6/10) detection and calling order.
If device is MMC type but reports neither mode page 2Ah
neither GET CONFIGURATION, try all CDs (old drives work like
that).
Try reading Lead-In and Lead-Out in Audio CD using Audio READ
CD commands.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Added support for DVD raw block (37856 bytes).
Check READ LONG up to 36 times the cooked block size. That
should be enough to detect huge blocked media (like DVD and
BD) without taking ages.
If READ LONG size had to be bruteforced, and debug is
activated, save the result.
* Commands/DumpMedia.cs:
Added statistics.
Corrected READ LONG information handling, some drives return
2s-complement in 32 bit. Upper 16 bits are ignored.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* Commands/MediaScan.cs:
Added statistics.
Start trying with 64 blocks at a time. Some drives report to
be able to read 255 at a time, but they really don't, they
take a lot longer to read.
* DiscImageChef.csproj:
Added support for settings.
Added statistics.
* Main.cs:
* Options.cs:
Added support for settings.
Added statistics.
2016-01-16 Natalia Portillo <claunia@claunia.com>
* Commands/Decode.cs:

View File

@@ -99,6 +99,9 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Analyze command", "Image without headers is {0} bytes.", _imageFormat.GetImageSize());
DicConsole.DebugWriteLine("Analyze command", "Image has {0} sectors.", _imageFormat.GetSectors());
DicConsole.DebugWriteLine("Analyze command", "Image identifies disk type as {0}.", _imageFormat.GetMediaType());
Core.Statistics.AddMediaFormat(_imageFormat.GetImageFormat());
Core.Statistics.AddMedia(_imageFormat.ImageInfo.mediaType, false);
}
catch (Exception ex)
{
@@ -116,11 +119,11 @@ namespace DiscImageChef.Commands
foreach (PartPlugin _partplugin in plugins.PartPluginsList.Values)
{
List<CommonTypes.Partition> _partitions;
if (_partplugin.GetInformation(_imageFormat, out _partitions))
{
partition_scheme = _partplugin.Name;
partitions = _partitions;
partitions.AddRange(_partitions);
Core.Statistics.AddPartition(_partplugin.Name);
break;
}
}
@@ -128,7 +131,7 @@ namespace DiscImageChef.Commands
if (_imageFormat.ImageHasPartitions())
{
partition_scheme = _imageFormat.GetImageFormat();
partitions = _imageFormat.GetPartitions();
partitions.AddRange(_imageFormat.GetPartitions());
}
if (partition_scheme == "")
@@ -175,6 +178,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name));
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector+partitions[i].PartitionSectors, out information);
DicConsole.Write(information);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
}
@@ -184,6 +188,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name));
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector+partitions[i].PartitionSectors, out information);
DicConsole.Write(information);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
}
@@ -206,6 +211,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name));
_plugin.GetInformation(_imageFormat, 0, _imageFormat.GetSectors()-1, out information);
DicConsole.Write(information);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
}
@@ -215,6 +221,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name));
_plugin.GetInformation(_imageFormat, 0, _imageFormat.GetSectors()-1, out information);
DicConsole.Write(information);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
}
@@ -223,6 +230,8 @@ namespace DiscImageChef.Commands
DicConsole.ErrorWriteLine(String.Format("Error reading file: {0}", ex.Message));
DicConsole.DebugWriteLine("Analyze command", ex.StackTrace);
}
Core.Statistics.AddCommand("analyze");
}
static void IdentifyFilesystems(ImagePlugin imagePlugin, out List<string> id_plugins, ulong partitionStart, ulong partitionEnd)

View File

@@ -57,7 +57,7 @@ namespace DiscImageChef.Commands
long mem;
object ctx;
double allSeparate = 0;
System.Collections.Generic.Dictionary<string, double> checksumTimes = new System.Collections.Generic.Dictionary<string, double>();
DicConsole.WriteLine();
@@ -125,6 +125,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to Adler32 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("Adler32", (end - start).TotalSeconds);
#endregion Adler32
#region CRC16
@@ -155,6 +156,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to CRC16 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("CRC16", (end - start).TotalSeconds);
#endregion CRC16
#region CRC32
@@ -185,6 +187,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to CRC32 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("CRC32", (end - start).TotalSeconds);
#endregion CRC32
#region CRC64
@@ -215,6 +218,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to CRC64 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("CRC64", (end - start).TotalSeconds);
#endregion CRC64
#region Fletcher32
@@ -244,7 +248,8 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to Fletcher32 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end-start).TotalSeconds;*/
allSeparate += (end-start).TotalSeconds;
checksumTimes.Add("Fletcher32", (end - start).TotalSeconds);*/
#endregion Fletcher32
#region MD5
@@ -275,6 +280,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to MD5 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("MD5", (end - start).TotalSeconds);
#endregion MD5
#region RIPEMD160
@@ -305,6 +311,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to RIPEMD160 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("RIPEMD160", (end - start).TotalSeconds);
#endregion RIPEMD160
#region SHA1
@@ -335,6 +342,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to SHA1 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("SHA1", (end - start).TotalSeconds);
#endregion SHA1
#region SHA256
@@ -365,6 +373,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to SHA256 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("SHA256", (end - start).TotalSeconds);
#endregion SHA256
#region SHA384
@@ -395,6 +404,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to SHA384 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("SHA384", (end - start).TotalSeconds);
#endregion SHA384
#region SHA512
@@ -425,6 +435,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to SHA512 buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("SHA512", (end - start).TotalSeconds);
#endregion SHA512
#region SpamSum
@@ -455,6 +466,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to SpamSum buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
allSeparate += (end - start).TotalSeconds;
checksumTimes.Add("SpamSum", (end - start).TotalSeconds);
#endregion SpamSum
#region Entropy
@@ -489,6 +501,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Took {0} seconds to entropy buffer, {1} MiB/sec.", (end - start).TotalSeconds, (bufferSize / 1048576) / (end - start).TotalSeconds);
double entropyTime = (end - start).TotalSeconds;
#endregion Entropy
#region Multitasking
@@ -657,6 +670,9 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine();
DicConsole.WriteLine("Max memory used is {0} bytes", maxMemory);
DicConsole.WriteLine("Min memory used is {0} bytes", minMemory);
Core.Statistics.AddCommand("benchmark");
Core.Statistics.AddBenchmark(checksumTimes, entropyTime, (end - start).TotalSeconds, allSeparate, maxMemory, minMemory);
}
#region Threading helpers

View File

@@ -77,6 +77,8 @@ namespace DiscImageChef.Commands
}
inputFormat.OpenImage(options.InputFile);
Core.Statistics.AddMediaFormat(inputFormat.GetImageFormat());
Core.Statistics.AddMedia(inputFormat.ImageInfo.mediaType, false);
if (inputFormat.ImageInfo.imageHasPartitions)
{
@@ -1045,6 +1047,8 @@ namespace DiscImageChef.Commands
if (options.DoSpamSum)
DicConsole.WriteLine("Disk's SpamSum: {0}", ssctx.End());
}
Core.Statistics.AddCommand("checksum");
}
#region Threading helpers

View File

@@ -96,6 +96,11 @@ namespace DiscImageChef.Commands
input1Format.OpenImage(options.InputFile1);
input2Format.OpenImage(options.InputFile2);
Core.Statistics.AddMediaFormat(input1Format.GetImageFormat());
Core.Statistics.AddMediaFormat(input2Format.GetImageFormat());
Core.Statistics.AddMedia(input1Format.ImageInfo.mediaType, false);
Core.Statistics.AddMedia(input2Format.ImageInfo.mediaType, false);
StringBuilder sb = new StringBuilder();
if (options.Verbose)
@@ -422,6 +427,8 @@ namespace DiscImageChef.Commands
sb.AppendLine("Images do not differ");
DicConsole.WriteLine(sb.ToString());
Core.Statistics.AddCommand("compare");
}
private static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, byte[] compareArray2)

View File

@@ -0,0 +1,169 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Configure.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Component
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright (C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
using System;
using DiscImageChef.Console;
using DiscImageChef.Settings;
namespace DiscImageChef.Commands
{
public static class Configure
{
public static void doConfigure ()
{
ConsoleKeyInfo pressedKey = new ConsoleKeyInfo();
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to save device reports globally? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.SaveReportsGlobally = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to save stats about your DiscImageChef usage? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
if (pressedKey.Key == ConsoleKey.Y)
{
Settings.Settings.Current.Stats = new StatsSettings();
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to share your stats anonymously? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.ShareStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about benchmarks? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.BenchmarkStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about command usage? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.CommandStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about found devices? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.DeviceStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about found filesystems? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.FilesystemStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about found media image formats? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.MediaImageStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about scanned media? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.MediaScanStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about found partitioning schemes? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.PartitionStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about media types? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.MediaStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to gather statistics about media image verifications? (Y/N): ");
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.VerifyStats = pressedKey.Key == ConsoleKey.Y;
}
else
Settings.Settings.Current.Stats = null;
Settings.Settings.SaveSettings();
}
}
}

View File

@@ -93,6 +93,8 @@ namespace DiscImageChef.Commands
return;
}
Core.Statistics.AddMediaFormat(_imageFormat.GetImageFormat());
FileInfo fi = new FileInfo(options.InputFile);
FileStream fs = new FileStream(options.InputFile, FileMode.Open, FileAccess.Read);
@@ -303,6 +305,7 @@ namespace DiscImageChef.Commands
Metadata.MediaType.MediaTypeToString(dskType, out dscType, out dscSubType);
sidecar.OpticalDisc[0].DiscType = dscType;
sidecar.OpticalDisc[0].DiscSubType = dscSubType;
Core.Statistics.AddMedia(dskType, false);
try
{
@@ -502,6 +505,7 @@ namespace DiscImageChef.Commands
if (_partplugin.GetInformation(_imageFormat, out _partitions))
{
partitions = _partitions;
Core.Statistics.AddPartition(_partplugin.Name);
break;
}
}
@@ -531,6 +535,7 @@ namespace DiscImageChef.Commands
string foo;
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out foo);
lstFs.Add(_plugin.XmlFSType);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
catch
@@ -560,6 +565,7 @@ namespace DiscImageChef.Commands
string foo;
_plugin.GetInformation(_imageFormat, (ulong)xmlTrk.StartSector, (ulong)xmlTrk.EndSector, out foo);
lstFs.Add(_plugin.XmlFSType);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
catch
@@ -660,6 +666,7 @@ namespace DiscImageChef.Commands
Metadata.MediaType.MediaTypeToString(_imageFormat.ImageInfo.mediaType, out dskType, out dskSubType);
sidecar.BlockMedia[0].DiskType = dskType;
sidecar.BlockMedia[0].DiskSubType = dskSubType;
Core.Statistics.AddMedia(_imageFormat.ImageInfo.mediaType, false);
sidecar.BlockMedia[0].Dimensions = Metadata.Dimensions.DimensionsFromMediaType(_imageFormat.ImageInfo.mediaType);
@@ -679,6 +686,7 @@ namespace DiscImageChef.Commands
if (_partplugin.GetInformation(_imageFormat, out _partitions))
{
partitions = _partitions;
Core.Statistics.AddPartition(_partplugin.Name);
break;
}
}
@@ -708,6 +716,7 @@ namespace DiscImageChef.Commands
string foo;
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors - 1, out foo);
lstFs.Add(_plugin.XmlFSType);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
catch
@@ -737,6 +746,7 @@ namespace DiscImageChef.Commands
string foo;
_plugin.GetInformation(_imageFormat, 0, _imageFormat.GetSectors() - 1, out foo);
lstFs.Add(_plugin.XmlFSType);
Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type);
}
}
catch
@@ -810,6 +820,8 @@ namespace DiscImageChef.Commands
System.Xml.Serialization.XmlSerializer xmlSer = new System.Xml.Serialization.XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
Core.Statistics.AddCommand("create-sidecar");
}
catch (Exception ex)
{

View File

@@ -62,6 +62,8 @@ namespace DiscImageChef.Commands
}
inputFormat.OpenImage(options.InputFile);
Core.Statistics.AddMediaFormat(inputFormat.GetImageFormat());
Core.Statistics.AddMedia(inputFormat.ImageInfo.mediaType, false);
if (options.DiskTags)
{
@@ -238,6 +240,8 @@ namespace DiscImageChef.Commands
}
}
}
Core.Statistics.AddCommand("decode");
}
}
}

View File

@@ -67,6 +67,8 @@ namespace DiscImageChef.Commands
return;
}
Core.Statistics.AddDevice(dev);
if (dev.IsUSB)
{
DicConsole.WriteLine("USB device");
@@ -1002,6 +1004,8 @@ namespace DiscImageChef.Commands
DicConsole.ErrorWriteLine("Unknown device type {0}, cannot get information.", dev.Type);
break;
}
Core.Statistics.AddCommand("device-info");
}
static void doWriteFile(string outputPrefix, string outputSuffix, string whatWriting, byte[] data)

View File

@@ -66,6 +66,8 @@ namespace DiscImageChef.Commands
return;
}
Core.Statistics.AddDevice(dev);
switch (dev.Type)
{
case DeviceType.ATA:
@@ -85,6 +87,8 @@ namespace DiscImageChef.Commands
default:
throw new NotSupportedException("Unknown device type.");
}
Core.Statistics.AddCommand("device-report");
}
static void doATADeviceReport(DeviceReportSubOptions options, Device dev)
@@ -679,7 +683,7 @@ namespace DiscImageChef.Commands
else
xmlFile = dev.Model + ".xml";
ConsoleKeyInfo pressedKey;
bool removable = true;
bool removable = false;
if (dev.IsUSB)
{
@@ -1280,20 +1284,23 @@ namespace DiscImageChef.Commands
report.SCSI.Inquiry.ResponseDataFormat = inq.ResponseDataFormat;
report.SCSI.Inquiry.ResponseDataFormatSpecified = true;
}
if (!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.VendorIdentification).Trim()))
if (!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.VendorIdentification)))
{
report.SCSI.Inquiry.VendorIdentification = StringHandlers.CToString(inq.VendorIdentification).Trim();
report.SCSI.Inquiry.VendorIdentificationSpecified = true;
if (!string.IsNullOrWhiteSpace(report.SCSI.Inquiry.VendorIdentification))
report.SCSI.Inquiry.VendorIdentificationSpecified = true;
}
if (!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.ProductIdentification).Trim()))
if (!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.ProductIdentification)))
{
report.SCSI.Inquiry.ProductIdentification = StringHandlers.CToString(inq.ProductIdentification).Trim();
report.SCSI.Inquiry.ProductIdentificationSpecified = true;
if (!string.IsNullOrWhiteSpace(report.SCSI.Inquiry.ProductIdentification))
report.SCSI.Inquiry.ProductIdentificationSpecified = true;
}
if (!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.ProductRevisionLevel).Trim()))
if (!string.IsNullOrWhiteSpace(StringHandlers.CToString(inq.ProductRevisionLevel)))
{
report.SCSI.Inquiry.ProductRevisionLevel = StringHandlers.CToString(inq.ProductRevisionLevel).Trim();
report.SCSI.Inquiry.ProductRevisionLevelSpecified = true;
if (!string.IsNullOrWhiteSpace(report.SCSI.Inquiry.ProductRevisionLevel))
report.SCSI.Inquiry.ProductRevisionLevelSpecified = true;
}
if (inq.VersionDescriptors != null)
{
@@ -1390,19 +1397,39 @@ namespace DiscImageChef.Commands
Decoders.SCSI.PeripheralDeviceTypes devType = dev.SCSIType;
DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Default, 0x3F, 0xFF, timeout, out duration);
if (sense || dev.Error)
{
DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (10)...");
sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Default, 0x3F, 0x00, timeout, out duration);
if (!sense && dev.Error)
{
report.SCSI.SupportsModeSense10 = true;
report.SCSI.SupportsModeSubpages = false;
decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, devType);
}
}
else
{
report.SCSI.SupportsModeSense10 = true;
report.SCSI.SupportsModeSubpages = true;
decMode = Decoders.SCSI.Modes.DecodeMode10(buffer, devType);
}
DicConsole.WriteLine("Querying all mode pages and subpages using SCSI MODE SENSE (6)...");
sense = dev.ModeSense6(out buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F, 0xFF, timeout, out duration);
if (sense || dev.Error)
{
sense = dev.ModeSense6(out buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F, 0x00, timeout, out duration);
DicConsole.WriteLine("Querying all mode pages using SCSI MODE SENSE (6)...");
sense = dev.ModeSense6(out buffer, out senseBuffer, false, ScsiModeSensePageControl.Default, 0x3F, 0x00, timeout, out duration);
if (sense || dev.Error)
{
DicConsole.WriteLine("Querying SCSI MODE SENSE (6)...");
sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration);
}
}
else
report.SCSI.SupportsModeSubpages = true;
if (sense || dev.Error)
{
DicConsole.WriteLine("Querying SCSI MODE SENSE (6)...");
sense = dev.ModeSense(out buffer, out senseBuffer, timeout, out duration);
}
if (!sense && !dev.Error && !decMode.HasValue)
decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, devType);
@@ -2121,6 +2148,20 @@ namespace DiscImageChef.Commands
tryPioneer |= dev.Manufacturer.ToLowerInvariant() == "pioneer";
tryNEC |= dev.Manufacturer.ToLowerInvariant() == "nec";
// Very old CD drives do not contain mode page 2Ah neither GET CONFIGURATION, so just try all CDs on them
// Also don't get confident, some drives didn't know CD-RW but are able to read them
if (mediaTypes.Count == 0 || mediaTypes.Contains("CD-ROM"))
{
if (!mediaTypes.Contains("CD-ROM"))
mediaTypes.Add("CD-ROM");
if (!mediaTypes.Contains("Audio CD"))
mediaTypes.Add("Audio CD");
if (!mediaTypes.Contains("CD-R"))
mediaTypes.Add("CD-R");
if (!mediaTypes.Contains("CD-RW"))
mediaTypes.Add("CD-RW");
}
mediaTypes.Sort();
List<testedMediaType> mediaTests = new List<testedMediaType>();
foreach (string mediaType in mediaTypes)
@@ -2436,7 +2477,7 @@ namespace DiscImageChef.Commands
mediaTest.SupportsReadCdMsfRaw = !dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000200, 0x00000201, 2352, MmcSectorTypes.AllTypes, false, false, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, timeout, out duration);
}
if (mediaTest.SupportsReadCdRaw)
if (mediaTest.SupportsReadCdRaw || mediaType == "Audio CD")
{
DicConsole.WriteLine("Trying to read CD Lead-In...");
for (int i = -150; i < 0; i++)
@@ -2453,7 +2494,10 @@ namespace DiscImageChef.Commands
}
DicConsole.WriteLine("Trying to read CD Lead-Out...");
mediaTest.CanReadLeadOut = !dev.ReadCd(out buffer, out senseBuffer, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, timeout, out duration);
if (mediaType == "Audio CD")
mediaTest.CanReadLeadOut = dev.ReadCd(out buffer, out senseBuffer, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.CDDA, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, timeout, out duration);
else
mediaTest.CanReadLeadOut = !dev.ReadCd(out buffer, out senseBuffer, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, timeout, out duration);
}
if (mediaType == "Audio CD" && mediaTest.SupportsReadCd)
@@ -2600,7 +2644,7 @@ namespace DiscImageChef.Commands
mediaTest.SupportsReadLong = true;
if (decSense.Value.InformationValid && decSense.Value.ILI)
{
mediaTest.LongBlockSize = 0xFFFF - decSense.Value.Information;
mediaTest.LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
mediaTest.LongBlockSizeSpecified = true;
}
}
@@ -2652,12 +2696,25 @@ namespace DiscImageChef.Commands
}
else if (mediaTest.BlockSize == 2048)
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, timeout, out duration);
if (!sense && !dev.Error)
if (mediaType.StartsWith("DVD"))
{
mediaTest.SupportsReadLong = true;
mediaTest.LongBlockSize = 2380;
mediaTest.LongBlockSizeSpecified = true;
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 37856, timeout, out duration);
if (!sense && !dev.Error)
{
mediaTest.SupportsReadLong = true;
mediaTest.LongBlockSize = 37856;
mediaTest.LongBlockSizeSpecified = true;
}
}
else
{
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, timeout, out duration);
if (!sense && !dev.Error)
{
mediaTest.SupportsReadLong = true;
mediaTest.LongBlockSize = 2380;
mediaTest.LongBlockSizeSpecified = true;
}
}
}
else if (mediaTest.BlockSize == 4096)
@@ -2710,12 +2767,18 @@ namespace DiscImageChef.Commands
if (pressedKey.Key == ConsoleKey.Y)
{
for (ushort i = (ushort)mediaTest.BlockSize; i < 0x4000; i++)
for (ushort i = (ushort)mediaTest.BlockSize; i < (ushort)mediaTest.BlockSize * 36; i++)
{
DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, out duration);
if (!sense)
{
if (options.Debug)
{
FileStream bingo = new FileStream(string.Format("{0}_readlong.bin", mediaType), FileMode.Create);
bingo.Write(buffer, 0, buffer.Length);
bingo.Close();
}
mediaTest.LongBlockSize = i;
mediaTest.LongBlockSizeSpecified = true;
break;
@@ -3149,7 +3212,7 @@ namespace DiscImageChef.Commands
mediaTest.SupportsReadLong = true;
if (decSense.Value.InformationValid && decSense.Value.ILI)
{
mediaTest.LongBlockSize = 0xFFFF - decSense.Value.Information;
mediaTest.LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
mediaTest.LongBlockSizeSpecified = true;
}
}
@@ -3227,12 +3290,18 @@ namespace DiscImageChef.Commands
if (pressedKey.Key == ConsoleKey.Y)
{
for (ushort i = (ushort)mediaTest.BlockSize; i < 0x4000; i++)
for (ushort i = (ushort)mediaTest.BlockSize; i < 0x8000; i++)
{
DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i);
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, out duration);
if (!sense)
{
if (options.Debug)
{
FileStream bingo = new FileStream(string.Format("{0}_readlong.bin", mediaTest.MediumTypeName), FileMode.Create);
bingo.Write(buffer, 0, buffer.Length);
bingo.Close();
}
mediaTest.LongBlockSize = i;
mediaTest.LongBlockSizeSpecified = true;
break;
@@ -3344,7 +3413,7 @@ namespace DiscImageChef.Commands
report.SCSI.ReadCapabilities.SupportsReadLong = true;
if (decSense.Value.InformationValid && decSense.Value.ILI)
{
report.SCSI.ReadCapabilities.LongBlockSize = 0xFFFF - decSense.Value.Information;
report.SCSI.ReadCapabilities.LongBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
report.SCSI.ReadCapabilities.LongBlockSizeSpecified = true;
}
}
@@ -3428,6 +3497,12 @@ namespace DiscImageChef.Commands
sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, out duration);
if (!sense)
{
if (options.Debug)
{
FileStream bingo = new FileStream(string.Format("{0}_readlong.bin", dev.Model), FileMode.Create);
bingo.Write(buffer, 0, buffer.Length);
bingo.Close();
}
report.SCSI.ReadCapabilities.LongBlockSize = i;
report.SCSI.ReadCapabilities.LongBlockSizeSpecified = true;
break;
@@ -3445,6 +3520,23 @@ namespace DiscImageChef.Commands
System.Xml.Serialization.XmlSerializer xmlSer = new System.Xml.Serialization.XmlSerializer(typeof(Metadata.DeviceReport));
xmlSer.Serialize(xmlFs, report);
xmlFs.Close();
if (Settings.Settings.Current.SaveReportsGlobally && !String.IsNullOrEmpty (Settings.Settings.ReportsPath))
{
xmlFs = new FileStream(Path.Combine(Settings.Settings.ReportsPath, xmlFile), FileMode.Create);
xmlSer.Serialize(xmlFs, report);
xmlFs.Close();
}
if (Settings.Settings.Current.ShareReports)
{
SubmitReport(xmlSer);
}
}
static void SubmitReport(System.Xml.Serialization.XmlSerializer xmlSer)
{
// TODO: Implement this
}
}
}

View File

@@ -81,6 +81,8 @@ namespace DiscImageChef.Commands
return;
}
Core.Statistics.AddDevice(dev);
switch (dev.Type)
{
case DeviceType.ATA:
@@ -100,6 +102,8 @@ namespace DiscImageChef.Commands
default:
throw new NotSupportedException("Unknown device type.");
}
Core.Statistics.AddCommand("dump-media");
}
static void doATAMediaScan(DumpMediaSubOptions options, Device dev)
@@ -1052,7 +1056,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Media identified as {0}", dskType);
byte[] readBuffer;
uint blocksToRead = 255;
uint blocksToRead = 64;
ulong errored = 0;
DateTime start;
@@ -1337,7 +1341,7 @@ namespace DiscImageChef.Commands
rawAble = true;
if (decSense.Value.InformationValid && decSense.Value.ILI)
{
longBlockSize = 0xFFFF - decSense.Value.Information;
longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
readLong16 = !dev.ReadLong16(out readBuffer, out senseBuf, false, 0, longBlockSize, dev.Timeout, out duration);
}
}
@@ -1356,7 +1360,7 @@ namespace DiscImageChef.Commands
rawAble = true;
if (decSense.Value.InformationValid && decSense.Value.ILI)
{
longBlockSize = 0xFFFF - decSense.Value.Information;
longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
readLong10 = !dev.ReadLong10(out readBuffer, out senseBuf, false, false, 0, (ushort)longBlockSize, dev.Timeout, out duration);
}
}
@@ -1485,7 +1489,7 @@ namespace DiscImageChef.Commands
rawAble = true;
if (decSense.Value.InformationValid && decSense.Value.ILI)
{
longBlockSize = 0xFFFF - decSense.Value.Information;
longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
syqReadLong10 = !dev.SyQuestReadLong10(out readBuffer, out senseBuf, 0, longBlockSize, dev.Timeout, out duration);
;
}
@@ -1504,7 +1508,7 @@ namespace DiscImageChef.Commands
rawAble = true;
if (decSense.Value.InformationValid && decSense.Value.ILI)
{
longBlockSize = 0xFFFF - decSense.Value.Information;
longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF);
syqReadLong6 = !dev.SyQuestReadLong6(out readBuffer, out senseBuf, 0, longBlockSize, dev.Timeout, out duration);
;
}
@@ -1932,6 +1936,8 @@ namespace DiscImageChef.Commands
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
Core.Statistics.AddMedia(dskType, true);
}
static void initMHDDLogFile(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead)

View File

@@ -63,6 +63,8 @@ namespace DiscImageChef.Commands
}
inputFormat.OpenImage(options.InputFile);
Core.Statistics.AddMediaFormat(inputFormat.GetImageFormat());
Core.Statistics.AddMedia(inputFormat.ImageInfo.mediaType, false);
if (options.SeparatedTracks)
{
@@ -170,7 +172,7 @@ namespace DiscImageChef.Commands
if(options.DuplicatedSectors)
DicConsole.WriteLine("Disk has {0} unique sectors ({1:P3})", uniqueSectors.Count, (double)uniqueSectors.Count/(double)sectors);
Core.Statistics.AddCommand("entropy");
}
}
}

View File

@@ -83,6 +83,8 @@ namespace DiscImageChef.Commands
else
DicConsole.WriteLine(kvp.Value.Name);
}
Core.Statistics.AddCommand("formats");
}
}
}

View File

@@ -67,6 +67,8 @@ namespace DiscImageChef.Commands
return;
}
Core.Statistics.AddDevice(dev);
switch (dev.Type)
{
case DeviceType.ATA:
@@ -86,6 +88,8 @@ namespace DiscImageChef.Commands
default:
throw new NotSupportedException("Unknown device type.");
}
Core.Statistics.AddCommand("media-info");
}
static void doATAMediaInfo(string outputPrefix, Device dev)
@@ -1076,6 +1080,7 @@ namespace DiscImageChef.Commands
dskType = MediaType.FlashDrive;
DicConsole.WriteLine("Media identified as {0}", dskType);
Core.Statistics.AddMedia(dskType, true);
sense = dev.ReadMediaSerialNumber(out cmdBuf, out senseBuf, dev.Timeout, out duration);
if (sense)

View File

@@ -57,14 +57,12 @@ namespace DiscImageChef.Commands
static string ibgMediaType;
static double ibgDivider;
static bool ibgStartSet;
static int ibgMinSampleRate;
static double ibgMaxSpeed;
static double ibgIntSpeed;
static int ibgSnaps;
static ulong ibgIntSector = 0;
static double ibgIntTime = 0;
static int ibgSampleRate;
static ulong ibgIntSector = 0;
static double ibgIntTime = 0;
static int ibgSampleRate;
public static void doMediaScan(MediaScanSubOptions options)
{
@@ -91,6 +89,8 @@ static int ibgSampleRate;
return;
}
Core.Statistics.AddDevice(dev);
switch (dev.Type)
{
case DeviceType.ATA:
@@ -110,6 +110,8 @@ static int ibgSampleRate;
default:
throw new NotSupportedException("Unknown device type.");
}
Core.Statistics.AddCommand("media-scan");
}
static void doATAMediaScan(string MHDDLogPath, string IBGLogPath, string devicePath, Device dev)
@@ -301,7 +303,7 @@ static int ibgSampleRate;
compactDisc = false;
byte[] readBuffer;
uint blocksToRead = 255;
uint blocksToRead = 64;
ulong A = 0; // <3ms
ulong B = 0; // >=3ms, <10ms
@@ -729,6 +731,8 @@ static int ibgSampleRate;
if (seekTotal != 0 || seekMin != double.MaxValue || seekMax != double.MinValue)
DicConsole.WriteLine("Testing {0} seeks, longest seek took {1} ms, fastest one took {2} ms. ({3} ms average)",
seekTimes, seekMax, seekMin, seekTotal / 1000);
Core.Statistics.AddMediaScan((long)A, (long)B, (long)C, (long)D, (long)E, (long)F, (long)blocks, (long)errored, (long)(blocks - errored));
}
static void initMHDDLogFile(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead)
@@ -873,12 +877,11 @@ static int ibgSampleRate;
ibgDatePoint = DateTime.Now;
ibgCulture = new CultureInfo("en-US");
ibgStartSet = false;
ibgMinSampleRate = int.MaxValue;
ibgMaxSpeed = 0;
ibgIntSpeed = 0;
ibgSnaps = 0;
ibgIntSector = 0;
ibgIntTime = 0;
ibgIntSpeed = 0;
ibgSnaps = 0;
ibgIntSector = 0;
ibgIntTime = 0;
switch (currentProfile)
{

View File

@@ -89,6 +89,8 @@ namespace DiscImageChef.Commands
DiscImageChef.PrintHex.PrintHexArray(sector, options.WidthBytes);
}
Core.Statistics.AddCommand("print-hex");
}
}
}

View File

@@ -0,0 +1,199 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Statistics.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Component
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright (C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
using System;
using DiscImageChef.Console;
namespace DiscImageChef.Commands
{
public static class Statistics
{
public static void showStats()
{
if(Core.Statistics.AllStats == null)
{
DicConsole.WriteLine("There are no statistics.");
return;
}
bool thereAreStats = false;
if (Core.Statistics.AllStats.Commands != null)
{
DicConsole.WriteLine("Commands statistics");
DicConsole.WriteLine("===================");
if (Core.Statistics.AllStats.Commands.Analyze > 0)
DicConsole.WriteLine("You have called the Analyze command {0} times", Core.Statistics.AllStats.Commands.Analyze);
if (Core.Statistics.AllStats.Commands.Benchmark > 0)
DicConsole.WriteLine("You have called the Benchmark command {0} times", Core.Statistics.AllStats.Commands.Benchmark);
if (Core.Statistics.AllStats.Commands.Checksum > 0)
DicConsole.WriteLine("You have called the Checksum command {0} times", Core.Statistics.AllStats.Commands.Checksum);
if (Core.Statistics.AllStats.Commands.Compare > 0)
DicConsole.WriteLine("You have called the Compare command {0} times", Core.Statistics.AllStats.Commands.Compare);
if (Core.Statistics.AllStats.Commands.CreateSidecar > 0)
DicConsole.WriteLine("You have called the Create-Sidecar command {0} times", Core.Statistics.AllStats.Commands.CreateSidecar);
if (Core.Statistics.AllStats.Commands.Decode > 0)
DicConsole.WriteLine("You have called the Decode command {0} times", Core.Statistics.AllStats.Commands.Decode);
if (Core.Statistics.AllStats.Commands.DeviceInfo > 0)
DicConsole.WriteLine("You have called the Device-Info command {0} times", Core.Statistics.AllStats.Commands.DeviceInfo);
if (Core.Statistics.AllStats.Commands.DeviceReport > 0)
DicConsole.WriteLine("You have called the Device-Report command {0} times", Core.Statistics.AllStats.Commands.DeviceReport);
if (Core.Statistics.AllStats.Commands.DumpMedia > 0)
DicConsole.WriteLine("You have called the Dump-Media command {0} times", Core.Statistics.AllStats.Commands.DumpMedia);
if (Core.Statistics.AllStats.Commands.Entropy > 0)
DicConsole.WriteLine("You have called the Entropy command {0} times", Core.Statistics.AllStats.Commands.Entropy);
if (Core.Statistics.AllStats.Commands.Formats > 0)
DicConsole.WriteLine("You have called the Formats command {0} times", Core.Statistics.AllStats.Commands.Formats);
if (Core.Statistics.AllStats.Commands.MediaInfo > 0)
DicConsole.WriteLine("You have called the Media-Info command {0} times", Core.Statistics.AllStats.Commands.MediaInfo);
if (Core.Statistics.AllStats.Commands.MediaScan > 0)
DicConsole.WriteLine("You have called the Media-Scan command {0} times", Core.Statistics.AllStats.Commands.MediaScan);
if (Core.Statistics.AllStats.Commands.PrintHex > 0)
DicConsole.WriteLine("You have called the Print-Hex command {0} times", Core.Statistics.AllStats.Commands.PrintHex);
if (Core.Statistics.AllStats.Commands.Verify > 0)
DicConsole.WriteLine("You have called the Verify command {0} times", Core.Statistics.AllStats.Commands.Verify);
DicConsole.WriteLine();
thereAreStats = true;
}
if(Core.Statistics.AllStats.Benchmark != null)
{
DicConsole.WriteLine("Benchmark statistics");
DicConsole.WriteLine("====================");
foreach (Core.ChecksumStats chk in Core.Statistics.AllStats.Benchmark.Checksum)
{
DicConsole.WriteLine("Took {0} seconds to calculate {1} algorithm", chk.Value, chk.algorithm);
}
DicConsole.WriteLine("Took {0} seconds to calculate all algorithms sequentially", Core.Statistics.AllStats.Benchmark.Sequential);
DicConsole.WriteLine("Took {0} seconds to calculate all algorithms at the same time", Core.Statistics.AllStats.Benchmark.All);
DicConsole.WriteLine("Took {0} seconds to calculate entropy", Core.Statistics.AllStats.Benchmark.Entropy);
DicConsole.WriteLine("Used a maximum of {0} bytes of memory", Core.Statistics.AllStats.Benchmark.MaxMemory);
DicConsole.WriteLine("Used a minimum of {0} bytes of memory", Core.Statistics.AllStats.Benchmark.MinMemory);
DicConsole.WriteLine();
thereAreStats = true;
}
if (Core.Statistics.AllStats.MediaImages != null && Core.Statistics.AllStats.MediaImages.Count > 0)
{
DicConsole.WriteLine("Media image statistics");
DicConsole.WriteLine("======================");
foreach (Core.NameValueStats nvs in Core.Statistics.AllStats.MediaImages)
DicConsole.WriteLine("Format {0} has been found {1} times.", nvs.name, nvs.Value);
DicConsole.WriteLine();
thereAreStats = true;
}
if (Core.Statistics.AllStats.Partitions != null && Core.Statistics.AllStats.Partitions.Count > 0)
{
DicConsole.WriteLine("Partition statistics");
DicConsole.WriteLine("====================");
foreach (Core.NameValueStats nvs in Core.Statistics.AllStats.Partitions)
DicConsole.WriteLine("Partitioning scheme {0} has been found {1} times.", nvs.name, nvs.Value);
DicConsole.WriteLine();
thereAreStats = true;
}
if (Core.Statistics.AllStats.Filesystems != null && Core.Statistics.AllStats.Filesystems.Count > 0)
{
DicConsole.WriteLine("Filesystem statistics");
DicConsole.WriteLine("=====================");
foreach (Core.NameValueStats nvs in Core.Statistics.AllStats.Filesystems)
DicConsole.WriteLine("Filesystem {0} has been found {1} times.", nvs.name, nvs.Value);
DicConsole.WriteLine();
thereAreStats = true;
}
if (Core.Statistics.AllStats.Devices != null && Core.Statistics.AllStats.Devices.Count > 0)
{
DicConsole.WriteLine("Device statistics");
DicConsole.WriteLine("=================");
foreach (Core.DeviceStats ds in Core.Statistics.AllStats.Devices)
DicConsole.WriteLine("Device model {0}, manufactured by {1}, with revision {2} and attached via {3}.", ds.Model, ds.Manufacturer, ds.Revision, ds.Bus);
DicConsole.WriteLine();
thereAreStats = true;
}
if (Core.Statistics.AllStats.Medias != null && Core.Statistics.AllStats.Medias.Count > 0)
{
DicConsole.WriteLine("Media statistics");
DicConsole.WriteLine("================");
foreach (Core.MediaStats ms in Core.Statistics.AllStats.Medias)
{
if (ms.real)
DicConsole.WriteLine("Media type {0} has been found {1} times in a real device.", ms.type, ms.Value);
else
DicConsole.WriteLine("Media type {0} has been found {1} times in a media image.", ms.type, ms.Value);
}
DicConsole.WriteLine();
thereAreStats = true;
}
if (Core.Statistics.AllStats.MediaScan != null)
{
DicConsole.WriteLine("Media scan statistics");
DicConsole.WriteLine("=====================");
DicConsole.WriteLine("Scanned a total of {0} sectors", Core.Statistics.AllStats.MediaScan.Sectors.Total);
DicConsole.WriteLine("{0} of them correctly", Core.Statistics.AllStats.MediaScan.Sectors.Correct);
DicConsole.WriteLine("{0} of them had errors", Core.Statistics.AllStats.MediaScan.Sectors.Error);
DicConsole.WriteLine("{0} of them took less than 3 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan3ms);
DicConsole.WriteLine("{0} of them took less than 10 ms but more than 3 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan10ms);
DicConsole.WriteLine("{0} of them took less than 50 ms but more than 10 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan50ms);
DicConsole.WriteLine("{0} of them took less than 150 ms but more than 50 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan150ms);
DicConsole.WriteLine("{0} of them took less than 500 ms but more than 150 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan500ms);
DicConsole.WriteLine("{0} of them took less than more than 500 ms", Core.Statistics.AllStats.MediaScan.Times.MoreThan500ms);
thereAreStats = true;
}
if (Core.Statistics.AllStats.Verify != null)
{
DicConsole.WriteLine("Verification statistics");
DicConsole.WriteLine("=======================");
DicConsole.WriteLine("{0} media images has been correctly verified", Core.Statistics.AllStats.Verify.MediaImages.Correct);
DicConsole.WriteLine("{0} media images has been determined as containing errors", Core.Statistics.AllStats.Verify.MediaImages.Failed);
DicConsole.WriteLine("{0} sectors has been verified", Core.Statistics.AllStats.Verify.Sectors.Total);
DicConsole.WriteLine("{0} sectors has been determined correct", Core.Statistics.AllStats.Verify.Sectors.Correct);
DicConsole.WriteLine("{0} sectors has been determined to contain errors", Core.Statistics.AllStats.Verify.Sectors.Error);
DicConsole.WriteLine("{0} sectors could not be determined as correct or not", Core.Statistics.AllStats.Verify.Sectors.Unverifiable);
thereAreStats = true;
}
if (!thereAreStats)
DicConsole.WriteLine("There are no statistics.");
}
}
}

View File

@@ -61,6 +61,14 @@ namespace DiscImageChef.Commands
}
inputFormat.OpenImage(options.InputFile);
Core.Statistics.AddMediaFormat(inputFormat.GetImageFormat());
Core.Statistics.AddMedia(inputFormat.ImageInfo.mediaType, false);
bool? correctDisc = null;
long totalSectors = 0;
long errorSectors = 0;
long correctSectors = 0;
long unknownSectors = 0;
if (options.VerifyDisc)
{
@@ -83,6 +91,7 @@ namespace DiscImageChef.Commands
break;
}
correctDisc = discCheckStatus;
DicConsole.VerboseWriteLine("Checking disc image checksums took {0} seconds", CheckTime.TotalSeconds);
}
@@ -253,7 +262,15 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Total errors............ {0}", FailingLBAs.Count);
DicConsole.WriteLine("Total unknowns.......... {0}", UnknownLBAs.Count);
DicConsole.WriteLine("Total errors+unknowns... {0}", FailingLBAs.Count + UnknownLBAs.Count);
totalSectors = (long)inputFormat.GetSectors();
errorSectors = FailingLBAs.Count;
unknownSectors = UnknownLBAs.Count;
correctSectors = totalSectors - errorSectors - unknownSectors;
}
Core.Statistics.AddCommand("verify");
Core.Statistics.AddVerify(correctDisc, correctSectors, errorSectors, unknownSectors, totalSectors);
}
}
}

View File

@@ -0,0 +1,725 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Statistics.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Component
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or(at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright(C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
namespace DiscImageChef.Core
{
[XmlRoot("DicStats", Namespace = "", IsNullable = false)]
public class Stats
{
public CommandsStats Commands;
[XmlArrayItem("Filesystem")]
public List<NameValueStats> Filesystems;
[XmlArrayItem("Scheme")]
public List<NameValueStats> Partitions;
[XmlArrayItem("Format")]
public List<NameValueStats> MediaImages;
[XmlArrayItem("Device", IsNullable = true)]
public List<DeviceStats> Devices;
[XmlArrayItem("Media")]
public List<MediaStats> Medias;
public BenchmarkStats Benchmark;
public MediaScanStats MediaScan;
public VerifyStats Verify;
}
public class CommandsStats
{
public long Analyze;
public long Benchmark;
public long Checksum;
public long Compare;
public long CreateSidecar;
public long Decode;
public long DeviceInfo;
public long DeviceReport;
public long DumpMedia;
public long Entropy;
public long Formats;
public long MediaInfo;
public long MediaScan;
public long PrintHex;
public long Verify;
}
public class VerifiedItems
{
public long Correct;
public long Failed;
}
public class VerifyStats
{
public VerifiedItems MediaImages;
public ScannedSectors Sectors;
}
public class ScannedSectors
{
public long Total;
public long Error;
public long Correct;
public long Unverifiable;
}
public class TimeStats
{
public long LessThan3ms;
public long LessThan10ms;
public long LessThan50ms;
public long LessThan150ms;
public long LessThan500ms;
public long MoreThan500ms;
}
public class MediaScanStats
{
public ScannedSectors Sectors;
public TimeStats Times;
}
public class ChecksumStats
{
[XmlAttribute]
public string algorithm;
[XmlText]
public double Value;
}
public class BenchmarkStats
{
[XmlElement("Checksum")]
public List<ChecksumStats> Checksum;
public double Entropy;
public double All;
public double Sequential;
public long MaxMemory;
public long MinMemory;
}
public class MediaStats
{
[XmlAttribute]
public bool real;
[XmlAttribute]
public string type;
[XmlText]
public long Value;
}
public class DeviceStats
{
public string Manufacturer;
public string Model;
public string Revision;
public string Bus;
[XmlIgnore]
public bool ManufacturerSpecified;
}
public class NameValueStats
{
[XmlAttribute]
public string name;
[XmlText]
public long Value;
}
public static class Statistics
{
public static Stats AllStats;
public static Stats CurrentStats;
public static void LoadStats()
{
if (File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")))
{
AllStats = new Stats();
CurrentStats = new Stats();
XmlSerializer xs = new XmlSerializer(AllStats.GetType());
StreamReader sr = new StreamReader(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"));
AllStats = (Stats)xs.Deserialize(sr);
sr.Close();
}
else if (Settings.Settings.Current.Stats != null)
{
AllStats = new Stats();
CurrentStats = new Stats();
}
else
{
AllStats = null;
CurrentStats = null;
}
}
public static void SaveStats()
{
if (AllStats != null)
{
FileStream fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"), FileMode.Create);
XmlSerializer xs = new XmlSerializer(AllStats.GetType());
xs.Serialize(fs, AllStats);
fs.Close();
if (CurrentStats != null)
{
string partial = string.Format("PartialStats_{0:yyyyMMddHHmmssfff}.xml", DateTime.UtcNow);
fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, partial), FileMode.Create);
xs = new XmlSerializer(CurrentStats.GetType());
xs.Serialize(fs, CurrentStats);
fs.Close();
}
if (Settings.Settings.Current.Stats.ShareStats)
SubmitStats();
}
}
public static void SubmitStats()
{
// TODO: Implement it
}
public static void AddCommand(string command)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.DeviceStats)
{
if (AllStats.Commands == null)
AllStats.Commands = new CommandsStats();
if (CurrentStats.Commands == null)
CurrentStats.Commands = new CommandsStats();
switch (command)
{
case "analyze":
AllStats.Commands.Analyze++;
CurrentStats.Commands.Analyze++;
break;
case "benchmark":
AllStats.Commands.Benchmark++;
CurrentStats.Commands.Benchmark++;
break;
case "checksum":
AllStats.Commands.Checksum++;
CurrentStats.Commands.Checksum++;
break;
case "compare":
AllStats.Commands.Compare++;
CurrentStats.Commands.Compare++;
break;
case "create-sidecar":
AllStats.Commands.CreateSidecar++;
CurrentStats.Commands.CreateSidecar++;
break;
case "decode":
AllStats.Commands.Decode++;
CurrentStats.Commands.Decode++;
break;
case "device-info":
AllStats.Commands.DeviceInfo++;
CurrentStats.Commands.DeviceInfo++;
break;
case "device-report":
AllStats.Commands.DeviceReport++;
CurrentStats.Commands.DeviceReport++;
break;
case "dump-media":
AllStats.Commands.DumpMedia++;
CurrentStats.Commands.DumpMedia++;
break;
case "entropy":
AllStats.Commands.Entropy++;
CurrentStats.Commands.Entropy++;
break;
case "formats":
AllStats.Commands.Formats++;
CurrentStats.Commands.Formats++;
break;
case "media-info":
AllStats.Commands.MediaInfo++;
CurrentStats.Commands.MediaInfo++;
break;
case "media-scan":
AllStats.Commands.MediaScan++;
CurrentStats.Commands.MediaScan++;
break;
case "print-hex":
AllStats.Commands.PrintHex++;
CurrentStats.Commands.PrintHex++;
break;
case "verify":
AllStats.Commands.Verify++;
CurrentStats.Commands.Verify++;
break;
}
}
}
public static void AddFilesystem(string filesystem)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.FilesystemStats)
{
if (AllStats.Filesystems == null)
AllStats.Filesystems = new List<NameValueStats>();
if (CurrentStats.Filesystems == null)
CurrentStats.Filesystems = new List<NameValueStats>();
NameValueStats old = null;
foreach (NameValueStats nvs in AllStats.Filesystems)
{
if (nvs.name == filesystem)
{
old = nvs;
break;
}
}
NameValueStats nw = new NameValueStats();
if (old != null)
{
nw.name = old.name;
nw.Value = old.Value + 1;
AllStats.Filesystems.Remove(old);
}
else
{
nw.name = filesystem;
nw.Value = 1;
}
AllStats.Filesystems.Add(nw);
old = null;
foreach (NameValueStats nvs in CurrentStats.Filesystems)
{
if (nvs.name == filesystem)
{
old = nvs;
break;
}
}
nw = new NameValueStats();
if (old != null)
{
nw.name = old.name;
nw.Value = old.Value + 1;
CurrentStats.Filesystems.Remove(old);
}
else
{
nw.name = filesystem;
nw.Value = 1;
}
CurrentStats.Filesystems.Add(nw);
}
}
public static void AddPartition(string partition)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.PartitionStats)
{
if (AllStats.Partitions == null)
AllStats.Partitions = new List<NameValueStats>();
if (CurrentStats.Partitions == null)
CurrentStats.Partitions = new List<NameValueStats>();
NameValueStats old = null;
foreach (NameValueStats nvs in AllStats.Partitions)
{
if (nvs.name == partition)
{
old = nvs;
break;
}
}
NameValueStats nw = new NameValueStats();
if (old != null)
{
nw.name = old.name;
nw.Value = old.Value + 1;
AllStats.Partitions.Remove(old);
}
else
{
nw.name = partition;
nw.Value = 1;
}
AllStats.Partitions.Add(nw);
old = null;
foreach (NameValueStats nvs in CurrentStats.Partitions)
{
if (nvs.name == partition)
{
old = nvs;
break;
}
}
nw = new NameValueStats();
if (old != null)
{
nw.name = old.name;
nw.Value = old.Value + 1;
CurrentStats.Partitions.Remove(old);
}
else
{
nw.name = partition;
nw.Value = 1;
}
CurrentStats.Partitions.Add(nw);
}
}
public static void AddMediaFormat(string format)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaImageStats)
{
if (AllStats.MediaImages == null)
AllStats.MediaImages = new List<NameValueStats>();
if (CurrentStats.MediaImages == null)
CurrentStats.MediaImages = new List<NameValueStats>();
NameValueStats old = null;
foreach (NameValueStats nvs in AllStats.MediaImages)
{
if (nvs.name == format)
{
old = nvs;
break;
}
}
NameValueStats nw = new NameValueStats();
if (old != null)
{
nw.name = old.name;
nw.Value = old.Value + 1;
AllStats.MediaImages.Remove(old);
}
else
{
nw.name = format;
nw.Value = 1;
}
AllStats.MediaImages.Add(nw);
old = null;
foreach (NameValueStats nvs in CurrentStats.MediaImages)
{
if (nvs.name == format)
{
old = nvs;
break;
}
}
nw = new NameValueStats();
if (old != null)
{
nw.name = old.name;
nw.Value = old.Value + 1;
CurrentStats.MediaImages.Remove(old);
}
else
{
nw.name = format;
nw.Value = 1;
}
CurrentStats.MediaImages.Add(nw);
}
}
public static void AddDevice(Devices.Device dev)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.DeviceStats)
{
if (AllStats.Devices == null)
AllStats.Devices = new List<DeviceStats>();
if (CurrentStats.Devices == null)
CurrentStats.Devices = new List<DeviceStats>();
string deviceBus;
if (dev.IsUSB)
deviceBus = "USB";
else if (dev.IsFireWire)
deviceBus = "FireWire";
else
deviceBus = dev.Type.ToString();
DeviceStats old = null;
foreach (DeviceStats ds in AllStats.Devices)
{
if (ds.Manufacturer == dev.Manufacturer &&
ds.Model == dev.Model &&
ds.Revision == dev.Revision &&
ds.Bus == deviceBus)
{
old = ds;
break;
}
}
if (old != null)
AllStats.Devices.Remove(old);
DeviceStats nw = new DeviceStats();
nw.Model = dev.Model;
nw.Manufacturer = dev.Manufacturer;
nw.Revision = dev.Revision;
nw.Bus = deviceBus;
nw.ManufacturerSpecified = true;
AllStats.Devices.Add(nw);
old = null;
foreach (DeviceStats ds in CurrentStats.Devices)
{
if (ds.Manufacturer == dev.Manufacturer &&
ds.Model == dev.Model &&
ds.Revision == dev.Revision &&
ds.Bus == deviceBus)
{
old = ds;
break;
}
}
if (old != null)
CurrentStats.Devices.Remove(old);
nw = new DeviceStats();
nw.Model = dev.Model;
nw.Manufacturer = dev.Manufacturer;
nw.Revision = dev.Revision;
nw.Bus = deviceBus;
nw.ManufacturerSpecified = true;
CurrentStats.Devices.Add(nw);
}
}
public static void AddMedia(CommonTypes.MediaType type, bool real)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaStats)
{
if (AllStats.Medias == null)
AllStats.Medias = new List<MediaStats>();
if (CurrentStats.Medias == null)
CurrentStats.Medias = new List<MediaStats>();
MediaStats old = null;
foreach (MediaStats ms in AllStats.Medias)
{
if (ms.real == real && ms.type == type.ToString())
{
old = ms;
break;
}
}
MediaStats nw = new MediaStats();
if (old != null)
{
nw.type = old.type;
nw.real = old.real;
nw.Value = old.Value + 1;
AllStats.Medias.Remove(old);
}
else
{
nw.type = type.ToString();
nw.real = real;
nw.Value = 1;
}
AllStats.Medias.Add(nw);
old = null;
foreach (MediaStats ms in CurrentStats.Medias)
{
if (ms.real == real && ms.type == type.ToString())
{
old = ms;
break;
}
}
nw = new MediaStats();
if (old != null)
{
nw.type = old.type;
nw.real = old.real;
nw.Value = old.Value + 1;
CurrentStats.Medias.Remove(old);
}
else
{
nw.type = type.ToString();
nw.real = real;
nw.Value = 1;
}
CurrentStats.Medias.Add(nw);
}
}
public static void AddBenchmark(Dictionary<string, double> checksums, double entropy, double all, double sequential, long maxMemory, long minMemory)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.BenchmarkStats)
{
CurrentStats.Benchmark = new BenchmarkStats();
CurrentStats.Benchmark.Checksum = new List<ChecksumStats>();
AllStats.Benchmark = new BenchmarkStats();
AllStats.Benchmark.Checksum = new List<ChecksumStats>();
foreach (KeyValuePair<string, double> kvp in checksums)
{
ChecksumStats st = new ChecksumStats();
st.algorithm = kvp.Key;
st.Value = kvp.Value;
CurrentStats.Benchmark.Checksum.Add(st);
AllStats.Benchmark.Checksum.Add(st);
}
CurrentStats.Benchmark.All = all;
CurrentStats.Benchmark.Entropy = entropy;
CurrentStats.Benchmark.MaxMemory = maxMemory;
CurrentStats.Benchmark.MinMemory = minMemory;
CurrentStats.Benchmark.Sequential = sequential;
AllStats.Benchmark.All = all;
AllStats.Benchmark.Entropy = entropy;
AllStats.Benchmark.MaxMemory = maxMemory;
AllStats.Benchmark.MinMemory = minMemory;
AllStats.Benchmark.Sequential = sequential;
}
}
public static void AddVerify(bool? mediaVerified, long correct, long failed, long unknown, long total)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.VerifyStats)
{
if (CurrentStats.Verify == null)
{
CurrentStats.Verify = new VerifyStats();
CurrentStats.Verify.MediaImages = new VerifiedItems();
CurrentStats.Verify.Sectors = new ScannedSectors();
}
if (AllStats.Verify == null)
{
AllStats.Verify = new VerifyStats();
AllStats.Verify.MediaImages = new VerifiedItems();
AllStats.Verify.Sectors = new ScannedSectors();
}
if (mediaVerified.HasValue)
{
if (mediaVerified.Value)
{
CurrentStats.Verify.MediaImages.Correct++;
AllStats.Verify.MediaImages.Correct++;
}
else
{
CurrentStats.Verify.MediaImages.Failed++;
AllStats.Verify.MediaImages.Failed++;
}
}
CurrentStats.Verify.Sectors.Correct += correct;
CurrentStats.Verify.Sectors.Error += failed;
CurrentStats.Verify.Sectors.Unverifiable += unknown;
CurrentStats.Verify.Sectors.Total += total;
AllStats.Verify.Sectors.Correct += correct;
AllStats.Verify.Sectors.Error += failed;
AllStats.Verify.Sectors.Unverifiable += unknown;
AllStats.Verify.Sectors.Total += total;
}
}
public static void AddMediaScan(long lessThan3ms, long lessThan10ms, long lessThan50ms, long lessThan150ms, long lessThan500ms, long moreThan500ms, long total, long error, long correct)
{
if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaScanStats)
{
if (CurrentStats.MediaScan == null)
{
CurrentStats.MediaScan = new MediaScanStats();
CurrentStats.MediaScan.Sectors = new ScannedSectors();
CurrentStats.MediaScan.Times = new TimeStats();
}
if (AllStats.MediaScan == null)
{
AllStats.MediaScan = new MediaScanStats();
AllStats.MediaScan.Sectors = new ScannedSectors();
AllStats.MediaScan.Times = new TimeStats();
}
CurrentStats.MediaScan.Sectors.Correct += correct;
CurrentStats.MediaScan.Sectors.Error += error;
CurrentStats.MediaScan.Sectors.Total += total;
CurrentStats.MediaScan.Times.LessThan3ms += lessThan3ms;
CurrentStats.MediaScan.Times.LessThan10ms += lessThan10ms;
CurrentStats.MediaScan.Times.LessThan50ms += lessThan50ms;
CurrentStats.MediaScan.Times.LessThan150ms += lessThan150ms;
CurrentStats.MediaScan.Times.LessThan500ms += lessThan500ms;
CurrentStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
AllStats.MediaScan.Sectors.Correct += correct;
AllStats.MediaScan.Sectors.Error += error;
AllStats.MediaScan.Sectors.Total += total;
AllStats.MediaScan.Times.LessThan3ms += lessThan3ms;
AllStats.MediaScan.Times.LessThan10ms += lessThan10ms;
AllStats.MediaScan.Times.LessThan50ms += lessThan50ms;
AllStats.MediaScan.Times.LessThan150ms += lessThan150ms;
AllStats.MediaScan.Times.LessThan500ms += lessThan500ms;
AllStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
}
}
}
}

View File

@@ -61,6 +61,9 @@
<Compile Include="Commands\DumpMedia.cs" />
<Compile Include="Core\Checksum.cs" />
<Compile Include="Commands\DeviceReport.cs" />
<Compile Include="Commands\Configure.cs" />
<Compile Include="Core\Statistics.cs" />
<Compile Include="Commands\Statistics.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -72,14 +75,14 @@
<Properties>
<Policies>
<VersionControlPolicy inheritsSet="Mono">
<CommitMessageStyle Indent=" " LastFilePostfix=":&#xA; " IncludeDirectoryPaths="True" />
<CommitMessageStyle Indent="&#x9;" LastFilePostfix=":&#xA; " IncludeDirectoryPaths="True" />
</VersionControlPolicy>
<ChangeLogPolicy UpdateMode="ProjectRoot" VcsIntegration="RequireEntry" inheritsSet="Mono">
<MessageStyle LastFilePostfix=":&#xA; " IncludeDirectoryPaths="True" />
</ChangeLogPolicy>
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
<CSharpFormattingPolicy IndentSwitchBody="True" AnonymousMethodBraceStyle="NextLine" PropertyBraceStyle="NextLine" PropertyGetBraceStyle="NextLine" PropertySetBraceStyle="NextLine" EventBraceStyle="NextLine" EventAddBraceStyle="NextLine" EventRemoveBraceStyle="NextLine" StatementBraceStyle="NextLine" ElseNewLinePlacement="NewLine" CatchNewLinePlacement="NewLine" FinallyNewLinePlacement="NewLine" WhileNewLinePlacement="DoNotCare" ArrayInitializerWrapping="DoNotChange" ArrayInitializerBraceStyle="NextLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
<CSharpFormattingPolicy NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" SpacingAfterMethodDeclarationName="False" SpaceAfterMethodCallName="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
<TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
<NameConventionPolicy>
<Rules>
@@ -201,5 +204,9 @@
<Project>{9F213318-5CB8-4066-A757-074489C9F818}</Project>
<Name>DiscImageChef.Metadata</Name>
</ProjectReference>
<ProjectReference Include="..\DiscImageChef.Settings\DiscImageChef.Settings.csproj">
<Project>{5C4C7BAA-CF60-4233-84ED-39CB2312AF38}</Project>
<Name>DiscImageChef.Settings</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@@ -37,12 +37,9 @@ Copyright (C) 2011-2014 Claunia.com
//$Id$
using System;
using System.Collections.Generic;
using DiscImageChef.ImagePlugins;
using DiscImageChef.PartPlugins;
using DiscImageChef.Plugins;
using System.Reflection;
using DiscImageChef.Console;
using DiscImageChef.Settings;
namespace DiscImageChef
{
@@ -80,6 +77,9 @@ namespace DiscImageChef
DicConsole.WriteLine("{0}", AssemblyCopyright);
DicConsole.WriteLine();
Settings.Settings.LoadSettings();
Core.Statistics.LoadStats();
switch (invokedVerb)
{
case "analyze":
@@ -202,9 +202,17 @@ namespace DiscImageChef
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Commands.DeviceReport.doDeviceReport(DeviceReportOptions);
break;
case "configure":
Commands.Configure.doConfigure ();
break;
case "stats":
Commands.Statistics.showStats ();
break;
default:
throw new ArgumentException("Should never arrive here!");
}
Core.Statistics.SaveStats();
}
}
}

View File

@@ -295,6 +295,14 @@ namespace DiscImageChef
public string DevicePath { get; set; }
}
public class ConfigureSubOptions : CommonSubOptions
{
}
public class StatsSubOptions : CommonSubOptions
{
}
public class Options
{
public Options()
@@ -314,6 +322,8 @@ namespace DiscImageChef
MediaScanVerb = new MediaScanSubOptions();
DumpMediaVerb = new DumpMediaSubOptions();
DeviceReportVerb = new DeviceReportSubOptions();
ConfigureVerb = new ConfigureSubOptions();
StatsVerb = new StatsSubOptions();
}
[VerbOption("analyze", HelpText = "Analyzes a disc image and searches for partitions and/or filesystems.")]
@@ -361,6 +371,12 @@ namespace DiscImageChef
[VerbOption("device-report", HelpText = "Tests the device capabilities and creates an XML report of them.")]
public DeviceReportSubOptions DeviceReportVerb { get; set; }
[VerbOption("configure", HelpText = "Configures user settings and statistics.")]
public ConfigureSubOptions ConfigureVerb { get; set; }
[VerbOption("stats", HelpText = "Shows statistics.")]
public StatsSubOptions StatsVerb { get; set; }
[HelpVerbOption]
public string DoHelpForVerb(string verbName)
{