mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Allow to specify geometry when converting images. Fixes #250.
This commit is contained in:
@@ -178,6 +178,14 @@ namespace Aaru.Commands.Image
|
|||||||
Argument = new Argument<string>(() => null), Required = false
|
Argument = new Argument<string>(() => null), Required = false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Add(new Option(new[]
|
||||||
|
{
|
||||||
|
"--geometry", "-g"
|
||||||
|
}, "Force geometry, only supported in not tape block media. Specify as C/H/S.")
|
||||||
|
{
|
||||||
|
Argument = new Argument<string>(() => null), Required = false
|
||||||
|
});
|
||||||
|
|
||||||
AddArgument(new Argument<string>
|
AddArgument(new Argument<string>
|
||||||
{
|
{
|
||||||
Arity = ArgumentArity.ExactlyOne, Description = "Input image path", Name = "input-path"
|
Arity = ArgumentArity.ExactlyOne, Description = "Input image path", Name = "input-path"
|
||||||
@@ -196,7 +204,7 @@ namespace Aaru.Commands.Image
|
|||||||
string driveSerialNumber, bool force, string inputPath, int lastMediaSequence,
|
string driveSerialNumber, bool force, string inputPath, int lastMediaSequence,
|
||||||
string mediaBarcode, string mediaManufacturer, string mediaModel,
|
string mediaBarcode, string mediaManufacturer, string mediaModel,
|
||||||
string mediaPartNumber, int mediaSequence, string mediaSerialNumber, string mediaTitle,
|
string mediaPartNumber, int mediaSequence, string mediaSerialNumber, string mediaTitle,
|
||||||
string outputPath, string options, string resumeFile, string format)
|
string outputPath, string options, string resumeFile, string format, string geometry)
|
||||||
{
|
{
|
||||||
MainClass.PrintCopyright();
|
MainClass.PrintCopyright();
|
||||||
|
|
||||||
@@ -219,6 +227,7 @@ namespace Aaru.Commands.Image
|
|||||||
AaruConsole.DebugWriteLine("Analyze command", "--drive-serial={0}", driveSerialNumber);
|
AaruConsole.DebugWriteLine("Analyze command", "--drive-serial={0}", driveSerialNumber);
|
||||||
AaruConsole.DebugWriteLine("Analyze command", "--force={0}", force);
|
AaruConsole.DebugWriteLine("Analyze command", "--force={0}", force);
|
||||||
AaruConsole.DebugWriteLine("Analyze command", "--format={0}", format);
|
AaruConsole.DebugWriteLine("Analyze command", "--format={0}", format);
|
||||||
|
AaruConsole.DebugWriteLine("Analyze command", "--geometry={0}", geometry);
|
||||||
AaruConsole.DebugWriteLine("Analyze command", "--input={0}", inputPath);
|
AaruConsole.DebugWriteLine("Analyze command", "--input={0}", inputPath);
|
||||||
AaruConsole.DebugWriteLine("Analyze command", "--media-barcode={0}", mediaBarcode);
|
AaruConsole.DebugWriteLine("Analyze command", "--media-barcode={0}", mediaBarcode);
|
||||||
AaruConsole.DebugWriteLine("Analyze command", "--media-lastsequence={0}", lastMediaSequence);
|
AaruConsole.DebugWriteLine("Analyze command", "--media-lastsequence={0}", lastMediaSequence);
|
||||||
@@ -246,6 +255,47 @@ namespace Aaru.Commands.Image
|
|||||||
return (int)ErrorNumber.InvalidArgument;
|
return (int)ErrorNumber.InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(uint cylinders, uint heads, uint sectors)? geometryValues = null;
|
||||||
|
|
||||||
|
if(geometry != null)
|
||||||
|
{
|
||||||
|
string[] geometryPieces = geometry.Split('/');
|
||||||
|
|
||||||
|
if(geometryPieces.Length == 0)
|
||||||
|
geometryPieces = geometry.Split('-');
|
||||||
|
|
||||||
|
if(geometryPieces.Length != 3)
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine("Invalid geometry specified");
|
||||||
|
|
||||||
|
return (int)ErrorNumber.InvalidArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!uint.TryParse(geometryPieces[0], out uint cylinders) ||
|
||||||
|
cylinders == 0)
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine("Invalid number of cylinders specified");
|
||||||
|
|
||||||
|
return (int)ErrorNumber.InvalidArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!uint.TryParse(geometryPieces[0], out uint heads) ||
|
||||||
|
heads == 0)
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine("Invalid number of heads specified");
|
||||||
|
|
||||||
|
return (int)ErrorNumber.InvalidArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!uint.TryParse(geometryPieces[0], out uint spt) ||
|
||||||
|
spt == 0)
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine("Invalid sectors per track specified");
|
||||||
|
|
||||||
|
return (int)ErrorNumber.InvalidArgument;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Resume resume = null;
|
Resume resume = null;
|
||||||
CICMMetadataType sidecar = null;
|
CICMMetadataType sidecar = null;
|
||||||
MediaType mediaType;
|
MediaType mediaType;
|
||||||
@@ -571,7 +621,7 @@ namespace Aaru.Commands.Image
|
|||||||
track.TrackSequence);
|
track.TrackSequence);
|
||||||
|
|
||||||
bool useNotLong = false;
|
bool useNotLong = false;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if(useLong)
|
if(useLong)
|
||||||
{
|
{
|
||||||
@@ -593,7 +643,8 @@ namespace Aaru.Commands.Image
|
|||||||
{
|
{
|
||||||
if(!force)
|
if(!force)
|
||||||
{
|
{
|
||||||
AaruConsole.ErrorWriteLine("Input image is not returning raw sectors, use force if you want to continue...");
|
AaruConsole.
|
||||||
|
ErrorWriteLine("Input image is not returning raw sectors, use force if you want to continue...");
|
||||||
|
|
||||||
return (int)Errno.InOutError;
|
return (int)Errno.InOutError;
|
||||||
}
|
}
|
||||||
@@ -764,12 +815,15 @@ namespace Aaru.Commands.Image
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AaruConsole.WriteLine("Setting geometry to {0} cylinders, {1} heads and {2} sectors per track",
|
(uint cylinders, uint heads, uint sectors) chs =
|
||||||
inputFormat.Info.Cylinders, inputFormat.Info.Heads,
|
geometryValues != null
|
||||||
inputFormat.Info.SectorsPerTrack);
|
? (geometryValues.Value.cylinders, geometryValues.Value.heads, geometryValues.Value.sectors)
|
||||||
|
: (inputFormat.Info.Cylinders, inputFormat.Info.Heads, inputFormat.Info.SectorsPerTrack);
|
||||||
|
|
||||||
if(!outputFormat.SetGeometry(inputFormat.Info.Cylinders, inputFormat.Info.Heads,
|
AaruConsole.WriteLine("Setting geometry to {0} cylinders, {1} heads and {2} sectors per track",
|
||||||
inputFormat.Info.SectorsPerTrack))
|
chs.cylinders, chs.heads, chs.sectors);
|
||||||
|
|
||||||
|
if(!outputFormat.SetGeometry(chs.cylinders, chs.heads, chs.sectors))
|
||||||
AaruConsole.ErrorWriteLine("Error {0} setting geometry, image may be incorrect, continuing...",
|
AaruConsole.ErrorWriteLine("Error {0} setting geometry, image may be incorrect, continuing...",
|
||||||
outputFormat.ErrorMessage);
|
outputFormat.ErrorMessage);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user