mirror of
https://github.com/aaru-dps/Aaru.CommonTypes.git
synced 2025-12-16 19:24:30 +00:00
Move to file scoped namespaces.
This commit is contained in:
@@ -35,100 +35,99 @@
|
||||
using System;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.CommonTypes
|
||||
namespace Aaru.CommonTypes;
|
||||
|
||||
public static partial class MediaTypeFromDevice
|
||||
{
|
||||
public static partial class MediaTypeFromDevice
|
||||
/// <summary>Tries to guess, from SCSI information, the media type of a device and/or its inserted media</summary>
|
||||
/// <param name="scsiPeripheralType">The SCSI Peripheral Type as indicated in the INQUIRY response</param>
|
||||
/// <param name="vendor">The vendor string of the device</param>
|
||||
/// <param name="model">The model string of the device</param>
|
||||
/// <param name="mediumType">The medium type byte from MODE SENSE</param>
|
||||
/// <param name="densityCode">The density type byte from MODE SENSE</param>
|
||||
/// <param name="blocks">How many blocks are on the media</param>
|
||||
/// <param name="blockSize">Size in bytes of each block</param>
|
||||
/// <param name="isUsb">Device is USB</param>
|
||||
/// <param name="opticalDisc">Is media an optical disc?</param>
|
||||
/// <returns>The media type</returns>
|
||||
public static MediaType GetFromScsi(byte scsiPeripheralType, string vendor, string model, byte mediumType,
|
||||
byte densityCode, ulong blocks, uint blockSize, bool isUsb,
|
||||
bool opticalDisc)
|
||||
{
|
||||
/// <summary>Tries to guess, from SCSI information, the media type of a device and/or its inserted media</summary>
|
||||
/// <param name="scsiPeripheralType">The SCSI Peripheral Type as indicated in the INQUIRY response</param>
|
||||
/// <param name="vendor">The vendor string of the device</param>
|
||||
/// <param name="model">The model string of the device</param>
|
||||
/// <param name="mediumType">The medium type byte from MODE SENSE</param>
|
||||
/// <param name="densityCode">The density type byte from MODE SENSE</param>
|
||||
/// <param name="blocks">How many blocks are on the media</param>
|
||||
/// <param name="blockSize">Size in bytes of each block</param>
|
||||
/// <param name="isUsb">Device is USB</param>
|
||||
/// <param name="opticalDisc">Is media an optical disc?</param>
|
||||
/// <returns>The media type</returns>
|
||||
public static MediaType GetFromScsi(byte scsiPeripheralType, string vendor, string model, byte mediumType,
|
||||
byte densityCode, ulong blocks, uint blockSize, bool isUsb,
|
||||
bool opticalDisc)
|
||||
switch(scsiPeripheralType)
|
||||
{
|
||||
switch(scsiPeripheralType)
|
||||
{
|
||||
// Direct access device
|
||||
case 0x00:
|
||||
// Simplified access device
|
||||
case 0x0E:
|
||||
if(mediumType == 0x03 ||
|
||||
mediumType == 0x05 ||
|
||||
mediumType == 0x07)
|
||||
goto case 0x07;
|
||||
// Direct access device
|
||||
case 0x00:
|
||||
// Simplified access device
|
||||
case 0x0E:
|
||||
if(mediumType == 0x03 ||
|
||||
mediumType == 0x05 ||
|
||||
mediumType == 0x07)
|
||||
goto case 0x07;
|
||||
|
||||
return GetFromSbc(vendor, model, mediumType, blocks, blockSize);
|
||||
return GetFromSbc(vendor, model, mediumType, blocks, blockSize);
|
||||
|
||||
// Sequential access device
|
||||
case 0x01:
|
||||
return GetFromSsc(scsiPeripheralType, vendor, model, mediumType, densityCode, blocks, blockSize);
|
||||
// Sequential access device
|
||||
case 0x01:
|
||||
return GetFromSsc(scsiPeripheralType, vendor, model, mediumType, densityCode, blocks, blockSize);
|
||||
|
||||
// Write-once device
|
||||
case 0x04:
|
||||
// Optical device
|
||||
case 0x07: return GetFromOdc(mediumType, blocks, blockSize);
|
||||
// Write-once device
|
||||
case 0x04:
|
||||
// Optical device
|
||||
case 0x07: return GetFromOdc(mediumType, blocks, blockSize);
|
||||
|
||||
// MultiMedia Device
|
||||
case 0x05: return GetFromMmc(model, mediumType, densityCode, blocks, blockSize, isUsb, opticalDisc);
|
||||
// MultiMedia Device
|
||||
case 0x05: return GetFromMmc(model, mediumType, densityCode, blocks, blockSize, isUsb, opticalDisc);
|
||||
|
||||
// MD DATA drives
|
||||
case 0x10 when model.StartsWith("MDM", StringComparison.Ordinal) ||
|
||||
model.StartsWith("MDH", StringComparison.Ordinal):
|
||||
if(blockSize == 2048)
|
||||
{
|
||||
// MD DATA drives
|
||||
case 0x10 when model.StartsWith("MDM", StringComparison.Ordinal) ||
|
||||
model.StartsWith("MDH", StringComparison.Ordinal):
|
||||
if(blockSize == 2048)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to MiniDisc for Data.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MDData;
|
||||
}
|
||||
|
||||
switch(blocks)
|
||||
{
|
||||
case 57312:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to MiniDisc for Data.",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 60 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MDData;
|
||||
}
|
||||
return MediaType.MD60;
|
||||
case 70464:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 74 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
switch(blocks)
|
||||
{
|
||||
case 57312:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 60 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
return MediaType.MD74;
|
||||
case 76096:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 80 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD60;
|
||||
case 70464:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 74 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
return MediaType.MD80;
|
||||
}
|
||||
|
||||
return MediaType.MD74;
|
||||
case 76096:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 80 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 60 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD80;
|
||||
}
|
||||
return MediaType.MD;
|
||||
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, media has {1} blocks of {2} bytes, setting media type to 60 minute MiniDisc.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
// Host managed zoned block device
|
||||
case 0x14:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, setting media type to host managed zoned block device.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.MD;
|
||||
|
||||
// Host managed zoned block device
|
||||
case 0x14:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI peripheral type is {0:X2}h, setting media type to host managed zoned block device.",
|
||||
scsiPeripheralType, blocks, blockSize);
|
||||
|
||||
return MediaType.Zone_HDD;
|
||||
}
|
||||
|
||||
return MediaType.Unknown;
|
||||
return MediaType.Zone_HDD;
|
||||
}
|
||||
|
||||
return MediaType.Unknown;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user