mirror of
https://github.com/aaru-dps/Aaru.CommonTypes.git
synced 2025-12-16 19:24:30 +00:00
Fix detection of flash drives that report themselves as CD drives when they're not.
This commit is contained in:
@@ -39,7 +39,8 @@ namespace Aaru.CommonTypes
|
||||
{
|
||||
public static partial class MediaTypeFromDevice
|
||||
{
|
||||
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)
|
||||
{
|
||||
switch(mediumType)
|
||||
{
|
||||
@@ -121,6 +122,14 @@ namespace Aaru.CommonTypes
|
||||
"SCSI medium type is {0:X2}h, setting media type to CD-RW.", mediumType);
|
||||
|
||||
return MediaType.CDRW;
|
||||
case 0x40 when isUsb:
|
||||
case 0x41 when isUsb:
|
||||
case 0x42 when isUsb:
|
||||
AaruConsole.DebugWriteLine("Media detection",
|
||||
"SCSI medium type is {0:X2}h and device is USB, setting media type to Flash Drive.",
|
||||
mediumType);
|
||||
|
||||
return MediaType.FlashDrive;
|
||||
case 0x80:
|
||||
if(model.ToLowerInvariant().StartsWith("ult", StringComparison.Ordinal))
|
||||
switch(densityCode)
|
||||
|
||||
@@ -47,9 +47,10 @@ namespace Aaru.CommonTypes
|
||||
/// <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>
|
||||
/// <returns></returns>
|
||||
public static MediaType GetFromScsi(byte scsiPeripheralType, string vendor, string model, byte mediumType,
|
||||
byte densityCode, ulong blocks, uint blockSize)
|
||||
byte densityCode, ulong blocks, uint blockSize, bool isUsb)
|
||||
{
|
||||
switch(scsiPeripheralType)
|
||||
{
|
||||
@@ -74,7 +75,7 @@ namespace Aaru.CommonTypes
|
||||
case 0x07: return GetFromOdc(mediumType, blocks, blockSize);
|
||||
|
||||
// MultiMedia Device
|
||||
case 0x05: return GetFromMmc(model, mediumType, densityCode, blocks, blockSize);
|
||||
case 0x05: return GetFromMmc(model, mediumType, densityCode, blocks, blockSize, isUsb);
|
||||
|
||||
// MD DATA drives
|
||||
case 0x10 when model.StartsWith("MDM", StringComparison.Ordinal) ||
|
||||
|
||||
Reference in New Issue
Block a user