From 1e4ac8b2fbe33bd6cbb882e2d6ffdf5eb3155f73 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 3 Dec 2020 18:19:05 +0000 Subject: [PATCH] Fix detection of flash drives that report themselves as CD drives when they're not. --- Aaru.Core/Devices/Dumping/SSC.cs | 19 ++++++++++--------- Aaru.Core/Devices/Dumping/Sbc/Dump.cs | 3 ++- Aaru.Core/Media/Info/ScsiInfo.cs | 9 ++++++--- Aaru.Images/ZZZRawImage/Read.cs | 4 +++- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index f9219f9e5..5e44e607e 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -308,7 +308,8 @@ namespace Aaru.Core.Devices.Dumping if(dskType == MediaType.Unknown) dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, _dev.Manufacturer, _dev.Model, - scsiMediumTypeTape, scsiDensityCodeTape, blocks, blockSize); + scsiMediumTypeTape, scsiDensityCodeTape, blocks, blockSize, + _dev.IsUsb); if(dskType == MediaType.Unknown) dskType = MediaType.UnknownTape; @@ -1037,23 +1038,23 @@ namespace Aaru.Core.Devices.Dumping mhddLog.Close(); ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); UpdateStatus?.Invoke($"Dump finished in {(end - start).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average dump speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); + Invoke($"Average dump speed {(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000):F3} KiB/sec."); UpdateStatus?. - Invoke($"Average write speed {((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); + Invoke($"Average write speed {(double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration:F3} KiB/sec."); _dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); _dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - ((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); _dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", - ((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration); + (double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration); #region Error handling if(_resume.BadBlocks.Count > 0 && @@ -1284,12 +1285,12 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke($"Sidecar created in {(end - chkStart).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average checksum speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalChkDuration / 1000):F3} KiB/sec."); + Invoke($"Average checksum speed {(double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000):F3} KiB/sec."); _dumpLog.WriteLine("Sidecar created in {0} seconds.", (end - chkStart).TotalSeconds); _dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - ((double)blockSize * (double)(blocks + 1)) / 1024 / (totalChkDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000)); if(_preSidecar != null) { @@ -1361,7 +1362,7 @@ namespace Aaru.Core.Devices.Dumping Invoke($"Took a total of {(end - start).TotalSeconds:F3} seconds ({totalDuration / 1000:F3} processing commands, {totalChkDuration / 1000:F3} checksumming, {imageWriteDuration:F3} writing, {(closeEnd - closeStart).TotalSeconds:F3} closing)."); UpdateStatus?. - Invoke($"Average speed: {((double)blockSize * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); + Invoke($"Average speed: {(double)blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index a7750d1cf..f12fd6983 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -180,7 +180,8 @@ namespace Aaru.Core.Devices.Dumping if(dskType == MediaType.Unknown) dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, _dev.Manufacturer, _dev.Model, - scsiMediumType, scsiDensityCode, blocks + 1, blockSize); + scsiMediumType, scsiDensityCode, blocks + 1, blockSize, + _dev.IsUsb); if(_dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) MMC.DetectDiscType(ref dskType, 1, null, _dev, out _, out _, 0); diff --git a/Aaru.Core/Media/Info/ScsiInfo.cs b/Aaru.Core/Media/Info/ScsiInfo.cs index dedcc8ee9..5ef692f91 100644 --- a/Aaru.Core/Media/Info/ScsiInfo.cs +++ b/Aaru.Core/Media/Info/ScsiInfo.cs @@ -283,7 +283,8 @@ namespace Aaru.Core.Media.Info break; } - if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) + if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice && + !(dev.IsUsb && (scsiMediumType == 0x40 || scsiMediumType == 0x41 || scsiMediumType == 0x42))) { sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout, out _); @@ -1397,7 +1398,8 @@ namespace Aaru.Core.Media.Info case MediaType.Unknown: MediaType = MediaTypeFromDevice.GetFromScsi((byte)dev.ScsiType, dev.Manufacturer, dev.Model, - scsiMediumType, scsiDensityCode, Blocks, BlockSize); + scsiMediumType, scsiDensityCode, Blocks, BlockSize, + dev.IsUsb); break; } @@ -1407,7 +1409,8 @@ namespace Aaru.Core.Media.Info containsFloppyPage) MediaType = MediaType.FlashDrive; - if(DeviceInfo.ScsiType != PeripheralDeviceTypes.MultiMediaDevice) + if(DeviceInfo.ScsiType != PeripheralDeviceTypes.MultiMediaDevice || + (dev.IsUsb && (scsiMediumType == 0x40 || scsiMediumType == 0x41 || scsiMediumType == 0x42))) return; sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.DiscInformation, diff --git a/Aaru.Images/ZZZRawImage/Read.cs b/Aaru.Images/ZZZRawImage/Read.cs index 13181ba96..36727e553 100644 --- a/Aaru.Images/ZZZRawImage/Read.cs +++ b/Aaru.Images/ZZZRawImage/Read.cs @@ -990,7 +990,9 @@ namespace Aaru.DiscImages _imageInfo.MediaType = MediaTypeFromDevice.GetFromScsi((byte)devType, _imageInfo.DriveManufacturer, _imageInfo.DriveModel, mediumType, densityCode, _imageInfo.Sectors, - _imageInfo.SectorSize); + _imageInfo.SectorSize, + _mediaTags.ContainsKey(MediaTagType. + USB_Descriptors)); } if(_imageInfo.MediaType == MediaType.Unknown)