Add option to not store paths and serial numbers when dumping. Fixes #213

This commit is contained in:
2020-03-11 15:28:04 +00:00
parent 695fb9e90a
commit 8bf8f4fd78
17 changed files with 166 additions and 52 deletions

View File

@@ -40,6 +40,7 @@ using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs.Devices.ATA;
using Aaru.Core.Devices.Report;
using Aaru.Core.Logging;
using Aaru.Decoders.PCMCIA;
using Schemas;
@@ -160,7 +161,7 @@ namespace Aaru.Core.Devices.Dumping
ResumeSupport.Process(ataReader.IsLba, removable, blocks, _dev.Manufacturer, _dev.Model,
_dev.Serial, _dev.PlatformId, ref _resume, ref currentTry, ref extents,
_dev.FirmwareRevision);
_dev.FirmwareRevision, _private);
if(currentTry == null ||
extents == null)
@@ -243,8 +244,10 @@ namespace Aaru.Core.Devices.Dumping
if(_skip < blocksToRead)
_skip = blocksToRead;
mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(_outputPrefix + ".ibg", ATA_PROFILE);
mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead,
_private);
ibgLog = new IbgLog(_outputPrefix + ".ibg", ATA_PROFILE);
if(_resume.NextBlock > 0)
{
@@ -461,8 +464,10 @@ namespace Aaru.Core.Devices.Dumping
}
else
{
mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead);
ibgLog = new IbgLog(_outputPrefix + ".ibg", ATA_PROFILE);
mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead,
_private);
ibgLog = new IbgLog(_outputPrefix + ".ibg", ATA_PROFILE);
ulong currentBlock = 0;
blocks = (ulong)(cylinders * heads * sectors);
@@ -720,6 +725,9 @@ namespace Aaru.Core.Devices.Dumping
}
}
if(!_private)
DeviceReport.ClearIdentify(ataIdentify);
ret = _outputPlugin.WriteMediaTag(ataIdentify, MediaTagType.ATA_IDENTIFY);
if(ret)
@@ -777,8 +785,11 @@ namespace Aaru.Core.Devices.Dumping
sidecar.BlockMedia[0].LogicalBlockSize = blockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
if(cylinders > 0 &&
heads > 0 &&

View File

@@ -352,7 +352,7 @@ namespace Aaru.Core.Devices.Dumping
}
ResumeSupport.Process(true, true, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision);
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private);
if(currentTry == null ||
extents == null)
@@ -940,7 +940,7 @@ namespace Aaru.Core.Devices.Dumping
sectorsForOffset = 0;
}
mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, _maximumReadable);
mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, _maximumReadable, _private);
ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0008);
audioExtents = new ExtentsULong();

View File

@@ -47,6 +47,7 @@ namespace Aaru.Core.Devices.Dumping
bool _dumpFirstTrackPregap;
bool _fixOffset;
uint _maximumReadable; // Maximum number of sectors drive can read at once
readonly bool _private;
Resume _resume;
Sidecar _sidecarClass;
uint _skip;
@@ -79,7 +80,7 @@ namespace Aaru.Core.Devices.Dumping
bool force, bool dumpRaw, bool persistent, bool stopOnError, Resume resume, DumpLog dumpLog,
Encoding encoding, string outputPrefix, string outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar, uint skip, bool metadata, bool trim, bool dumpFirstTrackPregap,
bool fixOffset, bool debug, DumpSubchannel subchannel, int speed)
bool fixOffset, bool debug, DumpSubchannel subchannel, int speed, bool @private)
{
_doResume = doResume;
_dev = dev;
@@ -108,6 +109,7 @@ namespace Aaru.Core.Devices.Dumping
_subchannel = subchannel;
_speedMultiplier = -1;
_speed = speed;
_private = @private;
}
/// <summary>Starts dumping with the stablished fields and autodetecting the device type</summary>

View File

@@ -261,7 +261,7 @@ namespace Aaru.Core.Devices.Dumping
bool ret;
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead, _private);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010);
ret = _outputPlugin.Create(_outputPath, DSK_TYPE, _formatOptions, blocks, BLOCK_SIZE);
@@ -294,7 +294,8 @@ namespace Aaru.Core.Devices.Dumping
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision);
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private);
if(currentTry == null ||
extents == null)
@@ -729,7 +730,7 @@ namespace Aaru.Core.Devices.Dumping
bool ret;
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead, _private);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", SBC_PROFILE);
ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, BLOCK_SIZE);
@@ -752,7 +753,8 @@ namespace Aaru.Core.Devices.Dumping
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision);
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private);
if(currentTry == null ||
extents == null)
@@ -1195,8 +1197,11 @@ namespace Aaru.Core.Devices.Dumping
sidecar.BlockMedia[0].LogicalBlockSize = (int)BLOCK_SIZE;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * BLOCK_SIZE;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * BLOCK_SIZE;
if(_dev.IsRemovable)
sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray();

