mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Allocate SENSE buffer only once.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
// Copyright © 2020-2025 Rebecca Wallander
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.CommonTypes.AaruMetadata;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
@@ -223,7 +224,7 @@ partial class Dump
|
||||
}
|
||||
|
||||
UpdateStatus?.Invoke(Localization.Core.Sending_MODE_SELECT_to_drive_return_damaged_blocks);
|
||||
sense = _dev.ModeSelect(md6, out byte[] senseBuf, true, false, _dev.Timeout, out _);
|
||||
sense = _dev.ModeSelect(md6, out ReadOnlySpan<byte> senseBuf, true, false, _dev.Timeout, out _);
|
||||
|
||||
if(sense) sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Helpers;
|
||||
using Aaru.Logging;
|
||||
using Humanizer;
|
||||
using Humanizer.Bytes;
|
||||
@@ -62,7 +61,7 @@ partial class Dump
|
||||
{
|
||||
blankExtents = new ExtentsULong();
|
||||
|
||||
written = _dev.MediumScan(out buffer,
|
||||
written = _dev.MediumScan(out ReadOnlySpan<byte> senseBuffer,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
@@ -76,7 +75,7 @@ partial class Dump
|
||||
uint.MaxValue,
|
||||
out _);
|
||||
|
||||
DecodedSense? decodedSense = Sense.Decode(buffer);
|
||||
DecodedSense? decodedSense = Sense.Decode(senseBuffer.ToArray());
|
||||
|
||||
if(_dev.LastError != 0 || decodedSense?.SenseKey == SenseKeys.IllegalRequest)
|
||||
{
|
||||
@@ -87,8 +86,7 @@ partial class Dump
|
||||
}
|
||||
|
||||
// TODO: Find a place where MEDIUM SCAN works properly
|
||||
else if(buffer?.Length > 0 && !ArrayHelpers.ArrayIsNullOrEmpty(buffer))
|
||||
AaruLogging.WriteLine(Localization.Core.MEDIUM_SCAN_github_plead_message);
|
||||
else if(senseBuffer.IsEmpty) AaruLogging.WriteLine(Localization.Core.MEDIUM_SCAN_github_plead_message);
|
||||
|
||||
changingCounter = false;
|
||||
changingWritten = false;
|
||||
@@ -181,8 +179,9 @@ partial class Dump
|
||||
writtenExtents.Add(0, blocks - 1);
|
||||
|
||||
foreach(Tuple<ulong, ulong> blank in blankExtents.ToArray())
|
||||
for(ulong b = blank.Item1; b <= blank.Item2; b++)
|
||||
writtenExtents.Remove(b);
|
||||
{
|
||||
for(ulong b = blank.Item1; b <= blank.Item2; b++) writtenExtents.Remove(b);
|
||||
}
|
||||
}
|
||||
|
||||
if(writtenExtents.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user