mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
* DiscImageChef.Decoders/SCSI/Modes.cs:
Check for vendor pages not following page format (even if they must). * DiscImageChef.Devices/Device/Constructor.cs: Some devices (at least smsc usb-floppy) crash and reset when receiving ata over the ATA PASS-THROUGH scsi command. This will check for SCSI compliance first giving devices time to reset. * DiscImageChef.Devices/Device/ScsiCommands.cs: Some devices (smsc usb floppies) return the real command result size disregarding allocation length and generating a buffer overflow. * DiscImageChef.Devices/Enums.cs: Added some vendor commands for Plextor and HL-DT-ST devices. * DiscImageChef/Commands/DeviceInfo.cs: Mode sense should be written even if it can't be decoded.
This commit is contained in:
@@ -95,33 +95,29 @@ namespace DiscImageChef.Devices
|
||||
AtaErrorRegistersCHS errorRegisters;
|
||||
|
||||
byte[] ataBuf;
|
||||
bool sense = AtaIdentify(out ataBuf, out errorRegisters);
|
||||
byte[] senseBuf;
|
||||
byte[] inqBuf;
|
||||
|
||||
if (!sense)
|
||||
bool scsiSense = ScsiInquiry(out inqBuf, out senseBuf);
|
||||
|
||||
if (!scsiSense)
|
||||
{
|
||||
type = DeviceType.ATA;
|
||||
Decoders.ATA.Identify.IdentifyDevice? ATAID = Decoders.ATA.Identify.Decode(ataBuf);
|
||||
Decoders.SCSI.Inquiry.SCSIInquiry? Inquiry = Decoders.SCSI.Inquiry.Decode(inqBuf);
|
||||
|
||||
if (ATAID.HasValue)
|
||||
type = DeviceType.SCSI;
|
||||
bool sense = ScsiInquiry(out inqBuf, out senseBuf, 0x80);
|
||||
if (!sense)
|
||||
serial = Decoders.SCSI.EVPD.DecodePage80(inqBuf);
|
||||
|
||||
if (Inquiry.HasValue)
|
||||
{
|
||||
string[] separated = ATAID.Value.Model.Split(' ');
|
||||
revision = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductRevisionLevel);
|
||||
model = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductIdentification);
|
||||
manufacturer = StringHandlers.SpacePaddedToString(Inquiry.Value.VendorIdentification);
|
||||
|
||||
if (separated.Length == 1)
|
||||
model = separated[0];
|
||||
else
|
||||
{
|
||||
manufacturer = separated[0];
|
||||
model = separated[separated.Length - 1];
|
||||
}
|
||||
|
||||
revision = ATAID.Value.FirmwareRevision;
|
||||
serial = ATAID.Value.SerialNumber;
|
||||
|
||||
scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess;
|
||||
scsiType = (Decoders.SCSI.PeripheralDeviceTypes)Inquiry.Value.PeripheralDeviceType;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
sense = AtapiIdentify(out ataBuf, out errorRegisters);
|
||||
|
||||
if (!sense)
|
||||
@@ -132,31 +128,32 @@ namespace DiscImageChef.Devices
|
||||
if (ATAID.HasValue)
|
||||
serial = ATAID.Value.SerialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] senseBuf;
|
||||
byte[] inqBuf;
|
||||
|
||||
sense = ScsiInquiry(out inqBuf, out senseBuf);
|
||||
|
||||
if (scsiSense || manufacturer == "ATA")
|
||||
{
|
||||
bool sense = AtaIdentify(out ataBuf, out errorRegisters);
|
||||
if (!sense)
|
||||
{
|
||||
Decoders.SCSI.Inquiry.SCSIInquiry? Inquiry = Decoders.SCSI.Inquiry.Decode(inqBuf);
|
||||
type = DeviceType.ATA;
|
||||
Decoders.ATA.Identify.IdentifyDevice? ATAID = Decoders.ATA.Identify.Decode(ataBuf);
|
||||
|
||||
if (type != DeviceType.ATAPI)
|
||||
if (ATAID.HasValue)
|
||||
{
|
||||
type = DeviceType.SCSI;
|
||||
sense = ScsiInquiry(out inqBuf, out senseBuf, 0x80);
|
||||
if (!sense)
|
||||
serial = Decoders.SCSI.EVPD.DecodePage80(inqBuf);
|
||||
}
|
||||
string[] separated = ATAID.Value.Model.Split(' ');
|
||||
|
||||
if (Inquiry.HasValue)
|
||||
{
|
||||
revision = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductRevisionLevel);
|
||||
model = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductIdentification);
|
||||
manufacturer = StringHandlers.SpacePaddedToString(Inquiry.Value.VendorIdentification);
|
||||
if (separated.Length == 1)
|
||||
model = separated[0];
|
||||
else
|
||||
{
|
||||
manufacturer = separated[0];
|
||||
model = separated[separated.Length - 1];
|
||||
}
|
||||
|
||||
scsiType = (Decoders.SCSI.PeripheralDeviceTypes)Inquiry.Value.PeripheralDeviceType;
|
||||
revision = ATAID.Value.FirmwareRevision;
|
||||
serial = ATAID.Value.SerialNumber;
|
||||
|
||||
scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[5];
|
||||
buffer = new byte[36];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 0, 0, 0, 5, 0 };
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0 };
|
||||
bool sense;
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
@@ -163,9 +163,9 @@ namespace DiscImageChef.Devices
|
||||
/// <param name="page">The Extended Vital Product Data</param>
|
||||
public bool ScsiInquiry(out byte[] buffer, out byte[] senseBuffer, byte page, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[5];
|
||||
buffer = new byte[36];
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 1, page, 0, 5, 0 };
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0 };
|
||||
bool sense;
|
||||
|
||||
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense);
|
||||
@@ -174,6 +174,10 @@ namespace DiscImageChef.Devices
|
||||
if (sense)
|
||||
return true;
|
||||
|
||||
// This is because INQ was returned instead of EVPD
|
||||
if (buffer[1] != page)
|
||||
return true;
|
||||
|
||||
byte pagesLength = (byte)(buffer[3] + 4);
|
||||
|
||||
cdb = new byte[] { (byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0 };
|
||||
@@ -336,7 +340,7 @@ namespace DiscImageChef.Devices
|
||||
{
|
||||
senseBuffer = new byte[32];
|
||||
byte[] cdb = new byte[10];
|
||||
buffer = new byte[4];
|
||||
buffer = new byte[4096];
|
||||
bool sense;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ModeSense10;
|
||||
|
||||
Reference in New Issue
Block a user