View File

@@ -64,8 +64,11 @@ namespace Aaru.Core.Devices.Dumping
internal static void Process(bool isLba, bool removable, ulong blocks, string manufacturer, string model,
string serial, PlatformID platform, ref Resume resume,
ref DumpHardwareType currentTry, ref ExtentsULong extents, string firmware,
bool isTape = false)
bool @private, bool isTape = false)
{
if(@private)
serial = null;
if(resume != null)
{
if(!isLba)

View File

@@ -47,6 +47,7 @@ using Aaru.Core.Logging;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Schemas;
using DeviceReport = Aaru.Core.Devices.Report.DeviceReport;
using MediaType = Aaru.CommonTypes.MediaType;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
using Version = Aaru.CommonTypes.Interop.Version;
@@ -108,6 +109,10 @@ namespace Aaru.Core.Devices.Dumping
mediaTags.Add(MediaTagType.PCMCIA_CIS, null);
sense = _dev.ScsiInquiry(out byte[] cmdBuf, out _);
if(_private)
cmdBuf = DeviceReport.ClearInquiry(cmdBuf);
mediaTags.Add(MediaTagType.SCSI_INQUIRY, cmdBuf);
if(!sense)
@@ -311,7 +316,7 @@ namespace Aaru.Core.Devices.Dumping
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
_dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", SBC_PROFILE);
ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, blockSize);
@@ -404,7 +409,8 @@ namespace Aaru.Core.Devices.Dumping
ExtentsULong extents = null;
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision);
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private);
if(currentTry == null ||
extents == null)
@@ -867,6 +873,9 @@ namespace Aaru.Core.Devices.Dumping
if(!sense)
{
if(_private)
cmdBuf = DeviceReport.ClearIdentify(cmdBuf);
ret = _outputPlugin.WriteMediaTag(cmdBuf, MediaTagType.ATAPI_IDENTIFY);
if(!ret &&
@@ -1232,8 +1241,11 @@ namespace Aaru.Core.Devices.Dumping
sidecar.BlockMedia[0].LogicalBlockSize = logicalBlockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
if(_dev.IsRemovable)
sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray();

View File

@@ -471,7 +471,7 @@ namespace Aaru.Core.Devices.Dumping
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
true);
_private, true);
if(currentTry == null ||
extents == null)
@@ -765,7 +765,7 @@ namespace Aaru.Core.Devices.Dumping
}
start = DateTime.UtcNow;
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, 1);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, 1, _private);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0008);
var currentTapeFile = new TapeFile
@@ -1345,8 +1345,11 @@ namespace Aaru.Core.Devices.Dumping
sidecar.BlockMedia[0].LogicalBlocks = blocks;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
if(_dev.IsRemovable)
sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray();

View File

@@ -247,7 +247,7 @@ namespace Aaru.Core.Devices.Dumping
ExtentsULong extents = null;
ResumeSupport.Process(true, false, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision);
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private);
if(currentTry == null ||
extents == null)
@@ -285,7 +285,7 @@ namespace Aaru.Core.Devices.Dumping
}
}
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", SD_PROFILE);
ret = _outputPlugin.Create(_outputPath,
@@ -601,6 +601,26 @@ namespace Aaru.Core.Devices.Dumping
if(cid != null)
{
if(_dev.Type == DeviceType.SecureDigital && _private)
{
// Clear serial number and manufacturing date
cid[9] = 0;
cid[10] = 0;
cid[11] = 0;
cid[12] = 0;
cid[13] = 0;
cid[14] = 0;
}
else if(_dev.Type == DeviceType.MMC && _private)
{
// Clear serial number and manufacturing date
cid[10] = 0;
cid[11] = 0;
cid[12] = 0;
cid[13] = 0;
cid[14] = 0;
}
cidDump = new DumpType
{
Image = _outputPath, Size = (ulong)cid.Length, Checksums = Checksum.GetChecksums(cid).ToArray()
@@ -775,8 +795,11 @@ namespace Aaru.Core.Devices.Dumping
sidecar.BlockMedia[0].LogicalBlockSize = blockSize;
sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer;
sidecar.BlockMedia[0].Model = _dev.Model;
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
if(!_private)
sidecar.BlockMedia[0].Serial = _dev.Serial;
sidecar.BlockMedia[0].Size = blocks * blockSize;
UpdateStatus?.Invoke("Writing metadata sidecar");

View File

@@ -454,7 +454,7 @@ namespace Aaru.Core.Devices.Dumping
_dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead);
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead);
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead, _private);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010);
ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, BLOCK_SIZE);
@@ -479,7 +479,7 @@ namespace Aaru.Core.Devices.Dumping
ExtentsULong extents = null;
ResumeSupport.Process(true, true, totalSize, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision);
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private);
if(currentTry == null ||
extents == null)