Add option to not write metadata dumping.

This commit is contained in:
2018-02-02 22:03:19 +00:00
parent efcf1720e2
commit 448d55b547
10 changed files with 650 additions and 637 deletions

View File

@@ -81,7 +81,9 @@ namespace DiscImageChef.Core.Devices.Dumping
DumpLog dumpLog, Encoding encoding, string outputPrefix,
string outputPath,
Dictionary<string, string>
formatOptions, CICMMetadataType preSidecar, uint skip)
formatOptions, CICMMetadataType preSidecar, uint skip,
bool
nometadata)
{
bool aborted;
@@ -116,7 +118,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DateTime start;
DateTime end;
double totalDuration = 0;
double totalChkDuration = 0;
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
@@ -450,6 +451,9 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
double totalChkDuration = 0;
if(!nometadata)
{
dumpLog.WriteLine("Creating sidecar.");
FiltersList filters = new FiltersList();
IFilter filter = filters.GetFilter(outputPath);
@@ -565,16 +569,20 @@ namespace DiscImageChef.Core.Devices.Dumping
if(filesystems.Count > 0)
foreach(var filesystem in filesystems.Select(o => new {o.start, o.type}).Distinct())
dumpLog.WriteLine("Found filesystem {0} at sector {1}", filesystem.type, filesystem.start);
dumpLog.WriteLine("Found filesystem {0} at sector {1}", filesystem.type,
filesystem.start);
DicConsole.WriteLine();
string xmlDskTyp, xmlDskSubTyp;
if(dev.IsCompactFlash)
Metadata.MediaType.MediaTypeToString(MediaType.CompactFlash, out xmlDskTyp, out xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(MediaType.CompactFlash, out xmlDskTyp,
out xmlDskSubTyp);
else if(dev.IsPcmcia)
Metadata.MediaType.MediaTypeToString(MediaType.PCCardTypeI, out xmlDskTyp, out xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(MediaType.PCCardTypeI, out xmlDskTyp,
out xmlDskSubTyp);
else
Metadata.MediaType.MediaTypeToString(MediaType.GENERIC_HDD, out xmlDskTyp, out xmlDskSubTyp);
Metadata.MediaType.MediaTypeToString(MediaType.GENERIC_HDD, out xmlDskTyp,
out xmlDskSubTyp);
sidecar.BlockMedia[0].DiskType = xmlDskTyp;
sidecar.BlockMedia[0].DiskSubType = xmlDskSubTyp;
sidecar.BlockMedia[0].Interface = "ATA";
@@ -595,6 +603,15 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].SectorsPerTrackSpecified = true;
}
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
DicConsole.WriteLine();
DicConsole
@@ -608,17 +625,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine("{0} sectors could not be read.", resume.BadBlocks.Count);
if(resume.BadBlocks.Count > 0) resume.BadBlocks.Sort();
DicConsole.WriteLine();
if(!aborted)
{
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
}
if(dev.IsCompactFlash) Statistics.AddMedia(MediaType.CompactFlash, true);

View File

@@ -91,7 +91,7 @@ namespace DiscImageChef.Core.Devices.Dumping
string
outputPrefix, string outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType
preSidecar, uint skip)
preSidecar, uint skip, bool nometadata)
{
uint subSize;
DateTime start;
@@ -920,6 +920,9 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
double totalChkDuration = 0;
if(!nometadata)
{
dumpLog.WriteLine("Creating sidecar.");
FiltersList filters = new FiltersList();
IFilter filter = filters.GetFilter(outputPath);
@@ -930,7 +933,7 @@ namespace DiscImageChef.Core.Devices.Dumping
CICMMetadataType sidecar = Sidecar.Create(inputPlugin, outputPath, filter.Id, encoding);
end = DateTime.UtcNow;
double totalChkDuration = (end - chkStart).TotalMilliseconds;
totalChkDuration = (end - chkStart).TotalMilliseconds;
dumpLog.WriteLine("Sidecar created in {0} seconds.", (end - chkStart).TotalSeconds);
dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
@@ -964,6 +967,15 @@ namespace DiscImageChef.Core.Devices.Dumping
if(outputPlugin.SupportedMediaTags.Contains(tag.Key))
Mmc.AddMediaTagToSidecar(outputPath, tag, ref sidecar);
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
DicConsole.WriteLine();
DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming, {3:F3} writing, {4:F3} closing).",
@@ -977,17 +989,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine("{0} sectors could not be read.", resume.BadBlocks.Count);
DicConsole.WriteLine();
if(!aborted)
{
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
Statistics.AddMedia(dskType, true);
}
}

