mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add support for negative sectors to read and write sector calls in images.
This commit is contained in:
@@ -1456,16 +1456,19 @@ public sealed partial class BlindWrite5
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, bool negative, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
{
|
||||
buffer = null;
|
||||
sectorStatus = SectorStatus.Dumped;
|
||||
|
||||
return ReadSectors(sectorAddress, 1, out buffer, out _);
|
||||
if(negative) return ErrorNumber.NotSupported;
|
||||
|
||||
return ReadSectors(sectorAddress, false, 1, out buffer, out _);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorTag(ulong sectorAddress, SectorTagType tag, out byte[] buffer) =>
|
||||
ReadSectorsTag(sectorAddress, 1, tag, out buffer);
|
||||
public ErrorNumber ReadSectorTag(ulong sectorAddress, bool negative, SectorTagType tag, out byte[] buffer) =>
|
||||
ReadSectorsTag(sectorAddress, false, 1, tag, out buffer);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSector(ulong sectorAddress, uint track, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
@@ -1480,11 +1483,14 @@ public sealed partial class BlindWrite5
|
||||
ReadSectorsTag(sectorAddress, 1, track, tag, out buffer);
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectors(ulong sectorAddress, uint length, out byte[] buffer, out SectorStatus[] sectorStatus)
|
||||
public ErrorNumber ReadSectors(ulong sectorAddress, bool negative, uint length, out byte[] buffer,
|
||||
out SectorStatus[] sectorStatus)
|
||||
{
|
||||
buffer = null;
|
||||
sectorStatus = null;
|
||||
|
||||
if(negative) return ErrorNumber.NotSupported;
|
||||
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap
|
||||
where sectorAddress >= kvp.Value
|
||||
from track in Tracks
|
||||
@@ -1498,10 +1504,13 @@ public sealed partial class BlindWrite5
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag, out byte[] buffer)
|
||||
public ErrorNumber ReadSectorsTag(ulong sectorAddress, bool negative, uint length, SectorTagType tag,
|
||||
out byte[] buffer)
|
||||
{
|
||||
buffer = null;
|
||||
|
||||
if(negative) return ErrorNumber.NotSupported;
|
||||
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in _offsetMap
|
||||
where sectorAddress >= kvp.Value
|
||||
from track in Tracks
|
||||
@@ -2144,11 +2153,12 @@ public sealed partial class BlindWrite5
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorLong(ulong sectorAddress, out byte[] buffer, out SectorStatus sectorStatus)
|
||||
public ErrorNumber ReadSectorLong(ulong sectorAddress, bool negative, out byte[] buffer,
|
||||
out SectorStatus sectorStatus)
|
||||
{
|
||||
sectorStatus = SectorStatus.Dumped;
|
||||
|
||||
return ReadSectorsLong(sectorAddress, 1, out buffer, out _);
|
||||
return ReadSectorsLong(sectorAddress, false, 1, out buffer, out _);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -2160,7 +2170,7 @@ public sealed partial class BlindWrite5
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadSectorsLong(ulong sectorAddress, uint length, out byte[] buffer,
|
||||
public ErrorNumber ReadSectorsLong(ulong sectorAddress, bool negative, uint length, out byte[] buffer,
|
||||
out SectorStatus[] sectorStatus)
|
||||
{
|
||||
buffer = null;
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed partial class BlindWrite5
|
||||
/// <inheritdoc />
|
||||
public bool? VerifySector(ulong sectorAddress)
|
||||
{
|
||||
ErrorNumber errno = ReadSectorLong(sectorAddress, out byte[] buffer, out _);
|
||||
ErrorNumber errno = ReadSectorLong(sectorAddress, false, out byte[] buffer, out _);
|
||||
|
||||
return errno != ErrorNumber.NoError ? null : CdChecksums.CheckCdSector(buffer);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public sealed partial class BlindWrite5
|
||||
{
|
||||
failingLbas = [];
|
||||
unknownLbas = [];
|
||||
ErrorNumber errno = ReadSectorsLong(sectorAddress, length, out byte[] buffer, out _);
|
||||
ErrorNumber errno = ReadSectorsLong(sectorAddress, false, length, out byte[] buffer, out _);
|
||||
|
||||
if(errno != ErrorNumber.NoError) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user