* DiscImageChef/Main.cs:

* DiscImageChef/Options.cs:
	* DiscImageChef/DiscImageChef.csproj:
	* DiscImageChef/Commands/MediaScan.cs:
	  Added media-scan command.

	* DiscImageChef.Decoders/SCSI/Inquiry.cs:
	  Fixes decoding for devices that follow old 5-byte SCSI
	  INQUIRY format.

	* DiscImageChef.Decoders/SCSI/Sense.cs:
	  Fixes printing of sense block missing a newline.

	* DiscImageChef.Devices/Device/Variables.cs:
	* DiscImageChef.Devices/Device/Constructor.cs:
	  Added an IsRemovable field.

	* DiscImageChef.Devices/Device/ScsiCommands.cs:
	  Fixed SCSI READ CAPACITY CDB size.
	Fixed READ CD-DA MSF method name.
	Implemented SCSI SEEK (6) and SEEK (10) commands.

	* DiscImageChef.Devices/Linux/Command.cs:
	* DiscImageChef.Devices/Windows/Command.cs:
	  Fixed memory leaking on unmanaged heap.

	* DiscImageChef.Helpers/StringHandlers.cs:
	  Fixed string conversion when input byte array is null.

	* DiscImageChef/Commands/MediaInfo.cs:
	  Check for inserted medium only on removable media devices.
This commit is contained in:
2015-12-30 11:45:27 +00:00
parent 6928fc1363
commit da29ec63eb
17 changed files with 1009 additions and 42 deletions

View File

@@ -1,3 +1,18 @@
2015-12-30 Natalia Portillo <claunia@claunia.com>
* Device/Variables.cs:
* Device/Constructor.cs:
Added an IsRemovable field.
* Device/ScsiCommands.cs:
Fixed SCSI READ CAPACITY CDB size.
Fixed READ CD-DA MSF method name.
Implemented SCSI SEEK (6) and SEEK (10) commands.
* Linux/Command.cs:
* Windows/Command.cs:
Fixed memory leaking on unmanaged heap.
2015-12-26 Natalia Portillo <claunia@claunia.com>
* Enums.cs:

View File

@@ -53,6 +53,7 @@ namespace DiscImageChef.Devices
platformID = Interop.DetectOS.GetRealPlatformID();
Timeout = 15;
error = false;
removable = false;
switch (platformID)
{
@@ -115,6 +116,7 @@ namespace DiscImageChef.Devices
revision = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductRevisionLevel);
model = StringHandlers.SpacePaddedToString(Inquiry.Value.ProductIdentification);
manufacturer = StringHandlers.SpacePaddedToString(Inquiry.Value.VendorIdentification);
removable = Inquiry.Value.RMB;
scsiType = (Decoders.SCSI.PeripheralDeviceTypes)Inquiry.Value.PeripheralDeviceType;
}
@@ -124,7 +126,7 @@ namespace DiscImageChef.Devices
if (!sense)
{
type = DeviceType.ATAPI;
Decoders.ATA.Identify.IdentifyDevice? ATAID = Decoders.ATA.Identify.Decode(ataBuf);
Identify.IdentifyDevice? ATAID = Identify.Decode(ataBuf);
if (ATAID.HasValue)
serial = ATAID.Value.SerialNumber;
@@ -137,7 +139,7 @@ namespace DiscImageChef.Devices
if (!sense)
{
type = DeviceType.ATA;
Decoders.ATA.Identify.IdentifyDevice? ATAID = Decoders.ATA.Identify.Decode(ataBuf);
Identify.IdentifyDevice? ATAID = Identify.Decode(ataBuf);
if (ATAID.HasValue)
{
@@ -155,6 +157,11 @@ namespace DiscImageChef.Devices
serial = ATAID.Value.SerialNumber;
scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess;
if ((ushort)ATAID.Value.GeneralConfiguration != 0x848A)
{
removable |= (ATAID.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) == Identify.GeneralConfigurationBit.Removable;
}
}
}
}

View File

@@ -592,7 +592,7 @@ namespace DiscImageChef.Devices
public bool ReadCapacity(out byte[] buffer, out byte[] senseBuffer, bool RelAddr, uint address, bool PMI, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
byte[] cdb = new byte[10];
buffer = new byte[8];
bool sense;
@@ -1398,7 +1398,7 @@ namespace DiscImageChef.Devices
/// <param name="endMsf">End MM:SS:FF of read encoded as 0x00MMSSFF.</param>
/// <param name="blockSize">Block size.</param>
/// <param name="subchannel">Subchannel selection.</param>
public bool ReadCdMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf, uint endMsf, uint blockSize, PioneerSubchannel subchannel, uint timeout, out double duration)
public bool ReadCdDaMsf(out byte[] buffer, out byte[] senseBuffer, uint startMsf, uint endMsf, uint blockSize, PioneerSubchannel subchannel, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[12];
@@ -1568,6 +1568,61 @@ namespace DiscImageChef.Devices
return sense;
}
/// <summary>
/// Moves the device reading element to the specified block address
/// </summary>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="lba">LBA.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Seek6(out byte[] senseBuffer, uint lba, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[6];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Seek6;
cdb[1] = (byte)((lba & 0x1F0000) >> 16);
cdb[2] = (byte)((lba & 0xFF00) >> 8);
cdb[3] = (byte)(lba & 0xFF);
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense);
error = lastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "SEEK (6) took {0} ms.", duration);
return sense;
}
/// <summary>
/// Moves the device reading element to the specified block address
/// </summary>
/// <param name="senseBuffer">Sense buffer.</param>
/// <param name="lba">LBA.</param>
/// <param name="timeout">Timeout.</param>
/// <param name="duration">Duration.</param>
public bool Seek10(out byte[] senseBuffer, uint lba, uint timeout, out double duration)
{
senseBuffer = new byte[32];
byte[] cdb = new byte[10];
byte[] buffer = new byte[0];
bool sense;
cdb[0] = (byte)ScsiCommands.Seek10;
cdb[2] = (byte)((lba & 0xFF000000) >> 24);
cdb[3] = (byte)((lba & 0xFF0000) >> 16);
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense);
error = lastError != 0;
DicConsole.DebugWriteLine("SCSI Device", "SEEK (10) took {0} ms.", duration);
return sense;
}
}
}

View File

@@ -52,6 +52,7 @@ namespace DiscImageChef.Devices
readonly string revision;
readonly string serial;
readonly Decoders.SCSI.PeripheralDeviceTypes scsiType;
readonly bool removable;
/// <summary>
/// Gets the Platform ID for this device
@@ -178,6 +179,14 @@ namespace DiscImageChef.Devices
return scsiType;
}
}
public bool IsRemovable
{
get
{
return removable;
}
}
}
}

View File

@@ -97,6 +97,10 @@ namespace DiscImageChef.Devices.Linux
duration = (double)io_hdr.duration;
Marshal.FreeHGlobal(io_hdr.dxferp);
Marshal.FreeHGlobal(io_hdr.cmdp);
Marshal.FreeHGlobal(io_hdr.sbp);
return error;
}

View File

@@ -100,6 +100,8 @@ namespace DiscImageChef.Devices.Windows
duration = (end - start).TotalMilliseconds;
Marshal.FreeHGlobal(sptd_sb.sptd.DataBuffer);
return error;
}
}