// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : Variables.cs // Author(s) : Natalia Portillo // // Component : Direct device access. // // --[ Description ] ---------------------------------------------------------- // // Contains various device variables. // // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 2.1 of the // License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, see . // // ---------------------------------------------------------------------------- // Copyright © 2011-2021 Natalia Portillo // ****************************************************************************/ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interop; using Aaru.CommonTypes.Structs.Devices.SCSI; namespace Aaru.Devices { public sealed partial class Device { 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. readonly byte[] _cachedCsd; readonly byte[] _cachedCid; readonly byte[] _cachedScr; readonly byte[] _cachedOcr; /// Gets the Platform ID for this device /// The Platform ID public PlatformID PlatformId { get; } /// Gets the file handle representing this device /// The file handle public object FileHandle { get; private set; } /// Gets or sets the standard timeout for commands sent to this device /// The timeout in seconds public uint Timeout { get; } /// Gets a value indicating whether this is in error. /// true if error; otherwise, false. public bool Error { get; private set; } /// Gets the last error number. /// The last error. public int LastError { get; private set; } /// Gets the device type. /// The device type. public DeviceType Type { get; } /// Gets the device's manufacturer /// The manufacturer. public string Manufacturer { get; } /// Gets the device model /// The model. public string Model { get; } /// Gets the device's firmware version. /// The firmware version. public string FirmwareRevision { get; } /// Gets the device's serial number. /// The serial number. public string Serial { get; } /// Gets the device's SCSI peripheral device type /// The SCSI peripheral device type. public PeripheralDeviceTypes ScsiType { get; } /// Gets a value indicating whether this device's media is removable. /// true if this device's media is removable; otherwise, false. public bool IsRemovable { get; } /// Gets a value indicating whether this device is attached via USB. /// true if this device is attached via USB; otherwise, false. public bool IsUsb { get; } /// Gets the USB vendor ID. /// The USB vendor ID. public ushort UsbVendorId => _usbVendor; /// Gets the USB product ID. /// The USB product ID. public ushort UsbProductId => _usbProduct; /// Gets the USB descriptors. /// The USB descriptors. public byte[] UsbDescriptors { get; } /// Gets the USB manufacturer string. /// The USB manufacturer string. public string UsbManufacturerString { get; } /// Gets the USB product string. /// The USB product string. public string UsbProductString { get; } /// Gets the USB serial string. /// The USB serial string. public string UsbSerialString { get; } /// Gets a value indicating whether this device is attached via FireWire. /// true if this device is attached via FireWire; otherwise, false. public bool IsFireWire { get; } /// Gets the FireWire GUID /// The FireWire GUID. public ulong FireWireGuid => _firewireGuid; /// Gets the FireWire model number /// The FireWire model. public uint FireWireModel => _firewireModel; /// Gets the FireWire model name. /// The FireWire model name. public string FireWireModelName { get; } /// Gets the FireWire vendor number. /// The FireWire vendor number. public uint FireWireVendor => _firewireVendor; /// Gets the FireWire vendor name. /// The FireWire vendor name. public string FireWireVendorName { get; } /// Gets a value indicating whether this device is a CompactFlash device. /// true if this device is a CompactFlash device; otherwise, false. public bool IsCompactFlash { get; } /// Gets a value indicating whether this device is a PCMCIA device. /// true if this device is a PCMCIA device; otherwise, false. public bool IsPcmcia { get; } /// Contains the PCMCIA CIS if applicable public byte[] Cis { get; } readonly Remote.Remote _remote; bool? _isRemoteAdmin; readonly string _devicePath; /// Returns if remote is running under administrative (aka root) privileges public bool IsRemoteAdmin { get { _isRemoteAdmin ??= _remote.IsRoot; return _isRemoteAdmin == true; } } /// Current device is remote public bool IsRemote => _remote != null; /// Remote application public string RemoteApplication => _remote?.ServerApplication; /// Remote application server public string RemoteVersion => _remote?.ServerVersion; /// Remote operating system name public string RemoteOperatingSystem => _remote?.ServerOperatingSystem; /// Remote operating system version public string RemoteOperatingSystemVersion => _remote?.ServerOperatingSystemVersion; /// Remote architecture public string RemoteArchitecture => _remote?.ServerArchitecture; /// Remote protocol version public int RemoteProtocolVersion => _remote?.ServerProtocolVersion ?? 0; } }