Fix misdetecting optical discs as flash drives.

This commit is contained in:
2020-12-29 19:37:16 +00:00
parent 16780e9ba3
commit 069a2e39cc
3 changed files with 9 additions and 7 deletions

View File

@@ -40,7 +40,7 @@ namespace Aaru.CommonTypes
public static partial class MediaTypeFromDevice
{
static MediaType GetFromMmc(string model, byte mediumType, byte densityCode, ulong blocks, uint blockSize,
bool isUsb)
bool isUsb, bool opticalDisc)
{
switch(mediumType)
{
@@ -122,9 +122,9 @@ 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:
case 0x40 when isUsb && !opticalDisc:
case 0x41 when isUsb && !opticalDisc:
case 0x42 when isUsb && !opticalDisc:
AaruConsole.DebugWriteLine("Media detection",
"SCSI medium type is {0:X2}h and device is USB, setting media type to Flash Drive.",
mediumType);

View File

@@ -48,9 +48,11 @@ namespace Aaru.CommonTypes
/// <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"></param>
/// <returns></returns>
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)
{
switch(scsiPeripheralType)
{
@@ -75,7 +77,7 @@ namespace Aaru.CommonTypes
case 0x07: return GetFromOdc(mediumType, blocks, blockSize);
// MultiMedia Device
case 0x05: return GetFromMmc(model, mediumType, densityCode, blocks, blockSize, isUsb);
case 0x05: return GetFromMmc(model, mediumType, densityCode, blocks, blockSize, isUsb, opticalDisc);
// MD DATA drives
case 0x10 when model.StartsWith("MDM", StringComparison.Ordinal) ||