mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Remove DiscImageChef.CommonTypes dependence on DiscImageChef.Decoders.
This commit is contained in:
@@ -37,7 +37,8 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interop;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using DiscImageChef.CommonTypes.Structs.Devices.ATA;
|
||||
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
|
||||
using DiscImageChef.Decoders.SCSI;
|
||||
using DiscImageChef.Decoders.SCSI.MMC;
|
||||
using DiscImageChef.Decoders.SecureDigital;
|
||||
@@ -50,6 +51,7 @@ using FileAttributes = DiscImageChef.Devices.Windows.FileAttributes;
|
||||
using FileFlags = DiscImageChef.Devices.Linux.FileFlags;
|
||||
using FileMode = DiscImageChef.Devices.Windows.FileMode;
|
||||
using FileShare = DiscImageChef.Devices.Windows.FileShare;
|
||||
using Inquiry = DiscImageChef.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
|
||||
using VendorString = DiscImageChef.Decoders.SecureDigital.VendorString;
|
||||
|
||||
@@ -761,7 +763,7 @@ namespace DiscImageChef.Devices
|
||||
|
||||
if(!scsiSense)
|
||||
{
|
||||
Inquiry.SCSIInquiry? inquiry = Inquiry.Decode(inqBuf);
|
||||
Inquiry? inquiry = Inquiry.Decode(inqBuf);
|
||||
|
||||
Type = DeviceType.SCSI;
|
||||
bool serialSense = ScsiInquiry(out inqBuf, out _, 0x80);
|
||||
|
||||
@@ -32,211 +32,156 @@
|
||||
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interop;
|
||||
using DiscImageChef.Decoders.SCSI;
|
||||
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
|
||||
|
||||
namespace DiscImageChef.Devices
|
||||
{
|
||||
public partial class Device
|
||||
{
|
||||
private readonly ushort usbVendor;
|
||||
private readonly ushort usbProduct;
|
||||
private readonly ulong firewireGuid;
|
||||
private readonly uint firewireModel;
|
||||
private readonly uint firewireVendor;
|
||||
readonly ushort usbVendor;
|
||||
readonly ushort usbProduct;
|
||||
readonly ulong firewireGuid;
|
||||
readonly uint firewireModel;
|
||||
readonly uint firewireVendor;
|
||||
|
||||
// MMC and SecureDigital, values that need to be get with card idle, something that may
|
||||
// not be possible to do but usually is already done by the SDHCI driver.
|
||||
private readonly byte[] cachedCsd;
|
||||
private readonly byte[] cachedCid;
|
||||
private readonly byte[] cachedScr;
|
||||
private readonly byte[] cachedOcr;
|
||||
readonly byte[] cachedCsd;
|
||||
readonly byte[] cachedCid;
|
||||
readonly byte[] cachedScr;
|
||||
readonly byte[] cachedOcr;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Platform ID for this device
|
||||
/// </summary>
|
||||
/// <summary>Gets the Platform ID for this device</summary>
|
||||
/// <value>The Platform ID</value>
|
||||
public PlatformID PlatformId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file handle representing this device
|
||||
/// </summary>
|
||||
/// <summary>Gets the file handle representing this device</summary>
|
||||
/// <value>The file handle</value>
|
||||
public object FileHandle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the standard timeout for commands sent to this device
|
||||
/// </summary>
|
||||
/// <summary>Gets or sets the standard timeout for commands sent to this device</summary>
|
||||
/// <value>The timeout in seconds</value>
|
||||
public uint Timeout { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this <see cref="Device" /> is in error.
|
||||
/// </summary>
|
||||
/// <summary>Gets a value indicating whether this <see cref="Device" /> is in error.</summary>
|
||||
/// <value><c>true</c> if error; otherwise, <c>false</c>.</value>
|
||||
public bool Error { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last error number.
|
||||
/// </summary>
|
||||
/// <summary>Gets the last error number.</summary>
|
||||
/// <value>The last error.</value>
|
||||
public int LastError { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device type.
|
||||
/// </summary>
|
||||
/// <summary>Gets the device type.</summary>
|
||||
/// <value>The device type.</value>
|
||||
public DeviceType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device's manufacturer
|
||||
/// </summary>
|
||||
/// <summary>Gets the device's manufacturer</summary>
|
||||
/// <value>The manufacturer.</value>
|
||||
public string Manufacturer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device model
|
||||
/// </summary>
|
||||
/// <summary>Gets the device model</summary>
|
||||
/// <value>The model.</value>
|
||||
public string Model { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device's firmware version.
|
||||
/// </summary>
|
||||
/// <summary>Gets the device's firmware version.</summary>
|
||||
/// <value>The firmware version.</value>
|
||||
public string FirmwareRevision { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device's serial number.
|
||||
/// </summary>
|
||||
/// <summary>Gets the device's serial number.</summary>
|
||||
/// <value>The serial number.</value>
|
||||
public string Serial { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device's SCSI peripheral device type
|
||||
/// </summary>
|
||||
/// <summary>Gets the device's SCSI peripheral device type</summary>
|
||||
/// <value>The SCSI peripheral device type.</value>
|
||||
public PeripheralDeviceTypes ScsiType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this device's media is removable.
|
||||
/// </summary>
|
||||
/// <summary>Gets a value indicating whether this device's media is removable.</summary>
|
||||
/// <value><c>true</c> if this device's media is removable; otherwise, <c>false</c>.</value>
|
||||
public bool IsRemovable { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this device is attached via USB.
|
||||
/// </summary>
|
||||
/// <summary>Gets a value indicating whether this device is attached via USB.</summary>
|
||||
/// <value><c>true</c> if this device is attached via USB; otherwise, <c>false</c>.</value>
|
||||
public bool IsUsb { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the USB vendor ID.
|
||||
/// </summary>
|
||||
/// <summary>Gets the USB vendor ID.</summary>
|
||||
/// <value>The USB vendor ID.</value>
|
||||
public ushort UsbVendorId => usbVendor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the USB product ID.
|
||||
/// </summary>
|
||||
/// <summary>Gets the USB product ID.</summary>
|
||||
/// <value>The USB product ID.</value>
|
||||
public ushort UsbProductId => usbProduct;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the USB descriptors.
|
||||
/// </summary>
|
||||
/// <summary>Gets the USB descriptors.</summary>
|
||||
/// <value>The USB descriptors.</value>
|
||||
public byte[] UsbDescriptors { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the USB manufacturer string.
|
||||
/// </summary>
|
||||
/// <summary>Gets the USB manufacturer string.</summary>
|
||||
/// <value>The USB manufacturer string.</value>
|
||||
public string UsbManufacturerString { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the USB product string.
|
||||
/// </summary>
|
||||
/// <summary>Gets the USB product string.</summary>
|
||||
/// <value>The USB product string.</value>
|
||||
public string UsbProductString { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the USB serial string.
|
||||
/// </summary>
|
||||
/// <summary>Gets the USB serial string.</summary>
|
||||
/// <value>The USB serial string.</value>
|
||||
public string UsbSerialString { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this device is attached via FireWire.
|
||||
/// </summary>
|
||||
/// <summary>Gets a value indicating whether this device is attached via FireWire.</summary>
|
||||
/// <value><c>true</c> if this device is attached via FireWire; otherwise, <c>false</c>.</value>
|
||||
public bool IsFireWire { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the FireWire GUID
|
||||
/// </summary>
|
||||
/// <summary>Gets the FireWire GUID</summary>
|
||||
/// <value>The FireWire GUID.</value>
|
||||
public ulong FireWireGuid => firewireGuid;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the FireWire model number
|
||||
/// </summary>
|
||||
/// <summary>Gets the FireWire model number</summary>
|
||||
/// <value>The FireWire model.</value>
|
||||
public uint FireWireModel => firewireModel;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the FireWire model name.
|
||||
/// </summary>
|
||||
/// <summary>Gets the FireWire model name.</summary>
|
||||
/// <value>The FireWire model name.</value>
|
||||
public string FireWireModelName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the FireWire vendor number.
|
||||
/// </summary>
|
||||
/// <summary>Gets the FireWire vendor number.</summary>
|
||||
/// <value>The FireWire vendor number.</value>
|
||||
public uint FireWireVendor => firewireVendor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the FireWire vendor name.
|
||||
/// </summary>
|
||||
/// <summary>Gets the FireWire vendor name.</summary>
|
||||
/// <value>The FireWire vendor name.</value>
|
||||
public string FireWireVendorName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this device is a CompactFlash device.
|
||||
/// </summary>
|
||||
/// <summary>Gets a value indicating whether this device is a CompactFlash device.</summary>
|
||||
/// <value><c>true</c> if this device is a CompactFlash device; otherwise, <c>false</c>.</value>
|
||||
public bool IsCompactFlash { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this device is a PCMCIA device.
|
||||
/// </summary>
|
||||
/// <summary>Gets a value indicating whether this device is a PCMCIA device.</summary>
|
||||
/// <value><c>true</c> if this device is a PCMCIA device; otherwise, <c>false</c>.</value>
|
||||
public bool IsPcmcia { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the PCMCIA CIS if applicable
|
||||
/// </summary>
|
||||
/// <summary>Contains the PCMCIA CIS if applicable</summary>
|
||||
public byte[] Cis { get; }
|
||||
|
||||
private readonly Remote.Remote _remote;
|
||||
private bool? _isRemoteAdmin;
|
||||
readonly Remote.Remote _remote;
|
||||
bool? _isRemoteAdmin;
|
||||
|
||||
public bool IsRemoteAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_isRemoteAdmin is null) _isRemoteAdmin = _remote.IsRoot;
|
||||
if(_isRemoteAdmin is null)
|
||||
_isRemoteAdmin = _remote.IsRoot;
|
||||
|
||||
return _isRemoteAdmin == true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRemote => _remote != null;
|
||||
public string RemoteApplication => _remote?.ServerApplication;
|
||||
public string RemoteVersion => _remote?.ServerVersion;
|
||||
public string RemoteOperatingSystem => _remote?.ServerOperatingSystem;
|
||||
public bool IsRemote => _remote != null;
|
||||
public string RemoteApplication => _remote?.ServerApplication;
|
||||
public string RemoteVersion => _remote?.ServerVersion;
|
||||
public string RemoteOperatingSystem => _remote?.ServerOperatingSystem;
|
||||
public string RemoteOperatingSystemVersion => _remote?.ServerOperatingSystemVersion;
|
||||
public string RemoteArchitecture => _remote?.ServerArchitecture;
|
||||
public int RemoteProtocolVersion => _remote?.ServerProtocolVersion ?? 0;
|
||||
public string RemoteArchitecture => _remote?.ServerArchitecture;
|
||||
public int RemoteProtocolVersion => _remote?.ServerProtocolVersion ?? 0;
|
||||
}
|
||||
}
|
||||
@@ -35,17 +35,15 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using DiscImageChef.Decoders.SCSI;
|
||||
using DiscImageChef.CommonTypes.Structs.Devices.ATA;
|
||||
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
|
||||
using static DiscImageChef.Devices.FreeBSD.Extern;
|
||||
|
||||
namespace DiscImageChef.Devices.FreeBSD
|
||||
{
|
||||
static class ListDevices
|
||||
internal static class ListDevices
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of all known storage devices on FreeBSD
|
||||
/// </summary>
|
||||
/// <summary>Gets a list of all known storage devices on FreeBSD</summary>
|
||||
/// <returns>List of devices</returns>
|
||||
internal static DeviceInfo[] GetList()
|
||||
{
|
||||
@@ -54,15 +52,16 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
|
||||
foreach(string passDevice in passDevices)
|
||||
{
|
||||
DeviceInfo deviceInfo = new DeviceInfo();
|
||||
IntPtr dev = cam_open_device(passDevice, FileFlags.ReadWrite);
|
||||
CamDevice camDevice = (CamDevice)Marshal.PtrToStructure(dev, typeof(CamDevice));
|
||||
var deviceInfo = new DeviceInfo();
|
||||
IntPtr dev = cam_open_device(passDevice, FileFlags.ReadWrite);
|
||||
var camDevice = (CamDevice)Marshal.PtrToStructure(dev, typeof(CamDevice));
|
||||
|
||||
IntPtr ccbPtr = cam_getccb(dev);
|
||||
|
||||
if(ccbPtr.ToInt64() == 0) continue;
|
||||
if(ccbPtr.ToInt64() == 0)
|
||||
continue;
|
||||
|
||||
CcbGetdev cgd = (CcbGetdev)Marshal.PtrToStructure(ccbPtr, typeof(CcbGetdev));
|
||||
var cgd = (CcbGetdev)Marshal.PtrToStructure(ccbPtr, typeof(CcbGetdev));
|
||||
|
||||
cgd.ccb_h.func_code = XptOpcode.XptGdevType;
|
||||
|
||||
@@ -73,6 +72,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
if(error < 0)
|
||||
{
|
||||
cam_freeccb(ccbPtr);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
// Little-endian FreeBSD gives it resorted
|
||||
// Big-endian FreeBSD, no idea
|
||||
byte[] atadTneid = new byte[512];
|
||||
|
||||
for(int aIndex = 0; aIndex < 512; aIndex += 2)
|
||||
{
|
||||
atadTneid[aIndex] = cgd.ident_data[aIndex + 1];
|
||||
@@ -103,6 +104,7 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
}
|
||||
|
||||
Identify.IdentifyDevice? idt = Identify.Decode(atadTneid);
|
||||
|
||||
if(idt.HasValue)
|
||||
{
|
||||
string[] separated = idt.Value.Model.Split(' ');
|
||||
@@ -123,12 +125,15 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
deviceInfo.Supported = simName != "ata";
|
||||
}
|
||||
|
||||
if(cgd.protocol == CamProto.ProtoAtapi) goto case CamProto.ProtoScsi;
|
||||
if(cgd.protocol == CamProto.ProtoAtapi)
|
||||
goto case CamProto.ProtoScsi;
|
||||
|
||||
break;
|
||||
}
|
||||
case CamProto.ProtoScsi:
|
||||
{
|
||||
Inquiry.SCSIInquiry? inq = Inquiry.Decode(cgd.inq_data);
|
||||
Inquiry? inq = Inquiry.Decode(cgd.inq_data);
|
||||
|
||||
if(inq.HasValue)
|
||||
{
|
||||
deviceInfo.Vendor = StringHandlers.CToString(inq.Value.VendorIdentification).Trim();
|
||||
@@ -142,11 +147,13 @@ namespace DiscImageChef.Devices.FreeBSD
|
||||
case CamProto.ProtoNvme:
|
||||
deviceInfo.Bus = "NVMe";
|
||||
deviceInfo.Supported = false;
|
||||
|
||||
break;
|
||||
case CamProto.ProtoMmcsd:
|
||||
deviceInfo.Model = "Unknown card";
|
||||
deviceInfo.Bus = "MMC/SD";
|
||||
deviceInfo.Supported = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user