Add XML comments to public entities.

This commit is contained in:
2021-08-17 13:55:59 +01:00
parent 433bed2145
commit fb6e3cf361
47 changed files with 852 additions and 31 deletions

View File

@@ -75,6 +75,7 @@ namespace Aaru.CommonTypes
/// <summary>Shows an error message</summary> /// <summary>Shows an error message</summary>
public delegate void ErrorMessageHandler(string text); public delegate void ErrorMessageHandler(string text);
/// <summary>Initializes a block map that's going to be filled with a media scan</summary>
public delegate void InitBlockMapHandler(ulong blocks, ulong blockSize, ulong blocksToRead, ushort currentProfile); public delegate void InitBlockMapHandler(ulong blocks, ulong blockSize, ulong blocksToRead, ushort currentProfile);
/// <summary>Updates lists of time taken on scanning from the specified sector</summary> /// <summary>Updates lists of time taken on scanning from the specified sector</summary>
@@ -84,5 +85,6 @@ namespace Aaru.CommonTypes
/// <summary>Specified a number of blocks could not be read on scan</summary> /// <summary>Specified a number of blocks could not be read on scan</summary>
public delegate void ScanUnreadableHandler(ulong sector); public delegate void ScanUnreadableHandler(ulong sector);
/// <summary>Sends the speed of scanning a specific sector</summary>
public delegate void ScanSpeedHandler(ulong sector, double currentSpeed); public delegate void ScanSpeedHandler(ulong sector, double currentSpeed);
} }

View File

@@ -38,10 +38,38 @@
namespace Aaru.CommonTypes.Enums namespace Aaru.CommonTypes.Enums
{ {
/// <summary>
/// Device types
/// </summary>
public enum DeviceType public enum DeviceType
{ {
Unknown = -1, ATA = 1, ATAPI = 2, /// <summary>
SCSI = 3, SecureDigital = 4, MMC = 5, /// Unknown device type
/// </summary>
Unknown = -1,
/// <summary>
/// ATA device
/// </summary>
ATA = 1,
/// <summary>
/// ATA Packet device (aka SCSI over ATA)
/// </summary>
ATAPI = 2,
/// <summary>
/// SCSI device (or USB-MSC, SBP2, FC, UAS, etc)
/// </summary>
SCSI = 3,
/// <summary>
/// SecureDigital memory card
/// </summary>
SecureDigital = 4,
/// <summary>
/// MultiMediaCard memory card
/// </summary>
MMC = 5,
/// <summary>
/// NVMe device
/// </summary>
NVMe = 6 NVMe = 6
} }
} }

View File

@@ -321,6 +321,9 @@ namespace Aaru.CommonTypes.Enums
NotFound = 0x40 NotFound = 0x40
} }
/// <summary>
/// Types of floppy disks
/// </summary>
public enum FloppyTypes : byte public enum FloppyTypes : byte
{ {
/// <summary>8" floppy</summary> /// <summary>8" floppy</summary>
@@ -337,6 +340,9 @@ namespace Aaru.CommonTypes.Enums
QuickDisk QuickDisk
} }
/// <summary>
/// Enumeration of floppy densities
/// </summary>
public enum FloppyDensities : byte public enum FloppyDensities : byte
{ {
/// <summary>Standard coercivity (about 300Oe as found in 8" and 5.25"-double-density disks).</summary> /// <summary>Standard coercivity (about 300Oe as found in 8" and 5.25"-double-density disks).</summary>
@@ -349,16 +355,76 @@ namespace Aaru.CommonTypes.Enums
Extended Extended
} }
/// <summary>
/// Capabilities for optical media image formats
/// </summary>
[Flags] [Flags]
public enum OpticalImageCapabilities : ulong public enum OpticalImageCapabilities : ulong
{ {
CanStoreAudioTracks = 0x01, CanStoreVideoTracks = 0x02, CanStoreDataTracks = 0x03, /// <summary>
CanStorePregaps = 0x04, CanStoreIndexes = 0x08, CanStoreSubchannelRw = 0x10, /// Can store Red Book audio tracks?
CanStoreSessions = 0x20, CanStoreIsrc = 0x40, CanStoreCdText = 0x80, /// </summary>
CanStoreMcn = 0x100, CanStoreRawData = 0x200, CanStoreNotCdSessions = 0x2000, CanStoreAudioTracks = 0x01,
/// <summary>
/// Can store CD-V analogue video tracks?
/// </summary>
CanStoreVideoTracks = 0x02,
/// <summary>
/// Can store Yellow Book data tracks?
/// </summary>
CanStoreDataTracks = 0x03,
/// <summary>
/// Can store pregaps without needing to interpret the subchannel?
/// </summary>
CanStorePregaps = 0x04,
/// <summary>
/// Can store indexes without needing to interpret the subchannel?
/// </summary>
CanStoreIndexes = 0x08,
/// <summary>
/// Can store raw P to W subchannel data?
/// </summary>
CanStoreSubchannelRw = 0x10,
/// <summary>
/// Can store more than one session?
/// </summary>
CanStoreSessions = 0x20,
/// <summary>
/// Can store track ISRCs without needing to interpret the subchannel?
/// </summary>
CanStoreIsrc = 0x40,
/// <summary>
/// Can store Lead-In's CD-TEXT?
/// </summary>
CanStoreCdText = 0x80,
/// <summary>
/// Can store the MCN without needing to interpret the subchannel?
/// </summary>
CanStoreMcn = 0x100,
/// <summary>
/// Can store the whole 2352 bytes of a sector?
/// </summary>
CanStoreRawData = 0x200,
/// <summary>
/// Can store more than 1 session in media that is not CD based (DVD et al)?
/// </summary>
CanStoreNotCdSessions = 0x2000,
/// <summary>
/// Can store more than 1 track in media that is not CD based (DVD et al)?
/// </summary>
CanStoreNotCdTracks = 0x4000, CanStoreNotCdTracks = 0x4000,
// TODO: Implement // TODO: Implement
CanStoreScrambledData = 0x400, CanStoreCookedData = 0x800, CanStoreMultipleTracks = 0x1000 /// <summary>
/// Can store scrambled data?
/// </summary>
CanStoreScrambledData = 0x400,
/// <summary>
/// Can store only the user area of a sector (2048, 2324, etc)?
/// </summary>
CanStoreCookedData = 0x800,
/// <summary>
/// Can store more than 1 track?
/// </summary>
CanStoreMultipleTracks = 0x1000
} }
} }

View File

