diff --git a/DiscImageChef/ChangeLog b/DiscImageChef/ChangeLog index 1b9599f4..f2524789 100644 --- a/DiscImageChef/ChangeLog +++ b/DiscImageChef/ChangeLog @@ -1,3 +1,10 @@ +2015-11-02 Natalia Portillo + + * Options.cs: + * Commands/DeviceInfo.cs: + Added option to dump binary responses got from devices while + getting device info. + 2015-11-02 Natalia Portillo * Commands/DeviceInfo.cs: diff --git a/DiscImageChef/Commands/DeviceInfo.cs b/DiscImageChef/Commands/DeviceInfo.cs index 59f6c000..c4f9a485 100644 --- a/DiscImageChef/Commands/DeviceInfo.cs +++ b/DiscImageChef/Commands/DeviceInfo.cs @@ -50,6 +50,8 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Device-Info command", "--debug={0}", options.Debug); DicConsole.DebugWriteLine("Device-Info command", "--verbose={0}", options.Verbose); DicConsole.DebugWriteLine("Device-Info command", "--device={0}", options.DevicePath); + DicConsole.DebugWriteLine("Device-Info command", "--output-prefix={0}", options.OutputPrefix); + FileStream outputFs; if (options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) @@ -88,6 +90,26 @@ namespace DiscImageChef.Commands break; } + if(!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + "_ata_identify.bin")) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing ATA IDENTIFY to {0}{1}", options.OutputPrefix, "_ata_identify.bin"); + outputFs = new FileStream(options.OutputPrefix + "_ata_identify.bin", FileMode.CreateNew); + outputFs.Write(ataBuf, 0, ataBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_ata_identify.bin"); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_ata_identify.bin"); + } + DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf)); break; } @@ -112,6 +134,26 @@ namespace DiscImageChef.Commands break; } + if (!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + "_atapi_identify.bin")) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing ATAPI IDENTIFY to {0}{1}", options.OutputPrefix, "_atapi_identify.bin"); + outputFs = new FileStream(options.OutputPrefix + "_atapi_identify.bin", FileMode.CreateNew); + outputFs.Write(ataBuf, 0, ataBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_atapi_identify.bin"); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_atapi_identify.bin"); + } + DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf)); // ATAPI devices are also SCSI devices @@ -139,6 +181,26 @@ namespace DiscImageChef.Commands if (dev.Type != DeviceType.ATAPI) DicConsole.WriteLine("SCSI device"); + if(!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + "_scsi_inquiry.bin")) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY to {0}{1}", options.OutputPrefix, "_scsi_inquiry.bin"); + outputFs = new FileStream(options.OutputPrefix + "_scsi_inquiry.bin", FileMode.CreateNew); + outputFs.Write(inqBuf, 0, inqBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_scsi_inquiry.bin"); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_scsi_inquiry.bin"); + } + Decoders.SCSI.Inquiry.SCSIInquiry? inq = Decoders.SCSI.Inquiry.Decode(inqBuf); DicConsole.WriteLine(Decoders.SCSI.Inquiry.Prettify(inq)); @@ -164,6 +226,26 @@ namespace DiscImageChef.Commands if (sb == null) sb = new StringBuilder(); sb.AppendFormat("Page 0x{0:X2}: ", Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf)).AppendLine(); + + if(!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page))) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY EVPD {2:X2}h to {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), page); + outputFs = new FileStream(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page), FileMode.CreateNew); + outputFs.Write(inqBuf, 0, inqBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page)); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page)); + } } } else if (page == 0x80) @@ -173,12 +255,58 @@ namespace DiscImageChef.Commands { scsi83 = true; scsiSerial = Decoders.SCSI.EVPD.DecodePage80(inqBuf); + + if(!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page))) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY EVPD {2:X2}h to {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), page); + outputFs = new FileStream(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page), FileMode.CreateNew); + outputFs.Write(inqBuf, 0, inqBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page)); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page)); + } } } else { if (page != 0x00) + { DicConsole.DebugWriteLine("Device-Info command", "Found undecoded SCSI VPD page 0x{0:X2}", page); + + sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); + if (!sense) + { + if(!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page))) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI INQUIRY EVPD {2:X2}h to {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), page); + outputFs = new FileStream(options.OutputPrefix + String.Format("_scsi_evpd_{0:X2}h.bin", page), FileMode.CreateNew); + outputFs.Write(inqBuf, 0, inqBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page)); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page)); + } + } + } } } } @@ -223,6 +351,26 @@ namespace DiscImageChef.Commands if (decMode.HasValue) { + if(!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + "_scsi_modesense.bin")) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI MODE SENSE to {0}{1}", options.OutputPrefix, "_scsi_modesense.bin"); + outputFs = new FileStream(options.OutputPrefix +"_scsi_modesense.bin", FileMode.CreateNew); + outputFs.Write(modeBuf, 0, modeBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_scsi_modesense.bin"); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_scsi_modesense.bin"); + } + DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModeHeader(decMode.Value.Header, devType)); if (decMode.Value.Pages != null) @@ -454,6 +602,26 @@ namespace DiscImageChef.Commands if (!sense) { + if(!string.IsNullOrEmpty(options.OutputPrefix)) + { + if (!File.Exists(options.OutputPrefix + "_mmc_getconfiguration.bin")) + { + try + { + DicConsole.DebugWriteLine("Device-Info command", "Writing SCSI MODE SENSE to {0}{1}", options.OutputPrefix, "_mmc_getconfiguration.bin"); + outputFs = new FileStream(options.OutputPrefix +"_mmc_getconfiguration.bin", FileMode.CreateNew); + outputFs.Write(confBuf, 0, confBuf.Length); + outputFs.Close(); + } + catch + { + DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_mmc_getconfiguration.bin"); + } + } + else + DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_mmc_getconfiguration.bin"); + } + Decoders.SCSI.MMC.Features.SeparatedFeatures ftr = Decoders.SCSI.MMC.Features.Separate(confBuf); DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", ftr.DataLength); diff --git a/DiscImageChef/Options.cs b/DiscImageChef/Options.cs index 768db960..cf60f942 100644 --- a/DiscImageChef/Options.cs +++ b/DiscImageChef/Options.cs @@ -218,6 +218,9 @@ namespace DiscImageChef { [Option('i', "device", Required = true, HelpText = "Device path.")] public string DevicePath { get; set; } + + [Option('w', "output-prefix", Required = false, DefaultValue = "", HelpText = "Write binary responses from device with that prefix.")] + public string OutputPrefix { get; set; } } public class FormatsSubOptions : CommonSubOptions