Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 45 additions & 25 deletions Aaru.Core/Devices/Dumping/Sbc/Dump.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// /***************************************************************************
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
Expand Down Expand Up @@ -80,6 +80,7 @@ void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, MediaType dskType, bool opt
var containsFloppyPage = false;
const ushort sbcProfile = 0x0001;
const uint DvdLeadinSectors = 4096; // Usable Lead-in before LBA 0 per DVD spec (PSN 0x02F000–0x02FFFF)
const uint BdFallbackNegativeSectors = 4832 * 32; // Usable lead-in clusters before LBA 0 per BD spec
double totalDuration = 0;
double currentSpeed = 0;
double maxSpeed = double.MinValue;
Expand Down Expand Up @@ -237,7 +238,7 @@ void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, MediaType dskType, bool opt
break;
}

if(scsiReader.FindReadCommand())
if(scsiReader.FindReadCommand(dskType))
{
AaruLogging.WriteLine(Localization.Core.ERROR_Cannot_find_correct_read_command_0, scsiReader.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Unable_to_read_medium);
Expand Down Expand Up @@ -327,7 +328,7 @@ void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, MediaType dskType, bool opt
scsiReader.otp = decodedPfi?.TrackPath ?? false;

if(scsiReader.HldtstReadRaw) blocksToRead = 1;
if(scsiReader.OmniDriveReadRaw) blocksToRead = 31;
if(scsiReader.OmniDriveReadRaw) blocksToRead = scsiReader.OmniDriveReadRawBluray ? 7u : 31u;

UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_raw_bytes_1_cooked_bytes_per_sector,
longBlockSize,
Expand Down Expand Up @@ -442,7 +443,8 @@ void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, MediaType dskType, bool opt
mediaTags.TryGetValue(MediaTagType.BD_DI, out byte[] di);
DI.DiscInformation? decodedDi = DI.Decode(di);

if(decodedDi.HasValue) nominalNegativeSectors = decodedDi.Value.Units[0].FirstAun;
if(scsiReader.OmniDriveReadRawBluray)
nominalNegativeSectors = BdFallbackNegativeSectors;

sense = _dev.ReadDiscInformation(out byte[] readBuffer,
out _,
Expand Down Expand Up @@ -871,35 +873,53 @@ void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, MediaType dskType, bool opt

if(scsiReader.HldtstReadRaw || scsiReader.ReadBuffer3CReadRaw || scsiReader.OmniDriveReadRaw)
{
uint nominalForRawDvd = 0;
uint overflowForRawDvd = 0;
uint nominalForRaw = 0;
uint overflowForRaw = 0;

if(scsiReader.OmniDriveReadRaw && outputFormat is IWritableOpticalImage optImg)
{
if(optImg.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreNegativeSectors))
nominalForRawDvd = nominalNegativeSectors;
nominalForRaw = nominalNegativeSectors;

if(optImg.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreOverflowSectors))
overflowForRawDvd = 100u;
overflowForRaw = scsiReader.OmniDriveReadRawBluray ? 0x432u : 100u;
}

ReadRawDvdData(blocks,
blocksToRead,
blockSize,
currentTry,
extents,
ref currentSpeed,
ref minSpeed,
ref maxSpeed,
ref totalDuration,
scsiReader,
mhddLog,
ibgLog,
ref imageWriteDuration,
ref newTrim,
discKey ?? null,
nominalForRawDvd,
overflowForRawDvd);
if(scsiReader.OmniDriveReadRawBluray)
ReadRawBdData(blocks,
blocksToRead,
blockSize,
currentTry,
extents,
ref currentSpeed,
ref minSpeed,
ref maxSpeed,
ref totalDuration,
scsiReader,
mhddLog,
ibgLog,
ref imageWriteDuration,
ref newTrim,
nominalForRaw,
overflowForRaw);
else
ReadRawDvdData(blocks,
blocksToRead,
blockSize,
currentTry,
extents,
ref currentSpeed,
ref minSpeed,
ref maxSpeed,
ref totalDuration,
scsiReader,
mhddLog,
ibgLog,
ref imageWriteDuration,
ref newTrim,
discKey ?? null,
nominalForRaw,
overflowForRaw);
}
else
{
Expand Down
8 changes: 8 additions & 0 deletions Aaru.Core/Devices/Dumping/Sbc/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ void RetrySbcData(Reader scsiReader, DumpHardware currentTry, ExtentsULong
}
else
{
if(scsiReader.OmniDriveReadRawBluray)
{
_resume.BadBlocks.Remove(badSector);
outputFormat.WriteSectorLong(buffer, badSector, false, SectorStatus.Dumped);

continue;
}

var cmi = new byte[1];

byte[] key = buffer.Skip(7).Take(5).ToArray();
Expand Down
Loading
Loading