mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Implemented SCSI PREVENT ALLOW MEDIUM REMOVAL command.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2015-10-24 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
|
* Enums.cs:
|
||||||
|
* Device/ScsiCommands.cs:
|
||||||
|
Implemented SCSI PREVENT ALLOW MEDIUM REMOVAL command.
|
||||||
|
|
||||||
2015-10-24 Natalia Portillo <claunia@claunia.com>
|
2015-10-24 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
* Enums.cs:
|
* Enums.cs:
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// Sends the SCSI MODE SENSE(6) command to the device as introduced in SCSI-1
|
/// Sends the SCSI MODE SENSE(6) command to the device as introduced in SCSI-1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
/// <param name="buffer">Buffer where the SCSI INQUIRY response will be stored</param>
|
/// <param name="buffer">Buffer where the SCSI MODE SENSE(6) response will be stored</param>
|
||||||
/// <param name="senseBuffer">Sense buffer.</param>
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
/// <param name="timeout">Timeout in seconds.</param>
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
@@ -227,7 +227,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// Sends the SCSI MODE SENSE(6) command to the device as introduced in SCSI-2
|
/// Sends the SCSI MODE SENSE(6) command to the device as introduced in SCSI-2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
/// <param name="buffer">Buffer where the SCSI INQUIRY response will be stored</param>
|
/// <param name="buffer">Buffer where the SCSI MODE SENSE(6) response will be stored</param>
|
||||||
/// <param name="senseBuffer">Sense buffer.</param>
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
/// <param name="timeout">Timeout in seconds.</param>
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
@@ -243,7 +243,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// Sends the SCSI MODE SENSE(6) command to the device as introduced in SCSI-3 SPC-3
|
/// Sends the SCSI MODE SENSE(6) command to the device as introduced in SCSI-3 SPC-3
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
/// <param name="buffer">Buffer where the SCSI INQUIRY response will be stored</param>
|
/// <param name="buffer">Buffer where the SCSI MODE SENSE(6) response will be stored</param>
|
||||||
/// <param name="senseBuffer">Sense buffer.</param>
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
/// <param name="timeout">Timeout in seconds.</param>
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
@@ -290,7 +290,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// Sends the SCSI MODE SENSE(10) command to the device as introduced in SCSI-2
|
/// Sends the SCSI MODE SENSE(10) command to the device as introduced in SCSI-2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
/// <param name="buffer">Buffer where the SCSI INQUIRY response will be stored</param>
|
/// <param name="buffer">Buffer where the SCSI MODE SENSE(10) response will be stored</param>
|
||||||
/// <param name="senseBuffer">Sense buffer.</param>
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
/// <param name="timeout">Timeout in seconds.</param>
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
@@ -306,7 +306,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// Sends the SCSI MODE SENSE(10) command to the device as introduced in SCSI-3 SPC-2
|
/// Sends the SCSI MODE SENSE(10) command to the device as introduced in SCSI-3 SPC-2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
/// <param name="buffer">Buffer where the SCSI INQUIRY response will be stored</param>
|
/// <param name="buffer">Buffer where the SCSI MODE SENSE(10) response will be stored</param>
|
||||||
/// <param name="senseBuffer">Sense buffer.</param>
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
/// <param name="timeout">Timeout in seconds.</param>
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
@@ -323,7 +323,7 @@ namespace DiscImageChef.Devices
|
|||||||
/// Sends the SCSI MODE SENSE(10) command to the device as introduced in SCSI-3 SPC-3
|
/// Sends the SCSI MODE SENSE(10) command to the device as introduced in SCSI-3 SPC-3
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
/// <param name="buffer">Buffer where the SCSI INQUIRY response will be stored</param>
|
/// <param name="buffer">Buffer where the SCSI MODE SENSE(10) response will be stored</param>
|
||||||
/// <param name="senseBuffer">Sense buffer.</param>
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
/// <param name="timeout">Timeout in seconds.</param>
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
@@ -370,6 +370,76 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
return sense;
|
return sense;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the SCSI PREVENT ALLOW MEDIUM REMOVAL command to prevent medium removal
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c>, if allow medium removal was prevented, <c>false</c> otherwise.</returns>
|
||||||
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
|
public bool PreventMediumRemoval(out byte[] senseBuffer, uint timeout, out double duration)
|
||||||
|
{
|
||||||
|
return PreventAllowMediumRemoval(out senseBuffer, ScsiPreventAllowMode.Prevent, timeout, out duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the SCSI PREVENT ALLOW MEDIUM REMOVAL command to allow medium removal
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c>, if allow medium removal was prevented, <c>false</c> otherwise.</returns>
|
||||||
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
|
public bool AllowMediumRemoval(out byte[] senseBuffer, uint timeout, out double duration)
|
||||||
|
{
|
||||||
|
return PreventAllowMediumRemoval(out senseBuffer, ScsiPreventAllowMode.Allow, timeout, out duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the SCSI PREVENT ALLOW MEDIUM REMOVAL command
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c>, if allow medium removal was prevented, <c>false</c> otherwise.</returns>
|
||||||
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
|
/// <param name="prevent"><c>true</c> to prevent medium removal, <c>false</c> to allow it.</param>
|
||||||
|
public bool PreventAllowMediumRemoval(out byte[] senseBuffer, bool prevent, uint timeout, out double duration)
|
||||||
|
{
|
||||||
|
if (prevent)
|
||||||
|
return PreventAllowMediumRemoval(out senseBuffer, ScsiPreventAllowMode.Prevent, timeout, out duration);
|
||||||
|
else
|
||||||
|
return PreventAllowMediumRemoval(out senseBuffer, ScsiPreventAllowMode.Allow, timeout, out duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the SCSI PREVENT ALLOW MEDIUM REMOVAL command
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c>, if allow medium removal was prevented, <c>false</c> otherwise.</returns>
|
||||||
|
/// <returns><c>true</c> if the command failed and <paramref name="senseBuffer"/> contains the sense buffer.</returns>
|
||||||
|
/// <param name="senseBuffer">Sense buffer.</param>
|
||||||
|
/// <param name="timeout">Timeout in seconds.</param>
|
||||||
|
/// <param name="duration">Duration in milliseconds it took for the device to execute the command.</param>
|
||||||
|
/// <param name="preventMode">Prevention mode.</param>
|
||||||
|
public bool PreventAllowMediumRemoval(out byte[] senseBuffer, ScsiPreventAllowMode preventMode, uint timeout, out double duration)
|
||||||
|
{
|
||||||
|
senseBuffer = new byte[32];
|
||||||
|
byte[] cdb = new byte[6];
|
||||||
|
bool sense;
|
||||||
|
byte[] buffer = new byte[0];
|
||||||
|
|
||||||
|
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
||||||
|
cdb[4] = (byte)((byte)preventMode & 0x03);
|
||||||
|
|
||||||
|
lastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.None, out duration, out sense);
|
||||||
|
error = lastError != 0;
|
||||||
|
|
||||||
|
DicConsole.DebugWriteLine("SCSI Device", "PREVENT ALLOW MEDIUM REMOVAL took {0} ms.", duration);
|
||||||
|
|
||||||
|
return sense;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2721,5 +2721,27 @@ namespace DiscImageChef.Devices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Saved = 0xC0
|
Saved = 0xC0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ScsiPreventAllowMode : byte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Allows medium removal from data transport and from medium changer
|
||||||
|
/// </summary>
|
||||||
|
Allow = 0x00,
|
||||||
|
/// <summary>
|
||||||
|
/// Prevents medium removal from data transport but allows it from medium changer
|
||||||
|
/// </summary>
|
||||||
|
Prevent = 0x01,
|
||||||
|
/// <summary>
|
||||||
|
/// Allows medium removal from data transport but prevents it from medium changer
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete]
|
||||||
|
PreventChanger = 0x02,
|
||||||
|
/// <summary>
|
||||||
|
/// Prevents medium removal from both data transport and medium changer
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete]
|
||||||
|
PreventAll = 0x03
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user