View File

@@ -84,7 +84,7 @@ namespace DiscImageChef.Core.Devices.Dumping
string
outputPrefix, string outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType
preSidecar, uint skip)
preSidecar, uint skip, bool nometadata)
{
bool sense;
ulong blocks;
@@ -200,7 +200,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
CompactDisc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
ref dskType, ref resume, ref dumpLog, dumpLeadIn, encoding, outputPrefix, outputPath,
formatOptions, preSidecar, skip);
formatOptions, preSidecar, skip, nometadata);
return;
}
@@ -602,13 +602,13 @@ namespace DiscImageChef.Core.Devices.Dumping
{
Xgd.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError, mediaTags,
ref dskType, ref resume, ref dumpLog, encoding, outputPrefix, outputPath, formatOptions,
preSidecar, skip);
preSidecar, skip, nometadata);
return;
}
Sbc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError, mediaTags,
ref dskType, true, ref resume, ref dumpLog, encoding, outputPrefix, outputPath, formatOptions,
preSidecar, skip);
preSidecar, skip, nometadata);
}
internal static void AddMediaTagToSidecar(string outputPath,

View File

@@ -50,7 +50,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DumpLog dumpLog, Encoding encoding, string outputPrefix,
string outputPath,
Dictionary<string, string>
formatOptions, CICMMetadataType preSidecar, uint skip)
formatOptions, CICMMetadataType preSidecar, uint skip, bool nometadata)
{
throw new NotImplementedException("NVMe devices not yet supported.");
}

View File

@@ -87,7 +87,7 @@ namespace DiscImageChef.Core.Devices.Dumping
string outputPath,
Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar,
uint skip)
uint skip, bool nometadata)
{
bool sense;
ulong blocks;
@@ -101,7 +101,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DateTime start;
DateTime end;
double totalDuration = 0;
double totalChkDuration = 0;
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
@@ -674,6 +673,9 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
double totalChkDuration = 0;
if(!nometadata)
{
dumpLog.WriteLine("Creating sidecar.");
FiltersList filters = new FiltersList();
IFilter filter = filters.GetFilter(outputPath);
@@ -810,11 +812,11 @@ namespace DiscImageChef.Core.Devices.Dumping
*/
dumpLog.WriteLine("Requesting MODE SENSE (10).");
sense = dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F,
0xFF, 5, out _);
if(!sense || dev.Error)
sense = dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
0x3F, 0x00, 5, out _);
0x3F, 0xFF, 5, out _);
if(!sense || dev.Error)
sense = dev.ModeSense10(out cmdBuf, out _, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _);
decMode = null;
@@ -829,8 +831,8 @@ namespace DiscImageChef.Core.Devices.Dumping
};
dumpLog.WriteLine("Requesting MODE SENSE (6).");
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F, 0x00,
5, out _);
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out _);
if(sense || dev.Error)
sense = dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out _);
@@ -883,6 +885,15 @@ namespace DiscImageChef.Core.Devices.Dumping
if(dev.IsRemovable) sidecar.BlockMedia[0].DumpHardwareArray = resume.Tries.ToArray();
}
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
DicConsole.WriteLine();
DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming, {3:F3} writing, {4:F3} closing).",
(end - start).TotalSeconds, totalDuration / 1000,
@@ -895,17 +906,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine("{0} sectors could not be read.", resume.BadBlocks.Count);
DicConsole.WriteLine();
if(!aborted)
{
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
Statistics.AddMedia(dskType, true);
}
}

View File

@@ -79,7 +79,7 @@ namespace DiscImageChef.Core.Devices.Dumping
string
outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType
preSidecar, uint skip)
preSidecar, uint skip, bool nometadata)
{
MediaType dskType = MediaType.Unknown;
int resets = 0;
@@ -212,12 +212,12 @@ namespace DiscImageChef.Core.Devices.Dumping
case PeripheralDeviceTypes.MultiMediaDevice:
Mmc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
ref dskType, ref resume, ref dumpLog, dumpLeadIn, encoding, outputPrefix, outputPath,
formatOptions, preSidecar, skip);
formatOptions, preSidecar, skip, nometadata);
return;
default:
Sbc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError, null,
ref dskType, false, ref resume, ref dumpLog, encoding, outputPrefix, outputPath,
formatOptions, preSidecar, skip);
formatOptions, preSidecar, skip, nometadata);
break;
}
}

View File

