* DiscImageChef/Main.cs:

* DiscImageChef/Options.cs:
	* DiscImageChef/DiscImageChef.csproj:
	* DiscImageChef/Commands/DeviceInfo.cs:
	  Added "device-info" command.

	* DiscImageChef.Decoders/SCSI.cs:
	  Correct size miscalculation.
	Do not print "Device claims no standard", generates too much
	  noise.

	* DiscImageChef.Devices/Device/Constructor.cs:
	  Add OS error detection and handling.
	On Linux move to opening O_RDONLY and O_NONBLOCK to allow
	  opening read-only media and removable drives without media.

	* DiscImageChef.Devices/Device/Variables.cs:
	* DiscImageChef.Devices/Device/ScsiCommands.cs:
	  Add OS error detection and handling.

	* DiscImageChef.Devices/DiscImageChef.Devices.csproj:
	* DiscImageChef.Interop/DiscImageChef.Interop.csproj:
	  Downgraded .NET version.
This commit is contained in:
2015-10-13 01:45:07 +01:00
parent 9f545eb8ab
commit 9f0d09b789
14 changed files with 206 additions and 13 deletions

View File

@@ -1,3 +1,11 @@
2015-10-13 Natalia Portillo <claunia@claunia.com>
* Main.cs:
* Options.cs:
* DiscImageChef.csproj:
* Commands/DeviceInfo.cs:
Added "device-info" command.
2015-10-12 Natalia Portillo <claunia@claunia.com>
* DetectImageFormat.cs:

View File

@@ -0,0 +1,90 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : DeviceInfo.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Component
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright (C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
using System;
using DiscImageChef.Devices;
using System.IO;
namespace DiscImageChef.Commands
{
public static class DeviceInfo
{
public static void doDeviceInfo(DeviceInfoSubOptions options)
{
if (MainClass.isDebug)
{
Console.WriteLine("--debug={0}", options.Debug);
Console.WriteLine("--verbose={0}", options.Verbose);
Console.WriteLine("--device={0}", options.DevicePath);
}
if (options.DevicePath.Length == 2 && options.DevicePath[1] == ':' &&
options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0]))
{
options.DevicePath = "\\\\.\\" + Char.ToUpper(options.DevicePath[0]) + ':';
}
Device dev = new Device(options.DevicePath);
if (dev.Error)
{
Console.WriteLine("Error {0} opening device.", dev.LastError);
return;
}
byte[] senseBuf;
byte[] inqBuf;
bool sense = dev.ScsiInquiry(out inqBuf, out senseBuf);
if(sense)
{
Console.WriteLine("SCSI error. Sense decoding not yet implemented.");
#if DEBUG
FileStream senseFs = File.Open("sense.bin", FileMode.OpenOrCreate);
senseFs.Write(senseBuf, 0, senseBuf.Length);
#endif
}
else
Console.WriteLine("SCSI OK");
Console.WriteLine("{0}", Decoders.SCSI.PrettifySCSIInquiry(inqBuf));
}
}
}

View File

@@ -51,6 +51,7 @@
<Compile Include="Commands\Decode.cs" />
<Compile Include="Commands\Entropy.cs" />
<Compile Include="DetectImageFormat.cs" />
<Compile Include="Commands\DeviceInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -171,5 +172,13 @@
<Project>{0BEB3088-B634-4289-AE17-CDF2D25D00D5}</Project>
<Name>DiscImageChef.Decoders</Name>
</ProjectReference>
<ProjectReference Include="..\DiscImageChef.Devices\DiscImageChef.Devices.csproj">
<Project>{57BB2341-AB62-48FD-91B8-46F5A2F9ED51}</Project>
<Name>DiscImageChef.Devices</Name>
</ProjectReference>
<ProjectReference Include="..\DiscImageChef.Interop\DiscImageChef.Interop.csproj">
<Project>{9183F2E0-A879-4F23-9EE3-C6908F1332B2}</Project>
<Name>DiscImageChef.Interop</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@@ -129,6 +129,12 @@ namespace DiscImageChef
isDebug = FormatsOptions.Debug;
Commands.Formats.ListFormats();
break;
case "device-info":
DeviceInfoSubOptions DeviceInfoOptions = (DeviceInfoSubOptions)invokedVerbInstance;
isVerbose = DeviceInfoOptions.Verbose;
isDebug = DeviceInfoOptions.Debug;
Commands.DeviceInfo.doDeviceInfo(DeviceInfoOptions);
break;
default:
throw new ArgumentException("Should never arrive here!");
}

View File

@@ -214,6 +214,12 @@ namespace DiscImageChef
public string InputFile { get; set; }
}
public class DeviceInfoSubOptions : CommonSubOptions
{
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
}
public class FormatsSubOptions : CommonSubOptions
{
}
@@ -230,6 +236,7 @@ namespace DiscImageChef
FormatsVerb = new FormatsSubOptions();
PrintHexVerb = new PrintHexSubOptions();
DecodeVerb = new DecodeSubOptions();
DeviceInfoVerb = new DeviceInfoSubOptions();
}
[VerbOption("analyze", HelpText = "Analyzes a disc image and searches for partitions and/or filesystems.")]
@@ -256,6 +263,9 @@ namespace DiscImageChef
[VerbOption("formats", HelpText = "Lists all supported disc images, partition schemes and file systems.")]
public FormatsSubOptions FormatsVerb { get; set; }
[VerbOption("device-info", HelpText = "Gets information about a device.")]
public DeviceInfoSubOptions DeviceInfoVerb { get; set; }
[HelpVerbOption]
public string DoHelpForVerb(string verbName)
{