mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Correct first track pregap references.
This commit is contained in:
@@ -179,7 +179,7 @@
|
||||
|
||||
### - Create sidecar
|
||||
- Add filesystems only to the appropriate partition and track.
|
||||
- Fix CD Lead-in, TOC and XGD tags.
|
||||
- Fix CD first track pregap, TOC and XGD tags.
|
||||
- Fix diameter setting.
|
||||
- Fix SCSI MODE SENSE.
|
||||
- Fix USB descriptors.
|
||||
|
||||
@@ -259,8 +259,8 @@ namespace DiscImageChef.CommonTypes.Enums
|
||||
Floppy_LeadOut,
|
||||
/// <summary>DVD Disc Control Blocks</summary>
|
||||
DCB,
|
||||
/// <summary>Compact Disc Lead-in</summary>
|
||||
CD_LeadIn,
|
||||
/// <summary>Compact Disc First Track Pregap</summary>
|
||||
CD_FirstTrackPregap,
|
||||
/// <summary>Compact Disc Lead-out</summary>
|
||||
CD_LeadOut,
|
||||
/// <summary>SCSI MODE SENSE (6)</summary>
|
||||
@@ -272,7 +272,9 @@ namespace DiscImageChef.CommonTypes.Enums
|
||||
/// <summary>XGD unlocked DMI</summary>
|
||||
Xbox_DMI,
|
||||
/// <summary>XDG unlocked PFI</summary>
|
||||
Xbox_PFI
|
||||
Xbox_PFI,
|
||||
/// <summary>Compact Disc Lead-in</summary>
|
||||
CD_LeadIn
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -77,20 +77,21 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <param name="resume">Information for dump resuming</param>
|
||||
/// <param name="dumpLog">Dump logger</param>
|
||||
/// <param name="dskType">Disc type as detected in MMC layer</param>
|
||||
/// <param name="dumpLeadIn">Try to read and dump as much Lead-in as possible</param>
|
||||
/// <param name="dumpFirstTrackPregap">Try to read and dump as much first track pregap as possible</param>
|
||||
/// <param name="outputPath">Path to output file</param>
|
||||
/// <param name="formatOptions">Formats to pass to output file plugin</param>
|
||||
/// <param name="encoding">Encoding to use when analyzing dump</param>
|
||||
/// <exception cref="NotImplementedException">If trying to dump scrambled sectors</exception>
|
||||
/// <exception cref="InvalidOperationException">If the resume file is invalid</exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">If the track type is unknown (never)</exception>
|
||||
internal static void Dump(Device dev, string devicePath,
|
||||
IWritableImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw,
|
||||
bool persistent, bool stopOnError, ref MediaType dskType,
|
||||
ref Resume resume, ref DumpLog dumpLog,
|
||||
bool dumpLeadIn, Encoding encoding,
|
||||
string outputPrefix, string outputPath,
|
||||
internal static void Dump(Device dev, string devicePath,
|
||||
IWritableImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw,
|
||||
bool persistent, bool stopOnError,
|
||||
ref MediaType dskType,
|
||||
ref Resume resume, ref DumpLog dumpLog,
|
||||
bool dumpFirstTrackPregap, Encoding encoding,
|
||||
string outputPrefix, string outputPath,
|
||||
Dictionary<string, string> formatOptions,
|
||||
CICMMetadataType preSidecar, uint skip,
|
||||
bool nometadata, bool notrim)
|
||||
@@ -764,32 +765,32 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
supportsLongSectors = false;
|
||||
}
|
||||
|
||||
// Check if something prevents from dumping the Lead-in
|
||||
if(dumpLeadIn && readcd)
|
||||
// Check if something prevents from dumping the first track pregap
|
||||
if(dumpFirstTrackPregap && readcd)
|
||||
{
|
||||
if(dev.PlatformId == PlatformID.FreeBSD)
|
||||
{
|
||||
dumpLog.WriteLine("FreeBSD panics when reading CD Lead-in, see upstream bug #224253. {0}continuing",
|
||||
dumpLog.WriteLine("FreeBSD panics when reading CD first track pregap, see upstream bug #224253. {0}continuing",
|
||||
force ? "" : "Not ");
|
||||
DicConsole
|
||||
.ErrorWriteLine("FreeBSD panics when reading CD Lead-in, see upstream bug #224253. {0}continuing",
|
||||
.ErrorWriteLine("FreeBSD panics when reading CD first track pregap, see upstream bug #224253. {0}continuing",
|
||||
force ? "" : "Not ");
|
||||
|
||||
if(!force) return;
|
||||
|
||||
dumpLeadIn = false;
|
||||
dumpFirstTrackPregap = false;
|
||||
}
|
||||
|
||||
if(!outputPlugin.SupportedMediaTags.Contains(MediaTagType.CD_LeadIn))
|
||||
if(!outputPlugin.SupportedMediaTags.Contains(MediaTagType.CD_FirstTrackPregap))
|
||||
{
|
||||
DicConsole.WriteLine("Output format does not support CD Lead-in, {0}continuing...",
|
||||
DicConsole.WriteLine("Output format does not support CD first track pregap, {0}continuing...",
|
||||
force ? "" : "not ");
|
||||
dumpLog.WriteLine("Output format does not support CD Lead-in, {0}continuing...",
|
||||
dumpLog.WriteLine("Output format does not support CD first track pregap, {0}continuing...",
|
||||
force ? "" : "not ");
|
||||
|
||||
if(!force) return;
|
||||
|
||||
dumpLeadIn = false;
|
||||
dumpFirstTrackPregap = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,18 +801,19 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
if(currentTry == null || extents == null)
|
||||
throw new InvalidOperationException("Could not process resume file, not continuing...");
|
||||
|
||||
// Try to read the Lead-in
|
||||
if(dumpLeadIn && readcd)
|
||||
// Try to read the first track pregap
|
||||
if(dumpFirstTrackPregap && readcd)
|
||||
{
|
||||
DicConsole.WriteLine("Trying to read Lead-In...");
|
||||
bool gotLeadIn = false;
|
||||
int leadInSectorsGood = 0;
|
||||
MemoryStream leadinMs = new MemoryStream();
|
||||
DicConsole.WriteLine("Trying to read first track pregap...");
|
||||
bool gotFirstTrackPregap = false;
|
||||
int firstTrackPregapSectorsGood = 0;
|
||||
MemoryStream firstTrackPregapMs = new MemoryStream();
|
||||
|
||||
readBuffer = null;
|
||||
|
||||
dumpLog.WriteLine("Reading Lead-in");
|
||||
for(int leadInBlock = -150; leadInBlock < 0 && resume.NextBlock == 0; leadInBlock++)
|
||||
dumpLog.WriteLine("Reading first track pregap");
|
||||
for(int firstTrackPregapBlock = -150; firstTrackPregapBlock < 0 && resume.NextBlock == 0;
|
||||
firstTrackPregapBlock++)
|
||||
{
|
||||
if(aborted)
|
||||
{
|
||||
@@ -824,37 +826,38 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed;
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
|
||||
DicConsole.Write("\rTrying to read lead-in sector {0} ({1:F3} MiB/sec.)", leadInBlock,
|
||||
currentSpeed);
|
||||
DicConsole.Write("\rTrying to read first track pregap sector {0} ({1:F3} MiB/sec.)",
|
||||
firstTrackPregapBlock, currentSpeed);
|
||||
|
||||
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)leadInBlock, blockSize, 1,
|
||||
sense = dev.ReadCd(out readBuffer, out senseBuf, (uint)firstTrackPregapBlock, blockSize, 1,
|
||||
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
|
||||
true, MmcErrorField.None, supportedSubchannel, dev.Timeout,
|
||||
out double cmdDuration);
|
||||
|
||||
if(!sense && !dev.Error)
|
||||
{
|
||||
leadinMs.Write(readBuffer, 0, (int)blockSize);
|
||||
gotLeadIn = true;
|
||||
leadInSectorsGood++;
|
||||
firstTrackPregapMs.Write(readBuffer, 0, (int)blockSize);
|
||||
gotFirstTrackPregap = true;
|
||||
firstTrackPregapSectorsGood++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write empty data
|
||||
if(gotLeadIn) leadinMs.Write(new byte[blockSize], 0, (int)blockSize);
|
||||
if(gotFirstTrackPregap) firstTrackPregapMs.Write(new byte[blockSize], 0, (int)blockSize);
|
||||
}
|
||||
|
||||
double newSpeed = blockSize / (double)1048576 / (cmdDuration / 1000);
|
||||
if(!double.IsInfinity(newSpeed)) currentSpeed = newSpeed;
|
||||
}
|
||||
|
||||
if(leadInSectorsGood > 0) mediaTags.Add(MediaTagType.CD_LeadIn, leadinMs.ToArray());
|
||||
if(firstTrackPregapSectorsGood > 0)
|
||||
mediaTags.Add(MediaTagType.CD_FirstTrackPregap, firstTrackPregapMs.ToArray());
|
||||
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Got {0} lead-in sectors.", leadInSectorsGood);
|
||||
dumpLog.WriteLine("Got {0} Lead-in sectors.", leadInSectorsGood);
|
||||
DicConsole.WriteLine("Got {0} first track pregap sectors.", firstTrackPregapSectorsGood);
|
||||
dumpLog.WriteLine("Got {0} first track pregap sectors.", firstTrackPregapSectorsGood);
|
||||
|
||||
leadinMs.Close();
|
||||
firstTrackPregapMs.Close();
|
||||
}
|
||||
|
||||
// Try how many blocks are readable at once
|
||||
|
||||
@@ -797,7 +797,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
Checksums = Checksum.GetChecksums(tag.Value).ToArray()
|
||||
};
|
||||
break;
|
||||
case MediaTagType.CD_LeadIn:
|
||||
case MediaTagType.CD_FirstTrackPregap:
|
||||
sidecar.OpticalDisc[0].LeadIn = new[]
|
||||
{
|
||||
new BorderType
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <param name="resume">Information for dump resuming</param>
|
||||
/// <param name="dumpLog">Dump logger</param>
|
||||
/// <param name="encoding">Encoding to use when analyzing dump</param>
|
||||
/// <param name="dumpLeadIn">Try to read and dump as much Lead-in as possible</param>
|
||||
/// <param name="dumpFirstTrackPregap">Try to read and dump as much Lead-in as possible</param>
|
||||
/// <param name="outputPath">Path to output file</param>
|
||||
/// <param name="formatOptions">Formats to pass to output file plugin</param>
|
||||
/// <exception cref="ArgumentException">If you asked to dump long sectors from a SCSI Streaming device</exception>
|
||||
@@ -74,7 +74,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
IWritableImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw,
|
||||
bool persistent, bool stopOnError, ref Resume resume,
|
||||
ref DumpLog dumpLog, bool dumpLeadIn,
|
||||
ref DumpLog dumpLog, bool dumpFirstTrackPregap,
|
||||
Encoding encoding, string outputPrefix,
|
||||
string outputPath, Dictionary<string, string> formatOptions,
|
||||
CICMMetadataType preSidecar, uint skip, bool nometadata,
|
||||
@@ -210,8 +210,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
return;
|
||||
case PeripheralDeviceTypes.MultiMediaDevice:
|
||||
Mmc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
|
||||
ref dskType, ref resume, ref dumpLog, dumpLeadIn, encoding, outputPrefix, outputPath,
|
||||
formatOptions, preSidecar, skip, nometadata, notrim);
|
||||
ref dskType, ref resume, ref dumpLog, dumpFirstTrackPregap, encoding, outputPrefix,
|
||||
outputPath, formatOptions, preSidecar, skip, nometadata, notrim);
|
||||
return;
|
||||
default:
|
||||
Sbc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError, null,
|
||||
|
||||
@@ -277,15 +277,16 @@ namespace DiscImageChef.Core
|
||||
Size = image.ReadDiskTag(MediaTagType.CD_FullTOC).Length
|
||||
};
|
||||
break;
|
||||
case MediaTagType.CD_LeadIn:
|
||||
case MediaTagType.CD_FirstTrackPregap:
|
||||
sidecar.OpticalDisc[0].LeadIn = new[]
|
||||
{
|
||||
new BorderType
|
||||
{
|
||||
Image = Path.GetFileName(imagePath),
|
||||
Checksums = Checksum
|
||||
.GetChecksums(image.ReadDiskTag(MediaTagType.CD_LeadIn)).ToArray(),
|
||||
Size = image.ReadDiskTag(MediaTagType.CD_LeadIn).Length
|
||||
.GetChecksums(image.ReadDiskTag(MediaTagType.CD_FirstTrackPregap))
|
||||
.ToArray(),
|
||||
Size = image.ReadDiskTag(MediaTagType.CD_FirstTrackPregap).Length
|
||||
}
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace DiscImageChef.DiscImages
|
||||
FloppyLeadOut = 60,
|
||||
/// <summary>Dvd Disc Control Block</summary>
|
||||
DvdDiscControlBlock = 61,
|
||||
/// <summary>CompactDisc Lead-in</summary>
|
||||
CompactDiscLeadIn = 62,
|
||||
/// <summary>CompactDisc First track pregap</summary>
|
||||
CompactDiscFirstTrackPregap = 62,
|
||||
/// <summary>CompactDisc Lead-out</summary>
|
||||
CompactDiscLeadOut = 63,
|
||||
/// <summary>SCSI MODE SENSE (6) response</summary>
|
||||
@@ -207,7 +207,9 @@ namespace DiscImageChef.DiscImages
|
||||
/// <summary>CompactDisc sector suffix (edc, ecc p, ecc q), only incorrect stored</summary>
|
||||
CdSectorSuffixCorrected = 77,
|
||||
/// <summary>CompactDisc MODE 2 subheader</summary>
|
||||
CompactDiscMode2Subheader = 78
|
||||
CompactDiscMode2Subheader = 78,
|
||||
/// <summary>CompactDisc Lead-in</summary>
|
||||
CompactDiscLeadIn = 79
|
||||
}
|
||||
|
||||
/// <summary>List of known blocks types</summary>
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace DiscImageChef.DiscImages
|
||||
case DataType.XboxSecuritySector: return MediaTagType.Xbox_SecuritySector;
|
||||
case DataType.FloppyLeadOut: return MediaTagType.Floppy_LeadOut;
|
||||
case DataType.DvdDiscControlBlock: return MediaTagType.DCB;
|
||||
case DataType.CompactDiscLeadIn: return MediaTagType.CD_LeadIn;
|
||||
case DataType.CompactDiscFirstTrackPregap: return MediaTagType.CD_FirstTrackPregap;
|
||||
case DataType.CompactDiscLeadOut: return MediaTagType.CD_LeadOut;
|
||||
case DataType.ScsiModeSense6: return MediaTagType.SCSI_MODESENSE_6;
|
||||
case DataType.ScsiModeSense10: return MediaTagType.SCSI_MODESENSE_10;
|
||||
@@ -330,6 +330,7 @@ namespace DiscImageChef.DiscImages
|
||||
case DataType.XboxDmi: return MediaTagType.Xbox_DMI;
|
||||
case DataType.XboxPfi: return MediaTagType.Xbox_PFI;
|
||||
case DataType.CompactDiscMediaCatalogueNumber: return MediaTagType.CD_MCN;
|
||||
case DataType.CompactDiscLeadIn: return MediaTagType.CD_LeadIn;
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
@@ -399,7 +400,7 @@ namespace DiscImageChef.DiscImages
|
||||
case MediaTagType.Xbox_SecuritySector: return DataType.XboxSecuritySector;
|
||||
case MediaTagType.Floppy_LeadOut: return DataType.FloppyLeadOut;
|
||||
case MediaTagType.DCB: return DataType.DvdDiscControlBlock;
|
||||
case MediaTagType.CD_LeadIn: return DataType.CompactDiscLeadIn;
|
||||
case MediaTagType.CD_FirstTrackPregap: return DataType.CompactDiscFirstTrackPregap;
|
||||
case MediaTagType.CD_LeadOut: return DataType.CompactDiscLeadOut;
|
||||
case MediaTagType.SCSI_MODESENSE_6: return DataType.ScsiModeSense6;
|
||||
case MediaTagType.SCSI_MODESENSE_10: return DataType.ScsiModeSense10;
|
||||
@@ -407,6 +408,7 @@ namespace DiscImageChef.DiscImages
|
||||
case MediaTagType.Xbox_DMI: return DataType.XboxDmi;
|
||||
case MediaTagType.Xbox_PFI: return DataType.XboxPfi;
|
||||
case MediaTagType.CD_MCN: return DataType.CompactDiscMediaCatalogueNumber;
|
||||
case MediaTagType.CD_LeadIn: return DataType.CompactDiscLeadIn;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(tag), tag, null);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace DiscImageChef.DiscImages
|
||||
{
|
||||
(MediaTagType.ATA_IDENTIFY, ".identify.bin"), (MediaTagType.BD_DI, ".di.bin"),
|
||||
(MediaTagType.CD_ATIP, ".atip.bin"), (MediaTagType.CD_FullTOC, ".toc.bin"),
|
||||
(MediaTagType.CD_LeadIn, ".leadin.bin"), (MediaTagType.CD_PMA, ".pma.bin"),
|
||||
(MediaTagType.CD_FirstTrackPregap, ".leadin.bin"), (MediaTagType.CD_PMA, ".pma.bin"),
|
||||
(MediaTagType.CD_TEXT, ".cdtext.bin"), (MediaTagType.DCB, ".dcb.bin"),
|
||||
(MediaTagType.DVD_ADIP, ".adip.bin"), (MediaTagType.DVD_BCA, ".bca.bin"),
|
||||
(MediaTagType.DVD_CMI, ".cmi.bin"), (MediaTagType.DVD_DMI, ".dmi.bin"),
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--retry-passes={0}", options.RetryPasses);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--persistent={0}", options.Persistent);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--resume={0}", options.Resume);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--lead-in={0}", options.LeadIn);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--first-pregap={0}", options.FirstTrackPregap);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--encoding={0}", options.EncodingName);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--output={0}", options.OutputFile);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--format={0}", options.OutputFormat);
|
||||
@@ -234,9 +234,9 @@ namespace DiscImageChef.Commands
|
||||
case DeviceType.SCSI:
|
||||
Scsi.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force,
|
||||
false, /*options.Raw,*/
|
||||
options.Persistent, options.StopOnError, ref resume, ref dumpLog, options.LeadIn,
|
||||
encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip,
|
||||
options.NoMetadata, options.NoTrim);
|
||||
options.Persistent, options.StopOnError, ref resume, ref dumpLog,
|
||||
options.FirstTrackPregap, encoding, outputPrefix, options.OutputFile, parsedOptions,
|
||||
sidecar, (uint)options.Skip, options.NoMetadata, options.NoTrim);
|
||||
break;
|
||||
default:
|
||||
dumpLog.WriteLine("Unknown device type.");
|
||||
|
||||
@@ -287,8 +287,9 @@ namespace DiscImageChef
|
||||
[Option('m', "resume", Default = true, HelpText = "Create/use resume mapfile.")]
|
||||
public bool Resume { get; set; }
|
||||
|
||||
[Option("lead-in", Default = false, HelpText = "Try to read lead-in. Only applicable to CD/DDCD/GD.")]
|
||||
public bool LeadIn { get; set; }
|
||||
[Option("first-pregap", Default = false,
|
||||
HelpText = "Try to read first track pregap. Only applicable to CD/DDCD/GD.")]
|
||||
public bool FirstTrackPregap { get; set; }
|
||||
|
||||
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
|
||||
public string EncodingName { get; set; }
|
||||
|
||||
2
TODO.md
2
TODO.md
@@ -33,7 +33,7 @@
|
||||
* Add support for differencing QCOW images. (https://github.com/claunia/DiscImageChef/issues/143)
|
||||
* Add support for differencing QED images. (https://github.com/claunia/DiscImageChef/issues/144)
|
||||
* Add support for DiscFerret devices. (https://github.com/claunia/DiscImageChef/issues/140)
|
||||
* Add support for dumping CD Lead-In in FreeBSD. (https://github.com/claunia/DiscImageChef/issues/113)
|
||||
* Add support for dumping CD First Track Pregap in FreeBSD. (https://github.com/claunia/DiscImageChef/issues/113)
|
||||
* Add support for encrypted NDIF images. (https://github.com/claunia/DiscImageChef/issues/149)
|
||||
* Add support for encrypted QCOW2 images. (https://github.com/claunia/DiscImageChef/issues/145)
|
||||
* Add support for encrypted QCOW images. (https://github.com/claunia/DiscImageChef/issues/146)
|
||||
|
||||
@@ -617,7 +617,7 @@ enum <ushort> DataType
|
||||
XboxSecuritySector = 59,
|
||||
FloppyLeadOut = 60,
|
||||
DvdDiscControlBlock = 61,
|
||||
CompactDiscLeadIn = 62,
|
||||
CompactDiscFirstTrackPregap = 62,
|
||||
CompactDiscLeadOut = 63,
|
||||
ScsiModeSense6 = 64,
|
||||
ScsiModeSense10 = 65,
|
||||
@@ -633,7 +633,8 @@ enum <ushort> DataType
|
||||
CompactDiscMediaCatalogueNumber = 75,
|
||||
CdSectorPrefixCorrected = 76,
|
||||
CdSectorSuffixCorrected = 77,
|
||||
CompactDiscMode2Subheader = 78
|
||||
CompactDiscMode2Subheader = 78,
|
||||
CompactDiscLeadIn = 79
|
||||
};
|
||||
|
||||
enum <uint> BlockType
|
||||
|
||||
Reference in New Issue
Block a user