@@ -79,7 +79,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DumpLog dumpLog, Encoding encoding, string outputPrefix,
string outputPath,
Dictionary<string, string>
formatOptions, CICMMetadataType preSidecar, uint skip)
formatOptions, CICMMetadataType preSidecar, uint skip, bool nometadata)
{
bool aborted;
@@ -196,7 +196,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DateTime start;
DateTime end;
double totalDuration = 0;
double totalChkDuration = 0;
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
@@ -417,6 +416,9 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
double totalChkDuration = 0;
if(!nometadata)
{
dumpLog.WriteLine("Creating sidecar.");
FiltersList filters = new FiltersList();
IFilter filter = filters.GetFilter(outputPath);
@@ -598,6 +600,15 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].Serial = dev.Serial;
sidecar.BlockMedia[0].Size = (long)(blocks * blockSize);
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
DicConsole.WriteLine();
DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming, {3:F3} writing, {4:F3} closing).",
@@ -612,17 +623,6 @@ namespace DiscImageChef.Core.Devices.Dumping
if(resume.BadBlocks.Count > 0) resume.BadBlocks.Sort();
DicConsole.WriteLine();
if(!aborted)
{
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
switch(dev.Type)
{
case DeviceType.MMC:

View File

@@ -88,7 +88,7 @@ namespace DiscImageChef.Core.Devices.Dumping
ref DumpLog dumpLog,
Encoding encoding, string outputPrefix, string outputPath,
Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar, uint skip)
CICMMetadataType preSidecar, uint skip, bool nometadata)
{
bool sense;
ulong blocks;
@@ -97,7 +97,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DateTime start;
DateTime end;
double totalDuration = 0;
double totalChkDuration = 0;
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
@@ -809,6 +808,9 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
double totalChkDuration = 0;
if(!nometadata)
{
dumpLog.WriteLine("Creating sidecar.");
FiltersList filters = new FiltersList();
IFilter filter = filters.GetFilter(outputPath);
@@ -863,6 +865,15 @@ namespace DiscImageChef.Core.Devices.Dumping
if(outputPlugin.SupportedMediaTags.Contains(tag.Key))
Mmc.AddMediaTagToSidecar(outputPath, tag, ref sidecar);
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
DicConsole.WriteLine();
DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming, {3:F3} writing, {4:F3} closing).",
(end - start).TotalSeconds, totalDuration / 1000,
@@ -875,17 +886,6 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine("{0} sectors could not be read.", resume.BadBlocks.Count);
DicConsole.WriteLine();
if(!aborted)
{
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(outputPrefix + ".cicm.xml", FileMode.Create);
XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
}
Statistics.AddMedia(dskType, true);
}
}

View File

@@ -77,6 +77,7 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Dump-Media command", "--options={0}", options.Options);
DicConsole.DebugWriteLine("Dump-Media command", "--cicm-xml={0}", options.CicmXml);
DicConsole.DebugWriteLine("Dump-Media command", "--skip={0}", options.Skip);
DicConsole.DebugWriteLine("Dump-Media command", "--no-metadata={0}", options.NoMetadata);
Dictionary<string, string> parsedOptions = Options.Parse(options.Options);
DicConsole.DebugWriteLine("Dump-Media command", "Parsed options:");
@@ -206,24 +207,26 @@ namespace DiscImageChef.Commands
case DeviceType.ATA:
Ata.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, options.Raw,
options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding, outputPrefix,
options.OutputFile, parsedOptions, sidecar, options.Skip);
options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata);
break;
case DeviceType.MMC:
case DeviceType.SecureDigital:
SecureDigital.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force,
options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog,
encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, options.Skip);
encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip,
options.NoMetadata);
break;
case DeviceType.NVMe:
NvMe.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, options.Raw,
options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding, outputPrefix,
options.OutputFile, parsedOptions, sidecar, options.Skip);
options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata);
break;
case DeviceType.ATAPI:
case DeviceType.SCSI:
Scsi.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, options.Raw,
options.Persistent, options.StopOnError, ref resume, ref dumpLog, options.LeadIn,
encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, options.Skip);
encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip,
options.NoMetadata);
break;
default:
dumpLog.WriteLine("Unknown device type.");

View File

@@ -310,7 +310,10 @@ namespace DiscImageChef
public string CicmXml { get; set; }
[Option('k', "skip", Default = 512, HelpText = "When an unreadable sector is found skip this many sectors.")]
public uint Skip { get; set; }
public int Skip { get; set; }
[Option("no-metadata", Default = false, HelpText = "Disables creating CICM XML sidecar.")]
public bool NoMetadata { get; set; }
}
[Verb("device-report", HelpText = "Tests the device capabilities and creates an XML report of them.")]