* DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs:

Corrected typo

	* DiscImageChef/Commands/DeviceInfo.cs:
	  Moved common code to a static method.
This commit is contained in:
2016-01-14 21:10:39 +00:00
parent afdcc5b729
commit 14b7be1172
4 changed files with 222 additions and 354 deletions

View File

@@ -1,3 +1,8 @@
2016-01-14 Natalia Portillo <claunia@claunia.com>
* Device/ScsiCommands/SyQuest.cs:
Corrected typo
2016-01-14 Natalia Portillo <claunia@claunia.com> 2016-01-14 Natalia Portillo <claunia@claunia.com>
* DiscImageChef.Devices.csproj: * DiscImageChef.Devices.csproj:

View File

@@ -136,7 +136,7 @@ namespace DiscImageChef.Devices
/// <param name="duration">Duration.</param> /// <param name="duration">Duration.</param>
public bool SyQuestReadUsageCounter(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration) public bool SyQuestReadUsageCounter(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
{ {
return AdaptecReadUsageCounter(out buffer, out senseBuffer, false, timeout, duration); return AdaptecReadUsageCounter(out buffer, out senseBuffer, false, timeout, out duration);
} }
/// <summary> /// <summary>

View File

@@ -1,3 +1,8 @@
2016-01-14 Natalia Portillo <claunia@claunia.com>
* Commands/DeviceInfo.cs:
Moved common code to a static method.
2016-01-11 Natalia Portillo <claunia@claunia.com> 2016-01-11 Natalia Portillo <claunia@claunia.com>
* Plugins.cs: * Plugins.cs:

View File

@@ -52,7 +52,6 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Device-Info command", "--verbose={0}", options.Verbose); DicConsole.DebugWriteLine("Device-Info command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Device-Info command", "--device={0}", options.DevicePath); DicConsole.DebugWriteLine("Device-Info command", "--device={0}", options.DevicePath);
DicConsole.DebugWriteLine("Device-Info command", "--output-prefix={0}", options.OutputPrefix); DicConsole.DebugWriteLine("Device-Info command", "--output-prefix={0}", options.OutputPrefix);
FileStream outputFs;
if (options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && if (options.DevicePath.Length == 2 && options.DevicePath[1] == ':' &&
options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0]))
@@ -115,25 +114,7 @@ namespace DiscImageChef.Commands
break; break;
} }
if(!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, "_ata_identify.bin", "ATA IDENTIFY", ataBuf);
{
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)); DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf));
break; break;
@@ -159,25 +140,7 @@ namespace DiscImageChef.Commands
break; break;
} }
if (!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, "_atapi_identify.bin", "ATAPI IDENTIFY", ataBuf);
{
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)); DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf));
@@ -201,30 +164,12 @@ namespace DiscImageChef.Commands
if (dev.Type != DeviceType.ATAPI) if (dev.Type != DeviceType.ATAPI)
DicConsole.WriteLine("SCSI device"); DicConsole.WriteLine("SCSI device");
if(!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, "_scsi_inquiry.bin", "SCSI IDENTIFY", inqBuf);
{
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); Decoders.SCSI.Inquiry.SCSIInquiry? inq = Decoders.SCSI.Inquiry.Decode(inqBuf);
DicConsole.WriteLine(Decoders.SCSI.Inquiry.Prettify(inq)); DicConsole.WriteLine(Decoders.SCSI.Inquiry.Prettify(inq));
bool scsi83 = false; bool scsi80 = false;
string scsiSerial = null; string scsiSerial = null;
StringBuilder sb = null; StringBuilder sb = null;
@@ -247,25 +192,7 @@ namespace DiscImageChef.Commands
sb = new StringBuilder(); sb = new StringBuilder();
sb.AppendFormat("Page 0x{0:X2}: ", Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf)).AppendLine(); sb.AppendFormat("Page 0x{0:X2}: ", Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf)).AppendLine();
if(!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), String.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
{
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) else if (page == 0x80)
@@ -273,28 +200,10 @@ namespace DiscImageChef.Commands
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
if (!sense) if (!sense)
{ {
scsi83 = true; scsi80 = true;
scsiSerial = Decoders.SCSI.EVPD.DecodePage80(inqBuf); scsiSerial = Decoders.SCSI.EVPD.DecodePage80(inqBuf);
if(!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), String.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
{
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 else
@@ -306,25 +215,7 @@ namespace DiscImageChef.Commands
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
if (!sense) if (!sense)
{ {
if(!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), String.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
{
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));
}
} }
} }
} }
@@ -332,7 +223,7 @@ namespace DiscImageChef.Commands
} }
} }
if (scsi83) if (scsi80)
DicConsole.WriteLine("Unit Serial Number: {0}", scsiSerial); DicConsole.WriteLine("Unit Serial Number: {0}", scsiSerial);
if (sb != null) if (sb != null)
@@ -370,27 +261,7 @@ namespace DiscImageChef.Commands
} }
if (!sense) if (!sense)
{ doWriteFile(options.OutputPrefix, "_scsi_modesense.bin", "SCSI MODE SENSE", modeBuf);
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");
}
}
if (decMode.HasValue) if (decMode.HasValue)
{ {
@@ -625,25 +496,7 @@ namespace DiscImageChef.Commands
if (!sense) if (!sense)
{ {
if(!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, "_mmc_getconfiguration.bin", "MMC GET CONFIGURATION", confBuf);
{
if (!File.Exists(options.OutputPrefix + "_mmc_getconfiguration.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing MMC GET CONFIGURATION 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); Decoders.SCSI.MMC.Features.SeparatedFeatures ftr = Decoders.SCSI.MMC.Features.Separate(confBuf);
@@ -886,7 +739,6 @@ namespace DiscImageChef.Commands
} }
} }
*/ */
}
#region Plextor #region Plextor
if (dev.Manufacturer == "PLEXTOR") if (dev.Manufacturer == "PLEXTOR")
@@ -933,25 +785,7 @@ namespace DiscImageChef.Commands
if (!plxtSense) if (!plxtSense)
{ {
if(!string.IsNullOrEmpty(options.OutputPrefix)) doWriteFile(options.OutputPrefix, "_plextor_eeprom.bin", "PLEXTOR READ EEPROM", plxtBuf);
{
if (!File.Exists(options.OutputPrefix + "_plextor_eeprom.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing PLEXTOR READ EEPROM to {0}{1}", options.OutputPrefix, "_plextor_eeprom.bin");
outputFs = new FileStream(options.OutputPrefix +"_plextor_eeprom.bin", FileMode.CreateNew);
outputFs.Write(plxtBuf, 0, plxtBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_plextor_eeprom.bin");
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_plextor_eeprom.bin");
}
ushort discs; ushort discs;
uint cdReadTime, cdWriteTime, dvdReadTime = 0, dvdWriteTime = 0; uint cdReadTime, cdWriteTime, dvdReadTime = 0, dvdWriteTime = 0;
@@ -1107,6 +941,7 @@ namespace DiscImageChef.Commands
} }
} }
#endregion Plextor #endregion Plextor
}
break; break;
} }
@@ -1115,6 +950,29 @@ namespace DiscImageChef.Commands
break; break;
} }
} }
static void doWriteFile(string outputPrefix, string outputSuffix, string whatWriting, byte[] data)
{
if(!string.IsNullOrEmpty(outputPrefix))
{
if (!File.Exists(outputPrefix + outputSuffix))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing " + whatWriting + " to {0}{1}", outputPrefix, outputSuffix);
FileStream outputFs = new FileStream(outputPrefix + outputSuffix, FileMode.CreateNew);
outputFs.Write(data, 0, data.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", outputPrefix, outputSuffix);
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", outputPrefix, outputSuffix);
}
}
} }
} }