@@ -43,8 +43,16 @@ using Schemas;
namespace Aaru.CommonTypes.Extents namespace Aaru.CommonTypes.Extents
{ {
/// <summary>
/// Converts extents
/// </summary>
public static class ExtentsConverter public static class ExtentsConverter
{ {
/// <summary>
/// Converts unsigned long integer extents into XML based extents
/// </summary>
/// <param name="extents">Extents</param>
/// <returns>XML based extents</returns>
public static ExtentType[] ToMetadata(ExtentsULong extents) public static ExtentType[] ToMetadata(ExtentsULong extents)
{ {
if(extents == null) if(extents == null)
@@ -63,6 +71,11 @@ namespace Aaru.CommonTypes.Extents
return array; return array;
} }
/// <summary>
/// Converts XML based extents into unsigned long integer extents
/// </summary>
/// <param name="extents">XML based extents</param>
/// <returns>Extents</returns>
public static ExtentsULong FromMetadata(ExtentType[] extents) public static ExtentsULong FromMetadata(ExtentType[] extents)
{ {
if(extents == null) if(extents == null)

View File

@@ -46,8 +46,14 @@ using Aaru.Console;
namespace Aaru.CommonTypes namespace Aaru.CommonTypes
{ {
/// <summary>
/// Manages the known filters
/// </summary>
public sealed class FiltersList public sealed class FiltersList
{ {
/// <summary>
/// List of known filters
/// </summary>
public readonly SortedDictionary<string, IFilter> Filters; public readonly SortedDictionary<string, IFilter> Filters;
/// <summary>Fills the list of all known filters</summary> /// <summary>Fills the list of all known filters</summary>

View File

@@ -40,8 +40,14 @@ using System.Linq;
namespace Aaru.CommonTypes namespace Aaru.CommonTypes
{ {
/// <summary>
/// Handles CHS geometries
/// </summary>
public static class Geometry public static class Geometry
{ {
/// <summary>
/// List of known disk geometries
/// </summary>
public static readonly (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding public static readonly (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding
encoding, bool variableSectorsPerTrack, MediaType type)[] KnownGeometries = encoding, bool variableSectorsPerTrack, MediaType type)[] KnownGeometries =
{ {
@@ -116,6 +122,11 @@ namespace Aaru.CommonTypes
(1024, 2, 32, 512, MediaEncoding.MFM, false, MediaType.FD32MB) (1024, 2, 32, 512, MediaEncoding.MFM, false, MediaType.FD32MB)
}; };
/// <summary>
/// Gets the media type for a given geometry
/// </summary>
/// <param name="geometry">Geometry</param>
/// <returns>Media type</returns>
public static MediaType GetMediaType( public static MediaType GetMediaType(
(ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool
variableSectorsPerTrack) geometry) => (from geom in KnownGeometries variableSectorsPerTrack) geometry) => (from geom in KnownGeometries
@@ -128,6 +139,11 @@ namespace Aaru.CommonTypes
geometry.variableSectorsPerTrack select geom.type). geometry.variableSectorsPerTrack select geom.type).
FirstOrDefault(); FirstOrDefault();
/// <summary>
/// Gets the geometry for a given media type
/// </summary>
/// <param name="mediaType">Media type</param>
/// <returns>Geometry</returns>
public static (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding public static (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding
, bool variableSectorsPerTrack, MediaType type) GetGeometry(MediaType mediaType) => , bool variableSectorsPerTrack, MediaType type) GetGeometry(MediaType mediaType) =>
(from geom in KnownGeometries where geom.type == mediaType select geom).FirstOrDefault(); (from geom in KnownGeometries where geom.type == mediaType select geom).FirstOrDefault();

View File

@@ -39,6 +39,9 @@ using System.IO;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Supported archive features
/// </summary>
[Flags] [Flags]
public enum ArchiveSupportedFeature : uint public enum ArchiveSupportedFeature : uint
{ {
@@ -68,6 +71,9 @@ namespace Aaru.CommonTypes.Interfaces
SupportsXAttrs = 1 << 6 SupportsXAttrs = 1 << 6
} }
/// <summary>
/// Defines the interface to handle an archive (e.g. ZIP, WAD, etc)
/// </summary>
public interface IArchive public interface IArchive
{ {
/// <summary>Descriptive name of the plugin</summary> /// <summary>Descriptive name of the plugin</summary>

View File

@@ -38,6 +38,9 @@
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines the interface to implement a checksum or hashing algorithm
/// </summary>
public interface IChecksum public interface IChecksum
{ {
/// <summary>Updates the hash with data.</summary> /// <summary>Updates the hash with data.</summary>

View File

@@ -45,6 +45,9 @@ namespace Aaru.CommonTypes.Interfaces
/// <summary>Interface to implement filesystem plugins.</summary> /// <summary>Interface to implement filesystem plugins.</summary>
public interface IFilesystem public interface IFilesystem
{ {
/// <summary>
/// Defines the encoding used to interpret strings in the filesystem
/// </summary>
Encoding Encoding { get; } Encoding Encoding { get; }
/// <summary>Plugin name.</summary> /// <summary>Plugin name.</summary>
string Name { get; } string Name { get; }

View File

@@ -41,6 +41,10 @@ using System.IO;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines a filter, that is, a transformation of the data from a file, like, for example, a compressor (e.g. GZIP),
/// or a container (e.g. AppleDouble)
/// </summary>
public interface IFilter public interface IFilter
{ {
/// <summary>Descriptive name of the plugin</summary> /// <summary>Descriptive name of the plugin</summary>

View File

@@ -41,6 +41,9 @@ using System.Collections.Generic;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines an image that can contain partitions
/// </summary>
public interface IPartitionableMediaImage public interface IPartitionableMediaImage
{ {
/// <summary> /// <summary>

View File

@@ -41,6 +41,9 @@ using System.Collections.Generic;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines a register of all known plugins
/// </summary>
public interface IPluginRegister public interface IPluginRegister
{ {
/// <summary>Gets all checksum plugins</summary> /// <summary>Gets all checksum plugins</summary>

View File

@@ -45,12 +45,17 @@ using Aaru.CommonTypes.Structs;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <inheritdoc /> /// <inheritdoc />
/// <summary>Interface to implement filesystem plugins.</summary> /// <summary>
/// Defines the interface to implement reading the contents of a filesystem
/// </summary>
public interface IReadOnlyFilesystem : IFilesystem public interface IReadOnlyFilesystem : IFilesystem
{ {
/// <summary>Retrieves a list of options supported by the filesystem, with name, type and description</summary> /// <summary>Retrieves a list of options supported by the filesystem, with name, type and description</summary>
IEnumerable<(string name, Type type, string description)> SupportedOptions { get; } IEnumerable<(string name, Type type, string description)> SupportedOptions { get; }
/// <summary>
/// Supported namespaces
/// </summary>
Dictionary<string, string> Namespaces { get; } Dictionary<string, string> Namespaces { get; }
/// <summary> /// <summary>
@@ -90,7 +95,7 @@ namespace Aaru.CommonTypes.Interfaces
/// <summary>Reads an extended attribute, alternate data stream or fork from the given file.</summary> /// <summary>Reads an extended attribute, alternate data stream or fork from the given file.</summary>
/// <returns>Error number.</returns> /// <returns>Error number.</returns>
/// <param name="path">File path.</param> /// <param name="path">File path.</param>
/// <param name="xattr">Extendad attribute, alternate data stream or fork name.</param> /// <param name="xattr">Extended attribute, alternate data stream or fork name.</param>
/// <param name="buf">Buffer.</param> /// <param name="buf">Buffer.</param>
Errno GetXattr(string path, string xattr, ref byte[] buf); Errno GetXattr(string path, string xattr, ref byte[] buf);

View File

@@ -42,6 +42,9 @@ using Aaru.CommonTypes.Structs;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines an image that can store the information from streaming, digital, tapes
/// </summary>
public interface ITapeImage : IMediaImage public interface ITapeImage : IMediaImage
{ {
/// <summary>Gets a list of all the files registered in the image</summary> /// <summary>Gets a list of all the files registered in the image</summary>

View File

@@ -39,6 +39,9 @@
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines an image that can verify the integrity of the image itself, but not its contents
/// </summary>
public interface IVerifiableImage public interface IVerifiableImage
{ {
/// <summary>Verifies media image internal checksum.</summary> /// <summary>Verifies media image internal checksum.</summary>

View File

@@ -41,6 +41,9 @@ using System.Collections.Generic;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines an image that can verify the integrity of the sectors it contains
/// </summary>
public interface IVerifiableSectorsImage public interface IVerifiableSectorsImage
{ {
/// <summary>Verifies a sector.</summary> /// <summary>Verifies a sector.</summary>

View File

@@ -62,7 +62,13 @@ namespace Aaru.CommonTypes.Interfaces
/// <summary>Gets a list of known extensions for format auto-choosing</summary> /// <summary>Gets a list of known extensions for format auto-choosing</summary>
IEnumerable<string> KnownExtensions { get; } IEnumerable<string> KnownExtensions { get; }
/// <summary>
/// If set to <c>true</c> means the image is opened for writing
/// </summary>
bool IsWriting { get; } bool IsWriting { get; }
/// <summary>
/// Contains a description of the last error
/// </summary>
string ErrorMessage { get; } string ErrorMessage { get; }
/// <summary> /// <summary>

View File

@@ -42,8 +42,14 @@ using Aaru.CommonTypes.Structs;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines an image that is writable and can store an optical disc (CD, DVD, etc)
/// </summary>
public interface IWritableOpticalImage : IWritableImage, IOpticalMediaImage public interface IWritableOpticalImage : IWritableImage, IOpticalMediaImage
{ {
/// <summary>
/// Image format capabilities
/// </summary>
OpticalImageCapabilities OpticalCapabilities { get; } OpticalImageCapabilities OpticalCapabilities { get; }
/// <summary>Sets tracks for optical media</summary> /// <summary>Sets tracks for optical media</summary>

View File

@@ -41,6 +41,9 @@ using Aaru.CommonTypes.Structs;
namespace Aaru.CommonTypes.Interfaces namespace Aaru.CommonTypes.Interfaces
{ {
/// <summary>
/// Defines an image that is writable and can store information about a streaming, digital, tape
/// </summary>
public interface IWritableTapeImage : ITapeImage, IWritableImage public interface IWritableTapeImage : ITapeImage, IWritableImage
{ {
/// <summary>Registers a new file in the image</summary> /// <summary>Registers a new file in the image</summary>

View File

@@ -44,14 +44,29 @@ using System.Security.Principal;
namespace Aaru.CommonTypes.Interop namespace Aaru.CommonTypes.Interop
{ {
/// <summary>
/// Detects the underlying execution framework and operating system
/// </summary>
public static class DetectOS public static class DetectOS
{ {
/// <summary>
/// Are we running under Mono?
/// </summary>
public static readonly bool IsMono = public static readonly bool IsMono =
RuntimeInformation.FrameworkDescription.StartsWith("Mono", StringComparison.Ordinal); RuntimeInformation.FrameworkDescription.StartsWith("Mono", StringComparison.Ordinal);
/// <summary>
/// Are we running under .NET Framework?
/// </summary>
public static readonly bool IsNetFramework = public static readonly bool IsNetFramework =
RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal); RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal);
/// <summary>
/// Are we running under .NET Core?
/// </summary>
public static readonly bool IsNetCore = public static readonly bool IsNetCore =
RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.Ordinal); RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.Ordinal);
/// <summary>
/// Are we running under .NET Native?
/// </summary>
public static readonly bool IsNetNative = public static readonly bool IsNetNative =
RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal); RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal);
@@ -61,6 +76,9 @@ namespace Aaru.CommonTypes.Interop
/// <summary>Checks if the underlying runtime runs in 32-bit mode</summary> /// <summary>Checks if the underlying runtime runs in 32-bit mode</summary>
public static readonly bool Is32Bit = IntPtr.Size == 4; public static readonly bool Is32Bit = IntPtr.Size == 4;
/// <summary>
/// Are we running under Windows?
/// </summary>
public static bool IsWindows => GetRealPlatformID() == PlatformID.Win32NT || public static bool IsWindows => GetRealPlatformID() == PlatformID.Win32NT ||
GetRealPlatformID() == PlatformID.Win32S || GetRealPlatformID() == PlatformID.Win32S ||
GetRealPlatformID() == PlatformID.Win32Windows || GetRealPlatformID() == PlatformID.Win32Windows ||
@@ -68,6 +86,9 @@ namespace Aaru.CommonTypes.Interop
GetRealPlatformID() == PlatformID.WindowsPhone || GetRealPlatformID() == PlatformID.WindowsPhone ||
GetRealPlatformID() == PlatformID.Xbox; GetRealPlatformID() == PlatformID.Xbox;
/// <summary>
/// Are we running with administrative (root) privileges?
/// </summary>
public static bool IsAdmin public static bool IsAdmin
{ {
get get

View File

@@ -115,6 +115,8 @@ namespace Aaru.CommonTypes.Interop
/// <summary>SCO UnixWare</summary> /// <summary>SCO UnixWare</summary>
UnixWare = 34, UnixWare = 34,
/// <summary>IBM z/OS</summary> /// <summary>IBM z/OS</summary>
zOS = 35, Unknown = -1 zOS = 35,
/// <summary>Unknown</summary>
Unknown = -1
} }
} }

View File

@@ -42,12 +42,19 @@ using System.Runtime;
namespace Aaru.CommonTypes.Interop namespace Aaru.CommonTypes.Interop
{ {
/// <summary>
/// Gets our own, or the runtime's version
/// </summary>
public static class Version public static class Version
{ {
/// <summary>Gets version string</summary> /// <summary>Gets version string</summary>
/// <returns>Version</returns> /// <returns>Version</returns>
public static string GetVersion() => typeof(Version).Assembly.GetName().Version?.ToString(); public static string GetVersion() => typeof(Version).Assembly.GetName().Version?.ToString();
/// <summary>
/// Gets .NET Core version
/// </summary>
/// <returns>Version</returns>
public static string GetNetCoreVersion() public static string GetNetCoreVersion()
{ {
Assembly assembly = typeof(GCSettings).Assembly; Assembly assembly = typeof(GCSettings).Assembly;
@@ -69,6 +76,10 @@ namespace Aaru.CommonTypes.Interop
return null; return null;
} }
/// <summary>
/// Gets Mono version
/// </summary>
/// <returns>Version</returns>
public static string GetMonoVersion() public static string GetMonoVersion()
{ {
if(!DetectOS.IsMono) if(!DetectOS.IsMono)

View File

@@ -40,6 +40,7 @@
// TODO: Rename contents // TODO: Rename contents
using System; using System;
#pragma warning disable 1591
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
// ReSharper disable IdentifierTypo // ReSharper disable IdentifierTypo

View File

@@ -38,6 +38,16 @@ namespace Aaru.CommonTypes
{ {
public static partial class MediaTypeFromDevice public static partial class MediaTypeFromDevice
{ {
/// <summary>
/// Gets the media type from an ATA (not ATAPI) device
/// </summary>
/// <param name="manufacturer">Manufacturer string</param>
/// <param name="model">Model string</param>
/// <param name="removable">Is the device removable?</param>
/// <param name="compactFlash">Does the device self-identify as CompactFlash?</param>
/// <param name="pcmcia">Is the device attached thru PCMCIA or CardBus?</param>
/// <param name="blocks">Number of blocks in device</param>
/// <returns>The media type</returns>
public static MediaType GetFromAta(string manufacturer, string model, bool removable, bool compactFlash, public static MediaType GetFromAta(string manufacturer, string model, bool removable, bool compactFlash,
bool pcmcia, ulong blocks) bool pcmcia, ulong blocks)
{ {

View File

@@ -37,8 +37,22 @@ using Aaru.Console;
namespace Aaru.CommonTypes namespace Aaru.CommonTypes
{ {
/// <summary>
/// Gets the media type from a real device
/// </summary>
public static partial class MediaTypeFromDevice public static partial class MediaTypeFromDevice
{ {
/// <summary>
/// Gets the media type from an SCSI MultiMedia Commands compliant device
/// </summary>
/// <param name="model">Model string</param>
/// <param name="mediumType">Medium type from MODE SENSE</param>
/// <param name="densityCode">Density code from MODE SENSE</param>
/// <param name="blocks">Number of blocks in media</param>
/// <param name="blockSize">Size of a block in bytes</param>
/// <param name="isUsb">Is the device USB attached</param>
/// <param name="opticalDisc">Is the media an optical disc</param>
/// <returns>Media type</returns>
static MediaType GetFromMmc(string model, byte mediumType, byte densityCode, ulong blocks, uint blockSize, static MediaType GetFromMmc(string model, byte mediumType, byte densityCode, ulong blocks, uint blockSize,
bool isUsb, bool opticalDisc) bool isUsb, bool opticalDisc)
{ {

View File

@@ -38,6 +38,13 @@ namespace Aaru.CommonTypes
{ {
public static partial class MediaTypeFromDevice public static partial class MediaTypeFromDevice
{ {
/// <summary>
/// Gets the device type from a SCSI Optical Device
/// </summary>
/// <param name="mediumType">Medium type from MODE SENSE</param>
/// <param name="blocks">Number of blocks in device</param>
/// <param name="blockSize">Size in bytes of a block</param>
/// <returns>Media type</returns>
static MediaType GetFromOdc(byte mediumType, ulong blocks, uint blockSize) static MediaType GetFromOdc(byte mediumType, ulong blocks, uint blockSize)
{ {
if(mediumType != 0x01 && if(mediumType != 0x01 &&

View File

@@ -39,6 +39,15 @@ namespace Aaru.CommonTypes
{ {
public static partial class MediaTypeFromDevice public static partial class MediaTypeFromDevice
{ {
/// <summary>
/// Gets the media type from a SCSI Block Commands compliant device
/// </summary>
/// <param name="vendor">Vendor string</param>
/// <param name="model">Model string</param>
/// <param name="mediumType">Medium type from MODE SENSE</param>
/// <param name="blocks">Number of blocks in device</param>
/// <param name="blockSize">Size of a block in bytes</param>
/// <returns>Media type</returns>
static MediaType GetFromSbc(string vendor, string model, byte mediumType, ulong blocks, uint blockSize) static MediaType GetFromSbc(string vendor, string model, byte mediumType, ulong blocks, uint blockSize)
{ {
if(vendor.ToLowerInvariant() == "syquest" && if(vendor.ToLowerInvariant() == "syquest" &&

View File

@@ -48,8 +48,8 @@ namespace Aaru.CommonTypes
/// <param name="blocks">How many blocks are on the media</param> /// <param name="blocks">How many blocks are on the media</param>
/// <param name="blockSize">Size in bytes of each block</param> /// <param name="blockSize">Size in bytes of each block</param>
/// <param name="isUsb">Device is USB</param> /// <param name="isUsb">Device is USB</param>
/// <param name="opticalDisc"></param> /// <param name="opticalDisc">Is media an optical disc?</param>
/// <returns></returns> /// <returns>The media type</returns>
public static MediaType GetFromScsi(byte scsiPeripheralType, string vendor, string model, byte mediumType, public static MediaType GetFromScsi(byte scsiPeripheralType, string vendor, string model, byte mediumType,
byte densityCode, ulong blocks, uint blockSize, bool isUsb, byte densityCode, ulong blocks, uint blockSize, bool isUsb,
bool opticalDisc) bool opticalDisc)

View File

@@ -39,6 +39,17 @@ namespace Aaru.CommonTypes
{ {
public static partial class MediaTypeFromDevice public static partial class MediaTypeFromDevice
{ {
/// <summary>
/// Gets the media type from an SCSI Streaming Commands compliant device
/// </summary>
/// <param name="scsiPeripheralType">Peripheral type</param>
/// <param name="vendor">Vendor string</param>
/// <param name="model">Model string</param>
/// <param name="mediumType">Medium type from MODE SENSE</param>
/// <param name="densityCode">Density code from MODE SENSE</param>
/// <param name="blocks">Number of blocks in media</param>
/// <param name="blockSize">Size of a block in bytes</param>
/// <returns>Media type</returns>
public static MediaType GetFromSsc(byte scsiPeripheralType, string vendor, string model, byte mediumType, public static MediaType GetFromSsc(byte scsiPeripheralType, string vendor, string model, byte mediumType,
byte densityCode, ulong blocks, uint blockSize) byte densityCode, ulong blocks, uint blockSize)
{ {

View File

@@ -40,12 +40,30 @@ using System.ComponentModel.DataAnnotations;
namespace Aaru.CommonTypes.Metadata namespace Aaru.CommonTypes.Metadata
{ {
/// <summary>
/// Describes CD reading offset
/// </summary>
public class CdOffset public class CdOffset
{ {
/// <summary>
/// Drive manufacturer
/// </summary>
public string Manufacturer { get; set; } public string Manufacturer { get; set; }
/// <summary>
/// Drive model
/// </summary>
public string Model { get; set; } public string Model { get; set; }
/// <summary>
/// Reading offset
/// </summary>
public short Offset { get; set; } public short Offset { get; set; }
/// <summary>
/// Number of times this offset has been submitted
/// </summary>
public int Submissions { get; set; } public int Submissions { get; set; }
/// <summary>
/// Percentage of submissions in agreement with this offset
/// </summary>
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:P0}")] [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:P0}")]
public float Agreement { get; set; } public float Agreement { get; set; }
} }

View File

@@ -43,6 +43,8 @@ using Aaru.CommonTypes.Structs.Devices.ATA;
using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.CommonTypes.Structs.Devices.SCSI.Modes; using Aaru.CommonTypes.Structs.Devices.SCSI.Modes;
using Newtonsoft.Json; using Newtonsoft.Json;
// This is obsolete
#pragma warning disable 1591
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
// ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Global

View File

@@ -47,6 +47,8 @@ using Aaru.CommonTypes.Structs.Devices.ATA;
using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.CommonTypes.Structs.Devices.SCSI.Modes; using Aaru.CommonTypes.Structs.Devices.SCSI.Modes;
using Newtonsoft.Json; using Newtonsoft.Json;
// TODO: Re-enable CS1591 in this file
#pragma warning disable 1591
// ReSharper disable VirtualMemberNeverOverridden.Global // ReSharper disable VirtualMemberNeverOverridden.Global
// ReSharper disable VirtualMemberCallInConstructor // ReSharper disable VirtualMemberCallInConstructor

View File

@@ -42,8 +42,16 @@ using Schemas;
namespace Aaru.CommonTypes.Metadata namespace Aaru.CommonTypes.Metadata
{ {
/// <summary>
/// Physical dimensions for media types
/// </summary>
public static class Dimensions public static class Dimensions
{ {
/// <summary>
/// Gets the physical dimensions, in metadata expected format, for a given media type
/// </summary>
/// <param name="dskType">Media type</param>
/// <returns>Dimensions metadata</returns>
public static DimensionsType DimensionsFromMediaType(CommonTypes.MediaType dskType) public static DimensionsType DimensionsFromMediaType(CommonTypes.MediaType dskType)
{ {
var dmns = new DimensionsType(); var dmns = new DimensionsType();

View File

@@ -39,8 +39,16 @@
#pragma warning disable 612 #pragma warning disable 612
namespace Aaru.CommonTypes.Metadata namespace Aaru.CommonTypes.Metadata
{ {
/// <summary>
/// Handles media type for metadata
/// </summary>
public static class MediaType public static class MediaType
{ {
/// <summary>
/// Converts a media type of a pair of type and subtype strings to use in metadata
/// </summary>
/// <param name="dskType">Media type</param>
/// <returns>Media type and subtype for metadata</returns>
public static (string type, string subType) MediaTypeToString(CommonTypes.MediaType dskType) public static (string type, string subType) MediaTypeToString(CommonTypes.MediaType dskType)
{ {
string discType; string discType;

View File

@@ -43,26 +43,61 @@ using Schemas;
namespace Aaru.CommonTypes.Metadata namespace Aaru.CommonTypes.Metadata
{ {
/// <summary>
/// Information that allows to resume a dump
/// </summary>
[Serializable, XmlRoot("DicResume", Namespace = "", IsNullable = false)] [Serializable, XmlRoot("DicResume", Namespace = "", IsNullable = false)]
public class Resume public class Resume
{ {
/// <summary>
/// List of blocks that returned an error on reading
/// </summary>
[XmlArrayItem("Block")] [XmlArrayItem("Block")]
public List<ulong> BadBlocks; public List<ulong> BadBlocks;
/// <summary>
/// Date/time this resume file was created
/// </summary>
[XmlElement(DataType = "dateTime")] [XmlElement(DataType = "dateTime")]
public DateTime CreationDate; public DateTime CreationDate;
/// <summary>
/// Last block on media
/// </summary>
public ulong LastBlock; public ulong LastBlock;
/// <summary>
/// Date/time this resume file was last written to
/// </summary>
[XmlElement(DataType = "dateTime")] [XmlElement(DataType = "dateTime")]
public DateTime LastWriteDate; public DateTime LastWriteDate;
/// <summary>
/// Next block to read
/// </summary>
public ulong NextBlock; public ulong NextBlock;
/// <summary>
/// Is media removable?
/// </summary>
public bool Removable; public bool Removable;
/// <summary>
/// Is media a tape?
/// </summary>
public bool Tape; public bool Tape;
/// <summary>
/// List of CD subchannels that did not read correctly
/// </summary>
[XmlArrayItem("Block")] [XmlArrayItem("Block")]
public List<int> BadSubchannels; public List<int> BadSubchannels;
/// <summary>
/// Extents of BLANK sectors for magneto-opticals
/// </summary>
[XmlArrayItem("Extent")] [XmlArrayItem("Extent")]
public ExtentType[] BlankExtents; public ExtentType[] BlankExtents;
/// <summary>
/// Title keys that has not been read
/// </summary>
[XmlArrayItem("Block")] [XmlArrayItem("Block")]
public List<ulong> MissingTitleKeys; public List<ulong> MissingTitleKeys;
/// <summary>
/// List of dump tries
/// </summary>
[XmlArrayItem("DumpTry")] [XmlArrayItem("DumpTry")]
public List<DumpHardwareType> Tries; public List<DumpHardwareType> Tries;
} }

View File

@@ -39,166 +39,351 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Xml.Serialization; using System.Xml.Serialization;
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedMember.Global
namespace Aaru.CommonTypes.Metadata namespace Aaru.CommonTypes.Metadata
{ {
/// <summary>
/// Statistics
/// </summary>
[XmlRoot("DicStats", Namespace = "", IsNullable = false)] [XmlRoot("DicStats", Namespace = "", IsNullable = false)]
public class Stats public class Stats
{ {
/// <summary>Executed commands</summary>
public CommandsStats Commands; public CommandsStats Commands;
/// <summary>Operating systems Aaru has run from</summary>
[XmlArrayItem("OperatingSystem")] [XmlArrayItem("OperatingSystem")]
public List<OsStats> OperatingSystems { get; set; } public List<OsStats> OperatingSystems { get; set; }
/// <summary>Aaru versions</summary>
[XmlArrayItem("Version")] [XmlArrayItem("Version")]
public List<NameValueStats> Versions { get; set; } public List<NameValueStats> Versions { get; set; }
/// <summary>Detected filesystems</summary>
[XmlArrayItem("Filesystem")] [XmlArrayItem("Filesystem")]
public List<NameValueStats> Filesystems { get; set; } public List<NameValueStats> Filesystems { get; set; }
/// <summary>Detected partitioning schemes</summary>
[XmlArrayItem("Scheme")] [XmlArrayItem("Scheme")]
public List<NameValueStats> Partitions { get; set; } public List<NameValueStats> Partitions { get; set; }
/// <summary>Media image formats</summary>
[XmlArrayItem("Format")] [XmlArrayItem("Format")]
public List<NameValueStats> MediaImages { get; set; } public List<NameValueStats> MediaImages { get; set; }
/// <summary>Used filters</summary>
[XmlArrayItem("Filter", IsNullable = true)] [XmlArrayItem("Filter", IsNullable = true)]
public List<NameValueStats> Filters { get; set; } public List<NameValueStats> Filters { get; set; }
/// <summary>Found devices</summary>
[XmlArrayItem("Device", IsNullable = true)] [XmlArrayItem("Device", IsNullable = true)]
public List<DeviceStats> Devices { get; set; } public List<DeviceStats> Devices { get; set; }
/// <summary>Found media types, real, and in image</summary>
[XmlArrayItem("Media")] [XmlArrayItem("Media")]
public List<MediaStats> Medias { get; set; } public List<MediaStats> Medias { get; set; }
/// <summary>Benchmark statistics</summary>
public BenchmarkStats Benchmark { get; set; } public BenchmarkStats Benchmark { get; set; }
/// <summary>Media scanning statistics</summary>
public MediaScanStats MediaScan { get; set; } public MediaScanStats MediaScan { get; set; }
/// <summary>Image verification statistics</summary>
public VerifyStats Verify { get; set; } public VerifyStats Verify { get; set; }
} }
/// <summary>
/// DTO for statistics
/// </summary>
[SuppressMessage("ReSharper", "CollectionNeverQueried.Global")]
public class StatsDto public class StatsDto
{ {
/// <summary>Executed commands</summary>
public List<NameValueStats> Commands { get; set; } public List<NameValueStats> Commands { get; set; }
/// <summary>Operating systems Aaru has run from</summary>
public List<OsStats> OperatingSystems { get; set; } public List<OsStats> OperatingSystems { get; set; }
/// <summary>Aaru versions</summary>
public List<NameValueStats> Versions { get; set; } public List<NameValueStats> Versions { get; set; }
/// <summary>Detected filesystems</summary>
public List<NameValueStats> Filesystems { get; set; } public List<NameValueStats> Filesystems { get; set; }
/// <summary>Detected partitioning schemes</summary>
public List<NameValueStats> Partitions { get; set; } public List<NameValueStats> Partitions { get; set; }
/// <summary>Media image formats</summary>
public List<NameValueStats> MediaFormats { get; set; } public List<NameValueStats> MediaFormats { get; set; }
/// <summary>Used filters</summary>
public List<NameValueStats> Filters { get; set; } public List<NameValueStats> Filters { get; set; }
/// <summary>Found devices</summary>
public List<DeviceStats> Devices { get; set; } public List<DeviceStats> Devices { get; set; }
/// <summary>Found media types, real, and in image</summary>
public List<MediaStats> Medias { get; set; } public List<MediaStats> Medias { get; set; }
/// <summary>Remote applications</summary>
public List<OsStats> RemoteApplications { get; set; } public List<OsStats> RemoteApplications { get; set; }
/// <summary>Remote application architectures</summary>
public List<NameValueStats> RemoteArchitectures { get; set; } public List<NameValueStats> RemoteArchitectures { get; set; }
/// <summary>Operating systems where a remote application has been running</summary>
public List<OsStats> RemoteOperatingSystems { get; set; } public List<OsStats> RemoteOperatingSystems { get; set; }
} }
/// <summary>
/// Command execution statistics
/// </summary>
[SuppressMessage("ReSharper", "UnassignedField.Global")]
public class CommandsStats public class CommandsStats
{ {
/// <summary>Number of times the filesystem info command has been used</summary>
public long Analyze; public long Analyze;
/// <summary>Number of times the benchmark command has been used</summary>
public long Benchmark; public long Benchmark;
/// <summary>Number of times the image checksum command has been used</summary>
public long Checksum; public long Checksum;
/// <summary>Number of times the image compare command has been used</summary>
public long Compare; public long Compare;
/// <summary>Number of times the image convert command has been used</summary>
public long ConvertImage; public long ConvertImage;
/// <summary>Number of times the image create-sidecar command has been used</summary>
public long CreateSidecar; public long CreateSidecar;
/// <summary>Number of times the image decode command has been used</summary>
public long Decode; public long Decode;
/// <summary>Number of times the device info command has been used</summary>
public long DeviceInfo; public long DeviceInfo;
/// <summary>Number of times the device report command has been used</summary>
public long DeviceReport; public long DeviceReport;
/// <summary>Number of times the media dump command has been used</summary>
public long DumpMedia; public long DumpMedia;
/// <summary>Number of times the image entropy command has been used</summary>
public long Entropy; public long Entropy;
/// <summary>Number of times the filesystem extract command has been used</summary>
public long ExtractFiles; public long ExtractFiles;
/// <summary>Number of times the list formats command has been used</summary>
public long Formats; public long Formats;
/// <summary>Number of times the image info command has been used</summary>
public long ImageInfo; public long ImageInfo;
/// <summary>Number of times the device list command has been used</summary>
public long ListDevices; public long ListDevices;
/// <summary>Number of times the list encodings command has been used</summary>
public long ListEncodings; public long ListEncodings;
/// <summary>Number of times the filesystem ls command has been used</summary>
public long Ls; public long Ls;
/// <summary>Number of times the media info command has been used</summary>
public long MediaInfo; public long MediaInfo;
/// <summary>Number of times the media scan command has been used</summary>
public long MediaScan; public long MediaScan;
/// <summary>Number of times the image printhex command has been used</summary>
public long PrintHex; public long PrintHex;
/// <summary>Number of times the image verify command has been used</summary>
public long Verify; public long Verify;
} }
/// <summary>Statistics of verified media</summary>
public class VerifiedItems public class VerifiedItems
{ {
/// <summary>Number of correct images</summary>
public long Correct; public long Correct;
/// <summary>Number of failed images</summary>
public long Failed; public long Failed;
} }
/// <summary>
/// Verification statistics
/// </summary>
public class VerifyStats public class VerifyStats
{ {
/// <summary>
/// Image verification statistics
/// </summary>
public VerifiedItems MediaImages; public VerifiedItems MediaImages;
/// <summary>
/// Image contents verification statistics
/// </summary>
public ScannedSectors Sectors; public ScannedSectors Sectors;
} }
/// <summary>
/// Image contents verification statistics
/// </summary>
public class ScannedSectors public class ScannedSectors
{ {
/// <summary>
/// Sectors found to be correct
/// </summary>
public long Correct; public long Correct;
/// <summary>
/// Sectors found to be incorrect
/// </summary>
public long Error; public long Error;
/// <summary>
/// Total number of verified sectors
/// </summary>
public long Total; public long Total;
/// <summary>
/// Total number of sectors that could not be verified
/// </summary>
public long Unverifiable; public long Unverifiable;
} }
/// <summary>
/// Media scanning time statistics
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class TimeStats public class TimeStats
{ {
/// <summary>Number of sectors that took more than 3ms but less than 100ms to read</summary>
public long LessThan10ms; public long LessThan10ms;
/// <summary>Number of sectors that took more than 50ms but less than 150ms to read</summary>
public long LessThan150ms; public long LessThan150ms;
/// <summary>Number of sectors that took less than 3ms to read</summary>
public long LessThan3ms; public long LessThan3ms;
/// <summary>Number of sectors that took more than 150ms but less than 500ms to read</summary>
public long LessThan500ms; public long LessThan500ms;
/// <summary>Number of sectors that took more than 10ms but less than 50ms to read</summary>
public long LessThan50ms; public long LessThan50ms;
/// <summary>Number of sectors that took more than 500ms to read</summary>
public long MoreThan500ms; public long MoreThan500ms;
} }
/// <summary>
/// Media scanning statistics
/// </summary>
public class MediaScanStats public class MediaScanStats
{ {
/// <summary>
/// Statistics of scanned sectors
/// </summary>
public ScannedSectors Sectors; public ScannedSectors Sectors;
/// <summary>
/// Scan time statistics
/// </summary>
public TimeStats Times; public TimeStats Times;
} }
/// <summary>
/// Checksum type statistics
/// </summary>
public class ChecksumStats public class ChecksumStats
{ {
/// <summary>
/// Checksum algorithm
/// </summary>
[XmlAttribute] [XmlAttribute]
public string algorithm; public string algorithm;
/// <summary>
/// Time taken to execute algorithm
/// </summary>
[XmlText] [XmlText]
public double Value; public double Value;
} }
/// <summary>
/// Benchmark statistics
/// </summary>
public class BenchmarkStats public class BenchmarkStats
{ {
/// <summary>
/// Total time taken to run the checksum algorithms in parallel
/// </summary>
public double All; public double All;
/// <summary>
/// List of time taken by each checksum algorithm
/// </summary>
[XmlElement("Checksum")] [XmlElement("Checksum")]
public List<ChecksumStats> Checksum; public List<ChecksumStats> Checksum;
/// <summary>
/// Time taken to benchmark entropy calculation
/// </summary>
public double Entropy; public double Entropy;
/// <summary>
/// Maximum amount of memory used while running the benchmark
/// </summary>
public long MaxMemory; public long MaxMemory;
/// <summary>
/// Minimum amount of memory used while running the benchmark
/// </summary>
public long MinMemory; public long MinMemory;
/// <summary>
/// Total time taken to run the checksum algorithms sequentially
/// </summary>
public double Sequential; public double Sequential;
} }
/// <summary>
/// Media statistics
/// </summary>
public class MediaStats public class MediaStats
{ {
/// <summary>
/// Found in a real device?
/// </summary>
[XmlAttribute] [XmlAttribute]
public bool real; public bool real;
/// <summary>
/// Media type
/// </summary>
[XmlAttribute] [XmlAttribute]
public string type; public string type;
/// <summary>
/// Number of times it has been found
/// </summary>
[XmlText] [XmlText]
public long Value; public long Value;
} }
/// <summary>
/// Device statistics
/// </summary>
public class DeviceStats public class DeviceStats
{ {
/// <summary>
/// Is manufacturer null?
/// </summary>
[XmlIgnore] [XmlIgnore]
public bool ManufacturerSpecified; public bool ManufacturerSpecified;
/// <summary>
/// Manufacturer string
/// </summary>
public string Manufacturer { get; set; } public string Manufacturer { get; set; }
/// <summary>
/// Model string
/// </summary>
public string Model { get; set; } public string Model { get; set; }
/// <summary>
/// Revision or firmware version
/// </summary>
public string Revision { get; set; } public string Revision { get; set; }
/// <summary>
/// Bus the device was attached to
/// </summary>
public string Bus { get; set; } public string Bus { get; set; }
} }
/// <summary>
/// Name=value pair statistics
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public class NameValueStats public class NameValueStats
{ {
/// <summary>
/// Name
/// </summary>
[XmlAttribute] [XmlAttribute]
public string name { get; set; } public string name { get; set; }
/// <summary>
/// Number of times it has been used/found
/// </summary>
[XmlText] [XmlText]
public long Value { get; set; } public long Value { get; set; }
} }
/// <summary>
/// Operating system statistics
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public class OsStats public class OsStats
{ {
/// <summary>
/// Operating system name
/// </summary>
[XmlAttribute] [XmlAttribute]
public string name { get; set; } public string name { get; set; }
/// <summary>
/// Operating system version
/// </summary>
[XmlAttribute] [XmlAttribute]
public string version { get; set; } public string version { get; set; }
/// <summary>
/// Number of times Aaru run on it
/// </summary>
[XmlText] [XmlText]
public long Value { get; set; } public long Value { get; set; }
} }

View File

@@ -41,6 +41,9 @@ using Schemas;
namespace Aaru.CommonTypes.Metadata namespace Aaru.CommonTypes.Metadata
{ {
/// <summary>
/// Manages Aaru's version for metadata
/// </summary>
public static class Version public static class Version
{ {
/// <summary>Gets XML software type for the running version</summary> /// <summary>Gets XML software type for the running version</summary>

View File

@@ -64,13 +64,16 @@ namespace Aaru.CommonTypes
/// <summary>Name of partition scheme that contains this partition</summary> /// <summary>Name of partition scheme that contains this partition</summary>
public string Scheme; public string Scheme;
/// <inheritdoc />
/// <summary>Compares two partitions</summary> /// <summary>Compares two partitions</summary>
/// <param name="other">Partition to compare with</param> /// <param name="other">Partition to compare with</param>
/// <returns>0 if both partitions start and end at the same sector</returns> /// <returns>0 if both partitions start and end at the same sector</returns>
public bool Equals(Partition other) => Start == other.Start && Length == other.Length; public bool Equals(Partition other) => Start == other.Start && Length == other.Length;
/// <inheritdoc />
public override bool Equals(object obj) => obj is Partition partition && Equals(partition); public override bool Equals(object obj) => obj is Partition partition && Equals(partition);
/// <inheritdoc />
public override int GetHashCode() => Start.GetHashCode() + End.GetHashCode(); public override int GetHashCode() => Start.GetHashCode() + End.GetHashCode();
/// <summary> /// <summary>
@@ -79,6 +82,7 @@ namespace Aaru.CommonTypes
/// </summary> /// </summary>
/// <param name="other">Partition to compare with</param> /// <param name="other">Partition to compare with</param>
/// <returns>A value that indicates the relative equality of the partitions being compared.</returns> /// <returns>A value that indicates the relative equality of the partitions being compared.</returns>
/// <inheritdoc />
public int CompareTo(Partition other) public int CompareTo(Partition other)
{ {
if(Start == other.Start && if(Start == other.Start &&

View File

@@ -82,6 +82,10 @@ namespace Aaru.CommonTypes
Archives = new SortedDictionary<string, IArchive>(); Archives = new SortedDictionary<string, IArchive>();
} }
/// <summary>
/// Adds plugins to the central plugin register
/// </summary>
/// <param name="pluginRegister">Plugin register</param>
public void AddPlugins(IPluginRegister pluginRegister) public void AddPlugins(IPluginRegister pluginRegister)
{ {
foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>()) foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>())

View File

@@ -106,15 +106,19 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
/// <summary>MUST NOT be set</summary> /// <summary>MUST NOT be set</summary>
MustBeClear = 0x8000, MustBeClear = 0x8000,
/// <summary>MUST be set</summary> /// <summary>MUST be set</summary>
MustBeSet = 0x4000, Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800, MustBeSet = 0x4000,
#pragma warning disable 1591
Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800,
Reserved10 = 0x0400, Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved10 = 0x0400, Reserved09 = 0x0200, Reserved08 = 0x0100,
Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020, Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020,
Reserved04 = 0x0010, Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved04 = 0x0010, Reserved03 = 0x0008, Reserved02 = 0x0004,
Reserved01 = 0x0002, Reserved01 = 0x0002,
#pragma warning restore 1591
/// <summary>Indicates a device specific minimum standby timer value</summary> /// <summary>Indicates a device specific minimum standby timer value</summary>
SpecificStandbyTimer = 0x0001 SpecificStandbyTimer = 0x0001
} }
/// <summary>Even more capabilities flag bits.</summary>
[Flags] [Flags]
public enum CapabilitiesBit3 : byte public enum CapabilitiesBit3 : byte
{ {
@@ -129,12 +133,15 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
/// <summary>If unset, sanitize commands are specified by ACS-2</summary> /// <summary>If unset, sanitize commands are specified by ACS-2</summary>
SanitizeCommands = 0x0008, SanitizeCommands = 0x0008,
/// <summary>SANITIZE ANTIFREEZE LOCK EXT is supported</summary> /// <summary>SANITIZE ANTIFREEZE LOCK EXT is supported</summary>
SanitizeAntifreeze = 0x0004, Reserved01 = 0x0002, SanitizeAntifreeze = 0x0004,
#pragma warning disable 1591
Reserved01 = 0x0002,
#pragma warning restore 1591
/// <summary>Multiple logical sector setting is valid</summary> /// <summary>Multiple logical sector setting is valid</summary>
MultipleValid = 0x0001 MultipleValid = 0x0001
} }
/// <summary>More capabilities flag bits.</summary> /// <summary>Command set flag bits.</summary>
[Flags] [Flags]
public enum CommandSetBit : ushort public enum CommandSetBit : ushort
{ {
@@ -172,7 +179,7 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
SMART = 0x0001 SMART = 0x0001
} }
/// <summary>More capabilities flag bits.</summary> /// <summary>More command set flag bits.</summary>
[Flags] [Flags]
public enum CommandSetBit2 : ushort public enum CommandSetBit2 : ushort
{ {
@@ -210,7 +217,7 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
DownloadMicrocode = 0x0001 DownloadMicrocode = 0x0001
} }
/// <summary>More capabilities flag bits.</summary> /// <summary>Even more command set flag bits.</summary>
[Flags] [Flags]
public enum CommandSetBit3 : ushort public enum CommandSetBit3 : ushort
{ {
@@ -248,15 +255,18 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
SMARTLog = 0x0001 SMARTLog = 0x0001
} }
/// <summary>More capabilities flag bits.</summary> /// <summary>Yet more command set flag bits.</summary>
[Flags] [Flags]
public enum CommandSetBit4 : ushort public enum CommandSetBit4 : ushort
{ {
/// <summary>MUST NOT be set</summary> /// <summary>MUST NOT be set</summary>
MustBeClear = 0x8000, MustBeClear = 0x8000,
/// <summary>MUST be set</summary> /// <summary>MUST be set</summary>
MustBeSet = 0x4000, Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800, MustBeSet = 0x4000,
#pragma warning disable 1591
Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800,
Reserved10 = 0x0400, Reserved10 = 0x0400,
#pragma warning restore 1591
/// <summary>DSN feature set is supported</summary> /// <summary>DSN feature set is supported</summary>
DSN = 0x0200, DSN = 0x0200,
/// <summary>Accessible Max Address Configuration is supported</summary> /// <summary>Accessible Max Address Configuration is supported</summary>
@@ -279,6 +289,7 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
DT1825 = 0x0001 DT1825 = 0x0001
} }
/// <summary>Yet again more command set flag bits.</summary>
[Flags] [Flags]
public enum CommandSetBit5 : ushort public enum CommandSetBit5 : ushort
{ {
@@ -316,18 +327,26 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
ZonedBit0 = 0x0001 ZonedBit0 = 0x0001
} }
/// <summary>
/// Data set management flag bits.
/// </summary>
[Flags] [Flags]
public enum DataSetMgmtBit : ushort public enum DataSetMgmtBit : ushort
{ {
#pragma warning disable 1591
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400, Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080, Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080,
Reserved06 = 0x0040, Reserved05 = 0x0020, Reserved04 = 0x0010, Reserved06 = 0x0040, Reserved05 = 0x0020, Reserved04 = 0x0010,
Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved01 = 0x0002, Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved01 = 0x0002,
#pragma warning restore 1591
/// <summary>TRIM is supported</summary> /// <summary>TRIM is supported</summary>
Trim = 0x0001 Trim = 0x0001
} }
/// <summary>
/// Device form factor
/// </summary>
public enum DeviceFormFactorEnum : ushort public enum DeviceFormFactorEnum : ushort
{ {
/// <summary>Size not reported</summary> /// <summary>Size not reported</summary>
@@ -410,8 +429,10 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
[Flags] [Flags]
public enum MajorVersionBit : ushort public enum MajorVersionBit : ushort
{ {
#pragma warning disable 1591
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
Reserved12 = 0x1000, Reserved12 = 0x1000,
#pragma warning restore 1591
/// <summary>ACS-4</summary> /// <summary>ACS-4</summary>
ACS4 = 0x0800, ACS4 = 0x0800,
/// <summary>ACS-3</summary> /// <summary>ACS-3</summary>
@@ -433,9 +454,15 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
/// <summary>ATA-2</summary> /// <summary>ATA-2</summary>
Ata2 = 0x0004, Ata2 = 0x0004,
/// <summary>ATA-1</summary> /// <summary>ATA-1</summary>
Ata1 = 0x0002, Reserved00 = 0x0001 Ata1 = 0x0002,
#pragma warning disable 1591
Reserved00 = 0x0001
#pragma warning restore 1591
} }
/// <summary>
/// SATA capabilities flags
/// </summary>
[Flags] [Flags]
public enum SATACapabilitiesBit : ushort public enum SATACapabilitiesBit : ushort
{ {
@@ -454,8 +481,11 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
/// <summary>Supports receipt of host initiated power management requests</summary> /// <summary>Supports receipt of host initiated power management requests</summary>
PowerReceipt = 0x0200, PowerReceipt = 0x0200,
/// <summary>Supports NCQ</summary> /// <summary>Supports NCQ</summary>
NCQ = 0x0100, Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020, NCQ = 0x0100,
#pragma warning disable 1591
Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020,
Reserved04 = 0x0010, Reserved04 = 0x0010,
#pragma warning restore 1591
/// <summary>Supports SATA Gen. 3 Signaling Speed (6.0Gb/s)</summary> /// <summary>Supports SATA Gen. 3 Signaling Speed (6.0Gb/s)</summary>
Gen3Speed = 0x0008, Gen3Speed = 0x0008,
/// <summary>Supports SATA Gen. 2 Signaling Speed (3.0Gb/s)</summary> /// <summary>Supports SATA Gen. 2 Signaling Speed (3.0Gb/s)</summary>
@@ -466,12 +496,17 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
Clear = 0x0001 Clear = 0x0001
} }
/// <summary>
/// More SATA capabilities flags
/// </summary>
[Flags] [Flags]
public enum SATACapabilitiesBit2 : ushort public enum SATACapabilitiesBit2 : ushort
{ {
#pragma warning disable 1591
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400, Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080, Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080,
#pragma warning restore 1591
/// <summary>Supports RECEIVE FPDMA QUEUED and SEND FPDMA QUEUED</summary> /// <summary>Supports RECEIVE FPDMA QUEUED and SEND FPDMA QUEUED</summary>
FPDMAQ = 0x0040, FPDMAQ = 0x0040,
/// <summary>Supports NCQ Queue Management</summary> /// <summary>Supports NCQ Queue Management</summary>
@@ -492,12 +527,17 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
Clear = 0x0001 Clear = 0x0001
} }
/// <summary>
/// SATA features flags
/// </summary>
[Flags] [Flags]
public enum SATAFeaturesBit : ushort public enum SATAFeaturesBit : ushort
{ {
#pragma warning disable 1591
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400, Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved09 = 0x0200, Reserved08 = 0x0100,
#pragma warning restore 1591
/// <summary>Supports NCQ autosense</summary> /// <summary>Supports NCQ autosense</summary>
NCQAutoSense = 0x0080, NCQAutoSense = 0x0080,
/// <summary>Automatic Partial to Slumber transitions are enabled</summary> /// <summary>Automatic Partial to Slumber transitions are enabled</summary>
@@ -520,13 +560,18 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
Clear = 0x0001 Clear = 0x0001
} }
/// <summary>
/// SCT Command Transport flags
/// </summary>
[Flags] [Flags]
public enum SCTCommandTransportBit : ushort public enum SCTCommandTransportBit : ushort
{ {
#pragma warning disable 1591
Vendor15 = 0x8000, Vendor14 = 0x4000, Vendor13 = 0x2000, Vendor15 = 0x8000, Vendor14 = 0x4000, Vendor13 = 0x2000,
Vendor12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400, Vendor12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080, Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved07 = 0x0080,
Reserved06 = 0x0040, Reserved06 = 0x0040,
#pragma warning restore 1591
/// <summary>SCT Command Transport Data Tables supported</summary> /// <summary>SCT Command Transport Data Tables supported</summary>
DataTables = 0x0020, DataTables = 0x0020,
/// <summary>SCT Command Transport Features Control supported</summary> /// <summary>SCT Command Transport Features Control supported</summary>
@@ -541,15 +586,20 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
Supported = 0x0001 Supported = 0x0001
} }
/// <summary>More capabilities flag bits.</summary> /// <summary>Security status flag bits.</summary>
[Flags] [Flags]
public enum SecurityStatusBit : ushort public enum SecurityStatusBit : ushort
{ {
#pragma warning disable 1591
Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000, Reserved15 = 0x8000, Reserved14 = 0x4000, Reserved13 = 0x2000,
Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400, Reserved12 = 0x1000, Reserved11 = 0x0800, Reserved10 = 0x0400,
Reserved09 = 0x0200, Reserved09 = 0x0200,
#pragma warning restore 1591
/// <summary>Maximum security level</summary> /// <summary>Maximum security level</summary>
Maximum = 0x0100, Reserved07 = 0x0080, Reserved06 = 0x0040, Maximum = 0x0100,
#pragma warning disable 1591
Reserved07 = 0x0080, Reserved06 = 0x0040,
#pragma warning restore 1591
/// <summary>Supports enhanced security erase</summary> /// <summary>Supports enhanced security erase</summary>
Enhanced = 0x0020, Enhanced = 0x0020,
/// <summary>Security count expired</summary> /// <summary>Security count expired</summary>
@@ -564,6 +614,9 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
Supported = 0x0001 Supported = 0x0001
} }
/// <summary>
/// Specific configuration flags
/// </summary>
public enum SpecificConfigurationEnum : ushort public enum SpecificConfigurationEnum : ushort
{ {
/// <summary>Device requires SET FEATURES to spin up and IDENTIFY DEVICE response is incomplete</summary> /// <summary>Device requires SET FEATURES to spin up and IDENTIFY DEVICE response is incomplete</summary>
@@ -576,29 +629,43 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
NotRequiresSetCompleteResponse = 0xC837 NotRequiresSetCompleteResponse = 0xC837
} }
/// <summary>
/// Transfer mode flags
/// </summary>
[Flags] [Flags]
public enum TransferMode : byte public enum TransferMode : byte
{ {
#pragma warning disable 1591
Mode7 = 0x80, Mode6 = 0x40, Mode5 = 0x20, Mode7 = 0x80, Mode6 = 0x40, Mode5 = 0x20,
Mode4 = 0x10, Mode3 = 0x08, Mode2 = 0x04, Mode4 = 0x10, Mode3 = 0x08, Mode2 = 0x04,
Mode1 = 0x02, Mode0 = 0x01 Mode1 = 0x02, Mode0 = 0x01
#pragma warning restore 1591
} }
/// <summary>
/// Trusted Computing flags
/// </summary>
[Flags] [Flags]
public enum TrustedComputingBit : ushort public enum TrustedComputingBit : ushort
{ {
/// <summary>MUST NOT be set</summary> /// <summary>MUST NOT be set</summary>
Clear = 0x8000, Clear = 0x8000,
/// <summary>MUST be set</summary> /// <summary>MUST be set</summary>
Set = 0x4000, Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800, Set = 0x4000,
#pragma warning disable 1591
Reserved13 = 0x2000, Reserved12 = 0x1000, Reserved11 = 0x0800,
Reserved10 = 0x0400, Reserved09 = 0x0200, Reserved08 = 0x0100, Reserved10 = 0x0400, Reserved09 = 0x0200, Reserved08 = 0x0100,
Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020, Reserved07 = 0x0080, Reserved06 = 0x0040, Reserved05 = 0x0020,
Reserved04 = 0x0010, Reserved03 = 0x0008, Reserved02 = 0x0004, Reserved04 = 0x0010, Reserved03 = 0x0008, Reserved02 = 0x0004,
Reserved01 = 0x0002, Reserved01 = 0x0002,
#pragma warning restore 1591
/// <summary>Trusted Computing feature set is supported</summary> /// <summary>Trusted Computing feature set is supported</summary>
TrustedComputing = 0x0001 TrustedComputing = 0x0001
} }
/// <summary>
/// IDENTIFY DEVICE decoded response
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 2)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 2)]
public struct IdentifyDevice public struct IdentifyDevice
{ {
@@ -950,6 +1017,11 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
public byte Checksum; public byte Checksum;
} }
/// <summary>
/// Decodes a raw IDENTIFY DEVICE response
/// </summary>
/// <param name="IdentifyDeviceResponse">Raw IDENTIFY DEVICE response</param>
/// <returns>Decoded IDENTIFY DEVICE</returns>
public static IdentifyDevice? Decode(byte[] IdentifyDeviceResponse) public static IdentifyDevice? Decode(byte[] IdentifyDeviceResponse)
{ {
if(IdentifyDeviceResponse == null) if(IdentifyDeviceResponse == null)
@@ -978,6 +1050,11 @@ namespace Aaru.CommonTypes.Structs.Devices.ATA
return ATAID; return ATAID;
} }
/// <summary>
/// Encodes a raw IDENTIFY DEVICE response
/// </summary>
/// <param name="identify">Decoded IDENTIFY DEVICE</param>
/// <returns>Raw IDENTIFY DEVICE response</returns>
public static byte[] Encode(IdentifyDevice? identify) public static byte[] Encode(IdentifyDevice? identify)
{ {
if(identify is null) if(identify is null)

View File

@@ -34,6 +34,9 @@ using System.Diagnostics.CodeAnalysis;
namespace Aaru.CommonTypes.Structs.Devices.SCSI namespace Aaru.CommonTypes.Structs.Devices.SCSI
{ {
/// <summary>
/// List of known SCSI peripheral qualifiers
/// </summary>
public enum PeripheralQualifiers : byte public enum PeripheralQualifiers : byte
{ {
/// <summary>Peripheral qualifier: Device is connected and supported</summary> /// <summary>Peripheral qualifier: Device is connected and supported</summary>
@@ -48,6 +51,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
VendorMask = 0x04 VendorMask = 0x04
} }
/// <summary>
/// List of known peripheral device types
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PeripheralDeviceTypes : byte public enum PeripheralDeviceTypes : byte
{ {
@@ -99,6 +105,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
UnknownDevice = 0x1F UnknownDevice = 0x1F
} }
/// <summary>
/// List of known ANSI SCSI standards
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ANSIVersions : byte public enum ANSIVersions : byte
{ {
@@ -118,6 +127,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
ANSI2008Version = 0x06 ANSI2008Version = 0x06
} }
/// <summary>
/// List of known ECMA SCSI standards
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ECMAVersions : byte public enum ECMAVersions : byte
{ {
@@ -127,6 +139,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
ECMA111 = 0x01 ECMA111 = 0x01
} }
/// <summary>
/// List of known ISO SCSI standards
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ISOVersions : byte public enum ISOVersions : byte
{ {
@@ -136,6 +151,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
ISO1995Version = 0x02 ISO1995Version = 0x02
} }
/// <summary>
/// List of known SCSI Parallel Interface clocking types
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum SPIClocking : byte public enum SPIClocking : byte
{ {
@@ -149,6 +167,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
STandDT = 0x03 STandDT = 0x03
} }
/// <summary>
/// List of known TGPS values
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum TGPSValues : byte public enum TGPSValues : byte
{ {
@@ -162,6 +183,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
Both = 0x03 Both = 0x03
} }
/// <summary>
/// List of known SCSI protocols
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ProtocolIdentifiers : byte public enum ProtocolIdentifiers : byte
{ {
@@ -193,13 +217,37 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
NoProtocol = 15 NoProtocol = 15
} }
/// <summary>
/// List of known SCSI definitions
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ScsiDefinitions : byte public enum ScsiDefinitions : byte
{ {
Current = 0, SCSI1 = 1, CCS = 2, /// <summary>
SCSI2 = 3, SCSI3 = 4 /// Unknown
/// </summary>
Current = 0,
/// <summary>
/// SCSI-1
/// </summary>
SCSI1 = 1,
/// <summary>
/// Unknown
/// </summary>
CCS = 2,
/// <summary>
/// SCSI-2
/// </summary>
SCSI2 = 3,
/// <summary>
/// SCSI-3
/// </summary>
SCSI3 = 4
} }
/// <summary>
/// List of known SCSI physical interfaces
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PhysicalInterfaces : uint public enum PhysicalInterfaces : uint
{ {

View File

@@ -251,6 +251,11 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
0x48, 0x69, 0x2D, 0x4D, 0x44, 0x20, 0x20, 0x20 0x48, 0x69, 0x2D, 0x4D, 0x44, 0x20, 0x20, 0x20
}; };
/// <summary>
/// Decodes a SCSI INQUIRY response
/// </summary>
/// <param name="SCSIInquiryResponse">INQUIRY raw response data</param>
/// <returns>Decoded SCSI INQUIRY</returns>
#region Public methods #region Public methods
public static Inquiry? Decode(byte[] SCSIInquiryResponse) public static Inquiry? Decode(byte[] SCSIInquiryResponse)
{ {
@@ -508,6 +513,11 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI
return decoded; return decoded;
} }
/// <summary>
/// Encodes a SCSI INQUIRY response
/// </summary>
/// <param name="inq">Decoded SCSI INQUIRY</param>
/// <returns>Raw SCSI INQUIRY response</returns>
public static byte[] Encode(Inquiry? inq) public static byte[] Encode(Inquiry? inq)
{ {
if(inq is null) if(inq is null)

View File

@@ -46,6 +46,9 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class ModePage_2A public class ModePage_2A
{ {
/// <summary>
/// Write speed performance descriptors
/// </summary>
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors; public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors;
/// <summary>Parameters can be saved</summary> /// <summary>Parameters can be saved</summary>
public bool PS { get; set; } public bool PS { get; set; }
@@ -94,43 +97,135 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes
/// <summary>Current drive speed in Kbytes/second</summary> /// <summary>Current drive speed in Kbytes/second</summary>
public ushort CurrentSpeed { get; set; } public ushort CurrentSpeed { get; set; }
/// <summary>
/// Can read packet media
/// </summary>
public bool Method2 { get; set; } public bool Method2 { get; set; }
/// <summary>
/// Can read CD-RW
/// </summary>
public bool ReadCDRW { get; set; } public bool ReadCDRW { get; set; }
/// <summary>
/// Can read CD-R
/// </summary>
public bool ReadCDR { get; set; } public bool ReadCDR { get; set; }
/// <summary>
/// Can write CD-RW
/// </summary>
public bool WriteCDRW { get; set; } public bool WriteCDRW { get; set; }
/// <summary>
/// Can write CD-R
/// </summary>
public bool WriteCDR { get; set; } public bool WriteCDR { get; set; }
/// <summary>
/// Supports IEC-958 digital output on port 2
/// </summary>
public bool DigitalPort2 { get; set; } public bool DigitalPort2 { get; set; }
/// <summary>
/// Supports IEC-958 digital output on port 1
/// </summary>
public bool DigitalPort1 { get; set; } public bool DigitalPort1 { get; set; }
/// <summary>
/// Can deliver a composite audio and video data stream
/// </summary>
public bool Composite { get; set; } public bool Composite { get; set; }
/// <summary>
/// This bit controls the behavior of the LOAD/UNLOAD command when trying to load a Slot with no Disc present
/// </summary>
public bool SSS { get; set; } public bool SSS { get; set; }
/// <summary>
/// Contains a changer that can report the exact contents of the slots
/// </summary>
public bool SDP { get; set; } public bool SDP { get; set; }
/// <summary>
/// Page length
/// </summary>
public byte Length { get; set; } public byte Length { get; set; }
/// <summary>
/// Set if LSB comes first
/// </summary>
public bool LSBF { get; set; } public bool LSBF { get; set; }
/// <summary>
/// Set if HIGH on LRCK indicates left channel. Clear if HIGH on LRCK indicates right channel.
/// </summary>
public bool RCK { get; set; } public bool RCK { get; set; }
/// <summary>
/// Set if data valid on the falling edge of the BCK signal. Clear if data valid on the rising edge of the BCK signal
/// </summary>
public bool BCK { get; set; } public bool BCK { get; set; }
/// <summary>
/// Can do a test write
/// </summary>
public bool TestWrite { get; set; } public bool TestWrite { get; set; }
/// <summary>
/// Maximum write speed
/// </summary>
public ushort MaxWriteSpeed { get; set; } public ushort MaxWriteSpeed { get; set; }
/// <summary>
/// Current write speed
/// </summary>
public ushort CurrentWriteSpeed { get; set; } public ushort CurrentWriteSpeed { get; set; }
/// <summary>
/// Can read disc's barcode
/// </summary>
public bool ReadBarcode { get; set; } public bool ReadBarcode { get; set; }
/// <summary>
/// Can read DVD-RAM
/// </summary>
public bool ReadDVDRAM { get; set; } public bool ReadDVDRAM { get; set; }
/// <summary>
/// Can read DVD-R
/// </summary>
public bool ReadDVDR { get; set; } public bool ReadDVDR { get; set; }
/// <summary>
/// Can read DVD-ROM
/// </summary>
public bool ReadDVDROM { get; set; } public bool ReadDVDROM { get; set; }
/// <summary>
/// Can write DVD-RAM
/// </summary>
public bool WriteDVDRAM { get; set; } public bool WriteDVDRAM { get; set; }
/// <summary>
/// Can write DVD-R
/// </summary>
public bool WriteDVDR { get; set; } public bool WriteDVDR { get; set; }
/// <summary>
/// Can read raw R-W subchannel from the Lead-In
/// </summary>
public bool LeadInPW { get; set; } public bool LeadInPW { get; set; }
/// <summary>
/// Can read both sides of a disc
/// </summary>
public bool SCC { get; set; } public bool SCC { get; set; }
/// <summary>
/// Support copyright management
/// </summary>
public ushort CMRSupported { get; set; } public ushort CMRSupported { get; set; }
/// <summary>
/// Supports buffer under-run free recording
/// </summary>
public bool BUF { get; set; } public bool BUF { get; set; }
/// <summary>
/// Selected rotational control
/// </summary>
public byte RotationControlSelected { get; set; } public byte RotationControlSelected { get; set; }
/// <summary>
/// Current write speed selected
/// </summary>
public ushort CurrentWriteSpeedSelected { get; set; } public ushort CurrentWriteSpeedSelected { get; set; }
/// <summary>
/// Database ID
/// </summary>
[JsonIgnore, Key] [JsonIgnore, Key]
public int Id { get; set; } public int Id { get; set; }
/// <summary>
/// Decodes the page 2Ah of a MODE SENSE response
/// </summary>
/// <param name="pageResponse">Raw page 2Ah</param>
/// <returns>Decoded page 2Ah</returns>
public static ModePage_2A Decode(byte[] pageResponse) public static ModePage_2A Decode(byte[] pageResponse)
{ {
if((pageResponse?[0] & 0x40) == 0x40) if((pageResponse?[0] & 0x40) == 0x40)
@@ -242,6 +337,11 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes
return decoded; return decoded;
} }
/// <summary>
/// Encodes a page 2Ah of a MODE SENSE response
/// </summary>
/// <param name="decoded">Decoded page 2Ah</param>
/// <returns>Raw page 2Ah</returns>
public static byte[] Encode(ModePage_2A decoded) public static byte[] Encode(ModePage_2A decoded)
{ {
byte[] pageResponse = new byte[512]; byte[] pageResponse = new byte[512];
@@ -464,10 +564,19 @@ namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes
} }
} }
/// <summary>
/// Page 2Ah write descriptor
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public struct ModePage_2A_WriteDescriptor public struct ModePage_2A_WriteDescriptor
{ {
/// <summary>
/// Rotational control
/// </summary>
public byte RotationControl; public byte RotationControl;
/// <summary>
/// Write speed
/// </summary>
public ushort WriteSpeed; public ushort WriteSpeed;
} }
#endregion Mode Page 0x2A: CD-ROM capabilities page #endregion Mode Page 0x2A: CD-ROM capabilities page

View File

@@ -227,6 +227,9 @@ namespace Aaru.CommonTypes.Structs
} }
} }
/// <summary>
/// Information about a volume
/// </summary>
public class FileSystemInfo public class FileSystemInfo
{ {
/// <summary>Blocks for this filesystem</summary> /// <summary>Blocks for this filesystem</summary>
@@ -246,25 +249,53 @@ namespace Aaru.CommonTypes.Structs
/// <summary>Filesystem type</summary> /// <summary>Filesystem type</summary>
public string Type; public string Type;
/// <summary>
/// Initializes an empty instance of this structure
/// </summary>
public FileSystemInfo() => Id = new FileSystemId(); public FileSystemInfo() => Id = new FileSystemId();
/// <summary>
/// Gets a clone of this structure
/// </summary>
/// <returns>Clone of this structure</returns>
public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone(); public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone();
} }
/// <summary>
/// Stores a filesystem volume unique identifier or serial number
/// </summary>
[StructLayout(LayoutKind.Explicit)] [StructLayout(LayoutKind.Explicit)]
public struct FileSystemId public struct FileSystemId
{ {
/// <summary>
/// Set to <c>true</c> if the identifier is a 32-bit integer
/// </summary>
[FieldOffset(0)] [FieldOffset(0)]
public bool IsInt; public bool IsInt;
/// <summary>
/// Set to <c>true</c> if the identifier is a 64-bit integer
/// </summary>
[FieldOffset(1)] [FieldOffset(1)]
public bool IsLong; public bool IsLong;
/// <summary>
/// Set to <c>true</c> if the identifier is a GUID
/// </summary>
[FieldOffset(2)] [FieldOffset(2)]
public bool IsGuid; public bool IsGuid;
/// <summary>
/// Identifier as a 32-bit integer
/// </summary>
[FieldOffset(3)] [FieldOffset(3)]
public uint Serial32; public uint Serial32;
/// <summary>
/// Identifier as a 64-bit integer
/// </summary>
[FieldOffset(3)] [FieldOffset(3)]
public ulong Serial64; public ulong Serial64;
/// <summary>
/// Identifier as a GUID
/// </summary>
[FieldOffset(3)] [FieldOffset(3)]
public Guid uuid; public Guid uuid;
} }

View File

@@ -167,6 +167,9 @@ namespace Aaru.CommonTypes.Structs
/// <summary>Partition type</summary> /// <summary>Partition type</summary>
public TrackType TrackType; public TrackType TrackType;
/// <summary>
/// Initializes an empty instance of this structure
/// </summary>
public Track() => Indexes = new Dictionary<ushort, int>(); public Track() => Indexes = new Dictionary<ushort, int>();
} }

View File

@@ -38,6 +38,9 @@
namespace Aaru.CommonTypes.Structs namespace Aaru.CommonTypes.Structs
{ {
/// <summary>
/// Describes a tape file
/// </summary>
public struct TapeFile public struct TapeFile
{ {
/// <summary>File number</summary> /// <summary>File number</summary>

View File

@@ -38,6 +38,9 @@
namespace Aaru.CommonTypes.Structs namespace Aaru.CommonTypes.Structs
{ {
/// <summary>
/// Describes a tape partition
/// </summary>
public struct TapePartition public struct TapePartition
{ {
/// <summary>Partition number</summary> /// <summary>Partition number</summary>