2017-05-31 01:00:58 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-05-31 01:00:58 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : SSC.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-05-31 01:00:58 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Core algorithms.
|
2017-05-31 01:00:58 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Dumps media from SCSI Streaming devices.
|
2017-05-31 01:00:58 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2017-05-31 01:00:58 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
// ReSharper disable JoinDeclarationAndInitializer
|
|
|
|
|
|
|
2017-05-31 01:00:58 +01:00
|
|
|
|
using System;
|
2019-05-03 00:24:30 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
2019-05-02 00:24:56 +01:00
|
|
|
|
using System.Linq;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using System.Text.Json;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using System.Threading;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Extents;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
using Aaru.Core.Logging;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.Decoders.SCSI;
|
|
|
|
|
|
using Aaru.Decoders.SCSI.SSC;
|
|
|
|
|
|
using Aaru.Devices;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
2023-09-26 02:40:11 +01:00
|
|
|
|
using Humanizer;
|
|
|
|
|
|
using Humanizer.Bytes;
|
2023-09-26 03:39:10 +01:00
|
|
|
|
using Humanizer.Localisation;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using TapeFile = Aaru.CommonTypes.Structs.TapeFile;
|
|
|
|
|
|
using TapePartition = Aaru.CommonTypes.Structs.TapePartition;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Version = Aaru.CommonTypes.Interop.Version;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Core.Devices.Dumping;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
partial class Dump
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>Dumps the tape from a SCSI Streaming device</summary>
|
|
|
|
|
|
void Ssc()
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
DecodedSense? decSense;
|
|
|
|
|
|
bool sense;
|
|
|
|
|
|
uint blockSize;
|
2022-03-17 23:54:41 +00:00
|
|
|
|
ulong blocks = 0;
|
|
|
|
|
|
MediaType dskType;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
double totalDuration = 0;
|
|
|
|
|
|
double currentSpeed = 0;
|
|
|
|
|
|
double maxSpeed = double.MinValue;
|
|
|
|
|
|
double minSpeed = double.MaxValue;
|
|
|
|
|
|
var outputTape = _outputPlugin as IWritableTapeImage;
|
|
|
|
|
|
|
|
|
|
|
|
_dev.RequestSense(out byte[] senseBuf, _dev.Timeout, out double duration);
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
|
|
|
|
|
|
|
|
|
|
|
InitProgress?.Invoke();
|
|
|
|
|
|
|
2023-10-05 02:19:02 +01:00
|
|
|
|
if(decSense.HasValue && decSense?.SenseKey != SenseKeys.NoSense)
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2023-10-05 02:19:02 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC,
|
|
|
|
|
|
decSense?.ASCQ);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_has_status_error_please_correct_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
2023-10-05 02:19:02 +01:00
|
|
|
|
decSense?.Description);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Not in BOM/P
|
2023-10-05 02:19:02 +01:00
|
|
|
|
if(decSense is { ASC: 0x00 } &&
|
|
|
|
|
|
decSense?.ASCQ != 0x00 &&
|
|
|
|
|
|
decSense?.ASCQ != 0x04 &&
|
|
|
|
|
|
decSense?.SenseKey != SenseKeys.IllegalRequest)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Rewinding_please_wait);
|
|
|
|
|
|
PulseProgress?.Invoke(Localization.Core.Rewinding_please_wait);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
// Rewind, let timeout apply
|
|
|
|
|
|
_dev.Rewind(out senseBuf, _dev.Timeout, out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Still rewinding?
|
|
|
|
|
|
// TODO: Pause?
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
PulseProgress?.Invoke(Localization.Core.Rewinding_please_wait);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dev.RequestSense(out senseBuf, _dev.Timeout, out duration);
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2022-03-17 23:54:41 +00:00
|
|
|
|
} while(decSense is { ASC: 0x00, ASCQ: 0x1A or not (0x04 and 0x00) });
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
_dev.RequestSense(out senseBuf, _dev.Timeout, out duration);
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
|
|
|
|
|
|
|
|
|
|
|
// And yet, did not rewind!
|
2021-03-26 00:37:54 +00:00
|
|
|
|
if(decSense.HasValue &&
|
2023-10-05 02:19:02 +01:00
|
|
|
|
(decSense?.ASC == 0x00 && decSense?.ASCQ != 0x04 && decSense?.ASCQ != 0x00 || decSense?.ASC != 0x00))
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
2023-10-05 02:19:02 +01:00
|
|
|
|
decSense?.Description);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2023-10-05 02:19:02 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC,
|
|
|
|
|
|
decSense?.ASCQ);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2017-05-31 01:00:58 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check position
|
2022-03-07 07:36:44 +00:00
|
|
|
|
sense = _dev.ReadPosition(out byte[] cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, out duration);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
// READ POSITION is mandatory starting SCSI-2, so do not cry if the drive does not recognize the command (SCSI-1 or earlier)
|
|
|
|
|
|
// Anyway, <=SCSI-1 tapes do not support partitions
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(decSense.HasValue &&
|
2023-10-05 02:19:02 +01:00
|
|
|
|
(decSense?.ASC == 0x20 && decSense?.ASCQ != 0x00 ||
|
|
|
|
|
|
decSense?.ASC != 0x20 && decSense?.SenseKey != SenseKeys.IllegalRequest))
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_get_position_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
2023-10-05 02:19:02 +01:00
|
|
|
|
decSense?.Description);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Could_not_get_position_Sense_follows);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2023-10-05 02:19:02 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC,
|
|
|
|
|
|
decSense?.ASCQ);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// Not in partition 0
|
|
|
|
|
|
if(cmdBuf[1] != 0)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Drive_not_in_partition_0_Rewinding_please_wait);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_not_in_partition_0_Rewinding_please_wait);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2017-05-31 01:00:58 +01:00
|
|
|
|
// Rewind, let timeout apply
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Locate(out senseBuf, false, 0, 0, _dev.Timeout, out duration);
|
|
|
|
|
|
|
|
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense?.Description);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC,
|
|
|
|
|
|
decSense?.ASCQ);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
|
|
|
|
|
// Still rewinding?
|
|
|
|
|
|
// TODO: Pause?
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Thread.Sleep(1000);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
PulseProgress?.Invoke(Localization.Core.Rewinding_please_wait);
|
2019-12-25 18:07:05 +00:00
|
|
|
|
_dev.RequestSense(out senseBuf, _dev.Timeout, out duration);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2022-11-13 20:46:24 +00:00
|
|
|
|
} while(decSense is { ASC: 0x00, ASCQ: 0x1A or 0x19 });
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
|
|
|
|
|
// And yet, did not rewind!
|
2021-03-26 00:37:54 +00:00
|
|
|
|
if(decSense.HasValue &&
|
2023-10-05 02:19:02 +01:00
|
|
|
|
(decSense?.ASC == 0x00 && decSense?.ASCQ != 0x04 && decSense?.ASCQ != 0x00 || decSense?.ASC != 0x00))
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
2023-10-05 02:19:02 +01:00
|
|
|
|
decSense?.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-05 02:19:02 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC,
|
|
|
|
|
|
decSense?.ASCQ);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2017-05-31 01:00:58 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
sense = _dev.ReadPosition(out cmdBuf, out senseBuf, SscPositionForms.Short, _dev.Timeout, out duration);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
|
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense?.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense?.SenseKey, decSense?.ASC,
|
|
|
|
|
|
decSense?.ASCQ);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2017-05-31 01:00:58 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
// Still not in partition 0!!!?
|
2017-05-31 01:00:58 +01:00
|
|
|
|
if(cmdBuf[1] != 0)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Drive_could_not_rewind_to_partition_0_but_no_error_occurred);
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_to_partition_0_but_no_error_occurred);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress?.Invoke();
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
byte scsiMediumTypeTape = 0;
|
|
|
|
|
|
byte scsiDensityCodeTape = 0;
|
|
|
|
|
|
byte[] mode6Data = null;
|
|
|
|
|
|
byte[] mode10Data = null;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_10);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5,
|
|
|
|
|
|
out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(!sense || _dev.Error)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F,
|
|
|
|
|
|
0x00, 5, out duration);
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Modes.DecodedMode? decMode = null;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(!sense && !_dev.Error)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
|
|
|
|
|
|
decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType);
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5,
|
|
|
|
|
|
out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense || _dev.Error)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
|
sense = _dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5,
|
|
|
|
|
|
out duration);
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense || _dev.Error)
|
|
|
|
|
|
sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(!sense && !_dev.Error)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
|
|
|
|
|
|
decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Check partitions page
|
|
|
|
|
|
if(decMode.HasValue)
|
|
|
|
|
|
{
|
2023-10-05 02:19:02 +01:00
|
|
|
|
scsiMediumTypeTape = (byte)(decMode?.Header.MediumType ?? default(MediumTypes));
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-05 02:19:02 +01:00
|
|
|
|
if(decMode?.Header.BlockDescriptors?.Length > 0)
|
|
|
|
|
|
scsiDensityCodeTape = (byte)(decMode?.Header.BlockDescriptors[0].Density ?? default(DensityType));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-05 02:19:02 +01:00
|
|
|
|
blockSize = decMode?.Header.BlockDescriptors?[0].BlockLength ?? 0;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Device_reports_0_blocks, blocks));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
blockSize = 1;
|
2019-04-20 02:43:53 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!_dev.ReadBlockLimits(out cmdBuf, out senseBuf, _dev.Timeout, out _))
|
|
|
|
|
|
{
|
|
|
|
|
|
BlockLimits.BlockLimitsData? blockLimits = BlockLimits.Decode(cmdBuf);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(blockLimits?.minBlockLen > blockSize)
|
|
|
|
|
|
blockSize = blockLimits?.minBlockLen ?? 0;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(blockSize == 0)
|
|
|
|
|
|
blockSize = 1;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-17 23:54:41 +00:00
|
|
|
|
dskType = MediaTypeFromDevice.GetFromScsi((byte)_dev.ScsiType, _dev.Manufacturer, _dev.Model,
|
|
|
|
|
|
scsiMediumTypeTape, scsiDensityCodeTape, blocks, blockSize,
|
|
|
|
|
|
_dev.IsUsb, false);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(dskType == MediaType.Unknown)
|
|
|
|
|
|
dskType = MediaType.UnknownTape;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-03 22:57:50 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_device_type_0, _dev.ScsiType));
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_medium_type_0, scsiMediumTypeTape));
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.SCSI_density_type_0, scsiDensityCodeTape));
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Media_identified_as_0, dskType));
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-03 22:57:50 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.SCSI_device_type_0, _dev.ScsiType);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.SCSI_medium_type_0, scsiMediumTypeTape);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.SCSI_density_type_0, scsiDensityCodeTape);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Media_identified_as_0, dskType);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-03 22:57:50 +01:00
|
|
|
|
var endOfMedia = false;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong currentBlock = 0;
|
|
|
|
|
|
uint currentFile = 0;
|
|
|
|
|
|
byte currentPartition = 0;
|
|
|
|
|
|
byte totalPartitions = 1; // TODO: Handle partitions.
|
2023-10-03 22:57:50 +01:00
|
|
|
|
var fixedLen = false;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
uint transferLen = blockSize;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-03 22:57:50 +01:00
|
|
|
|
firstRead:
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout,
|
|
|
|
|
|
out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(decSense.HasValue)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2023-10-04 09:38:17 +01:00
|
|
|
|
switch(decSense)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2023-10-04 09:38:17 +01:00
|
|
|
|
case { SenseKey: SenseKeys.IllegalRequest }:
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2023-10-04 09:38:17 +01:00
|
|
|
|
sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2019-04-30 21:32:43 +01:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
bool eom = decSense?.Fixed?.EOM == true;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(decSense?.Descriptor != null &&
|
|
|
|
|
|
decSense.Value.Descriptor.Value.Descriptors.TryGetValue(4, out byte[] sscDescriptor))
|
|
|
|
|
|
Sense.DecodeDescriptor04(sscDescriptor, out _, out eom, out _);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(!eom)
|
|
|
|
|
|
{
|
2023-10-04 17:34:40 +01:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Drive_could_not_return_back_Sense_follows +
|
|
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_return_back_Sense_follows);
|
2019-04-30 21:32:43 +01:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
|
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
fixedLen = true;
|
|
|
|
|
|
transferLen = 1;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize,
|
2023-10-04 17:34:40 +01:00
|
|
|
|
_dev.Timeout, out duration);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2017-11-20 05:07:16 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_read_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
|
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case { ASC: 0x00, ASCQ: 0x00 }:
|
2017-06-05 15:57:10 +01:00
|
|
|
|
{
|
2023-10-04 09:38:17 +01:00
|
|
|
|
bool ili = decSense.Value.Fixed?.ILI == true;
|
|
|
|
|
|
bool valid = decSense.Value.Fixed?.InformationValid == true;
|
|
|
|
|
|
uint information = decSense.Value.Fixed?.Information ?? 0;
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(decSense.Value.Descriptor.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
valid = decSense.Value.Descriptor.Value.Descriptors.TryGetValue(0, out byte[] desc00);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(valid)
|
|
|
|
|
|
information = (uint)Sense.DecodeDescriptor00(desc00);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(decSense.Value.Descriptor.Value.Descriptors.TryGetValue(4, out byte[] desc04))
|
|
|
|
|
|
Sense.DecodeDescriptor04(desc04, out _, out _, out ili);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(ili && valid)
|
|
|
|
|
|
{
|
|
|
|
|
|
blockSize = (uint)((int)blockSize -
|
|
|
|
|
|
BitConverter.ToInt32(BitConverter.GetBytes(information), 0));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
transferLen = blockSize;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
UpdateStatus?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1,
|
2023-10-04 09:38:17 +01:00
|
|
|
|
blockSize, currentBlock));
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, blockSize,
|
|
|
|
|
|
currentBlock);
|
2017-06-05 15:57:10 +01:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout,
|
|
|
|
|
|
out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
totalDuration += duration;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Drive_could_not_go_back_one_block_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
|
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
goto firstRead;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_read_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
|
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_read_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
|
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 09:38:17 +01:00
|
|
|
|
return;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_read_device_dont_know_why_exiting);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Cannot_read_device_dont_know_why_exiting);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-04-30 21:32:43 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, out duration);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
bool eom = decSense?.Fixed?.EOM == true;
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(decSense.Value.Descriptor.HasValue &&
|
|
|
|
|
|
decSense.Value.Descriptor.Value.Descriptors.TryGetValue(4, out byte[] desc04))
|
|
|
|
|
|
Sense.DecodeDescriptor04(desc04, out _, out eom, out _);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!eom)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_return_back_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_return_back_Sense_follows);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
2017-06-05 15:57:10 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2017-06-05 15:57:10 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
DumpHardware currentTry = null;
|
|
|
|
|
|
ExtentsULong extents = null;
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ResumeSupport.Process(true, _dev.IsRemovable, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial,
|
|
|
|
|
|
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
|
|
|
|
|
|
_private, _force, true);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(currentTry == null || extents == null)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-03 22:57:50 +01:00
|
|
|
|
var canLocateLong = false;
|
|
|
|
|
|
var canLocate = false;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Positioning_tape_to_block_1);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Positioning_tape_to_block_1);
|
2017-06-05 15:57:10 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Locate16(out senseBuf, 1, _dev.Timeout, out _);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.ReadPositionLong(out cmdBuf, out senseBuf, _dev.Timeout, out _);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense)
|
2019-05-01 18:56:19 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong position = Swapping.Swap(BitConverter.ToUInt64(cmdBuf, 8));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(position == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
canLocateLong = true;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.LOCATE_LONG_works);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.LOCATE_LONG_works);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-05-01 18:56:19 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-05-01 01:19:37 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Locate(out senseBuf, 1, _dev.Timeout, out _);
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.ReadPosition(out cmdBuf, out senseBuf, _dev.Timeout, out _);
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
|
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong position = Swapping.Swap(BitConverter.ToUInt32(cmdBuf, 4));
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(position == 1)
|
2019-05-01 19:37:44 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
canLocate = true;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.LOCATE_works);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.LOCATE_works);
|
2019-05-01 19:37:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_resume.NextBlock > 0)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Positioning_tape_to_block_0, _resume.NextBlock));
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Positioning_tape_to_block_0, _resume.NextBlock);
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(canLocateLong)
|
2019-05-01 19:37:44 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Locate16(out senseBuf, _resume.NextBlock, _dev.Timeout, out _);
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
|
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.ReadPositionLong(out cmdBuf, out senseBuf, _dev.Timeout, out _);
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
2019-05-01 19:37:44 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!_force)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-05-01 01:19:37 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_Dumping_from_the_start);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_Dumping_from_the_start);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
canLocateLong = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2019-05-01 01:19:37 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong position = Swapping.Swap(BitConverter.ToUInt64(cmdBuf, 8));
|
2019-05-01 01:19:37 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(position != _resume.NextBlock)
|
2019-05-01 01:19:37 +01:00
|
|
|
|
{
|
2019-12-25 18:07:05 +00:00
|
|
|
|
if(!_force)
|
2019-05-01 01:19:37 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 19:37:44 +01:00
|
|
|
|
return;
|
2019-05-01 01:19:37 +01:00
|
|
|
|
}
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 19:37:44 +01:00
|
|
|
|
canLocateLong = false;
|
2019-05-01 01:19:37 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!_force)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start);
|
|
|
|
|
|
|
|
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start);
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
canLocateLong = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(canLocate)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.Locate(out senseBuf, (uint)_resume.NextBlock, _dev.Timeout, out _);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.ReadPosition(out cmdBuf, out senseBuf, _dev.Timeout, out _);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
2019-05-01 17:46:56 +01:00
|
|
|
|
{
|
2019-12-25 18:07:05 +00:00
|
|
|
|
if(!_force)
|
2019-05-01 17:46:56 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 19:37:44 +01:00
|
|
|
|
return;
|
2019-05-01 17:46:56 +01:00
|
|
|
|
}
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_Dumping_from_the_start);
|
2019-05-01 17:46:56 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Could_not_check_current_position_unable_to_resume_Dumping_from_the_start);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
canLocate = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2019-05-01 17:46:56 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong position = Swapping.Swap(BitConverter.ToUInt32(cmdBuf, 4));
|
2019-05-01 17:46:56 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(position != _resume.NextBlock)
|
2019-05-01 17:46:56 +01:00
|
|
|
|
{
|
2019-12-25 18:07:05 +00:00
|
|
|
|
if(!_force)
|
2019-05-01 17:46:56 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 19:37:44 +01:00
|
|
|
|
return;
|
2019-05-01 17:46:56 +01:00
|
|
|
|
}
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_unable_to_resume_Dumping_from_the_start);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 19:37:44 +01:00
|
|
|
|
canLocate = false;
|
2019-05-01 17:46:56 +01:00
|
|
|
|
}
|
2019-05-01 19:37:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-12-25 18:07:05 +00:00
|
|
|
|
if(!_force)
|
2019-05-01 19:37:44 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 19:37:44 +01:00
|
|
|
|
return;
|
2019-05-01 01:19:37 +01:00
|
|
|
|
}
|
2019-05-01 19:37:44 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start);
|
|
|
|
|
|
|
|
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start);
|
|
|
|
|
|
|
2019-05-01 19:37:44 +01:00
|
|
|
|
canLocate = false;
|
2019-05-01 01:19:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-05-01 23:21:16 +01:00
|
|
|
|
else
|
2019-05-01 01:19:37 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!_force)
|
2019-05-01 23:21:16 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Cannot_reposition_tape_unable_to_resume_If_you_want_to_continue_use_force);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 23:21:16 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start);
|
|
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.Cannot_reposition_tape_unable_to_resume_Dumping_from_the_start);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
canLocate = false;
|
2019-05-01 01:19:37 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-10-03 22:57:50 +01:00
|
|
|
|
_ = canLocateLong
|
|
|
|
|
|
? _dev.Locate16(out senseBuf, false, 0, 0, _dev.Timeout, out duration)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
: _dev.Locate(out senseBuf, false, 0, 0, _dev.Timeout, out duration);
|
2019-05-01 01:19:37 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
Thread.Sleep(1000);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
PulseProgress?.Invoke(Localization.Core.Rewinding_please_wait);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dev.RequestSense(out senseBuf, _dev.Timeout, out duration);
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2022-11-13 20:46:24 +00:00
|
|
|
|
} while(decSense is { ASC: 0x00, ASCQ: 0x1A or 0x19 });
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// And yet, did not rewind!
|
|
|
|
|
|
if(decSense.HasValue &&
|
2023-10-03 22:57:50 +01:00
|
|
|
|
(decSense.Value.ASC == 0x00 && decSense.Value.ASCQ != 0x00 && decSense.Value.ASCQ != 0x04 ||
|
2022-03-06 13:29:38 +00:00
|
|
|
|
decSense.Value.ASC != 0x00))
|
2019-05-01 18:09:33 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 18:09:33 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-05-01 18:09:33 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
bool ret = outputTape.SetTape();
|
2019-04-30 23:33:33 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Cannot set image to tape mode
|
|
|
|
|
|
if(!ret)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Error_setting_output_image_in_tape_mode_not_continuing);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dumpLog.WriteLine(outputTape.ErrorMessage);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Error_setting_output_image_in_tape_mode_not_continuing +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
outputTape.ErrorMessage);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-04-30 23:33:33 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ret = outputTape.Create(_outputPath, dskType, _formatOptions, 0, 0);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Cannot create image
|
|
|
|
|
|
if(!ret)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Error_creating_output_image_not_continuing);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dumpLog.WriteLine(outputTape.ErrorMessage);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
outputTape.ErrorMessage);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_dumpStopwatch.Restart();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, 1, _private);
|
|
|
|
|
|
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0008);
|
|
|
|
|
|
|
|
|
|
|
|
var currentTapeFile = new TapeFile
|
|
|
|
|
|
{
|
|
|
|
|
|
File = currentFile,
|
|
|
|
|
|
FirstBlock = currentBlock,
|
|
|
|
|
|
Partition = currentPartition
|
|
|
|
|
|
};
|
2019-05-02 00:24:56 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var currentTapePartition = new TapePartition
|
|
|
|
|
|
{
|
|
|
|
|
|
Number = currentPartition,
|
|
|
|
|
|
FirstBlock = currentBlock
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if((canLocate || canLocateLong) && _resume.NextBlock > 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
currentBlock = _resume.NextBlock;
|
|
|
|
|
|
|
|
|
|
|
|
currentTapeFile =
|
2022-03-07 07:36:44 +00:00
|
|
|
|
outputTape.Files.FirstOrDefault(f => f.LastBlock == outputTape?.Files.Max(g => g.LastBlock));
|
2019-05-02 00:24:56 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTapePartition =
|
|
|
|
|
|
outputTape.TapePartitions.FirstOrDefault(p => p.LastBlock ==
|
|
|
|
|
|
outputTape?.TapePartitions.Max(g => g.LastBlock));
|
|
|
|
|
|
}
|
2019-05-02 00:24:56 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(mode6Data != null)
|
|
|
|
|
|
outputTape.WriteMediaTag(mode6Data, MediaTagType.SCSI_MODESENSE_6);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(mode10Data != null)
|
|
|
|
|
|
outputTape.WriteMediaTag(mode10Data, MediaTagType.SCSI_MODESENSE_10);
|
2019-05-02 00:48:03 +01:00
|
|
|
|
|
2023-10-03 22:57:50 +01:00
|
|
|
|
ulong currentSpeedSize = 0;
|
|
|
|
|
|
double imageWriteDuration = 0;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
InitProgress?.Invoke();
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_speedStopwatch.Restart();
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
while(currentPartition < totalPartitions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
2017-05-31 01:00:58 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-04-30 23:45:13 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(endOfMedia)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Finished_partition_0, currentPartition));
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Finished_partition_0, currentPartition);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTapeFile.LastBlock = currentBlock - 1;
|
2019-04-30 23:45:13 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(currentTapeFile.LastBlock > currentTapeFile.FirstBlock)
|
|
|
|
|
|
outputTape.AddFile(currentTapeFile);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTapePartition.LastBlock = currentBlock - 1;
|
|
|
|
|
|
outputTape.AddPartition(currentTapePartition);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentPartition++;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(currentPartition < totalPartitions)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFile++;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTapeFile = new TapeFile
|
|
|
|
|
|
{
|
|
|
|
|
|
File = currentFile,
|
|
|
|
|
|
FirstBlock = currentBlock,
|
|
|
|
|
|
Partition = currentPartition
|
|
|
|
|
|
};
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTapePartition = new TapePartition
|
|
|
|
|
|
{
|
|
|
|
|
|
Number = currentPartition,
|
|
|
|
|
|
FirstBlock = currentBlock
|
|
|
|
|
|
};
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Seeking_to_partition_0, currentPartition));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dev.Locate(out senseBuf, false, currentPartition, 0, _dev.Timeout, out duration);
|
|
|
|
|
|
totalDuration += duration;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(currentSpeed > maxSpeed && currentSpeed > 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
maxSpeed = currentSpeed;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(currentSpeed < minSpeed && currentSpeed > 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
minSpeed = currentSpeed;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
PulseProgress?.Invoke(string.Format(Localization.Core.Reading_block_0_1, currentBlock,
|
2023-09-26 10:51:43 +01:00
|
|
|
|
ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout,
|
|
|
|
|
|
out duration);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
totalDuration += duration;
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(sense && senseBuf?.Length != 0 && !ArrayHelpers.ArrayIsNullOrEmpty(senseBuf))
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
bool ili = decSense?.Fixed?.ILI == true;
|
|
|
|
|
|
bool valid = decSense?.Fixed?.InformationValid == true;
|
|
|
|
|
|
uint information = decSense?.Fixed?.Information ?? 0;
|
|
|
|
|
|
bool eom = decSense?.Fixed?.EOM == true;
|
|
|
|
|
|
bool filemark = decSense?.Fixed?.Filemark == true;
|
2021-03-26 00:37:54 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(decSense?.Descriptor.HasValue == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(decSense.Value.Descriptor.Value.Descriptors.TryGetValue(0, out byte[] desc00))
|
|
|
|
|
|
{
|
|
|
|
|
|
valid = true;
|
|
|
|
|
|
information = (uint)Sense.DecodeDescriptor00(desc00);
|
2021-03-26 00:37:54 +00:00
|
|
|
|
}
|
2019-05-16 23:29:54 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(decSense.Value.Descriptor.Value.Descriptors.TryGetValue(4, out byte[] desc04))
|
|
|
|
|
|
Sense.DecodeDescriptor04(desc04, out filemark, out eom, out ili);
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(decSense.Value is { ASC: 0x00, ASCQ: 0x00 } && ili && valid)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
|
blockSize = (uint)((int)blockSize - BitConverter.ToInt32(BitConverter.GetBytes(information), 0));
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!fixedLen)
|
|
|
|
|
|
transferLen = blockSize;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1,
|
|
|
|
|
|
blockSize, currentBlock));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, blockSize,
|
|
|
|
|
|
currentBlock);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, _dev.Timeout, out duration);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
totalDuration += duration;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
decSense = Sense.Decode(senseBuf);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows +
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Environment.NewLine +
|
|
|
|
|
|
decSense.Value.Description);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputTape.Close();
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
|
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
switch(decSense.Value.SenseKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SenseKeys.BlankCheck when currentBlock == 0:
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_dump_a_blank_tape);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputTape.Close();
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Cannot_dump_a_blank_tape);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// For sure this is an end-of-tape/partition
|
|
|
|
|
|
case SenseKeys.BlankCheck when decSense.Value.ASC == 0x00 &&
|
2022-03-16 11:47:00 +00:00
|
|
|
|
(decSense.Value.ASCQ is 0x02 or 0x05 || eom):
|
2017-05-31 01:00:58 +01:00
|
|
|
|
// TODO: Detect end of partition
|
|
|
|
|
|
endOfMedia = true;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Found_end_of_tape_partition);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Found_end_of_tape_partition);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2017-05-31 01:00:58 +01:00
|
|
|
|
continue;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
case SenseKeys.BlankCheck:
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Blank_block_found_end_of_tape);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
endOfMedia = true;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Blank_block_found_end_of_tape);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
switch(decSense.Value.SenseKey)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-11-13 19:38:03 +00:00
|
|
|
|
case SenseKeys.NoSense or SenseKeys.RecoveredError when decSense.Value.ASCQ is 0x02 or 0x05 || eom:
|
|
|
|
|
|
// TODO: Detect end of partition
|
|
|
|
|
|
endOfMedia = true;
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Found_end_of_tape_partition);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Found_end_of_tape_partition);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
case SenseKeys.NoSense or SenseKeys.RecoveredError when decSense.Value.ASCQ == 0x01 || filemark:
|
|
|
|
|
|
currentTapeFile.LastBlock = currentBlock - 1;
|
|
|
|
|
|
outputTape.AddFile(currentTapeFile);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
currentFile++;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
currentTapeFile = new TapeFile
|
|
|
|
|
|
{
|
|
|
|
|
|
File = currentFile,
|
|
|
|
|
|
FirstBlock = currentBlock,
|
|
|
|
|
|
Partition = currentPartition
|
|
|
|
|
|
};
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Changed_to_file_0_at_block_1, currentFile,
|
|
|
|
|
|
currentBlock));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Changed_to_file_0_at_block_1, currentFile, currentBlock);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
|
continue;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(decSense is null)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Invoke(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_cannot_be_decoded_look_at_log_for_dump,
|
|
|
|
|
|
currentBlock));
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_bytes_follow,
|
|
|
|
|
|
currentBlock));
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_dumpLog.WriteLine(PrintHex.ByteArrayToHexArrayString(senseBuf, 32));
|
2019-05-01 18:56:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.
|
|
|
|
|
|
Invoke(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_follow_1_2,
|
|
|
|
|
|
currentBlock, decSense.Value.SenseKey, decSense.Value.Description));
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_follows,
|
|
|
|
|
|
currentBlock));
|
2019-01-27 17:47:40 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey,
|
2022-03-07 07:36:44 +00:00
|
|
|
|
decSense.Value.ASC, decSense.Value.ASCQ);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Reset device after X errors
|
|
|
|
|
|
if(_stopOnError)
|
|
|
|
|
|
return; // TODO: Return more cleanly
|
2019-01-27 17:47:40 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Write empty data
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_writeStopwatch.Restart();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputTape.WriteSector(new byte[blockSize], currentBlock);
|
2023-09-26 20:16:24 +01:00
|
|
|
|
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
|
|
|
|
|
|
ibgLog.Write(currentBlock, 0);
|
|
|
|
|
|
_resume.BadBlocks.Add(currentBlock);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
mhddLog.Write(currentBlock, duration);
|
|
|
|
|
|
ibgLog.Write(currentBlock, currentSpeed * 1024);
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_writeStopwatch.Restart();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputTape.WriteSector(cmdBuf, currentBlock);
|
2023-09-26 20:16:24 +01:00
|
|
|
|
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
extents.Add(currentBlock, 1, true);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_writeStopwatch.Stop();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentBlock++;
|
|
|
|
|
|
_resume.NextBlock++;
|
|
|
|
|
|
currentSpeedSize += blockSize;
|
2019-04-20 02:43:53 +01:00
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
|
double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
|
2019-05-02 20:25:53 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(elapsed <= 0)
|
|
|
|
|
|
continue;
|
2019-04-30 23:45:13 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentSpeed = currentSpeedSize / (1048576 * elapsed);
|
|
|
|
|
|
currentSpeedSize = 0;
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_speedStopwatch.Restart();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
|
|
|
|
|
|
blocks = currentBlock + 1;
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_speedStopwatch.Stop();
|
|
|
|
|
|
_dumpStopwatch.Stop();
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// If not aborted this is added at the end of medium
|
|
|
|
|
|
if(_aborted)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentTapeFile.LastBlock = currentBlock - 1;
|
|
|
|
|
|
outputTape.AddFile(currentTapeFile);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTapePartition.LastBlock = currentBlock - 1;
|
|
|
|
|
|
outputTape.AddPartition(currentTapePartition);
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress?.Invoke();
|
|
|
|
|
|
mhddLog.Close();
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
|
ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-09-26 03:39:10 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
|
|
|
|
|
|
ByteSize.FromBytes(blockSize * (blocks + 1)).
|
|
|
|
|
|
Per(totalDuration.Milliseconds())));
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0,
|
|
|
|
|
|
ByteSize.FromBytes(blockSize * (blocks + 1)).
|
|
|
|
|
|
Per(imageWriteDuration.Seconds())));
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2023-09-26 03:39:10 +01:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
|
|
|
|
|
|
ByteSize.FromBytes(blockSize * (blocks + 1)).
|
|
|
|
|
|
Per(totalDuration.Milliseconds())));
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0,
|
|
|
|
|
|
ByteSize.FromBytes(blockSize * (blocks + 1)).
|
|
|
|
|
|
Per(imageWriteDuration.Seconds())));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-10-03 22:57:50 +01:00
|
|
|
|
#region Error handling
|
|
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0 && (canLocate || canLocateLong))
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2023-10-03 22:57:50 +01:00
|
|
|
|
var pass = 1;
|
|
|
|
|
|
var forward = false;
|
2022-11-13 20:08:10 +00:00
|
|
|
|
const bool runningPersistent = false;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Modes.ModePage? currentModePage = null;
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_persistent)
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: Implement persistent
|
|
|
|
|
|
}
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
InitProgress?.Invoke();
|
2023-10-03 22:57:50 +01:00
|
|
|
|
repeatRetry:
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong[] tmpArray = _resume.BadBlocks.ToArray();
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(ulong badBlock in tmpArray)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_aborted)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
if(forward)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
PulseProgress?.Invoke(runningPersistent
|
|
|
|
|
|
? string.
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
|
|
|
|
|
|
badBlock, pass)
|
2022-11-23 16:06:46 +00:00
|
|
|
|
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward,
|
|
|
|
|
|
badBlock, pass));
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2022-11-23 16:06:46 +00:00
|
|
|
|
else
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
PulseProgress?.Invoke(runningPersistent
|
|
|
|
|
|
? string.
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
|
|
|
|
|
|
badBlock, pass)
|
2022-11-23 16:06:46 +00:00
|
|
|
|
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
|
|
|
|
|
|
badBlock, pass));
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Positioning_tape_to_block_0, badBlock));
|
2023-10-03 22:57:50 +01:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Positioning_tape_to_block_0, badBlock));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(canLocateLong)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.Locate16(out senseBuf, _resume.NextBlock, _dev.Timeout, out _);
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.ReadPositionLong(out cmdBuf, out senseBuf, _dev.Timeout, out _);
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Could_not_check_current_position_continuing);
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_check_current_position_continuing);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
2019-05-01 18:56:19 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
ulong position = Swapping.Swap(BitConverter.ToUInt64(cmdBuf, 8));
|
|
|
|
|
|
|
|
|
|
|
|
if(position != _resume.NextBlock)
|
2019-05-01 18:56:19 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Current_position_is_not_as_expected_continuing);
|
|
|
|
|
|
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_continuing);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 18:56:19 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Cannot_position_tape_to_block_0, badBlock));
|
|
|
|
|
|
|
|
|
|
|
|
ErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_position_tape_to_block_0,
|
|
|
|
|
|
badBlock));
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.Locate(out senseBuf, (uint)_resume.NextBlock, _dev.Timeout, out _);
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!sense)
|
|
|
|
|
|
{
|
|
|
|
|
|
sense = _dev.ReadPosition(out cmdBuf, out senseBuf, _dev.Timeout, out _);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sense)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Could_not_check_current_position_continuing);
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_check_current_position_continuing);
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ulong position = Swapping.Swap(BitConverter.ToUInt32(cmdBuf, 4));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(position != _resume.NextBlock)
|
2019-05-01 18:56:19 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Current_position_is_not_as_expected_continuing);
|
|
|
|
|
|
|
|
|
|
|
|
StoppingErrorMessage?.Invoke(Localization.Core.
|
|
|
|
|
|
Current_position_is_not_as_expected_continuing);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-01 18:56:19 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
2019-05-01 18:56:19 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(string.Format(Localization.Core.Cannot_position_tape_to_block_0, badBlock));
|
|
|
|
|
|
|
|
|
|
|
|
ErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_position_tape_to_block_0,
|
|
|
|
|
|
badBlock));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
continue;
|
2019-05-01 18:56:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout,
|
|
|
|
|
|
out duration);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
totalDuration += duration;
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(!sense && !_dev.Error)
|
2019-05-01 18:56:19 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_resume.BadBlocks.Remove(badBlock);
|
|
|
|
|
|
extents.Add(badBlock);
|
|
|
|
|
|
outputTape.WriteSector(cmdBuf, badBlock);
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
|
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badBlock,
|
|
|
|
|
|
pass));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badBlock, pass);
|
2019-05-01 18:56:19 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else if(runningPersistent)
|
|
|
|
|
|
outputTape.WriteSector(cmdBuf, badBlock);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
pass++;
|
|
|
|
|
|
forward = !forward;
|
|
|
|
|
|
_resume.BadBlocks.Sort();
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!forward)
|
|
|
|
|
|
_resume.BadBlocks.Reverse();
|
|
|
|
|
|
|
|
|
|
|
|
goto repeatRetry;
|
2019-05-01 18:56:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(runningPersistent && currentModePage.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: Persistent mode
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
EndProgress?.Invoke();
|
|
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion Error handling
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_resume.BadBlocks.Sort();
|
2019-05-01 18:56:19 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(ulong bad in _resume.BadBlocks)
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Block_0_could_not_be_read, bad);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
|
2020-01-09 18:01:43 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputTape.SetDumpHardware(_resume.Tries);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Media Serial Number
|
2022-11-15 15:58:43 +00:00
|
|
|
|
var metadata = new CommonTypes.Structs.ImageInfo
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Application = "Aaru",
|
|
|
|
|
|
ApplicationVersion = Version.GetVersion()
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
if(!outputTape.SetImageInfo(metadata))
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2023-10-04 17:34:40 +01:00
|
|
|
|
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
|
|
|
|
|
|
Environment.NewLine +
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputTape.ErrorMessage);
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(_preSidecar != null)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
outputTape.SetMetadata(_preSidecar);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Closing_output_file);
|
|
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_imageCloseStopwatch.Restart();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
outputTape.Close();
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_imageCloseStopwatch.Stop();
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
2023-09-26 03:39:10 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Closed_in_0,
|
|
|
|
|
|
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(_aborted)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2020-01-09 18:01:43 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_aborted)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Aborted);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Aborted);
|
2019-04-30 23:33:33 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
double totalChkDuration = 0;
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_metadata)
|
|
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Creating_sidecar);
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Creating_sidecar);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var filters = new FiltersList();
|
|
|
|
|
|
IFilter filter = filters.GetFilter(_outputPath);
|
2022-03-07 07:36:44 +00:00
|
|
|
|
var inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber opened = inputPlugin.Open(filter);
|
|
|
|
|
|
|
|
|
|
|
|
if(opened != ErrorNumber.NoError)
|
2019-05-03 00:24:30 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
StoppingErrorMessage?.Invoke(string.Format(Localization.Core.Error_0_opening_created_image, opened));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2019-05-03 00:24:30 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_sidecarStopwatch.Restart();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
|
|
|
|
|
|
_sidecarClass.InitProgressEvent += InitProgress;
|
|
|
|
|
|
_sidecarClass.UpdateProgressEvent += UpdateProgress;
|
|
|
|
|
|
_sidecarClass.EndProgressEvent += EndProgress;
|
|
|
|
|
|
_sidecarClass.InitProgressEvent2 += InitProgress2;
|
|
|
|
|
|
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
|
|
|
|
|
|
_sidecarClass.EndProgressEvent2 += EndProgress2;
|
|
|
|
|
|
_sidecarClass.UpdateStatusEvent += UpdateStatus;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Metadata sidecar = _sidecarClass.Create();
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_sidecarStopwatch.Stop();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(!_aborted)
|
2019-05-03 00:24:30 +01:00
|
|
|
|
{
|
2023-09-26 20:16:24 +01:00
|
|
|
|
totalChkDuration = _sidecarStopwatch.ElapsedMilliseconds;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-09-26 03:39:10 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
|
2022-11-23 16:06:46 +00:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
|
|
|
|
|
|
ByteSize.FromBytes(blockSize * (blocks + 1)).
|
|
|
|
|
|
Per(totalChkDuration.Milliseconds())));
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2023-09-26 03:39:10 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
|
2023-09-26 20:16:24 +01:00
|
|
|
|
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
|
2023-10-04 17:34:40 +01:00
|
|
|
|
ByteSize.FromBytes(blockSize * (blocks + 1)).
|
|
|
|
|
|
Per(totalChkDuration.Milliseconds()).
|
2023-09-26 10:51:43 +01:00
|
|
|
|
Humanize());
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_preSidecar != null)
|
|
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
_preSidecar.BlockMedias = sidecar.BlockMedias;
|
|
|
|
|
|
sidecar = _preSidecar;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
List<(ulong start, string type)> filesystems = new();
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
if(sidecar.BlockMedias[0].FileSystemInformation != null)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
filesystems.AddRange(from partition in sidecar.BlockMedias[0].FileSystemInformation
|
2023-10-03 22:57:50 +01:00
|
|
|
|
where partition.FileSystems != null
|
|
|
|
|
|
from fileSystem in partition.FileSystems
|
2022-03-06 13:29:38 +00:00
|
|
|
|
select (partition.StartSector, fileSystem.Type));
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(filesystems.Count > 0)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
foreach(var filesystem in filesystems.Select(o => new
|
2023-10-04 17:34:40 +01:00
|
|
|
|
{
|
|
|
|
|
|
o.start,
|
|
|
|
|
|
o.type
|
|
|
|
|
|
}).
|
|
|
|
|
|
Distinct())
|
2021-08-03 14:12:59 +01:00
|
|
|
|
{
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1,
|
|
|
|
|
|
filesystem.type, filesystem.start));
|
|
|
|
|
|
|
|
|
|
|
|
_dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type,
|
|
|
|
|
|
filesystem.start);
|
2021-08-03 14:12:59 +01:00
|
|
|
|
}
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-12-17 20:59:12 +00:00
|
|
|
|
sidecar.BlockMedias[0].Dimensions = Dimensions.FromMediaType(dskType);
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
(string type, string subType) xmlType = CommonTypes.Metadata.MediaType.MediaTypeToString(dskType);
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].MediaType = xmlType.type;
|
|
|
|
|
|
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// TODO: Implement device firmware revision
|
2023-10-04 17:34:40 +01:00
|
|
|
|
if(!_dev.IsRemovable || _dev.IsUsb)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_dev.Type == DeviceType.ATAPI)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "ATAPI";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else if(_dev.IsUsb)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "USB";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else if(_dev.IsFireWire)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "FireWire";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Interface = "SCSI";
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].LogicalBlocks = blocks;
|
|
|
|
|
|
sidecar.BlockMedias[0].Manufacturer = _dev.Manufacturer;
|
|
|
|
|
|
sidecar.BlockMedias[0].Model = _dev.Model;
|
2020-03-11 15:28:04 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!_private)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Serial = _dev.Serial;
|
2020-03-11 15:28:04 +00:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].Size = blocks * blockSize;
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(_dev.IsRemovable)
|
2022-12-15 22:21:07 +00:00
|
|
|
|
sidecar.BlockMedias[0].DumpHardware = _resume.Tries;
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(Localization.Core.Writing_metadata_sidecar);
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-12-15 22:21:07 +00:00
|
|
|
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-12-16 03:05:50 +00:00
|
|
|
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
|
|
|
|
|
{
|
|
|
|
|
|
AaruMetadata = sidecar
|
2022-12-16 04:05:09 +00:00
|
|
|
|
}, typeof(MetadataJson), MetadataJsonContext.Default);
|
2022-12-15 22:21:07 +00:00
|
|
|
|
|
|
|
|
|
|
jsonFs.Close();
|
2019-05-03 00:24:30 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2019-05-03 00:24:30 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
UpdateStatus?.Invoke("");
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
|
|
|
|
|
|
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
|
|
|
|
|
|
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
|
|
|
|
|
|
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
|
|
|
|
|
|
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
|
|
|
|
|
|
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
|
|
|
|
|
|
ByteSize.FromBytes(blockSize * (blocks + 1)).
|
2023-10-04 17:34:40 +01:00
|
|
|
|
Per(totalDuration.Milliseconds()).
|
|
|
|
|
|
Humanize()));
|
2019-11-10 00:48:32 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(maxSpeed > 0)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2023-09-26 10:51:43 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0,
|
|
|
|
|
|
ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize()));
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2020-06-25 01:47:25 +01:00
|
|
|
|
|
2022-11-13 20:46:24 +00:00
|
|
|
|
if(minSpeed is > 0 and < double.MaxValue)
|
2023-10-03 22:57:50 +01:00
|
|
|
|
{
|
2023-09-26 02:40:11 +01:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0,
|
2023-09-26 10:51:43 +01:00
|
|
|
|
ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize()));
|
2023-10-03 22:57:50 +01:00
|
|
|
|
}
|
2020-06-25 01:47:25 +01:00
|
|
|
|
|
2022-11-23 16:06:46 +00:00
|
|
|
|
UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
UpdateStatus?.Invoke("");
|
2017-05-31 01:00:58 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Statistics.AddMedia(dskType, true);
|
2017-05-31 01:00:58 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|