mirror of
https://github.com/aaru-dps/Aaru.git
synced 2026-07-08 17:56:18 +00:00
Code restyling.
This commit is contained in:
@@ -11,8 +11,8 @@ indent_size=4
|
||||
brace_style=next_line
|
||||
int_align=true
|
||||
keep_existing_arrangement=false
|
||||
place_simple_blocks_on_single_line=false
|
||||
place_simple_declaration_blocks_on_single_line=false
|
||||
place_simple_blocks_on_single_line=true
|
||||
place_simple_declaration_blocks_on_single_line=true
|
||||
place_attribute_on_same_line=false
|
||||
space_after_unary_operator=false
|
||||
space_after_comma=true
|
||||
@@ -48,13 +48,13 @@ accessor_owner_body=expression_body
|
||||
force_attribute_style=join
|
||||
function_braces=next_line
|
||||
force_control_statements_braces=always_remove
|
||||
|
||||
space_in_singleline_accessorholder=true
|
||||
type_declaration_braces=next_line
|
||||
invocable_declaration_braces=next_line
|
||||
anonymous_method_declaration_braces=next_line
|
||||
|
||||
space_between_accessors_in_singleline_property=true
|
||||
indent_nested_usings_stmt=true
|
||||
|
||||
space_within_empty_braces=false
|
||||
indent_nested_fixed_stmt=true
|
||||
indent_nested_lock_stmt=true
|
||||
indent_nested_for_stmt=true
|
||||
@@ -175,7 +175,7 @@ wrap_before_linq_expression=false
|
||||
place_linq_into_on_new_line=false
|
||||
wrap_verbatim_interpolated_strings=wrap_if_long
|
||||
extra_spaces=remove_all
|
||||
space_after_keywords_in_control_flow_statements=true
|
||||
space_after_keywords_in_control_flow_statements=false
|
||||
space_between_method_call_name_and_opening_parenthesis=false
|
||||
space_between_method_declaration_name_and_open_parenthesis=false
|
||||
space_before_typeof_parentheses=false
|
||||
@@ -206,6 +206,10 @@ blank_lines_around_class_definition=1
|
||||
namespace_indentation=all
|
||||
space_within_template_argument=false
|
||||
align_union_type_usage=true
|
||||
space_in_singleline_method=true
|
||||
space_in_singleline_anonymous_method=true
|
||||
space_within_single_line_array_initializer_braces=true
|
||||
space_around_arrow_op=false
|
||||
|
||||
# These are for markup languages (HTML, XML, etc)
|
||||
spaces_around_eq_in_pi_attribute=false
|
||||
@@ -583,8 +587,8 @@ csharp_space_before_typeof_parentheses=false
|
||||
csharp_space_before_checked_parentheses=false
|
||||
csharp_space_before_sizeof_parentheses=false
|
||||
csharp_space_before_nameof_parentheses=false
|
||||
csharp_space_between_keyword_and_expression=false
|
||||
csharp_space_between_keyword_and_type=false
|
||||
csharp_space_between_keyword_and_expression=true
|
||||
csharp_space_between_keyword_and_type=true
|
||||
csharp_space_around_assignment_op=true
|
||||
csharp_space_around_logical_op=true
|
||||
csharp_space_around_binary_operator=true
|
||||
|
||||
6
.idea/.idea.Aaru/.idea/runConfigurations/GUI.xml
generated
6
.idea/.idea.Aaru/.idea/runConfigurations/GUI.xml
generated
@@ -1,14 +1,14 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="GUI" type="DotNetProject" factoryName=".NET Project">
|
||||
<option name="EXE_PATH" value="" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/Aaru/bin/Debug/netcoreapp2.0/Aaru.dll" />
|
||||
<option name="PROGRAM_PARAMETERS" value="help" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Aaru/bin/Debug/netcoreapp2.0" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="USE_MONO" value="0" />
|
||||
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||
<option name="PROJECT_PATH" value="$PROJECT_DIR$/Aaru/Aaru.csproj" />
|
||||
<option name="PROJECT_EXE_PATH_TRACKING" value="0" />
|
||||
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||
|
||||
Submodule Aaru.Checksums updated: 2d5bc1f8ed...5f2ddad918
Submodule Aaru.CommonTypes updated: c88447c86e...f990e1f2f8
@@ -65,23 +65,29 @@ namespace Aaru.Compression
|
||||
if(repeatMode && count > 0)
|
||||
{
|
||||
count--;
|
||||
|
||||
if(nextA)
|
||||
{
|
||||
nextA = false;
|
||||
|
||||
return repeatedbyteA;
|
||||
}
|
||||
|
||||
nextA = true;
|
||||
|
||||
return repeatedbyteB;
|
||||
}
|
||||
|
||||
if(!repeatMode && count > 0)
|
||||
if(!repeatMode &&
|
||||
count > 0)
|
||||
{
|
||||
count--;
|
||||
|
||||
return inStream.ReadByte();
|
||||
}
|
||||
|
||||
if(inStream.Position == inStream.Length) return -1;
|
||||
if(inStream.Position == inStream.Length)
|
||||
return -1;
|
||||
|
||||
while(true)
|
||||
{
|
||||
@@ -89,22 +95,28 @@ namespace Aaru.Compression
|
||||
byte b2 = (byte)inStream.ReadByte();
|
||||
short s = (short)((b1 << 8) | b2);
|
||||
|
||||
if(s == 0 || s >= DART_CHUNK || s <= -DART_CHUNK) continue;
|
||||
if(s == 0 ||
|
||||
s >= DART_CHUNK ||
|
||||
s <= -DART_CHUNK)
|
||||
continue;
|
||||
|
||||
if(s < 0)
|
||||
{
|
||||
repeatMode = true;
|
||||
repeatedbyteA = (byte)inStream.ReadByte();
|
||||
repeatedbyteB = (byte)inStream.ReadByte();
|
||||
count = -s * 2 - 1;
|
||||
count = (-s * 2) - 1;
|
||||
nextA = false;
|
||||
|
||||
return repeatedbyteA;
|
||||
}
|
||||
|
||||
if(s <= 0) continue;
|
||||
if(s <= 0)
|
||||
continue;
|
||||
|
||||
repeatMode = false;
|
||||
count = s * 2 - 1;
|
||||
count = (s * 2) - 1;
|
||||
|
||||
return inStream.ReadByte();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ namespace Aaru.Compression
|
||||
|
||||
/* Huffman coding parameters */
|
||||
|
||||
const int N_CHAR = 256 - THRESHOLD + F;
|
||||
const int N_CHAR = (256 - THRESHOLD) + F;
|
||||
/* character code (= 0..N_CHAR-1) */
|
||||
const int T = N_CHAR * 2 - 1; /* Size of table */
|
||||
const int ROOT = T - 1; /* root position */
|
||||
const int T = (N_CHAR * 2) - 1; /* Size of table */
|
||||
const int ROOT = T - 1; /* root position */
|
||||
const int MAX_FREQ = 0x8000;
|
||||
|
||||
/*
|
||||
@@ -80,61 +80,59 @@ namespace Aaru.Compression
|
||||
/* decoder table */
|
||||
readonly byte[] d_code =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
|
||||
0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
|
||||
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E,
|
||||
0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12,
|
||||
0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16,
|
||||
0x16, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x19, 0x19, 0x1A, 0x1A, 0x1B, 0x1B, 0x1C, 0x1C, 0x1D, 0x1D,
|
||||
0x1E, 0x1E, 0x1F, 0x1F, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, 0x26,
|
||||
0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E,
|
||||
0x2F, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E,
|
||||
0x3F
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
|
||||
0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
|
||||
0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10,
|
||||
0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14,
|
||||
0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x19, 0x19, 0x1A, 0x1A,
|
||||
0x1B, 0x1B, 0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 0x1F, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23,
|
||||
0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C,
|
||||
0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F
|
||||
};
|
||||
|
||||
readonly byte[] d_len =
|
||||
{
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
|
||||
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
|
||||
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
|
||||
0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
|
||||
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
|
||||
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08
|
||||
};
|
||||
readonly ushort[] freq = new ushort[T + 1]; /* cumulative freq table */
|
||||
|
||||
readonly Stream inStream;
|
||||
ushort[] freq = new ushort[T + 1]; /* cumulative freq table */
|
||||
|
||||
ushort getbuf;
|
||||
byte getlen;
|
||||
|
||||
/*
|
||||
* pointing parent nodes.
|
||||
* area [T..(T + N_CHAR - 1)] are pointers for leaves
|
||||
*/
|
||||
short[] prnt = new short[T + N_CHAR];
|
||||
readonly short[] prnt = new short[T + N_CHAR];
|
||||
|
||||
/* pointing children nodes (son[], son[] + 1)*/
|
||||
short[] son = new short[T];
|
||||
readonly short[] son = new short[T];
|
||||
readonly byte[] text_buf = new byte[(N + F) - 1];
|
||||
|
||||
ushort getbuf;
|
||||
byte getlen;
|
||||
|
||||
Tdlzhuf tdctl;
|
||||
byte[] text_buf = new byte[N + F - 1];
|
||||
|
||||
public TeleDiskLzh(Stream dataStream)
|
||||
{
|
||||
@@ -145,7 +143,9 @@ namespace Aaru.Compression
|
||||
tdctl.Ibufcnt = tdctl.Ibufndx = 0; // input buffer is empty
|
||||
tdctl.Bufcnt = 0;
|
||||
StartHuff();
|
||||
for(i = 0; i < N - F; i++) text_buf[i] = 0x20;
|
||||
|
||||
for(i = 0; i < N - F; i++)
|
||||
text_buf[i] = 0x20;
|
||||
|
||||
tdctl.R = N - F;
|
||||
inStream = dataStream;
|
||||
@@ -162,10 +162,12 @@ namespace Aaru.Compression
|
||||
short c;
|
||||
buf = new byte[len];
|
||||
int count; // was an unsigned long, seems unnecessary
|
||||
|
||||
for(count = 0; count < len;)
|
||||
if(tdctl.Bufcnt == 0)
|
||||
{
|
||||
if((c = DecodeChar()) < 0) return count; // fatal error
|
||||
if((c = DecodeChar()) < 0)
|
||||
return count; // fatal error
|
||||
|
||||
if(c < 256)
|
||||
{
|
||||
@@ -177,17 +179,20 @@ namespace Aaru.Compression
|
||||
else
|
||||
{
|
||||
short pos;
|
||||
if((pos = DecodePosition()) < 0) return count; // fatal error
|
||||
|
||||
if((pos = DecodePosition()) < 0)
|
||||
return count; // fatal error
|
||||
|
||||
tdctl.Bufpos = (ushort)((tdctl.R - pos - 1) & (N - 1));
|
||||
tdctl.Bufcnt = (ushort)(c - 255 + THRESHOLD);
|
||||
tdctl.Bufcnt = (ushort)((c - 255) + THRESHOLD);
|
||||
tdctl.Bufndx = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// still chars from last string
|
||||
while(tdctl.Bufndx < tdctl.Bufcnt && count < len)
|
||||
while(tdctl.Bufndx < tdctl.Bufcnt &&
|
||||
count < len)
|
||||
{
|
||||
c = text_buf[(tdctl.Bufpos + tdctl.Bufndx) & (N - 1)];
|
||||
buf[count] = (byte)c;
|
||||
@@ -198,7 +203,8 @@ namespace Aaru.Compression
|
||||
}
|
||||
|
||||
// reset bufcnt after copy string from text_buf[]
|
||||
if(tdctl.Bufndx >= tdctl.Bufcnt) tdctl.Bufndx = tdctl.Bufcnt = 0;
|
||||
if(tdctl.Bufndx >= tdctl.Bufcnt)
|
||||
tdctl.Bufndx = tdctl.Bufcnt = 0;
|
||||
}
|
||||
|
||||
return count; // count == len, success
|
||||
@@ -206,10 +212,12 @@ namespace Aaru.Compression
|
||||
|
||||
long DataRead(out byte[] buf, long size)
|
||||
{
|
||||
if(size > inStream.Length - inStream.Position) size = inStream.Length - inStream.Position;
|
||||
if(size > inStream.Length - inStream.Position)
|
||||
size = inStream.Length - inStream.Position;
|
||||
|
||||
buf = new byte[size];
|
||||
inStream.Read(buf, 0, (int)size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -219,7 +227,9 @@ namespace Aaru.Compression
|
||||
{
|
||||
tdctl.Ibufndx = 0;
|
||||
tdctl.Ibufcnt = (ushort)DataRead(out tdctl.Inbuf, BUFSZ);
|
||||
if(tdctl.Ibufcnt <= 0) return -1;
|
||||
|
||||
if(tdctl.Ibufcnt <= 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
while(getlen <= 8)
|
||||
@@ -234,22 +244,26 @@ namespace Aaru.Compression
|
||||
|
||||
int GetBit() /* get one bit */
|
||||
{
|
||||
if(NextWord() < 0) return -1;
|
||||
if(NextWord() < 0)
|
||||
return -1;
|
||||
|
||||
short i = (short)getbuf;
|
||||
getbuf <<= 1;
|
||||
getlen--;
|
||||
|
||||
return i < 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
int GetByte() /* get a byte */
|
||||
{
|
||||
if(NextWord() != 0) return -1;
|
||||
if(NextWord() != 0)
|
||||
return -1;
|
||||
|
||||
ushort i = getbuf;
|
||||
getbuf <<= 8;
|
||||
getlen -= 8;
|
||||
i = (ushort)(i >> 8);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -268,6 +282,7 @@ namespace Aaru.Compression
|
||||
|
||||
i = 0;
|
||||
int j = N_CHAR;
|
||||
|
||||
while(j <= ROOT)
|
||||
{
|
||||
freq[j] = (ushort)(freq[i] + freq[i + 1]);
|
||||
@@ -289,6 +304,7 @@ namespace Aaru.Compression
|
||||
|
||||
/* halven cumulative freq for leaf nodes */
|
||||
short j = 0;
|
||||
|
||||
for(i = 0; i < T; i++)
|
||||
if(son[i] >= T)
|
||||
{
|
||||
@@ -302,7 +318,8 @@ namespace Aaru.Compression
|
||||
{
|
||||
k = (short)(i + 1);
|
||||
ushort f = freq[j] = (ushort)(freq[i] + freq[k]);
|
||||
for(k = (short)(j - 1); f < freq[k]; k--) { }
|
||||
|
||||
for(k = (short)(j - 1); f < freq[k]; k--) {}
|
||||
|
||||
k++;
|
||||
ushort l = (ushort)((j - k) * 2);
|
||||
@@ -325,17 +342,22 @@ namespace Aaru.Compression
|
||||
|
||||
void Update(int c)
|
||||
{
|
||||
if(freq[ROOT] == MAX_FREQ) Reconst();
|
||||
if(freq[ROOT] == MAX_FREQ)
|
||||
Reconst();
|
||||
|
||||
c = prnt[c + T];
|
||||
|
||||
do
|
||||
{
|
||||
int k = ++freq[c];
|
||||
|
||||
/* swap nodes to keep the tree freq-ordered */
|
||||
int l;
|
||||
if(k <= freq[l = c + 1]) continue;
|
||||
|
||||
while(k > freq[++l]) { }
|
||||
if(k <= freq[l = c + 1])
|
||||
continue;
|
||||
|
||||
while(k > freq[++l]) {}
|
||||
|
||||
l--;
|
||||
freq[c] = freq[l];
|
||||
@@ -343,18 +365,22 @@ namespace Aaru.Compression
|
||||
|
||||
int i = son[c];
|
||||
prnt[i] = (short)l;
|
||||
if(i < T) prnt[i + 1] = (short)l;
|
||||
|
||||
if(i < T)
|
||||
prnt[i + 1] = (short)l;
|
||||
|
||||
int j = son[l];
|
||||
son[l] = (short)i;
|
||||
|
||||
prnt[j] = (short)c;
|
||||
if(j < T) prnt[j + 1] = (short)c;
|
||||
|
||||
if(j < T)
|
||||
prnt[j + 1] = (short)c;
|
||||
|
||||
son[c] = (short)j;
|
||||
|
||||
c = l;
|
||||
}
|
||||
while((c = prnt[c]) != 0); /* do it until reaching the root */
|
||||
} while((c = prnt[c]) != 0); /* do it until reaching the root */
|
||||
}
|
||||
|
||||
short DecodeChar()
|
||||
@@ -369,7 +395,9 @@ namespace Aaru.Compression
|
||||
while(c < T)
|
||||
{
|
||||
int ret;
|
||||
if((ret = GetBit()) < 0) return -1;
|
||||
|
||||
if((ret = GetBit()) < 0)
|
||||
return -1;
|
||||
|
||||
c += (ushort)ret;
|
||||
c = (ushort)son[c];
|
||||
@@ -377,6 +405,7 @@ namespace Aaru.Compression
|
||||
|
||||
c -= T;
|
||||
Update(c);
|
||||
|
||||
return (short)c;
|
||||
}
|
||||
|
||||
@@ -385,7 +414,8 @@ namespace Aaru.Compression
|
||||
short bit;
|
||||
|
||||
/* decode upper 6 bits from given table */
|
||||
if((bit = (short)GetByte()) < 0) return -1;
|
||||
if((bit = (short)GetByte()) < 0)
|
||||
return -1;
|
||||
|
||||
ushort i = (ushort)bit;
|
||||
ushort c = (ushort)(d_code[i] << 6);
|
||||
@@ -393,9 +423,11 @@ namespace Aaru.Compression
|
||||
|
||||
/* input lower 6 bits directly */
|
||||
j -= 2;
|
||||
|
||||
while(j-- > 0)
|
||||
{
|
||||
if((bit = (short)GetBit()) < 0) return -1;
|
||||
if((bit = (short)GetBit()) < 0)
|
||||
return -1;
|
||||
|
||||
i = (ushort)((i << 1) + bit);
|
||||
}
|
||||
@@ -407,14 +439,10 @@ namespace Aaru.Compression
|
||||
|
||||
struct Tdlzhuf
|
||||
{
|
||||
public ushort R,
|
||||
Bufcnt,
|
||||
Bufndx,
|
||||
Bufpos, // string buffer
|
||||
public ushort R, Bufcnt, Bufndx, Bufpos, // string buffer
|
||||
// the following to allow block reads from input in next_word()
|
||||
Ibufcnt,
|
||||
Ibufndx; // input buffer counters
|
||||
public byte[] Inbuf; // input buffer
|
||||
Ibufcnt, Ibufndx; // input buffer counters
|
||||
public byte[] Inbuf; // input buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,42 +54,42 @@ namespace Aaru.Core
|
||||
public class Checksum
|
||||
{
|
||||
readonly IChecksum adler32Ctx;
|
||||
HashPacket adlerPkt;
|
||||
Thread adlerThread;
|
||||
readonly IChecksum crc16Ctx;
|
||||
HashPacket crc16Pkt;
|
||||
Thread crc16Thread;
|
||||
readonly IChecksum crc32Ctx;
|
||||
HashPacket crc32Pkt;
|
||||
Thread crc32Thread;
|
||||
readonly IChecksum crc64Ctx;
|
||||
HashPacket crc64Pkt;
|
||||
Thread crc64Thread;
|
||||
readonly EnableChecksum enabled;
|
||||
readonly IChecksum f16Ctx;
|
||||
readonly IChecksum f32Ctx;
|
||||
readonly IChecksum md5Ctx;
|
||||
readonly IChecksum sha1Ctx;
|
||||
readonly IChecksum sha256Ctx;
|
||||
readonly IChecksum sha384Ctx;
|
||||
readonly IChecksum sha512Ctx;
|
||||
readonly IChecksum ssctx;
|
||||
HashPacket adlerPkt;
|
||||
Thread adlerThread;
|
||||
HashPacket crc16Pkt;
|
||||
Thread crc16Thread;
|
||||
HashPacket crc32Pkt;
|
||||
Thread crc32Thread;
|
||||
HashPacket crc64Pkt;
|
||||
Thread crc64Thread;
|
||||
HashPacket f16Pkt;
|
||||
Thread f16Thread;
|
||||
readonly IChecksum f32Ctx;
|
||||
HashPacket f32Pkt;
|
||||
Thread f32Thread;
|
||||
readonly IChecksum md5Ctx;
|
||||
HashPacket md5Pkt;
|
||||
Thread md5Thread;
|
||||
readonly IChecksum sha1Ctx;
|
||||
HashPacket sha1Pkt;
|
||||
Thread sha1Thread;
|
||||
readonly IChecksum sha256Ctx;
|
||||
HashPacket sha256Pkt;
|
||||
Thread sha256Thread;
|
||||
readonly IChecksum sha384Ctx;
|
||||
HashPacket sha384Pkt;
|
||||
Thread sha384Thread;
|
||||
readonly IChecksum sha512Ctx;
|
||||
HashPacket sha512Pkt;
|
||||
Thread sha512Thread;
|
||||
HashPacket spamsumPkt;
|
||||
Thread spamsumThread;
|
||||
readonly IChecksum ssctx;
|
||||
|
||||
public Checksum(EnableChecksum enabled = EnableChecksum.All)
|
||||
{
|
||||
@@ -314,7 +314,7 @@ namespace Aaru.Core
|
||||
sha512Thread.IsAlive ||
|
||||
spamsumThread.IsAlive ||
|
||||
f16Thread.IsAlive ||
|
||||
f32Thread.IsAlive) { }
|
||||
f32Thread.IsAlive) {}
|
||||
|
||||
if(enabled.HasFlag(EnableChecksum.SpamSum))
|
||||
adlerThread = new Thread(UpdateHash);
|
||||
@@ -665,7 +665,7 @@ namespace Aaru.Core
|
||||
sha512ThreadData.IsAlive ||
|
||||
spamsumThreadData.IsAlive ||
|
||||
f16ThreadData.IsAlive ||
|
||||
f32ThreadData.IsAlive) { }
|
||||
f32ThreadData.IsAlive) {}
|
||||
|
||||
List<ChecksumType> dataChecksums = new List<ChecksumType>();
|
||||
ChecksumType chk;
|
||||
|
||||
@@ -36,98 +36,63 @@ using Aaru.Console;
|
||||
|
||||
namespace Aaru.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstracts a datafile with a block based interface
|
||||
/// </summary>
|
||||
/// <summary>Abstracts a datafile with a block based interface</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")]
|
||||
public class DataFile
|
||||
{
|
||||
FileStream dataFs;
|
||||
readonly FileStream dataFs;
|
||||
|
||||
/// <summary>
|
||||
/// Opens, or create, a new file
|
||||
/// </summary>
|
||||
/// <summary>Opens, or create, a new file</summary>
|
||||
/// <param name="outputFile">File</param>
|
||||
public DataFile(string outputFile)
|
||||
{
|
||||
public DataFile(string outputFile) =>
|
||||
dataFs = new FileStream(outputFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the file
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
dataFs?.Close();
|
||||
}
|
||||
/// <summary>Closes the file</summary>
|
||||
public void Close() => dataFs?.Close();
|
||||
|
||||
/// <summary>
|
||||
/// Reads bytes at current position
|
||||
/// </summary>
|
||||
/// <summary>Reads bytes at current position</summary>
|
||||
/// <param name="array">Array to place read data within</param>
|
||||
/// <param name="offset">Offset of <see cref="array" /> where data will be read</param>
|
||||
/// <param name="count">How many bytes to read</param>
|
||||
/// <returns>How many bytes were read</returns>
|
||||
public int Read(byte[] array, int offset, int count) => dataFs.Read(array, offset, count);
|
||||
|
||||
/// <summary>
|
||||
/// Seeks to the specified block
|
||||
/// </summary>
|
||||
/// <summary>Seeks to the specified block</summary>
|
||||
/// <param name="block">Block to seek to</param>
|
||||
/// <param name="blockSize">Block size in bytes</param>
|
||||
/// <returns>Position</returns>
|
||||
public long Seek(ulong block, ulong blockSize) => dataFs.Seek((long)(block * blockSize), SeekOrigin.Begin);
|
||||
|
||||
/// <summary>
|
||||
/// Seeks to specified byte position
|
||||
/// </summary>
|
||||
/// <summary>Seeks to specified byte position</summary>
|
||||
/// <param name="offset">Byte position</param>
|
||||
/// <param name="origin">Where to count for position</param>
|
||||
/// <returns>Position</returns>
|
||||
public long Seek(ulong offset, SeekOrigin origin) => dataFs.Seek((long)offset, origin);
|
||||
|
||||
/// <summary>
|
||||
/// Seeks to specified byte position
|
||||
/// </summary>
|
||||
/// <summary>Seeks to specified byte position</summary>
|
||||
/// <param name="offset">Byte position</param>
|
||||
/// <param name="origin">Where to count for position</param>
|
||||
/// <returns>Position</returns>
|
||||
public long Seek(long offset, SeekOrigin origin) => dataFs.Seek(offset, origin);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data at current position
|
||||
/// </summary>
|
||||
/// <summary>Writes data at current position</summary>
|
||||
/// <param name="data">Data</param>
|
||||
public void Write(byte[] data)
|
||||
{
|
||||
Write(data, 0, data.Length);
|
||||
}
|
||||
public void Write(byte[] data) => Write(data, 0, data.Length);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data at current position
|
||||
/// </summary>
|
||||
/// <summary>Writes data at current position</summary>
|
||||
/// <param name="data">Data</param>
|
||||
/// <param name="offset">Offset of data from where to start taking data to write</param>
|
||||
/// <param name="count">How many bytes to write</param>
|
||||
public void Write(byte[] data, int offset, int count)
|
||||
{
|
||||
dataFs.Write(data, offset, count);
|
||||
}
|
||||
public void Write(byte[] data, int offset, int count) => dataFs.Write(data, offset, count);
|
||||
|
||||
/// <summary>
|
||||
/// Writes data at specified block
|
||||
/// </summary>
|
||||
/// <summary>Writes data at specified block</summary>
|
||||
/// <param name="data">Data</param>
|
||||
/// <param name="block">Block</param>
|
||||
/// <param name="blockSize">Bytes per block</param>
|
||||
public void WriteAt(byte[] data, ulong block, uint blockSize)
|
||||
{
|
||||
public void WriteAt(byte[] data, ulong block, uint blockSize) =>
|
||||
WriteAt(data, block, blockSize, 0, data.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes data at specified block
|
||||
/// </summary>
|
||||
/// <summary>Writes data at specified block</summary>
|
||||
/// <param name="data">Data</param>
|
||||
/// <param name="block">Block</param>
|
||||
/// <param name="blockSize">Bytes per block</param>
|
||||
@@ -139,14 +104,10 @@ namespace Aaru.Core
|
||||
dataFs.Write(data, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current file position
|
||||
/// </summary>
|
||||
/// <summary>Current file position</summary>
|
||||
public long Position => dataFs.Position;
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to a newly created file
|
||||
/// </summary>
|
||||
/// <summary>Writes data to a newly created file</summary>
|
||||
/// <param name="who">Who asked the file to be written (class, plugin, etc.)</param>
|
||||
/// <param name="data">Data to write</param>
|
||||
/// <param name="outputPrefix">First part of the file name</param>
|
||||
@@ -155,22 +116,22 @@ namespace Aaru.Core
|
||||
public static void WriteTo(string who, string outputPrefix, string outputSuffix, string whatWriting,
|
||||
byte[] data)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(outputPrefix) && !string.IsNullOrEmpty(outputSuffix))
|
||||
if(!string.IsNullOrEmpty(outputPrefix) &&
|
||||
!string.IsNullOrEmpty(outputSuffix))
|
||||
WriteTo(who, outputPrefix + outputSuffix, data, whatWriting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to a newly created file
|
||||
/// </summary>
|
||||
/// <summary>Writes data to a newly created file</summary>
|
||||
/// <param name="who">Who asked the file to be written (class, plugin, etc.)</param>
|
||||
/// <param name="filename">Filename to create</param>
|
||||
/// <param name="data">Data to write</param>
|
||||
/// <param name="whatWriting">What is the data about?</param>
|
||||
/// <param name="overwrite">If set to <c>true</c> overwrites the file, does nothing otherwise</param>
|
||||
public static void WriteTo(string who, string filename, byte[] data, string whatWriting = null,
|
||||
bool overwrite = false)
|
||||
bool overwrite = false)
|
||||
{
|
||||
if(string.IsNullOrEmpty(filename)) return;
|
||||
if(string.IsNullOrEmpty(filename))
|
||||
return;
|
||||
|
||||
if(File.Exists(filename))
|
||||
if(overwrite)
|
||||
@@ -178,17 +139,21 @@ namespace Aaru.Core
|
||||
else
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Not overwriting file {0}", filename);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine(who, "Writing " + whatWriting + " to {0}", filename);
|
||||
FileStream outputFs = new FileStream(filename, FileMode.CreateNew);
|
||||
var outputFs = new FileStream(filename, FileMode.CreateNew);
|
||||
outputFs.Write(data, 0, data.Length);
|
||||
outputFs.Close();
|
||||
}
|
||||
catch { AaruConsole.ErrorWriteLine("Unable to write file {0}", filename); }
|
||||
catch
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Unable to write file {0}", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,88 +32,56 @@
|
||||
|
||||
namespace Aaru.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializates a progress indicator (e.g. makes a progress bar visible)
|
||||
/// </summary>
|
||||
/// <summary>Initializates a progress indicator (e.g. makes a progress bar visible)</summary>
|
||||
public delegate void InitProgressHandler();
|
||||
|
||||
/// <summary>
|
||||
/// Updates a progress indicator with text
|
||||
/// </summary>
|
||||
/// <summary>Updates a progress indicator with text</summary>
|
||||
public delegate void UpdateProgressHandler(string text, long current, long maximum);
|
||||
|
||||
/// <summary>
|
||||
/// Pulses a progress indicator with indeterminate boundaries
|
||||
/// </summary>
|
||||
/// <summary>Pulses a progress indicator with indeterminate boundaries</summary>
|
||||
public delegate void PulseProgressHandler(string text);
|
||||
|
||||
/// <summary>
|
||||
/// Uninitializates a progress indicator (e.g. adds a newline to the console)
|
||||
/// </summary>
|
||||
/// <summary>Uninitializates a progress indicator (e.g. adds a newline to the console)</summary>
|
||||
public delegate void EndProgressHandler();
|
||||
|
||||
/// <summary>
|
||||
/// Initializates a secondary progress indicator (e.g. makes a progress bar visible)
|
||||
/// </summary>
|
||||
/// <summary>Initializates a secondary progress indicator (e.g. makes a progress bar visible)</summary>
|
||||
public delegate void InitProgressHandler2();
|
||||
|
||||
/// <summary>
|
||||
/// Updates a secondary progress indicator with text
|
||||
/// </summary>
|
||||
/// <summary>Updates a secondary progress indicator with text</summary>
|
||||
public delegate void UpdateProgressHandler2(string text, long current, long maximum);
|
||||
|
||||
/// <summary>
|
||||
/// Pulses a secondary progress indicator with indeterminate boundaries
|
||||
/// </summary>
|
||||
/// <summary>Pulses a secondary progress indicator with indeterminate boundaries</summary>
|
||||
public delegate void PulseProgressHandler2(string text);
|
||||
|
||||
/// <summary>
|
||||
/// Uninitializates a secondary progress indicator (e.g. adds a newline to the console)
|
||||
/// </summary>
|
||||
/// <summary>Uninitializates a secondary progress indicator (e.g. adds a newline to the console)</summary>
|
||||
public delegate void EndProgressHandler2();
|
||||
|
||||
/// <summary>
|
||||
/// Initializates two progress indicators (e.g. makes a progress bar visible)
|
||||
/// </summary>
|
||||
/// <summary>Initializates two progress indicators (e.g. makes a progress bar visible)</summary>
|
||||
public delegate void InitTwoProgressHandler();
|
||||
|
||||
/// <summary>
|
||||
/// Updates two progress indicators with text
|
||||
/// </summary>
|
||||
/// <summary>Updates two progress indicators with text</summary>
|
||||
public delegate void UpdateTwoProgressHandler(string text, long current, long maximum, string text2, long current2,
|
||||
long maximum2);
|
||||
long maximum2);
|
||||
|
||||
/// <summary>
|
||||
/// Pulses a progress indicator with indeterminate boundaries
|
||||
/// </summary>
|
||||
/// <summary>Pulses a progress indicator with indeterminate boundaries</summary>
|
||||
public delegate void PulseTwoProgressHandler(string text, string text2);
|
||||
|
||||
/// <summary>
|
||||
/// Uninitializates a progress indicator (e.g. adds a newline to the console)
|
||||
/// </summary>
|
||||
/// <summary>Uninitializates a progress indicator (e.g. adds a newline to the console)</summary>
|
||||
public delegate void EndTwoProgressHandler();
|
||||
|
||||
/// <summary>
|
||||
/// Updates a status indicator
|
||||
/// </summary>
|
||||
/// <summary>Updates a status indicator</summary>
|
||||
public delegate void UpdateStatusHandler(string text);
|
||||
|
||||
/// <summary>
|
||||
/// Shows an error message
|
||||
/// </summary>
|
||||
/// <summary>Shows an error message</summary>
|
||||
public delegate void ErrorMessageHandler(string text);
|
||||
|
||||
public delegate void InitBlockMapHandler(ulong blocks, ulong blockSize, ulong blocksToRead, ushort currentProfile);
|
||||
|
||||
/// <summary>
|
||||
/// Updates lists of time taken on scanning from the specified sector
|
||||
/// </summary>
|
||||
/// <summary>Updates lists of time taken on scanning from the specified sector</summary>
|
||||
/// <param name="duration">Time in milliseconds</param>
|
||||
public delegate void ScanTimeHandler(ulong sector, double duration);
|
||||
|
||||
/// <summary>
|
||||
/// Specified a number of blocks could not be read on scan
|
||||
/// </summary>
|
||||
/// <summary>Specified a number of blocks could not be read on scan</summary>
|
||||
public delegate void ScanUnreadableHandler(ulong sector);
|
||||
|
||||
public delegate void ScanSpeedHandler(ulong sector, double currentSpeed);
|
||||
|
||||
@@ -35,12 +35,12 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.PCMCIA;
|
||||
using Schemas;
|
||||
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
@@ -247,8 +247,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b,
|
||||
sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
}
|
||||
@@ -276,8 +275,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + (b * blockSize)),
|
||||
sectorSize);
|
||||
Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + (b * blockSize)), sectorSize);
|
||||
|
||||
Array.Copy(sub, subSize * b, cmdBuf, (int)(sectorSize + (b * blockSize)), subSize);
|
||||
}
|
||||
|
||||
@@ -34,14 +34,14 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.Database.Models;
|
||||
using Aaru.Decoders.CD;
|
||||
using Aaru.Devices;
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
|
||||
@@ -295,8 +295,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
for(int b = 0; b < _maximumReadable; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b,
|
||||
sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Checksums;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Devices;
|
||||
|
||||
// ReSharper disable JoinDeclarationAndInitializer
|
||||
@@ -124,7 +124,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
public static void SolveTrackPregaps(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus,
|
||||
Track[] tracks, bool supportsPqSubchannel, bool supportsRwSubchannel,
|
||||
Aaru.Database.Models.Device dbDev, out bool inexactPositioning)
|
||||
Database.Models.Device dbDev, out bool inexactPositioning)
|
||||
{
|
||||
bool sense = true; // Sense indicator
|
||||
byte[] subBuf = null;
|
||||
@@ -154,10 +154,10 @@ namespace Aaru.Core.Devices.Dumping
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", bcd == true
|
||||
? "Subchannel is BCD"
|
||||
: bcd == false
|
||||
? "Subchannel is not BCD"
|
||||
: "Could not detect drive subchannel BCD");
|
||||
? "Subchannel is BCD"
|
||||
: bcd == false
|
||||
? "Subchannel is not BCD"
|
||||
: "Could not detect drive subchannel BCD");
|
||||
|
||||
if(bcd is null)
|
||||
{
|
||||
@@ -209,8 +209,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}", lba, retries + 1,
|
||||
sense);
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "LBA: {0}, Try {1}, Sense {2}", lba,
|
||||
retries + 1, sense);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -221,10 +221,10 @@ namespace Aaru.Core.Devices.Dumping
|
||||
CRC16CCITTContext.Data(subBuf, 10, out crc);
|
||||
|
||||
AaruConsole.DebugWriteLine("Pregap calculator",
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q: {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3],
|
||||
subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9],
|
||||
subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q: {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3],
|
||||
subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9],
|
||||
subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
|
||||
crcOk = crc[0] == subBuf[10] && crc[1] == subBuf[11];
|
||||
|
||||
@@ -262,10 +262,10 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(crcOk)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator",
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2],
|
||||
subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8],
|
||||
subBuf[9], subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2],
|
||||
subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8],
|
||||
subBuf[9], subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
}
|
||||
else
|
||||
continue;
|
||||
@@ -317,10 +317,10 @@ namespace Aaru.Core.Devices.Dumping
|
||||
CRC16CCITTContext.Data(subBuf, 10, out crc);
|
||||
|
||||
AaruConsole.DebugWriteLine("Pregap calculator",
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q: {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3],
|
||||
subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9],
|
||||
subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q: {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2], subBuf[3],
|
||||
subBuf[4], subBuf[5], subBuf[6], subBuf[7], subBuf[8], subBuf[9],
|
||||
subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
|
||||
crcOk = crc[0] == subBuf[10] && crc[1] == subBuf[11];
|
||||
|
||||
@@ -358,10 +358,11 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(crcOk)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator",
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2],
|
||||
subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7],
|
||||
subBuf[8], subBuf[9], subBuf[10], subBuf[11], crc[0], crc[1]);
|
||||
"LBA: {0}, Try {1}, Sense {2}, Q (FIXED): {3:X2} {4:X2} {5:X2} {6:X2} {7:X2} {8:X2} {9:X2} {10:X2} {11:X2} {12:X2} CRC 0x{13:X2}{14:X2}, Calculated CRC: 0x{15:X2}{16:X2}",
|
||||
lba, retries + 1, sense, subBuf[0], subBuf[1], subBuf[2],
|
||||
subBuf[3], subBuf[4], subBuf[5], subBuf[6], subBuf[7],
|
||||
subBuf[8], subBuf[9], subBuf[10], subBuf[11], crc[0],
|
||||
crc[1]);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -387,18 +388,18 @@ namespace Aaru.Core.Devices.Dumping
|
||||
track.TrackType == TrackType.Audio))
|
||||
{
|
||||
dumpLog?.
|
||||
WriteLine($"Could not read subchannel for this track, supposing 150 sectors.");
|
||||
WriteLine("Could not read subchannel for this track, supposing 150 sectors.");
|
||||
|
||||
updateStatus?.
|
||||
Invoke($"Could not read subchannel for this track, supposing 150 sectors.");
|
||||
Invoke("Could not read subchannel for this track, supposing 150 sectors.");
|
||||
}
|
||||
else
|
||||
{
|
||||
dumpLog?.
|
||||
WriteLine($"Could not read subchannel for this track, supposing 0 sectors.");
|
||||
WriteLine("Could not read subchannel for this track, supposing 0 sectors.");
|
||||
|
||||
updateStatus?.
|
||||
Invoke($"Could not read subchannel for this track, supposing 0 sectors.");
|
||||
Invoke("Could not read subchannel for this track, supposing 0 sectors.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -501,7 +502,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(diff != 0)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "Invalid Q position for LBA {0}, got {1}", lba,
|
||||
posQ);
|
||||
posQ);
|
||||
|
||||
inexactPositioning = true;
|
||||
}
|
||||
@@ -513,7 +514,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(crcOk || pregapQ - pregaps[track.TrackSequence] < 10)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Pregap calculator", "Pregap for track {0}: {1}",
|
||||
track.TrackSequence, pregapQ);
|
||||
track.TrackSequence, pregapQ);
|
||||
|
||||
pregaps[track.TrackSequence] = pregapQ;
|
||||
}
|
||||
@@ -546,7 +547,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
}
|
||||
}
|
||||
|
||||
static bool GetSectorForPregapRaw(Device dev, uint lba, Aaru.Database.Models.Device dbDev, out byte[] subBuf)
|
||||
static bool GetSectorForPregapRaw(Device dev, uint lba, Database.Models.Device dbDev, out byte[] subBuf)
|
||||
{
|
||||
byte[] cmdBuf;
|
||||
bool sense;
|
||||
@@ -601,7 +602,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
return sense;
|
||||
}
|
||||
|
||||
static bool GetSectorForPregapQ16(Device dev, uint lba, Aaru.Database.Models.Device dbDev, out byte[] subBuf)
|
||||
static bool GetSectorForPregapQ16(Device dev, uint lba, Database.Models.Device dbDev, out byte[] subBuf)
|
||||
{
|
||||
byte[] cmdBuf;
|
||||
bool sense;
|
||||
|
||||
@@ -46,9 +46,9 @@ namespace Aaru.Core.Devices.Dumping
|
||||
dumpLog?.WriteLine("Checking if drive supports full raw subchannel reading...");
|
||||
updateStatus?.Invoke("Checking if drive supports full raw subchannel reading...");
|
||||
|
||||
return!dev.ReadCd(out _, out _, 0, 2352 + 96, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw, dev.Timeout,
|
||||
out _);
|
||||
return !dev.ReadCd(out _, out _, 0, 2352 + 96, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Raw,
|
||||
dev.Timeout, out _);
|
||||
}
|
||||
|
||||
public static bool SupportsPqSubchannel(Device dev, DumpLog dumpLog, UpdateStatusHandler updateStatus)
|
||||
@@ -56,9 +56,9 @@ namespace Aaru.Core.Devices.Dumping
|
||||
dumpLog?.WriteLine("Checking if drive supports PQ subchannel reading...");
|
||||
updateStatus?.Invoke("Checking if drive supports PQ subchannel reading...");
|
||||
|
||||
return!dev.ReadCd(out _, out _, 0, 2352 + 16, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Q16, dev.Timeout,
|
||||
out _);
|
||||
return !dev.ReadCd(out _, out _, 0, 2352 + 16, 1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.Q16,
|
||||
dev.Timeout, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.CD;
|
||||
using Aaru.Devices;
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Database;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
@@ -42,8 +42,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
readonly DumpSubchannel _subchannel;
|
||||
readonly bool _trim;
|
||||
bool _aborted;
|
||||
AaruContext _ctx; // Master database context
|
||||
Aaru.Database.Models.Device _dbDev; // Device database entry
|
||||
AaruContext _ctx; // Master database context
|
||||
Database.Models.Device _dbDev; // Device database entry
|
||||
bool _dumpFirstTrackPregap;
|
||||
bool _fixOffset;
|
||||
uint _maximumReadable; // Maximum number of sectors drive can read at once
|
||||
@@ -113,7 +113,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
public void Start()
|
||||
{
|
||||
// Open master database
|
||||
_ctx = AaruContext.Create(Aaru.Settings.Settings.MasterDbPath);
|
||||
_ctx = AaruContext.Create(Settings.Settings.MasterDbPath);
|
||||
|
||||
// Search for device in master database
|
||||
_dbDev = _ctx.Devices.FirstOrDefault(d => d.Manufacturer == _dev.Manufacturer && d.Model == _dev.Model &&
|
||||
|
||||
@@ -30,17 +30,12 @@
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping
|
||||
{
|
||||
public partial class Dump
|
||||
{
|
||||
public void NVMe()
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("NVMe devices not yet supported.");
|
||||
}
|
||||
public void NVMe() => StoppingErrorMessage?.Invoke("NVMe devices not yet supported.");
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
@@ -13,6 +12,7 @@ using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
@@ -622,8 +622,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
var metadata = new CommonTypes.Structs.ImageInfo
|
||||
{
|
||||
Application = "Aaru", ApplicationVersion = Version.GetVersion(),
|
||||
MediaPartNumber = mediaPartNumber
|
||||
Application = "Aaru", ApplicationVersion = Version.GetVersion(), MediaPartNumber = mediaPartNumber
|
||||
};
|
||||
|
||||
if(!_outputPlugin.SetMetadata(metadata))
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(oldTry.Software == null)
|
||||
throw new InvalidOperationException("Found corrupt resume file, cannot continue...");
|
||||
|
||||
if(oldTry.Software.Name != "Aaru" ||
|
||||
if(oldTry.Software.Name != "Aaru" ||
|
||||
oldTry.Software.OperatingSystem != platform.ToString() ||
|
||||
oldTry.Software.Version != Version.GetVersion())
|
||||
continue;
|
||||
|
||||
@@ -35,7 +35,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
@@ -44,6 +43,7 @@ using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Devices;
|
||||
using Schemas;
|
||||
|
||||
@@ -36,13 +36,13 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Xml.Serialization;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.SSC;
|
||||
using Aaru.Devices;
|
||||
|
||||
@@ -35,12 +35,12 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.MMC;
|
||||
using Schemas;
|
||||
using MediaType = Aaru.CommonTypes.MediaType;
|
||||
@@ -95,7 +95,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
ExtendedCSD ecsdDecoded = Aaru.Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
|
||||
ExtendedCSD ecsdDecoded = Decoders.MMC.Decoders.DecodeExtendedCSD(ecsd);
|
||||
blocksToRead = ecsdDecoded.OptimalReadSize;
|
||||
blocks = ecsdDecoded.SectorCount;
|
||||
blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512);
|
||||
@@ -120,7 +120,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
{
|
||||
if(blocks == 0)
|
||||
{
|
||||
CSD csdDecoded = Aaru.Decoders.MMC.Decoders.DecodeCSD(csd);
|
||||
CSD csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd);
|
||||
blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2));
|
||||
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
Aaru.Decoders.SecureDigital.CSD csdDecoded = Aaru.Decoders.SecureDigital.Decoders.DecodeCSD(csd);
|
||||
Decoders.SecureDigital.CSD csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
|
||||
|
||||
blocks = (ulong)(csdDecoded.Structure == 0
|
||||
? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Extents;
|
||||
@@ -42,6 +41,7 @@ using Aaru.CommonTypes.Interop;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.Xbox;
|
||||
|
||||
@@ -82,18 +82,18 @@ namespace Aaru.Core.Devices.Info
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}",
|
||||
errorRegisters.SectorCount);
|
||||
errorRegisters.SectorCount);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}",
|
||||
errorRegisters.CylinderHigh);
|
||||
errorRegisters.CylinderHigh);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}",
|
||||
errorRegisters.CylinderLow);
|
||||
errorRegisters.CylinderLow);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}",
|
||||
errorRegisters.DeviceHead);
|
||||
errorRegisters.DeviceHead);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
||||
|
||||
@@ -128,18 +128,18 @@ namespace Aaru.Core.Devices.Info
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.Error);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}",
|
||||
errorRegisters.SectorCount);
|
||||
errorRegisters.SectorCount);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.Sector);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}",
|
||||
errorRegisters.CylinderHigh);
|
||||
errorRegisters.CylinderHigh);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}",
|
||||
errorRegisters.CylinderLow);
|
||||
errorRegisters.CylinderLow);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}",
|
||||
errorRegisters.DeviceHead);
|
||||
errorRegisters.DeviceHead);
|
||||
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
||||
|
||||
@@ -308,20 +308,20 @@ namespace Aaru.Core.Devices.Info
|
||||
|
||||
switch(dev.Model)
|
||||
{
|
||||
case"DVDR PX-708A":
|
||||
case"DVDR PX-708A2":
|
||||
case"DVDR PX-712A":
|
||||
case "DVDR PX-708A":
|
||||
case "DVDR PX-708A2":
|
||||
case "DVDR PX-712A":
|
||||
plxtDvd = true;
|
||||
|
||||
plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout,
|
||||
out _);
|
||||
|
||||
break;
|
||||
case"DVDR PX-714A":
|
||||
case"DVDR PX-716A":
|
||||
case"DVDR PX-716AL":
|
||||
case"DVDR PX-755A":
|
||||
case"DVDR PX-760A":
|
||||
case "DVDR PX-714A":
|
||||
case "DVDR PX-716A":
|
||||
case "DVDR PX-716AL":
|
||||
case "DVDR PX-755A":
|
||||
case "DVDR PX-760A":
|
||||
{
|
||||
plxtBuf = new byte[256 * 4];
|
||||
|
||||
@@ -514,22 +514,22 @@ namespace Aaru.Core.Devices.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
{
|
||||
DensitySupport = seqBuf;
|
||||
DensitySupportHeader = Aaru.Decoders.SCSI.SSC.DensitySupport.DecodeDensity(seqBuf);
|
||||
DensitySupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeDensity(seqBuf);
|
||||
}
|
||||
|
||||
sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, true, false, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.ErrorWriteLine("REPORT DENSITY SUPPORT (MEDIUM):\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
{
|
||||
MediumDensitySupport = seqBuf;
|
||||
MediaTypeSupportHeader = Aaru.Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(seqBuf);
|
||||
MediaTypeSupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(seqBuf);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Aaru.Core.Devices
|
||||
(uint, byte, byte) GetDeviceChs()
|
||||
{
|
||||
if(dev.Type != DeviceType.ATA)
|
||||
return(0, 0, 0);
|
||||
return (0, 0, 0);
|
||||
|
||||
if(ataId.CurrentCylinders > 0 &&
|
||||
ataId.CurrentHeads > 0 &&
|
||||
@@ -78,14 +78,14 @@ namespace Aaru.Core.Devices
|
||||
ataId.Cylinders <= 0 ||
|
||||
ataId.Heads <= 0 ||
|
||||
ataId.SectorsPerTrack <= 0)
|
||||
return(Cylinders, Heads, Sectors);
|
||||
return (Cylinders, Heads, Sectors);
|
||||
|
||||
Cylinders = ataId.Cylinders;
|
||||
Heads = (byte)ataId.Heads;
|
||||
Sectors = (byte)ataId.SectorsPerTrack;
|
||||
Blocks = (ulong)(Cylinders * Heads * Sectors);
|
||||
|
||||
return(Cylinders, Heads, Sectors);
|
||||
return (Cylinders, Heads, Sectors);
|
||||
}
|
||||
|
||||
ulong AtaGetBlocks()
|
||||
@@ -333,8 +333,7 @@ namespace Aaru.Core.Devices
|
||||
}
|
||||
else if(ataReadDmaRetryLba)
|
||||
{
|
||||
sense = dev.ReadDma(out buffer, out errorLba, true, (uint)block, (byte)count, timeout,
|
||||
out duration);
|
||||
sense = dev.ReadDma(out buffer, out errorLba, true, (uint)block, (byte)count, timeout, out duration);
|
||||
|
||||
error = !(!sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && buffer.Length > 0);
|
||||
status = errorLba.Status;
|
||||
@@ -342,8 +341,7 @@ namespace Aaru.Core.Devices
|
||||
}
|
||||
else if(ataReadDmaLba)
|
||||
{
|
||||
sense = dev.ReadDma(out buffer, out errorLba, false, (uint)block, (byte)count, timeout,
|
||||
out duration);
|
||||
sense = dev.ReadDma(out buffer, out errorLba, false, (uint)block, (byte)count, timeout, out duration);
|
||||
|
||||
error = !(!sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0 && buffer.Length > 0);
|
||||
status = errorLba.Status;
|
||||
@@ -381,8 +379,7 @@ namespace Aaru.Core.Devices
|
||||
|
||||
if(ataReadDmaRetry)
|
||||
{
|
||||
sense = dev.ReadDma(out buffer, out errorChs, true, cylinder, head, sectir, 1, timeout,
|
||||
out duration);
|
||||
sense = dev.ReadDma(out buffer, out errorChs, true, cylinder, head, sectir, 1, timeout, out duration);
|
||||
|
||||
error = !(!sense && (errorChs.Status & 0x27) == 0 && errorChs.Error == 0 && buffer.Length > 0);
|
||||
status = errorChs.Status;
|
||||
@@ -390,8 +387,7 @@ namespace Aaru.Core.Devices
|
||||
}
|
||||
else if(ataReadDma)
|
||||
{
|
||||
sense = dev.ReadDma(out buffer, out errorChs, false, cylinder, head, sectir, 1, timeout,
|
||||
out duration);
|
||||
sense = dev.ReadDma(out buffer, out errorChs, false, cylinder, head, sectir, 1, timeout, out duration);
|
||||
|
||||
error = !(!sense && (errorChs.Status & 0x27) == 0 && errorChs.Error == 0 && buffer.Length > 0);
|
||||
status = errorChs.Status;
|
||||
@@ -422,14 +418,14 @@ namespace Aaru.Core.Devices
|
||||
{
|
||||
bool sense = dev.Seek(out AtaErrorRegistersLba28 errorLba, (uint)block, timeout, out duration);
|
||||
|
||||
return!(!sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0);
|
||||
return !(!sense && (errorLba.Status & 0x27) == 0 && errorLba.Error == 0);
|
||||
}
|
||||
|
||||
bool AtaSeekChs(ushort cylinder, byte head, byte sector, out double duration)
|
||||
{
|
||||
bool sense = dev.Seek(out AtaErrorRegistersChs errorChs, cylinder, head, sector, timeout, out duration);
|
||||
|
||||
return!(!sense && (errorChs.Status & 0x27) == 0 && errorChs.Error == 0);
|
||||
return !(!sense && (errorChs.Status & 0x27) == 0 && errorChs.Error == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,11 +376,11 @@ namespace Aaru.Core.Devices
|
||||
{
|
||||
switch(dev.Manufacturer)
|
||||
{
|
||||
case"HL-DT-ST":
|
||||
case "HL-DT-ST":
|
||||
hldtstReadRaw = !dev.HlDtStReadRawDvd(out _, out senseBuf, 0, 1, timeout, out _);
|
||||
|
||||
break;
|
||||
case"PLEXTOR":
|
||||
case "PLEXTOR":
|
||||
plextorReadRaw = !dev.PlextorReadRawDvd(out _, out senseBuf, 0, 1, timeout, out _);
|
||||
|
||||
break;
|
||||
|
||||
@@ -183,8 +183,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadSectorsData = readBuf;
|
||||
|
||||
@@ -195,8 +195,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadSectorsRetryData = readBuf;
|
||||
|
||||
@@ -207,8 +207,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaData = readBuf;
|
||||
|
||||
@@ -219,8 +219,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaRetryData = readBuf;
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Aaru.Core.Devices.Report
|
||||
mediaTest.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
|
||||
errorChs.Status, errorChs.Error);
|
||||
errorChs.Status, errorChs.Error);
|
||||
|
||||
AaruConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
|
||||
sense = _dev.Read(out readBuf, out AtaErrorRegistersLba28 errorLba, false, 0, 1, _dev.Timeout, out _);
|
||||
@@ -238,8 +238,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLbaData = readBuf;
|
||||
|
||||
@@ -250,8 +250,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadRetryLbaData = readBuf;
|
||||
|
||||
@@ -262,8 +262,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaLbaData = readBuf;
|
||||
|
||||
@@ -274,8 +274,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaRetryLbaData = readBuf;
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace Aaru.Core.Devices.Report
|
||||
mediaTest.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
|
||||
errorChs.Status, errorChs.Error);
|
||||
errorChs.Status, errorChs.Error);
|
||||
|
||||
AaruConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
|
||||
sense = _dev.Read(out readBuf, out AtaErrorRegistersLba48 errorLba48, 0, 1, _dev.Timeout, out _);
|
||||
@@ -293,8 +293,8 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLba48Data = readBuf;
|
||||
|
||||
@@ -305,8 +305,8 @@ namespace Aaru.Core.Devices.Report
|
||||
errorLba48.Error == 0 && readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadDmaLba48Data = readBuf;
|
||||
|
||||
@@ -340,8 +340,8 @@ namespace Aaru.Core.Devices.Report
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongData = readBuf;
|
||||
|
||||
@@ -356,8 +356,8 @@ namespace Aaru.Core.Devices.Report
|
||||
checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongRetryData = readBuf;
|
||||
|
||||
@@ -371,8 +371,8 @@ namespace Aaru.Core.Devices.Report
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongLbaData = readBuf;
|
||||
|
||||
@@ -386,8 +386,8 @@ namespace Aaru.Core.Devices.Report
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report",
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
"Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense,
|
||||
errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
mediaTest.ReadLongRetryLbaData = readBuf;
|
||||
}
|
||||
@@ -523,7 +523,7 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadSectorsData = readBuf;
|
||||
|
||||
@@ -534,7 +534,7 @@ namespace Aaru.Core.Devices.Report
|
||||
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadSectorsRetryData = readBuf;
|
||||
|
||||
@@ -545,7 +545,7 @@ namespace Aaru.Core.Devices.Report
|
||||
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadDmaData = readBuf;
|
||||
|
||||
@@ -556,7 +556,7 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadDmaRetryData = readBuf;
|
||||
|
||||
@@ -565,7 +565,7 @@ namespace Aaru.Core.Devices.Report
|
||||
capabilities.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
|
||||
errorChs.Status, errorChs.Error);
|
||||
errorChs.Status, errorChs.Error);
|
||||
|
||||
AaruConsole.WriteLine("Trying READ SECTOR(S) in LBA mode...");
|
||||
sense = _dev.Read(out readBuf, out AtaErrorRegistersLba28 errorLba, false, 0, 1, _dev.Timeout, out _);
|
||||
@@ -574,7 +574,7 @@ namespace Aaru.Core.Devices.Report
|
||||
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadLbaData = readBuf;
|
||||
|
||||
@@ -585,7 +585,7 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadRetryLbaData = readBuf;
|
||||
|
||||
@@ -596,7 +596,7 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadDmaLbaData = readBuf;
|
||||
|
||||
@@ -607,7 +607,7 @@ namespace Aaru.Core.Devices.Report
|
||||
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadDmaRetryLbaData = readBuf;
|
||||
|
||||
@@ -616,7 +616,7 @@ namespace Aaru.Core.Devices.Report
|
||||
capabilities.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}", sense,
|
||||
errorLba.Status, errorLba.Error);
|
||||
errorLba.Status, errorLba.Error);
|
||||
|
||||
AaruConsole.WriteLine("Trying READ SECTOR(S) in LBA48 mode...");
|
||||
sense = _dev.Read(out readBuf, out AtaErrorRegistersLba48 errorLba48, 0, 1, _dev.Timeout, out _);
|
||||
@@ -625,7 +625,7 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba48.Status, errorLba48.Error, readBuf.Length);
|
||||
sense, errorLba48.Status, errorLba48.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadLba48Data = readBuf;
|
||||
|
||||
@@ -636,7 +636,7 @@ namespace Aaru.Core.Devices.Report
|
||||
readBuf.Length > 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba48.Status, errorLba48.Error, readBuf.Length);
|
||||
sense, errorLba48.Status, errorLba48.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadDmaLba48Data = readBuf;
|
||||
|
||||
@@ -671,7 +671,7 @@ namespace Aaru.Core.Devices.Report
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadLongData = readBuf;
|
||||
|
||||
@@ -686,7 +686,7 @@ namespace Aaru.Core.Devices.Report
|
||||
checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
sense, errorChs.Status, errorChs.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadLongRetryData = readBuf;
|
||||
|
||||
@@ -700,7 +700,7 @@ namespace Aaru.Core.Devices.Report
|
||||
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadLongLbaData = readBuf;
|
||||
|
||||
@@ -715,7 +715,7 @@ namespace Aaru.Core.Devices.Report
|
||||
checkCorrectRead;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Report", "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}",
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
sense, errorLba.Status, errorLba.Error, readBuf.Length);
|
||||
|
||||
capabilities.ReadLongRetryLbaData = readBuf;
|
||||
|
||||
|
||||
@@ -718,8 +718,8 @@ namespace Aaru.Core.Devices.Report
|
||||
|
||||
switch(mediaType)
|
||||
{
|
||||
case"DVD-ROM":
|
||||
case"HD DVD-ROM":
|
||||
case "DVD-ROM":
|
||||
case "HD DVD-ROM":
|
||||
AaruConsole.WriteLine("Querying DVD BCA...");
|
||||
|
||||
mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
@@ -743,8 +743,8 @@ namespace Aaru.Core.Devices.Report
|
||||
mediaTest.DvdAacsData = buffer;
|
||||
|
||||
break;
|
||||
case"Nintendo GameCube game":
|
||||
case"Nintendo Wii game":
|
||||
case "Nintendo GameCube game":
|
||||
case "Nintendo Wii game":
|
||||
AaruConsole.WriteLine("Querying DVD BCA...");
|
||||
|
||||
mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
@@ -757,12 +757,12 @@ namespace Aaru.Core.Devices.Report
|
||||
mediaTest.DvdBcaData = buffer;
|
||||
|
||||
break;
|
||||
case"BD-ROM":
|
||||
case"Ultra HD Blu-ray movie":
|
||||
case"PlayStation 3 game":
|
||||
case"PlayStation 4 game":
|
||||
case"Xbox One game":
|
||||
case"Nintendo Wii U game":
|
||||
case "BD-ROM":
|
||||
case "Ultra HD Blu-ray movie":
|
||||
case "PlayStation 3 game":
|
||||
case "PlayStation 4 game":
|
||||
case "Xbox One game":
|
||||
case "Nintendo Wii U game":
|
||||
AaruConsole.WriteLine("Querying BD BCA...");
|
||||
|
||||
mediaTest.CanReadBCA = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
@@ -775,10 +775,10 @@ namespace Aaru.Core.Devices.Report
|
||||
mediaTest.BluBcaData = buffer;
|
||||
|
||||
break;
|
||||
case"DVD-RAM (1st gen, marked 2.6Gb or 5.2Gb)":
|
||||
case"DVD-RAM (2nd gen, marked 4.7Gb or 9.4Gb)":
|
||||
case"HD DVD-RAM":
|
||||
case"PD-650":
|
||||
case "DVD-RAM (1st gen, marked 2.6Gb or 5.2Gb)":
|
||||
case "DVD-RAM (2nd gen, marked 4.7Gb or 9.4Gb)":
|
||||
case "HD DVD-RAM":
|
||||
case "PD-650":
|
||||
mediaTest.CanReadDDS = !_dev.ReadDiscStructure(out buffer, out senseBuffer,
|
||||
MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdramDds, 0, _dev.Timeout,
|
||||
@@ -1284,7 +1284,7 @@ namespace Aaru.Core.Devices.Report
|
||||
out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadCorrectedSubchannelWithC2);
|
||||
!mediaTest.CanReadCorrectedSubchannelWithC2);
|
||||
|
||||
mediaTest.CorrectedSubchannelWithC2Data = buffer;
|
||||
}
|
||||
@@ -1393,7 +1393,7 @@ namespace Aaru.Core.Devices.Report
|
||||
out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadCorrectedSubchannelWithC2);
|
||||
!mediaTest.CanReadCorrectedSubchannelWithC2);
|
||||
|
||||
mediaTest.CorrectedSubchannelWithC2Data = buffer;
|
||||
}
|
||||
@@ -1500,7 +1500,7 @@ namespace Aaru.Core.Devices.Report
|
||||
out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadCorrectedSubchannelWithC2);
|
||||
!mediaTest.CanReadCorrectedSubchannelWithC2);
|
||||
|
||||
mediaTest.CorrectedSubchannelWithC2Data = buffer;
|
||||
}
|
||||
@@ -1665,13 +1665,13 @@ namespace Aaru.Core.Devices.Report
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report",
|
||||
"First session Lead-Out starts at {0:D2}:{1:D2}:{2:D2}",
|
||||
firstSessionLeadOutTrack.PMIN, firstSessionLeadOutTrack.PSEC,
|
||||
firstSessionLeadOutTrack.PFRAME);
|
||||
"First session Lead-Out starts at {0:D2}:{1:D2}:{2:D2}",
|
||||
firstSessionLeadOutTrack.PMIN, firstSessionLeadOutTrack.PSEC,
|
||||
firstSessionLeadOutTrack.PFRAME);
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Second session starts at {0:D2}:{1:D2}:{2:D2}",
|
||||
secondSessionFirstTrack.PMIN, secondSessionFirstTrack.PSEC,
|
||||
secondSessionFirstTrack.PFRAME);
|
||||
secondSessionFirstTrack.PMIN, secondSessionFirstTrack.PSEC,
|
||||
secondSessionFirstTrack.PFRAME);
|
||||
|
||||
// Skip Lead-Out pre-gap
|
||||
uint firstSessionLeadOutLba = (uint)((firstSessionLeadOutTrack.PMIN * 60 * 75) +
|
||||
@@ -1715,7 +1715,7 @@ namespace Aaru.Core.Devices.Report
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadingIntersessionLeadOut);
|
||||
!mediaTest.CanReadingIntersessionLeadOut);
|
||||
|
||||
mediaTest.IntersessionLeadOutData = buffer;
|
||||
|
||||
@@ -1750,7 +1750,7 @@ namespace Aaru.Core.Devices.Report
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadingIntersessionLeadIn);
|
||||
!mediaTest.CanReadingIntersessionLeadIn);
|
||||
|
||||
mediaTest.IntersessionLeadInData = buffer;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||
using Aaru.Core.Logging;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning
|
||||
{
|
||||
|
||||
@@ -39,34 +39,19 @@ namespace Aaru.Core.Devices.Scanning
|
||||
}
|
||||
}
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
aborted = true;
|
||||
}
|
||||
public void Abort() => aborted = true;
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when the progress bar is not longer needed
|
||||
/// </summary>
|
||||
/// <summary>Event raised when the progress bar is not longer needed</summary>
|
||||
public event EndProgressHandler EndProgress;
|
||||
/// <summary>
|
||||
/// Event raised when a progress bar is needed
|
||||
/// </summary>
|
||||
/// <summary>Event raised when a progress bar is needed</summary>
|
||||
public event InitProgressHandler InitProgress;
|
||||
/// <summary>
|
||||
/// Event raised to report status updates
|
||||
/// </summary>
|
||||
/// <summary>Event raised to report status updates</summary>
|
||||
public event UpdateStatusHandler UpdateStatus;
|
||||
/// <summary>
|
||||
/// Event raised to report a fatal error that stops the dumping operation and should call user's attention
|
||||
/// </summary>
|
||||
/// <summary>Event raised to report a fatal error that stops the dumping operation and should call user's attention</summary>
|
||||
public event ErrorMessageHandler StoppingErrorMessage;
|
||||
/// <summary>
|
||||
/// Event raised to update the values of a determinate progress bar
|
||||
/// </summary>
|
||||
/// <summary>Event raised to update the values of a determinate progress bar</summary>
|
||||
public event UpdateProgressHandler UpdateProgress;
|
||||
/// <summary>
|
||||
/// Event raised to update the status of an undeterminate progress bar
|
||||
/// </summary>
|
||||
/// <summary>Event raised to update the status of an undeterminate progress bar</summary>
|
||||
public event PulseProgressHandler PulseProgress;
|
||||
public event ScanTimeHandler ScanTime;
|
||||
public event ScanUnreadableHandler ScanUnreadable;
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Aaru.Core.Devices.Scanning
|
||||
ScanResults Nvme()
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("NVMe devices not yet supported.");
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.CD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
|
||||
@@ -34,82 +34,44 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the results of a media scan
|
||||
/// </summary>
|
||||
/// <summary>Contains the results of a media scan</summary>
|
||||
public struct ScanResults
|
||||
{
|
||||
/// <summary>
|
||||
/// Total time spent scanning
|
||||
/// </summary>
|
||||
/// <summary>Total time spent scanning</summary>
|
||||
public double TotalTime;
|
||||
/// <summary>
|
||||
/// Total time spent by the device processing commands
|
||||
/// </summary>
|
||||
/// <summary>Total time spent by the device processing commands</summary>
|
||||
public double ProcessingTime;
|
||||
/// <summary>
|
||||
/// Average scan speed
|
||||
/// </summary>
|
||||
/// <summary>Average scan speed</summary>
|
||||
public double AvgSpeed;
|
||||
/// <summary>
|
||||
/// Maximum scan speed burst
|
||||
/// </summary>
|
||||
/// <summary>Maximum scan speed burst</summary>
|
||||
public double MaxSpeed;
|
||||
/// <summary>
|
||||
/// Minimum scan speed
|
||||
/// </summary>
|
||||
/// <summary>Minimum scan speed</summary>
|
||||
public double MinSpeed;
|
||||
/// <summary>
|
||||
/// Sectors that took less than 3 milliseconds to be processed
|
||||
/// </summary>
|
||||
/// <summary>Sectors that took less than 3 milliseconds to be processed</summary>
|
||||
public ulong A;
|
||||
/// <summary>
|
||||
/// Sectors that took less than 10 milliseconds but more than 3 milliseconds to be processed
|
||||
/// </summary>
|
||||
/// <summary>Sectors that took less than 10 milliseconds but more than 3 milliseconds to be processed</summary>
|
||||
public ulong B;
|
||||
/// <summary>
|
||||
/// Sectors that took less than 50 milliseconds but more than 10 milliseconds to be processed
|
||||
/// </summary>
|
||||
/// <summary>Sectors that took less than 50 milliseconds but more than 10 milliseconds to be processed</summary>
|
||||
public ulong C;
|
||||
/// <summary>
|
||||
/// Sectors that took less than 150 milliseconds but more than 50 milliseconds to be processed
|
||||
/// </summary>
|
||||
/// <summary>Sectors that took less than 150 milliseconds but more than 50 milliseconds to be processed</summary>
|
||||
public ulong D;
|
||||
/// <summary>
|
||||
/// Sectors that took less than 500 milliseconds but more than 150 milliseconds to be processed
|
||||
/// </summary>
|
||||
/// <summary>Sectors that took less than 500 milliseconds but more than 150 milliseconds to be processed</summary>
|
||||
public ulong E;
|
||||
/// <summary>
|
||||
/// Sectors that took more than 500 milliseconds to be processed
|
||||
/// </summary>
|
||||
/// <summary>Sectors that took more than 500 milliseconds to be processed</summary>
|
||||
public ulong F;
|
||||
/// <summary>
|
||||
/// List of sectors that could not be read
|
||||
/// </summary>
|
||||
/// <summary>List of sectors that could not be read</summary>
|
||||
public List<ulong> UnreadableSectors;
|
||||
/// <summary>
|
||||
/// Slowest seek
|
||||
/// </summary>
|
||||
/// <summary>Slowest seek</summary>
|
||||
public double SeekMax;
|
||||
/// <summary>
|
||||
/// Fastest seek
|
||||
/// </summary>
|
||||
/// <summary>Fastest seek</summary>
|
||||
public double SeekMin;
|
||||
/// <summary>
|
||||
/// Total time spent seeking
|
||||
/// </summary>
|
||||
/// <summary>Total time spent seeking</summary>
|
||||
public double SeekTotal;
|
||||
/// <summary>
|
||||
/// How many seeks have been done
|
||||
/// </summary>
|
||||
/// <summary>How many seeks have been done</summary>
|
||||
public int SeekTimes;
|
||||
/// <summary>
|
||||
/// How many blocks were scanned
|
||||
/// </summary>
|
||||
/// <summary>How many blocks were scanned</summary>
|
||||
public ulong Blocks;
|
||||
/// <summary>
|
||||
/// How many blocks could not be read
|
||||
/// </summary>
|
||||
/// <summary>How many blocks could not be read</summary>
|
||||
public ulong Errored;
|
||||
}
|
||||
}
|
||||
@@ -32,22 +32,20 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Decoders.MMC;
|
||||
|
||||
namespace Aaru.Core.Devices.Scanning
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements scanning a SecureDigital or MultiMediaCard flash card
|
||||
/// </summary>
|
||||
/// <summary>Implements scanning a SecureDigital or MultiMediaCard flash card</summary>
|
||||
public partial class MediaScan
|
||||
{
|
||||
ScanResults SecureDigital()
|
||||
{
|
||||
ScanResults results = new ScanResults();
|
||||
byte[] cmdBuf;
|
||||
bool sense;
|
||||
var results = new ScanResults();
|
||||
byte[] cmdBuf;
|
||||
bool sense;
|
||||
results.Blocks = 0;
|
||||
const uint TIMEOUT = 5;
|
||||
double duration;
|
||||
@@ -61,12 +59,14 @@ namespace Aaru.Core.Devices.Scanning
|
||||
case DeviceType.MMC:
|
||||
{
|
||||
sense = dev.ReadExtendedCsd(out cmdBuf, out _, TIMEOUT, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
ExtendedCSD ecsd = Aaru.Decoders.MMC.Decoders.DecodeExtendedCSD(cmdBuf);
|
||||
ExtendedCSD ecsd = Decoders.MMC.Decoders.DecodeExtendedCSD(cmdBuf);
|
||||
blocksToRead = ecsd.OptimalReadSize;
|
||||
results.Blocks = ecsd.SectorCount;
|
||||
blockSize = (uint)(ecsd.SectorSize == 1 ? 4096 : 512);
|
||||
|
||||
// Supposing it's high-capacity MMC if it has Extended CSD...
|
||||
byteAddressed = false;
|
||||
}
|
||||
@@ -74,9 +74,10 @@ namespace Aaru.Core.Devices.Scanning
|
||||
if(sense || results.Blocks == 0)
|
||||
{
|
||||
sense = dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
CSD csd = Aaru.Decoders.MMC.Decoders.DecodeCSD(cmdBuf);
|
||||
CSD csd = Decoders.MMC.Decoders.DecodeCSD(cmdBuf);
|
||||
results.Blocks = (ulong)((csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2));
|
||||
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
|
||||
}
|
||||
@@ -88,13 +89,17 @@ namespace Aaru.Core.Devices.Scanning
|
||||
case DeviceType.SecureDigital:
|
||||
{
|
||||
sense = dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
Aaru.Decoders.SecureDigital.CSD csd = Aaru.Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
|
||||
Decoders.SecureDigital.CSD csd = Decoders.SecureDigital.Decoders.DecodeCSD(cmdBuf);
|
||||
|
||||
results.Blocks = (ulong)(csd.Structure == 0
|
||||
? (csd.Size + 1) * Math.Pow(2, csd.SizeMultiplier + 2)
|
||||
: (csd.Size + 1) * 1024);
|
||||
|
||||
blockSize = (uint)Math.Pow(2, csd.ReadBlockLength);
|
||||
|
||||
// Structure >=1 for SDHC/SDXC, so that's block addressed
|
||||
byteAddressed = csd.Structure == 0;
|
||||
}
|
||||
@@ -106,6 +111,7 @@ namespace Aaru.Core.Devices.Scanning
|
||||
if(results.Blocks == 0)
|
||||
{
|
||||
StoppingErrorMessage?.Invoke("Unable to get device size.");
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -113,14 +119,18 @@ namespace Aaru.Core.Devices.Scanning
|
||||
{
|
||||
sense = dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, TIMEOUT, out duration);
|
||||
|
||||
if(sense) blocksToRead /= 2;
|
||||
if(sense)
|
||||
blocksToRead /= 2;
|
||||
|
||||
if(!sense || blocksToRead == 1) break;
|
||||
if(!sense ||
|
||||
blocksToRead == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
if(sense)
|
||||
{
|
||||
StoppingErrorMessage?.Invoke($"Device error {dev.LastError} trying to guess ideal transfer length.");
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -143,27 +153,35 @@ namespace Aaru.Core.Devices.Scanning
|
||||
results.SeekTotal = 0;
|
||||
const int SEEK_TIMES = 1000;
|
||||
|
||||
Random rnd = new Random();
|
||||
var rnd = new Random();
|
||||
|
||||
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
|
||||
|
||||
InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, SD_PROFILE);
|
||||
MhddLog mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
|
||||
IbgLog ibgLog = new IbgLog(ibgLogPath, SD_PROFILE);
|
||||
var mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
|
||||
var ibgLog = new IbgLog(ibgLogPath, SD_PROFILE);
|
||||
|
||||
start = DateTime.UtcNow;
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
ulong sectorSpeedStart = 0;
|
||||
InitProgress?.Invoke();
|
||||
|
||||
for(ulong i = 0; i < results.Blocks; i += blocksToRead)
|
||||
{
|
||||
if(aborted) break;
|
||||
if(aborted)
|
||||
break;
|
||||
|
||||
if(results.Blocks - i < blocksToRead) blocksToRead = (byte)(results.Blocks - i);
|
||||
if(results.Blocks - i < blocksToRead)
|
||||
blocksToRead = (byte)(results.Blocks - i);
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(currentSpeed > results.MaxSpeed && currentSpeed != 0) results.MaxSpeed = currentSpeed;
|
||||
if(currentSpeed < results.MinSpeed && currentSpeed != 0) results.MinSpeed = currentSpeed;
|
||||
if(currentSpeed > results.MaxSpeed &&
|
||||
currentSpeed != 0)
|
||||
results.MaxSpeed = currentSpeed;
|
||||
|
||||
if(currentSpeed < results.MinSpeed &&
|
||||
currentSpeed != 0)
|
||||
results.MinSpeed = currentSpeed;
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
|
||||
UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", (long)i,
|
||||
@@ -174,12 +192,18 @@ namespace Aaru.Core.Devices.Scanning
|
||||
|
||||
if(!error)
|
||||
{
|
||||
if(duration >= 500) results.F += blocksToRead;
|
||||
else if(duration >= 150) results.E += blocksToRead;
|
||||
else if(duration >= 50) results.D += blocksToRead;
|
||||
else if(duration >= 10) results.C += blocksToRead;
|
||||
else if(duration >= 3) results.B += blocksToRead;
|
||||
else results.A += blocksToRead;
|
||||
if(duration >= 500)
|
||||
results.F += blocksToRead;
|
||||
else if(duration >= 150)
|
||||
results.E += blocksToRead;
|
||||
else if(duration >= 50)
|
||||
results.D += blocksToRead;
|
||||
else if(duration >= 10)
|
||||
results.C += blocksToRead;
|
||||
else if(duration >= 3)
|
||||
results.B += blocksToRead;
|
||||
else
|
||||
results.A += blocksToRead;
|
||||
|
||||
ScanTime?.Invoke(i, duration);
|
||||
mhddLog.Write(i, duration);
|
||||
@@ -189,7 +213,9 @@ namespace Aaru.Core.Devices.Scanning
|
||||
{
|
||||
ScanUnreadable?.Invoke(i);
|
||||
results.Errored += blocksToRead;
|
||||
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
|
||||
|
||||
for(ulong b = i; b < i + blocksToRead; b++)
|
||||
results.UnreadableSectors.Add(b);
|
||||
|
||||
mhddLog.Write(i, duration < 500 ? 65535 : duration);
|
||||
|
||||
@@ -199,10 +225,12 @@ namespace Aaru.Core.Devices.Scanning
|
||||
sectorSpeedStart += blocksToRead;
|
||||
|
||||
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds;
|
||||
if(elapsed < 1) continue;
|
||||
|
||||
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
|
||||
ScanSpeed?.Invoke(i, currentSpeed * 1024);
|
||||
if(elapsed < 1)
|
||||
continue;
|
||||
|
||||
currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed);
|
||||
ScanSpeed?.Invoke(i, currentSpeed * 1024);
|
||||
sectorSpeedStart = 0;
|
||||
timeSpeedStart = DateTime.UtcNow;
|
||||
}
|
||||
@@ -210,14 +238,18 @@ namespace Aaru.Core.Devices.Scanning
|
||||
end = DateTime.UtcNow;
|
||||
EndProgress?.Invoke();
|
||||
mhddLog.Close();
|
||||
|
||||
ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
||||
blockSize * (double)(results.Blocks + 1) / 1024 /
|
||||
(results.ProcessingTime / 1000), devicePath);
|
||||
(blockSize * (double)(results.Blocks + 1)) / 1024 /
|
||||
(results.ProcessingTime / 1000),
|
||||
devicePath);
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
for(int i = 0; i < SEEK_TIMES; i++)
|
||||
{
|
||||
if(aborted) break;
|
||||
if(aborted)
|
||||
break;
|
||||
|
||||
uint seekPos = (uint)rnd.Next((int)results.Blocks);
|
||||
|
||||
@@ -227,8 +259,13 @@ namespace Aaru.Core.Devices.Scanning
|
||||
out double seekCur);
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(seekCur > results.SeekMax && seekCur != 0) results.SeekMax = seekCur;
|
||||
if(seekCur < results.SeekMin && seekCur != 0) results.SeekMin = seekCur;
|
||||
if(seekCur > results.SeekMax &&
|
||||
seekCur != 0)
|
||||
results.SeekMax = seekCur;
|
||||
|
||||
if(seekCur < results.SeekMin &&
|
||||
seekCur != 0)
|
||||
results.SeekMin = seekCur;
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
|
||||
results.SeekTotal += seekCur;
|
||||
@@ -239,7 +276,7 @@ namespace Aaru.Core.Devices.Scanning
|
||||
|
||||
results.ProcessingTime /= 1000;
|
||||
results.TotalTime = (end - start).TotalSeconds;
|
||||
results.AvgSpeed = blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime;
|
||||
results.AvgSpeed = (blockSize * (double)(results.Blocks + 1)) / 1048576 / results.ProcessingTime;
|
||||
results.SeekTimes = SEEK_TIMES;
|
||||
|
||||
return results;
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace Aaru.Core
|
||||
{
|
||||
public class Entropy
|
||||
{
|
||||
bool debug;
|
||||
IMediaImage inputFormat;
|
||||
bool verbose;
|
||||
readonly bool debug;
|
||||
readonly IMediaImage inputFormat;
|
||||
bool verbose;
|
||||
|
||||
public Entropy(bool debug, bool verbose, IMediaImage inputFormat)
|
||||
{
|
||||
@@ -67,6 +67,7 @@ namespace Aaru.Core
|
||||
if(!(inputFormat is IOpticalMediaImage opticalMediaImage))
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("The selected image does not support tracks.");
|
||||
|
||||
return entropyResultses.ToArray();
|
||||
}
|
||||
|
||||
@@ -78,46 +79,56 @@ namespace Aaru.Core
|
||||
|
||||
foreach(Track currentTrack in inputTracks)
|
||||
{
|
||||
EntropyResults trackEntropy = new EntropyResults {Track = currentTrack.TrackSequence, Entropy = 0};
|
||||
UpdateProgressEvent
|
||||
?.Invoke($"Entropying track {currentTrack.TrackSequence} of {inputTracks.Max(t => t.TrackSequence)}",
|
||||
var trackEntropy = new EntropyResults
|
||||
{
|
||||
Track = currentTrack.TrackSequence, Entropy = 0
|
||||
};
|
||||
|
||||
UpdateProgressEvent?.
|
||||
Invoke($"Entropying track {currentTrack.TrackSequence} of {inputTracks.Max(t => t.TrackSequence)}",
|
||||
currentTrack.TrackSequence, inputTracks.Max(t => t.TrackSequence));
|
||||
|
||||
ulong[] entTable = new ulong[256];
|
||||
ulong trackSize = 0;
|
||||
List<string> uniqueSectorsPerTrack = new List<string>();
|
||||
|
||||
trackEntropy.Sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
|
||||
trackEntropy.Sectors = (currentTrack.TrackEndSector - currentTrack.TrackStartSector) + 1;
|
||||
|
||||
AaruConsole.VerboseWriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence,
|
||||
trackEntropy.Sectors);
|
||||
trackEntropy.Sectors);
|
||||
|
||||
InitProgress2Event?.Invoke();
|
||||
|
||||
for(ulong i = currentTrack.TrackStartSector; i <= currentTrack.TrackEndSector; i++)
|
||||
{
|
||||
UpdateProgress2Event
|
||||
?.Invoke($"Entropying sector {i + 1} of track {currentTrack.TrackSequence}",
|
||||
UpdateProgress2Event?.
|
||||
Invoke($"Entropying sector {i + 1} of track {currentTrack.TrackSequence}",
|
||||
(long)(currentTrack.TrackEndSector - (i + 1)),
|
||||
(long)trackEntropy.Sectors);
|
||||
|
||||
byte[] sector = opticalMediaImage.ReadSector(i, currentTrack.TrackSequence);
|
||||
|
||||
if(duplicatedSectors)
|
||||
{
|
||||
string sectorHash = Sha1Context.Data(sector, out _);
|
||||
if(!uniqueSectorsPerTrack.Contains(sectorHash)) uniqueSectorsPerTrack.Add(sectorHash);
|
||||
|
||||
if(!uniqueSectorsPerTrack.Contains(sectorHash))
|
||||
uniqueSectorsPerTrack.Add(sectorHash);
|
||||
}
|
||||
|
||||
foreach(byte b in sector) entTable[b]++;
|
||||
foreach(byte b in sector)
|
||||
entTable[b]++;
|
||||
|
||||
trackSize += (ulong)sector.LongLength;
|
||||
}
|
||||
|
||||
EndProgress2Event?.Invoke();
|
||||
|
||||
trackEntropy.Entropy += entTable.Select(l => (double)l / (double)trackSize)
|
||||
.Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
|
||||
trackEntropy.Entropy += entTable.Select(l => (double)l / (double)trackSize).
|
||||
Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
|
||||
|
||||
if(duplicatedSectors) trackEntropy.UniqueSectors = uniqueSectorsPerTrack.Count;
|
||||
if(duplicatedSectors)
|
||||
trackEntropy.UniqueSectors = uniqueSectorsPerTrack.Count;
|
||||
|
||||
entropyResultses.Add(trackEntropy);
|
||||
}
|
||||
@@ -126,8 +137,10 @@ namespace Aaru.Core
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
if(debug) AaruConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
|
||||
else AaruConsole.ErrorWriteLine("Unable to get separate tracks, not calculating their entropy");
|
||||
if(debug)
|
||||
AaruConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
|
||||
else
|
||||
AaruConsole.ErrorWriteLine("Unable to get separate tracks, not calculating their entropy");
|
||||
}
|
||||
|
||||
return entropyResultses.ToArray();
|
||||
@@ -135,14 +148,19 @@ namespace Aaru.Core
|
||||
|
||||
public EntropyResults CalculateMediaEntropy(bool duplicatedSectors)
|
||||
{
|
||||
EntropyResults entropy = new EntropyResults {Entropy = 0};
|
||||
ulong[] entTable = new ulong[256];
|
||||
ulong diskSize = 0;
|
||||
List<string> uniqueSectors = new List<string>();
|
||||
var entropy = new EntropyResults
|
||||
{
|
||||
Entropy = 0
|
||||
};
|
||||
|
||||
ulong[] entTable = new ulong[256];
|
||||
ulong diskSize = 0;
|
||||
List<string> uniqueSectors = new List<string>();
|
||||
|
||||
entropy.Sectors = inputFormat.Info.Sectors;
|
||||
AaruConsole.WriteLine("Sectors {0}", entropy.Sectors);
|
||||
InitProgressEvent?.Invoke();
|
||||
|
||||
for(ulong i = 0; i < entropy.Sectors; i++)
|
||||
{
|
||||
UpdateProgressEvent?.Invoke($"Entropying sector {i + 1}", (long)(i + 1), (long)entropy.Sectors);
|
||||
@@ -151,20 +169,24 @@ namespace Aaru.Core
|
||||
if(duplicatedSectors)
|
||||
{
|
||||
string sectorHash = Sha1Context.Data(sector, out _);
|
||||
if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash);
|
||||
|
||||
if(!uniqueSectors.Contains(sectorHash))
|
||||
uniqueSectors.Add(sectorHash);
|
||||
}
|
||||
|
||||
foreach(byte b in sector) entTable[b]++;
|
||||
foreach(byte b in sector)
|
||||
entTable[b]++;
|
||||
|
||||
diskSize += (ulong)sector.LongLength;
|
||||
}
|
||||
|
||||
EndProgressEvent?.Invoke();
|
||||
|
||||
entropy.Entropy += entTable.Select(l => (double)l / (double)diskSize)
|
||||
.Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
|
||||
entropy.Entropy += entTable.Select(l => (double)l / (double)diskSize).
|
||||
Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
|
||||
|
||||
if(duplicatedSectors) entropy.UniqueSectors = uniqueSectors.Count;
|
||||
if(duplicatedSectors)
|
||||
entropy.UniqueSectors = uniqueSectors.Count;
|
||||
|
||||
return entropy;
|
||||
}
|
||||
|
||||
@@ -8,15 +8,14 @@ namespace Aaru.Core
|
||||
{
|
||||
public static string Print(int errno)
|
||||
{
|
||||
switch (DetectOS.GetRealPlatformID())
|
||||
switch(DetectOS.GetRealPlatformID())
|
||||
{
|
||||
case PlatformID.Win32S:
|
||||
case PlatformID.Win32Windows:
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.WinCE:
|
||||
case PlatformID.WindowsPhone:
|
||||
case PlatformID.Xbox:
|
||||
return PrintWin32Error(errno);
|
||||
case PlatformID.Xbox: return PrintWin32Error(errno);
|
||||
case PlatformID.Unix:
|
||||
case PlatformID.MacOSX:
|
||||
case PlatformID.iOS:
|
||||
@@ -41,32 +40,24 @@ namespace Aaru.Core
|
||||
case PlatformID.Ultrix:
|
||||
case PlatformID.OpenServer:
|
||||
case PlatformID.UnixWare:
|
||||
case PlatformID.zOS:
|
||||
return PrintUnixError(errno);
|
||||
case PlatformID.Wii:
|
||||
return $"Unknown error code {errno}";
|
||||
case PlatformID.WiiU:
|
||||
return $"Unknown error code {errno}";
|
||||
case PlatformID.PlayStation3:
|
||||
return $"Unknown error code {errno}";
|
||||
case PlatformID.PlayStation4:
|
||||
return $"Unknown error code {errno}";
|
||||
case PlatformID.NonStop:
|
||||
return $"Unknown error code {errno}";
|
||||
case PlatformID.Unknown:
|
||||
return $"Unknown error code {errno}";
|
||||
default:
|
||||
return $"Unknown error code {errno}";
|
||||
case PlatformID.zOS: return PrintUnixError(errno);
|
||||
case PlatformID.Wii: return $"Unknown error code {errno}";
|
||||
case PlatformID.WiiU: return $"Unknown error code {errno}";
|
||||
case PlatformID.PlayStation3: return $"Unknown error code {errno}";
|
||||
case PlatformID.PlayStation4: return $"Unknown error code {errno}";
|
||||
case PlatformID.NonStop: return $"Unknown error code {errno}";
|
||||
case PlatformID.Unknown: return $"Unknown error code {errno}";
|
||||
default: return $"Unknown error code {errno}";
|
||||
}
|
||||
|
||||
throw new Exception("Arrived an unexpected place");
|
||||
}
|
||||
|
||||
private static string PrintUnixError(int errno)
|
||||
static string PrintUnixError(int errno)
|
||||
{
|
||||
switch (errno)
|
||||
switch(errno)
|
||||
{
|
||||
case 2: // ENOENT
|
||||
case 2: // ENOENT
|
||||
case 19: // ENODEV
|
||||
return "The specified device cannot be found.";
|
||||
case 13: // EACCESS
|
||||
@@ -75,14 +66,13 @@ namespace Aaru.Core
|
||||
return "The specified device is in use by another process.";
|
||||
case 30: // EROFS
|
||||
return "Cannot open the device in writable mode, as needed by some commands.";
|
||||
default:
|
||||
return $"Unknown error code {errno}";
|
||||
default: return $"Unknown error code {errno}";
|
||||
}
|
||||
}
|
||||
|
||||
private static string PrintWin32Error(int errno)
|
||||
static string PrintWin32Error(int errno)
|
||||
{
|
||||
switch (errno)
|
||||
switch(errno)
|
||||
{
|
||||
case 2: // ERROR_FILE_NOT_FOUND
|
||||
case 3: // ERROR_PATH_NOT_FOUND
|
||||
@@ -91,15 +81,14 @@ namespace Aaru.Core
|
||||
return "Not enough permissions to open the device.";
|
||||
case 19: // ERROR_WRITE_PROTECT
|
||||
return "Cannot open the device in writable mode, as needed by some commands.";
|
||||
case 32: // ERROR_SHARING_VIOLATION
|
||||
case 33: // ERROR_LOCK_VIOLATION
|
||||
case 32: // ERROR_SHARING_VIOLATION
|
||||
case 33: // ERROR_LOCK_VIOLATION
|
||||
case 108: // ERROR_DRIVE_LOCKED
|
||||
case 170: // ERROR_BUSY
|
||||
return "The specified device is in use by another process.";
|
||||
case 130: // ERROR_DIRECT_ACCESS_HANDLE
|
||||
return "Tried to open a file instead of a device.";
|
||||
default:
|
||||
return $"Unknown error code {errno}";
|
||||
default: return $"Unknown error code {errno}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace Aaru.Core
|
||||
{
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
|
||||
idPlugins = (from plugin in plugins.PluginsList.Values
|
||||
where plugin.Identify(imagePlugin, partition)
|
||||
idPlugins = (from plugin in plugins.PluginsList.Values where plugin.Identify(imagePlugin, partition)
|
||||
select plugin.Name.ToLower()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ namespace Aaru.Core
|
||||
{
|
||||
get
|
||||
{
|
||||
PluginBase instance = new PluginBase();
|
||||
var instance = new PluginBase();
|
||||
|
||||
IPluginRegister checksumRegister = new Register();
|
||||
IPluginRegister imagesRegister = new Aaru.DiscImages.Register();
|
||||
IPluginRegister imagesRegister = new DiscImages.Register();
|
||||
IPluginRegister filesystemsRegister = new Aaru.Filesystems.Register();
|
||||
IPluginRegister filtersRegister = new Aaru.Filters.Register();
|
||||
IPluginRegister filtersRegister = new Filters.Register();
|
||||
IPluginRegister partitionsRegister = new Aaru.Partitions.Register();
|
||||
|
||||
instance.AddPlugins(checksumRegister);
|
||||
|
||||
@@ -40,9 +40,7 @@ namespace Aaru.Core
|
||||
{
|
||||
public static class ImageFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// Detects the image plugin that recognizes the data inside a filter
|
||||
/// </summary>
|
||||
/// <summary>Detects the image plugin that recognizes the data inside a filter</summary>
|
||||
/// <param name="imageFilter">Filter</param>
|
||||
/// <returns>Detected image plugin</returns>
|
||||
public static IMediaImage Detect(IFilter imageFilter)
|
||||
@@ -62,9 +60,12 @@ namespace Aaru.Core
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imageplugin.Name);
|
||||
if(!imageplugin.Identify(imageFilter)) continue;
|
||||
|
||||
if(!imageplugin.Identify(imageFilter))
|
||||
continue;
|
||||
|
||||
imageFormat = imageplugin;
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
@@ -73,7 +74,8 @@ namespace Aaru.Core
|
||||
// ignored
|
||||
}
|
||||
|
||||
if(imageFormat != null) return imageFormat;
|
||||
if(imageFormat != null)
|
||||
return imageFormat;
|
||||
|
||||
// Check only RAW plugin
|
||||
foreach(IMediaImage imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin =>
|
||||
@@ -84,9 +86,12 @@ namespace Aaru.Core
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imageplugin.Name);
|
||||
if(!imageplugin.Identify(imageFilter)) continue;
|
||||
|
||||
if(!imageplugin.Identify(imageFilter))
|
||||
continue;
|
||||
|
||||
imageFormat = imageplugin;
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
@@ -98,7 +103,10 @@ namespace Aaru.Core
|
||||
// Still not recognized
|
||||
return imageFormat;
|
||||
}
|
||||
catch { return null; }
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,15 +68,16 @@ namespace Aaru.Core
|
||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.Application) &&
|
||||
!string.IsNullOrWhiteSpace(imageFormat.Info.ApplicationVersion))
|
||||
AaruConsole.WriteLine("Was created with {0} version {1}", imageFormat.Info.Application,
|
||||
imageFormat.Info.ApplicationVersion);
|
||||
imageFormat.Info.ApplicationVersion);
|
||||
else if(!string.IsNullOrWhiteSpace(imageFormat.Info.Application))
|
||||
AaruConsole.WriteLine("Was created with {0}", imageFormat.Info.Application);
|
||||
|
||||
AaruConsole.WriteLine("Image without headers is {0} bytes long", imageFormat.Info.ImageSize);
|
||||
|
||||
AaruConsole.WriteLine("Contains a media of {0} sectors with a maximum sector size of {1} bytes (if all sectors are of the same size this would be {2} bytes)",
|
||||
imageFormat.Info.Sectors, imageFormat.Info.SectorSize,
|
||||
imageFormat.Info.Sectors * imageFormat.Info.SectorSize);
|
||||
AaruConsole.
|
||||
WriteLine("Contains a media of {0} sectors with a maximum sector size of {1} bytes (if all sectors are of the same size this would be {2} bytes)",
|
||||
imageFormat.Info.Sectors, imageFormat.Info.SectorSize,
|
||||
imageFormat.Info.Sectors * imageFormat.Info.SectorSize);
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.Creator))
|
||||
AaruConsole.WriteLine("Created by: {0}", imageFormat.Info.Creator);
|
||||
@@ -88,7 +89,7 @@ namespace Aaru.Core
|
||||
AaruConsole.WriteLine("Last modified on {0}", imageFormat.Info.LastModificationTime);
|
||||
|
||||
AaruConsole.WriteLine("Contains a media of type {0} and XML type {1}", imageFormat.Info.MediaType,
|
||||
imageFormat.Info.XmlMediaType);
|
||||
imageFormat.Info.XmlMediaType);
|
||||
|
||||
AaruConsole.WriteLine("{0} partitions", imageFormat.Info.HasPartitions ? "Has" : "Doesn't have");
|
||||
AaruConsole.WriteLine("{0} sessions", imageFormat.Info.HasSessions ? "Has" : "Doesn't have");
|
||||
@@ -99,7 +100,7 @@ namespace Aaru.Core
|
||||
if(imageFormat.Info.MediaSequence != 0 &&
|
||||
imageFormat.Info.LastMediaSequence != 0)
|
||||
AaruConsole.WriteLine("Media is number {0} on a set of {1} medias", imageFormat.Info.MediaSequence,
|
||||
imageFormat.Info.LastMediaSequence);
|
||||
imageFormat.Info.LastMediaSequence);
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(imageFormat.Info.MediaTitle))
|
||||
AaruConsole.WriteLine("Media title: {0}", imageFormat.Info.MediaTitle);
|
||||
@@ -137,8 +138,8 @@ namespace Aaru.Core
|
||||
imageFormat.Info.XmlMediaType != XmlMediaType.OpticalDisc &&
|
||||
(!(imageFormat is ITapeImage tapeImage) || !tapeImage.IsTape))
|
||||
AaruConsole.WriteLine("Media geometry: {0} cylinders, {1} heads, {2} sectors per track",
|
||||
imageFormat.Info.Cylinders, imageFormat.Info.Heads,
|
||||
imageFormat.Info.SectorsPerTrack);
|
||||
imageFormat.Info.Cylinders, imageFormat.Info.Heads,
|
||||
imageFormat.Info.SectorsPerTrack);
|
||||
|
||||
if(imageFormat.Info.ReadableMediaTags != null &&
|
||||
imageFormat.Info.ReadableMediaTags.Count > 0)
|
||||
@@ -339,7 +340,7 @@ namespace Aaru.Core
|
||||
byte[] mcn = imageFormat.ReadDiskTag(MediaTagType.CD_MCN);
|
||||
|
||||
AaruConsole.WriteLine("CompactDisc Media Catalogue Number contained in image: {0}",
|
||||
Encoding.UTF8.GetString(mcn));
|
||||
Encoding.UTF8.GetString(mcn));
|
||||
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
@@ -390,7 +391,7 @@ namespace Aaru.Core
|
||||
byte[] dds = imageFormat.ReadDiskTag(MediaTagType.BD_DDS);
|
||||
|
||||
AaruConsole.WriteLine("Bluray Disc Definition Structure contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.Bluray.DDS.Prettify(dds));
|
||||
AaruConsole.Write("{0}", Decoders.Bluray.DDS.Prettify(dds));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -456,12 +457,12 @@ namespace Aaru.Core
|
||||
case TupleCodes.CISTPL_SWIL:
|
||||
case TupleCodes.CISTPL_VERS_2:
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "Found undecoded tuple ID {0}",
|
||||
tuple.Code);
|
||||
tuple.Code);
|
||||
|
||||
break;
|
||||
default:
|
||||
AaruConsole.DebugWriteLine("Device-Info command", "Found unknown tuple ID 0x{0:X2}",
|
||||
(byte)tuple.Code);
|
||||
(byte)tuple.Code);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -475,7 +476,7 @@ namespace Aaru.Core
|
||||
byte[] cid = imageFormat.ReadDiskTag(MediaTagType.SD_CID);
|
||||
|
||||
AaruConsole.WriteLine("SecureDigital CID contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.SecureDigital.Decoders.PrettifyCID(cid));
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCID(cid));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -485,7 +486,7 @@ namespace Aaru.Core
|
||||
byte[] csd = imageFormat.ReadDiskTag(MediaTagType.SD_CSD);
|
||||
|
||||
AaruConsole.WriteLine("SecureDigital CSD contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.SecureDigital.Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -495,7 +496,7 @@ namespace Aaru.Core
|
||||
byte[] scr = imageFormat.ReadDiskTag(MediaTagType.SD_SCR);
|
||||
|
||||
AaruConsole.WriteLine("SecureDigital SCR contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.SecureDigital.Decoders.PrettifySCR(scr));
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifySCR(scr));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -505,7 +506,7 @@ namespace Aaru.Core
|
||||
byte[] ocr = imageFormat.ReadDiskTag(MediaTagType.SD_OCR);
|
||||
|
||||
AaruConsole.WriteLine("SecureDigital OCR contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.SecureDigital.Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -515,7 +516,7 @@ namespace Aaru.Core
|
||||
byte[] cid = imageFormat.ReadDiskTag(MediaTagType.MMC_CID);
|
||||
|
||||
AaruConsole.WriteLine("MultiMediaCard CID contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyCID(cid));
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCID(cid));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -525,7 +526,7 @@ namespace Aaru.Core
|
||||
byte[] csd = imageFormat.ReadDiskTag(MediaTagType.MMC_CSD);
|
||||
|
||||
AaruConsole.WriteLine("MultiMediaCard CSD contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCSD(csd));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -535,7 +536,7 @@ namespace Aaru.Core
|
||||
byte[] ecsd = imageFormat.ReadDiskTag(MediaTagType.MMC_ExtendedCSD);
|
||||
|
||||
AaruConsole.WriteLine("MultiMediaCard ExtendedCSD contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd));
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -545,7 +546,7 @@ namespace Aaru.Core
|
||||
byte[] ocr = imageFormat.ReadDiskTag(MediaTagType.MMC_OCR);
|
||||
|
||||
AaruConsole.WriteLine("MultiMediaCard OCR contained in image:");
|
||||
AaruConsole.Write("{0}", Aaru.Decoders.MMC.Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyOCR(ocr));
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
|
||||
@@ -609,14 +610,14 @@ namespace Aaru.Core
|
||||
AaruConsole.WriteLine("Image sessions:");
|
||||
|
||||
AaruConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", "Session", "First track",
|
||||
"Last track", "Start", "End");
|
||||
"Last track", "Start", "End");
|
||||
|
||||
AaruConsole.WriteLine("=========================================================");
|
||||
|
||||
foreach(Session session in opticalImage.Sessions)
|
||||
AaruConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", session.SessionSequence,
|
||||
session.StartTrack, session.EndTrack, session.StartSector,
|
||||
session.EndSector);
|
||||
session.StartTrack, session.EndTrack, session.StartSector,
|
||||
session.EndSector);
|
||||
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
@@ -634,16 +635,16 @@ namespace Aaru.Core
|
||||
AaruConsole.WriteLine("Image tracks:");
|
||||
|
||||
AaruConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}", "Track", "Type",
|
||||
"Bps", "Raw bps", "Subchannel", "Pregap", "Start", "End");
|
||||
"Bps", "Raw bps", "Subchannel", "Pregap", "Start", "End");
|
||||
|
||||
AaruConsole.
|
||||
WriteLine("=================================================================================");
|
||||
|
||||
foreach(Track track in opticalImage.Tracks)
|
||||
AaruConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}",
|
||||
track.TrackSequence, track.TrackType, track.TrackBytesPerSector,
|
||||
track.TrackRawBytesPerSector, track.TrackSubchannelType,
|
||||
track.TrackPregap, track.TrackStartSector, track.TrackEndSector);
|
||||
track.TrackSequence, track.TrackType, track.TrackBytesPerSector,
|
||||
track.TrackRawBytesPerSector, track.TrackSubchannelType,
|
||||
track.TrackPregap, track.TrackStartSector, track.TrackEndSector);
|
||||
|
||||
AaruConsole.WriteLine();
|
||||
}
|
||||
@@ -724,7 +725,7 @@ namespace Aaru.Core
|
||||
AaruConsole.WriteLine("Dump hardware information:");
|
||||
|
||||
AaruConsole.WriteLine(format, MANUFACTURER_STRING, MODEL_STRING, SERIAL_STRING, SOFTWARE_STRING,
|
||||
VERSION_STRING, OS_STRING, START_STRING, END_STRING);
|
||||
VERSION_STRING, OS_STRING, START_STRING, END_STRING);
|
||||
|
||||
AaruConsole.WriteLine(new string(separator));
|
||||
|
||||
@@ -732,8 +733,8 @@ namespace Aaru.Core
|
||||
{
|
||||
foreach(ExtentType extent in dump.Extents)
|
||||
AaruConsole.WriteLine(format, dump.Manufacturer, dump.Model, dump.Serial, dump.Software.Name,
|
||||
dump.Software.Version, dump.Software.OperatingSystem, extent.Start,
|
||||
extent.End);
|
||||
dump.Software.Version, dump.Software.OperatingSystem, extent.Start,
|
||||
extent.End);
|
||||
}
|
||||
|
||||
AaruConsole.WriteLine();
|
||||
|
||||
@@ -836,7 +836,7 @@ namespace Aaru.Core.Media.Detection
|
||||
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("Media-info Command", "PlayStation 2 boot sectors SHA256: {0}",
|
||||
ps2BootSectorsHash);
|
||||
ps2BootSectorsHash);
|
||||
|
||||
if(ps2BootSectorsHash == PS2_PAL_HASH ||
|
||||
ps2BootSectorsHash == PS2_NTSC_HASH ||
|
||||
@@ -942,7 +942,7 @@ namespace Aaru.Core.Media.Detection
|
||||
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
|
||||
|
||||
AaruConsole.DebugWriteLine("Media-info Command", "PlayStation 2 boot sectors SHA256: {0}",
|
||||
ps2BootSectorsHash);
|
||||
ps2BootSectorsHash);
|
||||
|
||||
if(ps2BootSectorsHash == PS2_PAL_HASH ||
|
||||
ps2BootSectorsHash == PS2_NTSC_HASH ||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.Database.Models;
|
||||
using Aaru.Decoders.CD;
|
||||
using Aaru.Devices;
|
||||
@@ -125,17 +125,18 @@ namespace Aaru.Core.Media.Info
|
||||
// Clear cache
|
||||
for(int i = 0; i < 63; i++)
|
||||
{
|
||||
sense = dev.ReadCd(out _, out _, (uint)(wantedLba + 3 + (16 * i)), sectorSize, 16, MmcSectorTypes.AllTypes, false,
|
||||
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
sense = dev.ReadCd(out _, out _, (uint)(wantedLba + 3 + (16 * i)), sectorSize, 16,
|
||||
MmcSectorTypes.AllTypes, false, false, false,
|
||||
MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
if(sense || dev.Error)
|
||||
break;
|
||||
}
|
||||
|
||||
sense = dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda, false,
|
||||
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
|
||||
MmcSubchannel.None, dev.Timeout, out _);
|
||||
sense = dev.ReadCd(out cmdBuf, out _, wantedLba, sectorSize, 3, MmcSectorTypes.Cdda,
|
||||
false, false, false, MmcHeaderCodes.None, true, false,
|
||||
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
|
||||
|
||||
for(int i = 0; i < cmdBuf.Length - sectorSync.Length; i++)
|
||||
{
|
||||
|
||||
@@ -34,11 +34,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.Decoders.CD;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
@@ -133,7 +133,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Error testing unit was ready:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ namespace Aaru.Core.Media.Info
|
||||
else
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Error testing unit was ready:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
MediaInserted = true;
|
||||
|
||||
DeviceInfo = new Devices.Info.DeviceInfo(dev);
|
||||
DeviceInfo = new DeviceInfo(dev);
|
||||
|
||||
byte scsiMediumType = 0;
|
||||
byte scsiDensityCode = 0;
|
||||
@@ -240,7 +240,7 @@ namespace Aaru.Core.Media.Info
|
||||
!seqBuf.SequenceEqual(medBuf))
|
||||
{
|
||||
DensitySupport = seqBuf;
|
||||
DensitySupportHeader = Aaru.Decoders.SCSI.SSC.DensitySupport.DecodeDensity(seqBuf);
|
||||
DensitySupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeDensity(seqBuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ namespace Aaru.Core.Media.Info
|
||||
!seqBuf.SequenceEqual(medBuf))
|
||||
{
|
||||
MediaTypeSupport = medBuf;
|
||||
MediaTypeSupportHeader = Aaru.Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(seqBuf);
|
||||
MediaTypeSupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(seqBuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ GET CONFIGURATION:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -287,7 +287,7 @@ namespace Aaru.Core.Media.Info
|
||||
Features.SeparatedFeatures ftr = Features.Separate(cmdBuf);
|
||||
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "GET CONFIGURATION current profile is {0:X4}h",
|
||||
ftr.CurrentProfile);
|
||||
ftr.CurrentProfile);
|
||||
|
||||
switch(ftr.CurrentProfile)
|
||||
{
|
||||
@@ -451,8 +451,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Recognized Format Layers\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Recognized Format Layers\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
RecognizedFormatLayers = cmdBuf;
|
||||
|
||||
@@ -460,8 +460,9 @@ namespace Aaru.Core.Media.Info
|
||||
MmcDiscStructureFormat.WriteProtectionStatus, 0, dev.Timeout, out _);
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Write Protection Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Write Protection Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
WriteProtectionStatus = cmdBuf;
|
||||
|
||||
@@ -499,7 +500,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -579,7 +580,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DMI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -612,7 +613,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: CMI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdCmi = cmdBuf;
|
||||
}
|
||||
@@ -629,7 +630,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: BCA\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdBca = cmdBuf;
|
||||
|
||||
@@ -638,7 +639,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD AACS\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdAacs = cmdBuf;
|
||||
|
||||
@@ -653,7 +654,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DDS\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdRamDds = cmdBuf;
|
||||
|
||||
@@ -662,7 +663,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Medium Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdRamCartridgeStatus = cmdBuf;
|
||||
|
||||
@@ -672,7 +673,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: SAI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdRamSpareArea = cmdBuf;
|
||||
|
||||
@@ -687,8 +688,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Last-Out Border RMD\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Last-Out Border RMD\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
LastBorderOutRmd = cmdBuf;
|
||||
|
||||
@@ -765,7 +766,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Pre-Recorded Info\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdPreRecordedInfo = cmdBuf;
|
||||
}
|
||||
@@ -783,7 +784,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD-R Media ID\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrMediaIdentifier = cmdBuf;
|
||||
|
||||
@@ -793,7 +794,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD-R PFI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrPhysicalInformation = cmdBuf;
|
||||
|
||||
@@ -810,7 +811,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: ADIP\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdPlusAdip = cmdBuf;
|
||||
|
||||
@@ -819,7 +820,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DCB\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdPlusDcb = cmdBuf;
|
||||
|
||||
@@ -834,7 +835,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: HD DVD CMI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
HddvdCopyrightInformation = cmdBuf;
|
||||
|
||||
@@ -850,8 +851,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: HD DVD-R Medium Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: HD DVD-R Medium Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
HddvdrMediumStatus = cmdBuf;
|
||||
|
||||
@@ -860,7 +861,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Last RMD\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
HddvdrLastRmd = cmdBuf;
|
||||
}
|
||||
@@ -877,7 +878,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Layer Capacity\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrLayerCapacity = cmdBuf;
|
||||
}
|
||||
@@ -892,8 +893,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Middle Zone Start\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Middle Zone Start\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrDlMiddleZoneStart = cmdBuf;
|
||||
|
||||
@@ -902,8 +903,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Jump Interval Size\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Jump Interval Size\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrDlJumpIntervalSize = cmdBuf;
|
||||
|
||||
@@ -913,8 +914,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Manual Layer Jump Start LBA\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Manual Layer Jump Start LBA\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrDlManualLayerJumpStartLba = cmdBuf;
|
||||
|
||||
@@ -923,8 +924,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Remap Anchor Point\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Remap Anchor Point\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdrDlRemapAnchorPoint = cmdBuf;
|
||||
|
||||
@@ -942,7 +943,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayDiscInformation = cmdBuf;
|
||||
|
||||
@@ -951,7 +952,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PAC\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayPac = cmdBuf;
|
||||
|
||||
@@ -968,7 +969,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: BCA\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayBurstCuttingArea = cmdBuf;
|
||||
|
||||
@@ -985,7 +986,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DDS\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayDds = cmdBuf;
|
||||
|
||||
@@ -994,8 +995,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Cartridge Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Cartridge Status\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayCartridgeStatus = cmdBuf;
|
||||
|
||||
@@ -1005,8 +1006,8 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command",
|
||||
"READ DISC STRUCTURE: Spare Area Information\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
"READ DISC STRUCTURE: Spare Area Information\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BluraySpareAreaInformation = cmdBuf;
|
||||
|
||||
@@ -1015,7 +1016,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Raw DFL\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayRawDfl = cmdBuf;
|
||||
|
||||
@@ -1024,7 +1025,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 001b\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayTrackResources = cmdBuf;
|
||||
|
||||
@@ -1033,7 +1034,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 010b\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
BlurayPowResources = cmdBuf;
|
||||
|
||||
@@ -1053,7 +1054,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(tocSense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: TOC\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1071,7 +1072,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: ATIP\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1094,7 +1095,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 000b\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1121,12 +1122,12 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Session info\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
Session = cmdBuf;
|
||||
DecodedSession = Aaru.Decoders.CD.Session.Decode(cmdBuf);
|
||||
DecodedSession = Decoders.CD.Session.Decode(cmdBuf);
|
||||
|
||||
if(DecodedSession.HasValue)
|
||||
{
|
||||
@@ -1140,7 +1141,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Raw TOC\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1173,7 +1174,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: PMA\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
Pma = cmdBuf;
|
||||
|
||||
@@ -1182,7 +1183,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: CD-TEXT\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1227,7 +1228,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1260,7 +1261,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DMI\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
DvdDmi = cmdBuf;
|
||||
}
|
||||
@@ -1272,7 +1273,7 @@ namespace Aaru.Core.Media.Info
|
||||
if(sense)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "READ MEDIA SERIAL NUMBER\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1300,7 +1301,7 @@ namespace Aaru.Core.Media.Info
|
||||
|
||||
if(sense)
|
||||
AaruConsole.DebugWriteLine("Media-Info command", "KREON EXTRACT SS:\n{0}",
|
||||
Sense.PrettifySense(senseBuf));
|
||||
Sense.PrettifySense(senseBuf));
|
||||
else
|
||||
XboxSecuritySector = cmdBuf;
|
||||
|
||||
@@ -1340,7 +1341,7 @@ namespace Aaru.Core.Media.Info
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Dump-media command", "Video partition total size: {0} sectors",
|
||||
totalSize);
|
||||
totalSize);
|
||||
|
||||
ulong l0Video = (PFI.Decode(cmdBuf).Value.Layer0EndPSN -
|
||||
PFI.Decode(cmdBuf).Value.DataAreaStartPSN) + 1;
|
||||
@@ -1371,7 +1372,7 @@ namespace Aaru.Core.Media.Info
|
||||
(ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) + 1;
|
||||
|
||||
AaruConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors",
|
||||
gameSize);
|
||||
gameSize);
|
||||
|
||||
// Get middle zone size
|
||||
AaruConsole.DebugWriteLine("Dump-media command", "Getting middle zone size");
|
||||
@@ -1406,7 +1407,7 @@ namespace Aaru.Core.Media.Info
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors",
|
||||
totalSize);
|
||||
totalSize);
|
||||
|
||||
ulong middleZone =
|
||||
(totalSize -
|
||||
@@ -1505,7 +1506,7 @@ namespace Aaru.Core.Media.Info
|
||||
public Dictionary<byte, string> Isrcs { get; }
|
||||
public bool MediaInserted { get; }
|
||||
public MediaType MediaType { get; }
|
||||
public Devices.Info.DeviceInfo DeviceInfo { get; }
|
||||
public DeviceInfo DeviceInfo { get; }
|
||||
public byte[] ReadCapacity { get; }
|
||||
public ulong Blocks { get; }
|
||||
public uint BlockSize { get; }
|
||||
|
||||
@@ -46,9 +46,10 @@ namespace Aaru.Core
|
||||
bool inValue = false;
|
||||
string name = null;
|
||||
string value;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if(options == null) return parsed;
|
||||
if(options == null)
|
||||
return parsed;
|
||||
|
||||
for(int index = 0; index < options.Length; index++)
|
||||
{
|
||||
@@ -58,31 +59,40 @@ namespace Aaru.Core
|
||||
{
|
||||
case '\\' when !escaped:
|
||||
escaped = true;
|
||||
|
||||
break;
|
||||
case '"' when !escaped:
|
||||
quoted = !quoted;
|
||||
|
||||
break;
|
||||
case '=' when quoted:
|
||||
sb.Append(c);
|
||||
|
||||
break;
|
||||
case '=':
|
||||
name = sb.ToString().ToLower(CultureInfo.CurrentCulture);
|
||||
sb = new StringBuilder();
|
||||
inValue = true;
|
||||
|
||||
break;
|
||||
case ',' when quoted:
|
||||
sb.Append(c);
|
||||
|
||||
break;
|
||||
case ',' when inValue:
|
||||
value = sb.ToString();
|
||||
sb = new StringBuilder();
|
||||
inValue = false;
|
||||
|
||||
if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) continue;
|
||||
if(string.IsNullOrEmpty(name) ||
|
||||
string.IsNullOrEmpty(value))
|
||||
continue;
|
||||
|
||||
if(parsed.ContainsKey(name)) parsed.Remove(name);
|
||||
if(parsed.ContainsKey(name))
|
||||
parsed.Remove(name);
|
||||
|
||||
parsed.Add(name, value);
|
||||
|
||||
break;
|
||||
default:
|
||||
if(escaped)
|
||||
@@ -91,76 +101,96 @@ namespace Aaru.Core
|
||||
case 'a':
|
||||
sb.Append('\a');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case 'b':
|
||||
sb.Append('\b');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case 'f':
|
||||
sb.Append('\f');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case 'n':
|
||||
sb.Append('\n');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case 'r':
|
||||
sb.Append('\r');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case 't':
|
||||
sb.Append('\t');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case 'v':
|
||||
sb.Append('\v');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case '\\':
|
||||
sb.Append('\\');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case '\'':
|
||||
sb.Append('\'');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case '"':
|
||||
sb.Append('"');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case '0':
|
||||
sb.Append('\0');
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
case 'u':
|
||||
string unicode = options.Substring(index + 1, 4);
|
||||
sb.Append((char)int.Parse(unicode, NumberStyles.HexNumber));
|
||||
escaped = false;
|
||||
index += 4;
|
||||
|
||||
break;
|
||||
case 'U':
|
||||
string longUnicode = options.Substring(index + 1, 8);
|
||||
sb.Append((char)int.Parse(longUnicode, NumberStyles.HexNumber));
|
||||
escaped = false;
|
||||
index += 8;
|
||||
|
||||
break;
|
||||
default:
|
||||
sb.Append(c);
|
||||
escaped = false;
|
||||
|
||||
break;
|
||||
}
|
||||
else sb.Append(c);
|
||||
else
|
||||
sb.Append(c);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!inValue) return parsed;
|
||||
if(!inValue)
|
||||
return parsed;
|
||||
|
||||
value = sb.ToString();
|
||||
|
||||
if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) return parsed;
|
||||
if(string.IsNullOrEmpty(name) ||
|
||||
string.IsNullOrEmpty(value))
|
||||
return parsed;
|
||||
|
||||
if(parsed.ContainsKey(name)) parsed.Remove(name);
|
||||
if(parsed.ContainsKey(name))
|
||||
parsed.Remove(name);
|
||||
|
||||
parsed.Add(name, value);
|
||||
|
||||
|
||||
@@ -40,14 +40,10 @@ using Aaru.Partitions;
|
||||
|
||||
namespace Aaru.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements methods for handling partitions
|
||||
/// </summary>
|
||||
/// <summary>Implements methods for handling partitions</summary>
|
||||
public static class Partitions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of all partitions present in the specified image
|
||||
/// </summary>
|
||||
/// <summary>Gets a list of all partitions present in the specified image</summary>
|
||||
/// <param name="image">Image</param>
|
||||
/// <returns>List of found partitions</returns>
|
||||
public static List<Partition> GetAll(IMediaImage image)
|
||||
@@ -57,8 +53,8 @@ namespace Aaru.Core
|
||||
List<Partition> childPartitions = new List<Partition>();
|
||||
List<ulong> checkedLocations = new List<ulong>();
|
||||
|
||||
ITapeImage tapeImage = image as ITapeImage;
|
||||
IPartitionableMediaImage partitionableImage = image as IPartitionableMediaImage;
|
||||
var tapeImage = image as ITapeImage;
|
||||
var partitionableImage = image as IPartitionableMediaImage;
|
||||
|
||||
// Create partitions from image files
|
||||
if(tapeImage?.Files != null)
|
||||
@@ -68,12 +64,14 @@ namespace Aaru.Core
|
||||
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, tapeFile.FirstBlock))
|
||||
{
|
||||
foundPartitions.AddRange(partitions);
|
||||
|
||||
AaruConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", partitionPlugin.Name,
|
||||
tapeFile.FirstBlock);
|
||||
tapeFile.FirstBlock);
|
||||
}
|
||||
|
||||
checkedLocations.Add(tapeFile.FirstBlock);
|
||||
}
|
||||
|
||||
// Getting all partitions from device (e.g. tracks)
|
||||
else if(partitionableImage?.Partitions != null)
|
||||
foreach(Partition imagePartition in partitionableImage.Partitions)
|
||||
@@ -82,12 +80,14 @@ namespace Aaru.Core
|
||||
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, imagePartition.Start))
|
||||
{
|
||||
foundPartitions.AddRange(partitions);
|
||||
|
||||
AaruConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", partitionPlugin.Name,
|
||||
imagePartition.Start);
|
||||
imagePartition.Start);
|
||||
}
|
||||
|
||||
checkedLocations.Add(imagePartition.Start);
|
||||
}
|
||||
|
||||
// Getting all partitions at start of device
|
||||
else
|
||||
{
|
||||
@@ -107,6 +107,7 @@ namespace Aaru.Core
|
||||
{
|
||||
childPartitions.Add(foundPartitions[0]);
|
||||
foundPartitions.RemoveAt(0);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -115,12 +116,14 @@ namespace Aaru.Core
|
||||
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Partitions", "Trying {0} @ {1}", partitionPlugin.Name,
|
||||
foundPartitions[0].Start);
|
||||
foundPartitions[0].Start);
|
||||
|
||||
if(!partitionPlugin.GetInformation(image, out List<Partition> partitions, foundPartitions[0].Start))
|
||||
continue;
|
||||
|
||||
AaruConsole.DebugWriteLine("Partitions", "Found {0} @ {1}", partitionPlugin.Name,
|
||||
foundPartitions[0].Start);
|
||||
foundPartitions[0].Start);
|
||||
|
||||
childs.AddRange(partitions);
|
||||
}
|
||||
|
||||
@@ -133,8 +136,10 @@ namespace Aaru.Core
|
||||
foundPartitions.RemoveAt(0);
|
||||
|
||||
foreach(Partition child in childs)
|
||||
if(checkedLocations.Contains(child.Start)) childPartitions.Add(child);
|
||||
else foundPartitions.Add(child);
|
||||
if(checkedLocations.Contains(child.Start))
|
||||
childPartitions.Add(child);
|
||||
else
|
||||
foundPartitions.Add(child);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,7 +147,7 @@ namespace Aaru.Core
|
||||
foundPartitions.RemoveAt(0);
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine("Partitions", "Got {0} parents", foundPartitions.Count);
|
||||
AaruConsole.DebugWriteLine("Partitions", "Got {0} parents", foundPartitions.Count);
|
||||
AaruConsole.DebugWriteLine("Partitions", "Got {0} partitions", childPartitions.Count);
|
||||
}
|
||||
|
||||
@@ -153,12 +158,11 @@ namespace Aaru.Core
|
||||
childPartitions.Select(detectedPartition => detectedPartition.Start).ToList();
|
||||
|
||||
if(tapeImage.Files != null)
|
||||
childPartitions.AddRange(tapeImage.Files.Where(f => !startLocations.Contains(f.FirstBlock))
|
||||
.Select(tapeFile => new Partition
|
||||
childPartitions.AddRange(tapeImage.Files.Where(f => !startLocations.Contains(f.FirstBlock)).
|
||||
Select(tapeFile => new Partition
|
||||
{
|
||||
Start = tapeFile.FirstBlock,
|
||||
Length = tapeFile.LastBlock -
|
||||
tapeFile.FirstBlock + 1,
|
||||
Start = tapeFile.FirstBlock,
|
||||
Length = (tapeFile.LastBlock - tapeFile.FirstBlock) + 1,
|
||||
Sequence = tapeFile.File
|
||||
}));
|
||||
}
|
||||
@@ -169,34 +173,36 @@ namespace Aaru.Core
|
||||
|
||||
if(partitionableImage.Partitions != null)
|
||||
childPartitions.AddRange(partitionableImage.Partitions.Where(imagePartition =>
|
||||
!startLocations
|
||||
.Contains(imagePartition
|
||||
.Start)));
|
||||
!startLocations.
|
||||
Contains(imagePartition.
|
||||
Start)));
|
||||
}
|
||||
|
||||
Partition[] childArray = childPartitions
|
||||
.OrderBy(part => part.Start).ThenBy(part => part.Length).ThenBy(part => part.Scheme)
|
||||
.ToArray();
|
||||
Partition[] childArray = childPartitions.
|
||||
OrderBy(part => part.Start).ThenBy(part => part.Length).
|
||||
ThenBy(part => part.Scheme).ToArray();
|
||||
|
||||
for(long i = 0; i < childArray.LongLength; i++) childArray[i].Sequence = (ulong)i;
|
||||
for(long i = 0; i < childArray.LongLength; i++)
|
||||
childArray[i].Sequence = (ulong)i;
|
||||
|
||||
return childArray.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds all partition schemes from the specified list of partitions to statistics
|
||||
/// </summary>
|
||||
/// <summary>Adds all partition schemes from the specified list of partitions to statistics</summary>
|
||||
/// <param name="partitions">List of partitions</param>
|
||||
public static void AddSchemesToStats(List<Partition> partitions)
|
||||
{
|
||||
if(partitions == null || partitions.Count == 0) return;
|
||||
if(partitions == null ||
|
||||
partitions.Count == 0)
|
||||
return;
|
||||
|
||||
List<string> schemes = new List<string>();
|
||||
|
||||
foreach(Partition part in partitions.Where(part => !schemes.Contains(part.Scheme)))
|
||||
schemes.Add(part.Scheme);
|
||||
|
||||
foreach(string scheme in schemes) Statistics.AddPartition(scheme);
|
||||
foreach(string scheme in schemes)
|
||||
Statistics.AddPartition(scheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Aaru.Core
|
||||
{
|
||||
if(page.Subpage != 0)
|
||||
AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h subpage {1:X2}h",
|
||||
page.Page, page.Subpage);
|
||||
page.Page, page.Subpage);
|
||||
else
|
||||
AaruConsole.WriteLine("Found unknown vendor mode page {0:X2}h", page.Page);
|
||||
}
|
||||
@@ -70,8 +70,8 @@ namespace Aaru.Core
|
||||
{
|
||||
if(page.Subpage == 0)
|
||||
AaruConsole.WriteLine(devType == PeripheralDeviceTypes.MultiMediaDevice
|
||||
? Modes.PrettifyModePage_01_MMC(page.PageResponse)
|
||||
: Modes.PrettifyModePage_01(page.PageResponse));
|
||||
? Modes.PrettifyModePage_01_MMC(page.PageResponse)
|
||||
: Modes.PrettifyModePage_01(page.PageResponse));
|
||||
else
|
||||
goto default;
|
||||
|
||||
@@ -126,8 +126,8 @@ namespace Aaru.Core
|
||||
{
|
||||
if(page.Subpage == 0)
|
||||
AaruConsole.WriteLine(devType == PeripheralDeviceTypes.MultiMediaDevice
|
||||
? Modes.PrettifyModePage_07_MMC(page.PageResponse)
|
||||
: Modes.PrettifyModePage_07(page.PageResponse));
|
||||
? Modes.PrettifyModePage_07_MMC(page.PageResponse)
|
||||
: Modes.PrettifyModePage_07(page.PageResponse));
|
||||
else
|
||||
goto default;
|
||||
|
||||
@@ -193,8 +193,8 @@ namespace Aaru.Core
|
||||
{
|
||||
if(page.Subpage == 0)
|
||||
AaruConsole.WriteLine(devType == PeripheralDeviceTypes.SequentialAccess
|
||||
? Modes.PrettifyModePage_10_SSC(page.PageResponse)
|
||||
: Modes.PrettifyModePage_10(page.PageResponse));
|
||||
? Modes.PrettifyModePage_10_SSC(page.PageResponse)
|
||||
: Modes.PrettifyModePage_10(page.PageResponse));
|
||||
else
|
||||
goto default;
|
||||
|
||||
@@ -244,8 +244,8 @@ namespace Aaru.Core
|
||||
{
|
||||
if(page.Subpage == 0)
|
||||
AaruConsole.WriteLine(devType == PeripheralDeviceTypes.MultiMediaDevice
|
||||
? Modes.PrettifyModePage_1C_SFF(page.PageResponse)
|
||||
: Modes.PrettifyModePage_1C(page.PageResponse));
|
||||
? Modes.PrettifyModePage_1C_SFF(page.PageResponse)
|
||||
: Modes.PrettifyModePage_1C(page.PageResponse));
|
||||
else if(page.Subpage == 1)
|
||||
AaruConsole.WriteLine(Modes.PrettifyModePage_1C_S01(page.PageResponse));
|
||||
else
|
||||
@@ -360,7 +360,7 @@ namespace Aaru.Core
|
||||
{
|
||||
if(page.Subpage != 0)
|
||||
AaruConsole.WriteLine("Found unknown mode page {0:X2}h subpage {1:X2}h", page.Page,
|
||||
page.Subpage);
|
||||
page.Subpage);
|
||||
else
|
||||
AaruConsole.WriteLine("Found unknown mode page {0:X2}h", page.Page);
|
||||
|
||||
|
||||
@@ -50,34 +50,30 @@ using Version = Aaru.CommonTypes.Metadata.Version;
|
||||
|
||||
namespace Aaru.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles connections to Aaru.Server
|
||||
/// </summary>
|
||||
/// <summary>Handles connections to Aaru.Server</summary>
|
||||
public static class Remote
|
||||
{
|
||||
/// <summary>
|
||||
/// Submits a device report
|
||||
/// </summary>
|
||||
/// <summary>Submits a device report</summary>
|
||||
/// <param name="report">Device report</param>
|
||||
public static void SubmitReport(DeviceReportV2 report)
|
||||
{
|
||||
Thread submitThread = new Thread(() =>
|
||||
var submitThread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
System.Console.WriteLine("Uploading device report");
|
||||
#else
|
||||
#else
|
||||
Aaru.Console.AaruConsole.DebugWriteLine("Submit stats", "Uploading device report");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
string json = JsonConvert.SerializeObject(report, Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
|
||||
WebRequest request = WebRequest.Create("https://www.aaru.app/api/uploadreportv2");
|
||||
string json = JsonConvert.SerializeObject(report, Formatting.Indented, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
|
||||
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
|
||||
var request = WebRequest.Create("https://www.aaru.app/api/uploadreportv2");
|
||||
((HttpWebRequest)request).UserAgent = $"Aaru {typeof(Version).Assembly.GetName().Version}";
|
||||
request.Method = "POST";
|
||||
request.ContentLength = jsonBytes.Length;
|
||||
@@ -87,10 +83,11 @@ namespace Aaru.Core
|
||||
reqStream.Close();
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK) return;
|
||||
if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK)
|
||||
return;
|
||||
|
||||
Stream data = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||
Stream data = response.GetResponseStream();
|
||||
var reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||
|
||||
reader.ReadToEnd();
|
||||
data.Close();
|
||||
@@ -100,20 +97,23 @@ namespace Aaru.Core
|
||||
{
|
||||
// Can't connect to the server, do nothing
|
||||
}
|
||||
|
||||
// ReSharper disable once RedundantCatchClause
|
||||
catch
|
||||
{
|
||||
#if DEBUG
|
||||
if(Debugger.IsAttached) throw;
|
||||
#endif
|
||||
#if DEBUG
|
||||
if(Debugger.IsAttached)
|
||||
throw;
|
||||
#endif
|
||||
}
|
||||
});
|
||||
|
||||
submitThread.Start();
|
||||
}
|
||||
|
||||
public static void UpdateMasterDatabase(bool create)
|
||||
{
|
||||
AaruContext mctx = AaruContext.Create(Aaru.Settings.Settings.MasterDbPath);
|
||||
var mctx = AaruContext.Create(Settings.Settings.MasterDbPath);
|
||||
mctx.Database.Migrate();
|
||||
mctx.SaveChanges();
|
||||
|
||||
@@ -125,10 +125,18 @@ namespace Aaru.Core
|
||||
if(!create)
|
||||
{
|
||||
List<DateTime> latestAll = new List<DateTime>();
|
||||
if(mctx.UsbVendors.Any()) latestAll.Add(mctx.UsbVendors.Max(v => v.ModifiedWhen));
|
||||
if(mctx.UsbProducts.Any()) latestAll.Add(mctx.UsbProducts.Max(p => p.ModifiedWhen));
|
||||
if(mctx.CdOffsets.Any()) latestAll.Add(mctx.CdOffsets.Max(o => o.ModifiedWhen));
|
||||
if(mctx.Devices.Any()) latestAll.Add(mctx.Devices.Max(d => d.LastSynchronized));
|
||||
|
||||
if(mctx.UsbVendors.Any())
|
||||
latestAll.Add(mctx.UsbVendors.Max(v => v.ModifiedWhen));
|
||||
|
||||
if(mctx.UsbProducts.Any())
|
||||
latestAll.Add(mctx.UsbProducts.Max(p => p.ModifiedWhen));
|
||||
|
||||
if(mctx.CdOffsets.Any())
|
||||
latestAll.Add(mctx.CdOffsets.Max(o => o.ModifiedWhen));
|
||||
|
||||
if(mctx.Devices.Any())
|
||||
latestAll.Add(mctx.Devices.Max(d => d.LastSynchronized));
|
||||
|
||||
if(latestAll.Any())
|
||||
{
|
||||
@@ -150,8 +158,7 @@ namespace Aaru.Core
|
||||
|
||||
DateTime updateStart = DateTime.UtcNow;
|
||||
|
||||
WebRequest request =
|
||||
WebRequest.Create($"https://www.aaru.app/api/update?timestamp={lastUpdate}");
|
||||
var request = WebRequest.Create($"https://www.aaru.app/api/update?timestamp={lastUpdate}");
|
||||
((HttpWebRequest)request).UserAgent = $"Aaru {typeof(Version).Assembly.GetName().Version}";
|
||||
request.Method = "GET";
|
||||
request.ContentType = "application/json";
|
||||
@@ -160,36 +167,48 @@ namespace Aaru.Core
|
||||
if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Error {0} when trying to get updated entities.",
|
||||
((HttpWebResponse)response).StatusCode);
|
||||
((HttpWebResponse)response).StatusCode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Stream data = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||
SyncDto sync = JsonConvert.DeserializeObject<SyncDto>(reader.ReadToEnd());
|
||||
Stream data = response.GetResponseStream();
|
||||
var reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||
SyncDto sync = JsonConvert.DeserializeObject<SyncDto>(reader.ReadToEnd());
|
||||
|
||||
if(create)
|
||||
{
|
||||
AaruConsole.WriteLine("Adding USB vendors");
|
||||
|
||||
foreach(UsbVendorDto vendor in sync.UsbVendors)
|
||||
mctx.UsbVendors.Add(new UsbVendor(vendor.VendorId, vendor.Vendor));
|
||||
|
||||
AaruConsole.WriteLine("Added {0} usb vendors", sync.UsbVendors.Count);
|
||||
|
||||
AaruConsole.WriteLine("Adding USB products");
|
||||
|
||||
foreach(UsbProductDto product in sync.UsbProducts)
|
||||
mctx.UsbProducts.Add(new UsbProduct(product.VendorId, product.ProductId, product.Product));
|
||||
|
||||
AaruConsole.WriteLine("Added {0} usb products", sync.UsbProducts.Count);
|
||||
|
||||
AaruConsole.WriteLine("Adding CompactDisc read offsets");
|
||||
|
||||
foreach(CdOffsetDto offset in sync.Offsets)
|
||||
mctx.CdOffsets.Add(new CdOffset(offset) {Id = offset.Id});
|
||||
mctx.CdOffsets.Add(new CdOffset(offset)
|
||||
{
|
||||
Id = offset.Id
|
||||
});
|
||||
|
||||
AaruConsole.WriteLine("Added {0} CompactDisc read offsets", sync.Offsets.Count);
|
||||
|
||||
AaruConsole.WriteLine("Adding known devices");
|
||||
foreach(DeviceDto device in sync.Devices) mctx.Devices.Add(new Device(device) {Id = device.Id});
|
||||
|
||||
foreach(DeviceDto device in sync.Devices)
|
||||
mctx.Devices.Add(new Device(device)
|
||||
{
|
||||
Id = device.Id
|
||||
});
|
||||
|
||||
AaruConsole.WriteLine("Added {0} known devices", sync.Devices.Count);
|
||||
}
|
||||
@@ -205,6 +224,7 @@ namespace Aaru.Core
|
||||
long modifiedDevices = 0;
|
||||
|
||||
AaruConsole.WriteLine("Updating USB vendors");
|
||||
|
||||
foreach(UsbVendorDto vendor in sync.UsbVendors)
|
||||
{
|
||||
UsbVendor existing = mctx.UsbVendors.FirstOrDefault(v => v.Id == vendor.VendorId);
|
||||
@@ -223,10 +243,11 @@ namespace Aaru.Core
|
||||
}
|
||||
}
|
||||
|
||||
AaruConsole.WriteLine("Added {0} USB vendors", addedVendors);
|
||||
AaruConsole.WriteLine("Added {0} USB vendors", addedVendors);
|
||||
AaruConsole.WriteLine("Modified {0} USB vendors", modifiedVendors);
|
||||
|
||||
AaruConsole.WriteLine("Updating USB products");
|
||||
|
||||
foreach(UsbProductDto product in sync.UsbProducts)
|
||||
{
|
||||
UsbProduct existing =
|
||||
@@ -247,10 +268,11 @@ namespace Aaru.Core
|
||||
}
|
||||
}
|
||||
|
||||
AaruConsole.WriteLine("Added {0} USB products", addedProducts);
|
||||
AaruConsole.WriteLine("Added {0} USB products", addedProducts);
|
||||
AaruConsole.WriteLine("Modified {0} USB products", modifiedProducts);
|
||||
|
||||
AaruConsole.WriteLine("Updating CompactDisc read offsets");
|
||||
|
||||
foreach(CdOffsetDto offset in sync.Offsets)
|
||||
{
|
||||
CdOffset existing = mctx.CdOffsets.FirstOrDefault(o => o.Id == offset.Id);
|
||||
@@ -269,14 +291,19 @@ namespace Aaru.Core
|
||||
else
|
||||
{
|
||||
addedOffsets++;
|
||||
mctx.CdOffsets.Add(new CdOffset(offset) {Id = offset.Id});
|
||||
|
||||
mctx.CdOffsets.Add(new CdOffset(offset)
|
||||
{
|
||||
Id = offset.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
AaruConsole.WriteLine("Added {0} CompactDisc read offsets", addedOffsets);
|
||||
AaruConsole.WriteLine("Added {0} CompactDisc read offsets", addedOffsets);
|
||||
AaruConsole.WriteLine("Modified {0} CompactDisc read offsets", modifiedOffsets);
|
||||
|
||||
AaruConsole.WriteLine("Updating known devices");
|
||||
|
||||
foreach(DeviceDto device in sync.Devices)
|
||||
{
|
||||
Device existing = mctx.Devices.FirstOrDefault(d => d.Id == device.Id);
|
||||
@@ -297,19 +324,22 @@ namespace Aaru.Core
|
||||
else
|
||||
{
|
||||
addedDevices++;
|
||||
|
||||
mctx.Devices.Add(new Device(device)
|
||||
{
|
||||
Id = device.Id,
|
||||
OptimalMultipleSectorsRead = device.OptimalMultipleSectorsRead
|
||||
Id = device.Id, OptimalMultipleSectorsRead = device.OptimalMultipleSectorsRead
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
AaruConsole.WriteLine("Added {0} known devices", addedDevices);
|
||||
AaruConsole.WriteLine("Added {0} known devices", addedDevices);
|
||||
AaruConsole.WriteLine("Modified {0} known devices", modifiedDevices);
|
||||
}
|
||||
}
|
||||
catch(Exception ex) { AaruConsole.ErrorWriteLine("Exception {0} when updating database.", ex); }
|
||||
catch(Exception ex)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine("Exception {0} when updating database.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AaruConsole.WriteLine("Saving changes...");
|
||||
|
||||
@@ -43,9 +43,7 @@ namespace Aaru.Core
|
||||
public partial class Sidecar
|
||||
{
|
||||
// TODO: Complete it
|
||||
/// <summary>
|
||||
/// Creates a metadata sidecar for an audio media (e.g. cassette)
|
||||
/// </summary>
|
||||
/// <summary>Creates a metadata sidecar for an audio media (e.g. cassette)</summary>
|
||||
/// <param name="image">Image</param>
|
||||
/// <param name="filterId">Filter uuid</param>
|
||||
/// <param name="imagePath">Image path</param>
|
||||
@@ -53,28 +51,26 @@ namespace Aaru.Core
|
||||
/// <param name="plugins">Image plugins</param>
|
||||
/// <param name="imgChecksums">List of image checksums</param>
|
||||
/// <param name="sidecar">Metadata sidecar</param>
|
||||
static void AudioMedia(IMediaImage image, Guid filterId, string imagePath,
|
||||
FileInfo fi, PluginBase plugins,
|
||||
static void AudioMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
|
||||
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
|
||||
{
|
||||
sidecar.AudioMedia = new[]
|
||||
{
|
||||
new AudioMediaType
|
||||
{
|
||||
Checksums = imgChecksums.ToArray(),
|
||||
Image = new ImageType
|
||||
Checksums = imgChecksums.ToArray(), Image = new ImageType
|
||||
{
|
||||
format = image.Format,
|
||||
offset = 0,
|
||||
offsetSpecified = true,
|
||||
Value = Path.GetFileName(imagePath)
|
||||
format = image.Format, offset = 0, offsetSpecified = true, Value = Path.GetFileName(imagePath)
|
||||
},
|
||||
Size = (ulong)fi.Length,
|
||||
Sequence = new SequenceType {MediaTitle = image.Info.MediaTitle}
|
||||
Size = (ulong)fi.Length, Sequence = new SequenceType
|
||||
{
|
||||
MediaTitle = image.Info.MediaTitle
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
|
||||
if(image.Info.MediaSequence != 0 &&
|
||||
image.Info.LastMediaSequence != 0)
|
||||
{
|
||||
sidecar.AudioMedia[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
|
||||
sidecar.AudioMedia[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
|
||||
|
||||
@@ -40,14 +40,12 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||
using Aaru.Console;
|
||||
using Aaru.Decoders.ATA;
|
||||
using Aaru.Decoders.PCMCIA;
|
||||
using Aaru.DiscImages;
|
||||
using Aaru.Filters;
|
||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||
using Schemas;
|
||||
using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify;
|
||||
using MediaType = Aaru.CommonTypes.Metadata.MediaType;
|
||||
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
|
||||
|
||||
@@ -152,8 +150,7 @@ namespace Aaru.Core
|
||||
|
||||
if(manfid != null)
|
||||
{
|
||||
sidecar.BlockMedia[0].PCMCIA.ManufacturerCode =
|
||||
manfid.ManufacturerID;
|
||||
sidecar.BlockMedia[0].PCMCIA.ManufacturerCode = manfid.ManufacturerID;
|
||||
|
||||
sidecar.BlockMedia[0].PCMCIA.CardCode = manfid.CardID;
|
||||
sidecar.BlockMedia[0].PCMCIA.ManufacturerCodeSpecified = true;
|
||||
@@ -417,7 +414,7 @@ namespace Aaru.Core
|
||||
//goto skipImageChecksum;
|
||||
|
||||
uint sectorsToRead = 64;
|
||||
ulong sectors = tapePartition.LastBlock - tapePartition.FirstBlock + 1;
|
||||
ulong sectors = (tapePartition.LastBlock - tapePartition.FirstBlock) + 1;
|
||||
ulong doneSectors = 0;
|
||||
|
||||
InitProgress2();
|
||||
@@ -492,7 +489,7 @@ namespace Aaru.Core
|
||||
//goto skipImageChecksum;
|
||||
|
||||
uint sectorsToRead = 64;
|
||||
ulong sectors = tapeFile.LastBlock - tapeFile.FirstBlock + 1;
|
||||
ulong sectors = (tapeFile.LastBlock - tapeFile.FirstBlock) + 1;
|
||||
ulong doneSectors = 0;
|
||||
|
||||
InitProgress2();
|
||||
@@ -861,10 +858,10 @@ namespace Aaru.Core
|
||||
{
|
||||
scpImage.Open(scpFilter);
|
||||
}
|
||||
catch(NotImplementedException) { }
|
||||
catch(NotImplementedException) {}
|
||||
|
||||
if(image.Info.Heads == 2 && scpImage.Header.heads == 0 ||
|
||||
image.Info.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2))
|
||||
if((image.Info.Heads == 2 && scpImage.Header.heads == 0) ||
|
||||
(image.Info.Heads == 1 && (scpImage.Header.heads == 1 || scpImage.Header.heads == 2)))
|
||||
if(scpImage.Header.end + 1 >= image.Info.Cylinders)
|
||||
{
|
||||
List<BlockTrackType> scpBlockTrackTypes = new List<BlockTrackType>();
|
||||
@@ -899,8 +896,9 @@ namespace Aaru.Core
|
||||
if(scpImage.ScpTracks.TryGetValue(t, out SuperCardPro.TrackHeader scpTrack))
|
||||
{
|
||||
byte[] trackContents =
|
||||
new byte[scpTrack.Entries.Last().dataOffset +
|
||||
scpTrack.Entries.Last().trackLength - scpImage.Header.offsets[t] + 1];
|
||||
new byte[((scpTrack.Entries.Last().dataOffset +
|
||||
scpTrack.Entries.Last().trackLength) - scpImage.Header.offsets[t]) +
|
||||
1];
|
||||
|
||||
scpStream.Position = scpImage.Header.offsets[t];
|
||||
scpStream.Read(trackContents, 0, trackContents.Length);
|
||||
@@ -967,7 +965,7 @@ namespace Aaru.Core
|
||||
{
|
||||
kfImage.Open(kfFilter);
|
||||
}
|
||||
catch(NotImplementedException) { }
|
||||
catch(NotImplementedException) {}
|
||||
|
||||
if(kfImage.Info.Heads == image.Info.Heads)
|
||||
if(kfImage.Info.Cylinders >= image.Info.Cylinders)
|
||||
@@ -1051,7 +1049,7 @@ namespace Aaru.Core
|
||||
{
|
||||
dfiImage.Open(dfiFilter);
|
||||
}
|
||||
catch(NotImplementedException) { }
|
||||
catch(NotImplementedException) {}
|
||||
|
||||
UpdateStatus("Hashing DiscFerret image...");
|
||||
|
||||
|
||||
@@ -38,9 +38,7 @@ namespace Aaru.Core
|
||||
{
|
||||
public partial class Sidecar
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a metadata sidecar for a block tape (e.g. scsi streaming)
|
||||
/// </summary>
|
||||
/// <summary>Creates a metadata sidecar for a block tape (e.g. scsi streaming)</summary>
|
||||
/// <param name="files">List of files</param>
|
||||
/// <param name="folderName">Dump path</param>
|
||||
/// <param name="blockSize">Expected block size in bytes</param>
|
||||
@@ -52,24 +50,21 @@ namespace Aaru.Core
|
||||
{
|
||||
new BlockMediaType
|
||||
{
|
||||
Image =
|
||||
new ImageType
|
||||
{
|
||||
format = "Directory", offsetSpecified = false, Value = folderName
|
||||
},
|
||||
Sequence =
|
||||
new SequenceType {MediaTitle = folderName, MediaSequence = 1, TotalMedia = 1},
|
||||
PhysicalBlockSize = blockSize,
|
||||
LogicalBlockSize = blockSize,
|
||||
TapeInformation = new[]
|
||||
Image = new ImageType
|
||||
{
|
||||
format = "Directory", offsetSpecified = false, Value = folderName
|
||||
},
|
||||
Sequence = new SequenceType
|
||||
{
|
||||
MediaTitle = folderName, MediaSequence = 1, TotalMedia = 1
|
||||
},
|
||||
PhysicalBlockSize = blockSize, LogicalBlockSize = blockSize, TapeInformation = new[]
|
||||
{
|
||||
new TapePartitionType
|
||||
{
|
||||
Image = new ImageType
|
||||
{
|
||||
format = "Directory",
|
||||
offsetSpecified = false,
|
||||
Value = folderName
|
||||
format = "Directory", offsetSpecified = false, Value = folderName
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,32 +72,32 @@ namespace Aaru.Core
|
||||
}
|
||||
};
|
||||
|
||||
if(aborted) return sidecar;
|
||||
if(aborted)
|
||||
return sidecar;
|
||||
|
||||
ulong currentBlock = 0;
|
||||
ulong totalSize = 0;
|
||||
Checksum tapeWorker = new Checksum();
|
||||
var tapeWorker = new Checksum();
|
||||
List<TapeFileType> tapeFiles = new List<TapeFileType>();
|
||||
|
||||
UpdateStatus("Hashing files...");
|
||||
|
||||
for(int i = 0; i < files.Count; i++)
|
||||
{
|
||||
if(aborted) return sidecar;
|
||||
if(aborted)
|
||||
return sidecar;
|
||||
|
||||
fs = new FileStream(files[i], FileMode.Open, FileAccess.Read);
|
||||
Checksum fileWorker = new Checksum();
|
||||
TapeFileType tapeFile = new TapeFileType
|
||||
var fileWorker = new Checksum();
|
||||
|
||||
var tapeFile = new TapeFileType
|
||||
{
|
||||
Image = new ImageType
|
||||
{
|
||||
format = "Raw disk image (sector by sector copy)",
|
||||
offset = 0,
|
||||
format = "Raw disk image (sector by sector copy)", offset = 0,
|
||||
Value = Path.GetFileName(files[i])
|
||||
},
|
||||
Size = (ulong)fs.Length,
|
||||
BlockSize = blockSize,
|
||||
StartBlock = currentBlock,
|
||||
Sequence = (ulong)i
|
||||
Size = (ulong)fs.Length, BlockSize = blockSize, StartBlock = currentBlock, Sequence = (ulong)i
|
||||
};
|
||||
|
||||
const uint SECTORS_TO_READ = 512;
|
||||
@@ -110,11 +105,13 @@ namespace Aaru.Core
|
||||
ulong doneSectors = 0;
|
||||
|
||||
InitProgress2();
|
||||
|
||||
while(doneSectors < sectors)
|
||||
{
|
||||
if(aborted)
|
||||
{
|
||||
EndProgress2();
|
||||
|
||||
return sidecar;
|
||||
}
|
||||
|
||||
@@ -124,16 +121,20 @@ namespace Aaru.Core
|
||||
{
|
||||
sector = new byte[SECTORS_TO_READ * blockSize];
|
||||
fs.Read(sector, 0, sector.Length);
|
||||
|
||||
UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}",
|
||||
(long)doneSectors, (long)sectors);
|
||||
|
||||
doneSectors += SECTORS_TO_READ;
|
||||
}
|
||||
else
|
||||
{
|
||||
sector = new byte[(uint)(sectors - doneSectors) * blockSize];
|
||||
fs.Read(sector, 0, sector.Length);
|
||||
|
||||
UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}",
|
||||
(long)doneSectors, (long)sectors);
|
||||
|
||||
doneSectors += sectors - doneSectors;
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ namespace Aaru.Core
|
||||
tapeWorker.Update(sector);
|
||||
}
|
||||
|
||||
tapeFile.EndBlock = tapeFile.StartBlock + sectors - 1;
|
||||
tapeFile.EndBlock = (tapeFile.StartBlock + sectors) - 1;
|
||||
currentBlock += sectors;
|
||||
totalSize += (ulong)fs.Length;
|
||||
tapeFile.Checksums = fileWorker.End().ToArray();
|
||||
@@ -165,19 +166,32 @@ namespace Aaru.Core
|
||||
{
|
||||
sidecar.BlockMedia[0].DiskType = "Quarter-inch cartridge";
|
||||
|
||||
if(totalSize <= 20 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-11";
|
||||
else if(totalSize <= 40 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-40";
|
||||
else if(totalSize <= 60 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-24";
|
||||
else if(totalSize <= 80 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-80";
|
||||
else if(totalSize <= 120 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-120";
|
||||
else if(totalSize <= 150 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-150";
|
||||
else if(totalSize <= 320 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-320";
|
||||
else if(totalSize <= 340 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-3010";
|
||||
else if(totalSize <= 525 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-525";
|
||||
else if(totalSize <= 670 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-3020";
|
||||
else if(totalSize <= 1200 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-3080";
|
||||
else if(totalSize <= 1350 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-1350";
|
||||
else if(totalSize <= (long)4000 * 1048576) sidecar.BlockMedia[0].DiskSubType = "QIC-3095";
|
||||
if(totalSize <= 20 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-11";
|
||||
else if(totalSize <= 40 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-40";
|
||||
else if(totalSize <= 60 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-24";
|
||||
else if(totalSize <= 80 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-80";
|
||||
else if(totalSize <= 120 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-120";
|
||||
else if(totalSize <= 150 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-150";
|
||||
else if(totalSize <= 320 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-320";
|
||||
else if(totalSize <= 340 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-3010";
|
||||
else if(totalSize <= 525 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-525";
|
||||
else if(totalSize <= 670 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-3020";
|
||||
else if(totalSize <= 1200 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-3080";
|
||||
else if(totalSize <= 1350 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-1350";
|
||||
else if(totalSize <= (long)4000 * 1048576)
|
||||
sidecar.BlockMedia[0].DiskSubType = "QIC-3095";
|
||||
else
|
||||
{
|
||||
sidecar.BlockMedia[0].DiskType = "Unknown tape";
|
||||
|
||||
@@ -42,39 +42,21 @@ namespace Aaru.Core
|
||||
public event EndProgressHandler2 EndProgressEvent2;
|
||||
public event UpdateStatusHandler UpdateStatusEvent;
|
||||
|
||||
public void InitProgress()
|
||||
{
|
||||
InitProgressEvent?.Invoke();
|
||||
}
|
||||
public void InitProgress() => InitProgressEvent?.Invoke();
|
||||
|
||||
public void UpdateProgress(string text, long current, long maximum)
|
||||
{
|
||||
public void UpdateProgress(string text, long current, long maximum) =>
|
||||
UpdateProgressEvent?.Invoke(string.Format(text, current, maximum), current, maximum);
|
||||
}
|
||||
|
||||
public void EndProgress()
|
||||
{
|
||||
EndProgressEvent?.Invoke();
|
||||
}
|
||||
public void EndProgress() => EndProgressEvent?.Invoke();
|
||||
|
||||
public void InitProgress2()
|
||||
{
|
||||
InitProgressEvent2?.Invoke();
|
||||
}
|
||||
public void InitProgress2() => InitProgressEvent2?.Invoke();
|
||||
|
||||
public void UpdateProgress2(string text, long current, long maximum)
|
||||
{
|
||||
public void UpdateProgress2(string text, long current, long maximum) =>
|
||||
UpdateProgressEvent2?.Invoke(string.Format(text, current, maximum), current, maximum);
|
||||
}
|
||||
|
||||
public void EndProgress2()
|
||||
{
|
||||
EndProgressEvent2?.Invoke();
|
||||
}
|
||||
public void EndProgress2() => EndProgressEvent2?.Invoke();
|
||||
|
||||
public void UpdateStatus(string text, params object[] args)
|
||||
{
|
||||
public void UpdateStatus(string text, params object[] args) =>
|
||||
UpdateStatusEvent?.Invoke(string.Format(text, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,12 @@ namespace Aaru.Core
|
||||
{
|
||||
FilesystemContentsType Files(IReadOnlyFilesystem filesystem)
|
||||
{
|
||||
FilesystemContentsType contents = new FilesystemContentsType();
|
||||
var contents = new FilesystemContentsType();
|
||||
|
||||
Errno ret = filesystem.ReadDir("/", out List<string> dirents);
|
||||
|
||||
if(ret != Errno.NoError) return null;
|
||||
if(ret != Errno.NoError)
|
||||
return null;
|
||||
|
||||
List<DirectoryType> directories = new List<DirectoryType>();
|
||||
List<ContentsFileType> files = new List<ContentsFileType>();
|
||||
@@ -27,27 +28,32 @@ namespace Aaru.Core
|
||||
if(ret != Errno.NoError)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Create-Sidecar command", "Cannot stat {0}", dirent);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(stat.Attributes.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
directories.Add(SidecarDirectory(filesystem, "", dirent, stat));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
files.Add(SidecarFile(filesystem, "", dirent, stat));
|
||||
}
|
||||
|
||||
if(files.Count > 0) contents.File = files.OrderBy(f => f.name).ToArray();
|
||||
if(directories.Count > 0) contents.Directory = directories.OrderBy(d => d.name).ToArray();
|
||||
if(files.Count > 0)
|
||||
contents.File = files.OrderBy(f => f.name).ToArray();
|
||||
|
||||
if(directories.Count > 0)
|
||||
contents.Directory = directories.OrderBy(d => d.name).ToArray();
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
DirectoryType SidecarDirectory(IReadOnlyFilesystem filesystem, string path, string filename, FileEntryInfo stat)
|
||||
{
|
||||
DirectoryType directory = new DirectoryType();
|
||||
var directory = new DirectoryType();
|
||||
|
||||
if(stat.AccessTimeUtc.HasValue)
|
||||
{
|
||||
@@ -112,7 +118,8 @@ namespace Aaru.Core
|
||||
|
||||
Errno ret = filesystem.ReadDir(path + "/" + filename, out List<string> dirents);
|
||||
|
||||
if(ret != Errno.NoError) return null;
|
||||
if(ret != Errno.NoError)
|
||||
return null;
|
||||
|
||||
List<DirectoryType> directories = new List<DirectoryType>();
|
||||
List<ContentsFileType> files = new List<ContentsFileType>();
|
||||
@@ -124,28 +131,33 @@ namespace Aaru.Core
|
||||
if(ret != Errno.NoError)
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Create-Sidecar command", "Cannot stat {0}", dirent);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(entryStat.Attributes.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
directories.Add(SidecarDirectory(filesystem, path + "/" + filename, dirent, entryStat));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
files.Add(SidecarFile(filesystem, path + "/" + filename, dirent, entryStat));
|
||||
}
|
||||
|
||||
if(files.Count > 0) directory.File = files.OrderBy(f => f.name).ToArray();
|
||||
if(directories.Count > 0) directory.Directory = directories.OrderBy(d => d.name).ToArray();
|
||||
if(files.Count > 0)
|
||||
directory.File = files.OrderBy(f => f.name).ToArray();
|
||||
|
||||
if(directories.Count > 0)
|
||||
directory.Directory = directories.OrderBy(d => d.name).ToArray();
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
ContentsFileType SidecarFile(IReadOnlyFilesystem filesystem, string path, string filename, FileEntryInfo stat)
|
||||
{
|
||||
ContentsFileType file = new ContentsFileType();
|
||||
Checksum fileChkWorker = new Checksum();
|
||||
var file = new ContentsFileType();
|
||||
var fileChkWorker = new Checksum();
|
||||
|
||||
if(stat.AccessTimeUtc.HasValue)
|
||||
{
|
||||
@@ -210,14 +222,17 @@ namespace Aaru.Core
|
||||
}
|
||||
|
||||
byte[] data = new byte[0];
|
||||
|
||||
if(stat.Length > 0)
|
||||
{
|
||||
long position = 0;
|
||||
UpdateStatus($"Hashing file {path}/{filename}...");
|
||||
InitProgress2();
|
||||
|
||||
while(position < stat.Length - 1048576)
|
||||
{
|
||||
if(aborted) return file;
|
||||
if(aborted)
|
||||
return file;
|
||||
|
||||
data = new byte[1048576];
|
||||
filesystem.Read(path + "/" + filename, position, 1048576, ref data);
|
||||
@@ -240,11 +255,13 @@ namespace Aaru.Core
|
||||
|
||||
file.Checksums = fileChkWorker.End().ToArray();
|
||||
}
|
||||
else file.Checksums = emptyChecksums;
|
||||
else
|
||||
file.Checksums = emptyChecksums;
|
||||
|
||||
Errno ret = filesystem.ListXAttr(path + "/" + filename, out List<string> xattrs);
|
||||
|
||||
if(ret != Errno.NoError) return file;
|
||||
if(ret != Errno.NoError)
|
||||
return file;
|
||||
|
||||
List<ExtendedAttributeType> xattrTypes = new List<ExtendedAttributeType>();
|
||||
|
||||
@@ -252,20 +269,20 @@ namespace Aaru.Core
|
||||
{
|
||||
ret = filesystem.GetXattr(path + "/" + filename, xattr, ref data);
|
||||
|
||||
if(ret != Errno.NoError) continue;
|
||||
if(ret != Errno.NoError)
|
||||
continue;
|
||||
|
||||
Checksum xattrChkWorker = new Checksum();
|
||||
var xattrChkWorker = new Checksum();
|
||||
xattrChkWorker.Update(data);
|
||||
|
||||
xattrTypes.Add(new ExtendedAttributeType
|
||||
{
|
||||
Checksums = xattrChkWorker.End().ToArray(),
|
||||
length = (ulong)data.Length,
|
||||
name = xattr
|
||||
Checksums = xattrChkWorker.End().ToArray(), length = (ulong)data.Length, name = xattr
|
||||
});
|
||||
}
|
||||
|
||||
if(xattrTypes.Count > 0) file.ExtendedAttributes = xattrTypes.OrderBy(x => x.name).ToArray();
|
||||
if(xattrTypes.Count > 0)
|
||||
file.ExtendedAttributes = xattrTypes.OrderBy(x => x.name).ToArray();
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -34,14 +34,13 @@ namespace Aaru.Core
|
||||
{
|
||||
public partial class Sidecar
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a LBA to MM:SS:FF string for CDs
|
||||
/// </summary>
|
||||
/// <summary>Converts a LBA to MM:SS:FF string for CDs</summary>
|
||||
/// <param name="lba">LBA</param>
|
||||
/// <returns>MM:SS:FF</returns>
|
||||
static string LbaToMsf(long lba)
|
||||
{
|
||||
long m, s, f;
|
||||
|
||||
if(lba >= -150)
|
||||
{
|
||||
m = (lba + 150) / (75 * 60);
|
||||
@@ -62,14 +61,13 @@ namespace Aaru.Core
|
||||
return $"{m}:{s:D2}:{f:D2}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a LBA to MM:SS:FF string for DDCDs
|
||||
/// </summary>
|
||||
/// <summary>Converts a LBA to MM:SS:FF string for DDCDs</summary>
|
||||
/// <param name="lba">LBA</param>
|
||||
/// <returns>MM:SS:FF</returns>
|
||||
static string DdcdLbaToMsf(long lba)
|
||||
{
|
||||
long h, m, s, f;
|
||||
|
||||
if(lba >= -150)
|
||||
{
|
||||
h = (lba + 150) / (75 * 60 * 60);
|
||||
@@ -82,13 +80,13 @@ namespace Aaru.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
h = (lba + 450150 * 2) / (75 * 60 * 60);
|
||||
lba -= h * (75 * 60 * 60);
|
||||
m = (lba + 450150 * 2) / (75 * 60);
|
||||
lba -= m * (75 * 60);
|
||||
s = (lba + 450150 * 2) / 75;
|
||||
lba -= s * 75;
|
||||
f = lba + 450150 * 2;
|
||||
h = (lba + (450150 * 2)) / (75 * 60 * 60);
|
||||
lba -= h * (75 * 60 * 60);
|
||||
m = (lba + (450150 * 2)) / (75 * 60);
|
||||
lba -= m * (75 * 60);
|
||||
s = (lba + (450150 * 2)) / 75;
|
||||
lba -= s * 75;
|
||||
f = lba + (450150 * 2);
|
||||
}
|
||||
|
||||
return string.Format("{3}:{0:D2}:{1:D2}:{2:D2}", m, s, f, h);
|
||||
|
||||
@@ -43,9 +43,7 @@ namespace Aaru.Core
|
||||
public partial class Sidecar
|
||||
{
|
||||
// TODO: Complete it
|
||||
/// <summary>
|
||||
/// Creates a metadata sidecar for linear media (e.g. ROM chip)
|
||||
/// </summary>
|
||||
/// <summary>Creates a metadata sidecar for linear media (e.g. ROM chip)</summary>
|
||||
/// <param name="image">Image</param>
|
||||
/// <param name="filterId">Filter uuid</param>
|
||||
/// <param name="imagePath">Image path</param>
|
||||
@@ -53,25 +51,18 @@ namespace Aaru.Core
|
||||
/// <param name="plugins">Image plugins</param>
|
||||
/// <param name="imgChecksums">List of image checksums</param>
|
||||
/// <param name="sidecar">Metadata sidecar</param>
|
||||
void LinearMedia(IMediaImage image, Guid filterId, string imagePath,
|
||||
FileInfo fi, PluginBase plugins,
|
||||
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
|
||||
{
|
||||
void LinearMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
|
||||
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding) =>
|
||||
sidecar.LinearMedia = new[]
|
||||
{
|
||||
new LinearMediaType
|
||||
{
|
||||
Checksums = imgChecksums.ToArray(),
|
||||
Image = new ImageType
|
||||
Checksums = imgChecksums.ToArray(), Image = new ImageType
|
||||
{
|
||||
format = image.Format,
|
||||
offset = 0,
|
||||
offsetSpecified = true,
|
||||
Value = Path.GetFileName(imagePath)
|
||||
format = image.Format, offset = 0, offsetSpecified = true, Value = Path.GetFileName(imagePath)
|
||||
},
|
||||
Size = (ulong)fi.Length
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -476,19 +476,19 @@ namespace Aaru.Core
|
||||
case CommonTypes.Enums.TrackType.Data:
|
||||
switch(sidecar.OpticalDisc[0].DiscType)
|
||||
{
|
||||
case"BD":
|
||||
case "BD":
|
||||
xmlTrk.TrackType1 = TrackTypeTrackType.bluray;
|
||||
|
||||
break;
|
||||
case"DDCD":
|
||||
case "DDCD":
|
||||
xmlTrk.TrackType1 = TrackTypeTrackType.ddcd;
|
||||
|
||||
break;
|
||||
case"DVD":
|
||||
case "DVD":
|
||||
xmlTrk.TrackType1 = TrackTypeTrackType.dvd;
|
||||
|
||||
break;
|
||||
case"HD DVD":
|
||||
case "HD DVD":
|
||||
xmlTrk.TrackType1 = TrackTypeTrackType.hddvd;
|
||||
|
||||
break;
|
||||
@@ -516,13 +516,13 @@ namespace Aaru.Core
|
||||
|
||||
switch(sidecar.OpticalDisc[0].DiscType)
|
||||
{
|
||||
case"CD":
|
||||
case"GD":
|
||||
case "CD":
|
||||
case "GD":
|
||||
xmlTrk.StartMSF = LbaToMsf((long)xmlTrk.StartSector);
|
||||
xmlTrk.EndMSF = LbaToMsf((long)xmlTrk.EndSector);
|
||||
|
||||
break;
|
||||
case"DDCD":
|
||||
case "DDCD":
|
||||
xmlTrk.StartMSF = DdcdLbaToMsf((long)xmlTrk.StartSector);
|
||||
xmlTrk.EndMSF = DdcdLbaToMsf((long)xmlTrk.EndSector);
|
||||
|
||||
@@ -540,11 +540,12 @@ namespace Aaru.Core
|
||||
xmlTrk.Image.offsetSpecified = true;
|
||||
}
|
||||
|
||||
xmlTrk.Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * (ulong)trk.TrackRawBytesPerSector;
|
||||
xmlTrk.Size = ((xmlTrk.EndSector - xmlTrk.StartSector) + 1) * (ulong)trk.TrackRawBytesPerSector;
|
||||
|
||||
xmlTrk.BytesPerSector = (uint)trk.TrackBytesPerSector;
|
||||
|
||||
uint sectorsToRead = 512;
|
||||
ulong sectors = xmlTrk.EndSector - xmlTrk.StartSector + 1;
|
||||
ulong sectors = (xmlTrk.EndSector - xmlTrk.StartSector) + 1;
|
||||
ulong doneSectors = 0;
|
||||
|
||||
// If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum.
|
||||
@@ -584,7 +585,7 @@ namespace Aaru.Core
|
||||
sector = image.ReadSectorsLong(doneSectors, sectorsToRead, xmlTrk.Sequence.TrackNumber);
|
||||
|
||||
UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors,
|
||||
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
||||
(long)((trk.TrackEndSector - trk.TrackStartSector) + 1));
|
||||
|
||||
doneSectors += sectorsToRead;
|
||||
}
|
||||
@@ -594,7 +595,7 @@ namespace Aaru.Core
|
||||
xmlTrk.Sequence.TrackNumber);
|
||||
|
||||
UpdateProgress2("Hashings sector {0} of {1}", (long)doneSectors,
|
||||
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
||||
(long)((trk.TrackEndSector - trk.TrackStartSector) + 1));
|
||||
|
||||
doneSectors += sectors - doneSectors;
|
||||
}
|
||||
@@ -619,7 +620,7 @@ namespace Aaru.Core
|
||||
},
|
||||
|
||||
// TODO: Packed subchannel has different size?
|
||||
Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * 96
|
||||
Size = ((xmlTrk.EndSector - xmlTrk.StartSector) + 1) * 96
|
||||
};
|
||||
|
||||
switch(trk.TrackSubchannelType)
|
||||
@@ -649,7 +650,7 @@ namespace Aaru.Core
|
||||
|
||||
var subChkWorker = new Checksum();
|
||||
|
||||
sectors = xmlTrk.EndSector - xmlTrk.StartSector + 1;
|
||||
sectors = (xmlTrk.EndSector - xmlTrk.StartSector) + 1;
|
||||
doneSectors = 0;
|
||||
|
||||
InitProgress2();
|
||||
@@ -672,7 +673,7 @@ namespace Aaru.Core
|
||||
SectorTagType.CdSectorSubchannel);
|
||||
|
||||
UpdateProgress2("Hashings subchannel sector {0} of {1}", (long)doneSectors,
|
||||
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
||||
(long)((trk.TrackEndSector - trk.TrackStartSector) + 1));
|
||||
|
||||
doneSectors += sectorsToRead;
|
||||
}
|
||||
@@ -683,7 +684,7 @@ namespace Aaru.Core
|
||||
SectorTagType.CdSectorSubchannel);
|
||||
|
||||
UpdateProgress2("Hashings subchannel sector {0} of {1}", (long)doneSectors,
|
||||
(long)(trk.TrackEndSector - trk.TrackStartSector + 1));
|
||||
(long)((trk.TrackEndSector - trk.TrackStartSector) + 1));
|
||||
|
||||
doneSectors += sectors - doneSectors;
|
||||
}
|
||||
@@ -741,19 +742,19 @@ namespace Aaru.Core
|
||||
|
||||
switch(plugin.XmlFsType.Type)
|
||||
{
|
||||
case"Opera":
|
||||
case "Opera":
|
||||
dskType = MediaType.ThreeDO;
|
||||
|
||||
break;
|
||||
case"PC Engine filesystem":
|
||||
case "PC Engine filesystem":
|
||||
dskType = MediaType.SuperCDROM2;
|
||||
|
||||
break;
|
||||
case"Nintendo Wii filesystem":
|
||||
case "Nintendo Wii filesystem":
|
||||
dskType = MediaType.WOD;
|
||||
|
||||
break;
|
||||
case"Nintendo Gamecube filesystem":
|
||||
case "Nintendo Gamecube filesystem":
|
||||
dskType = MediaType.GOD;
|
||||
|
||||
break;
|
||||
@@ -781,7 +782,7 @@ namespace Aaru.Core
|
||||
|
||||
var xmlPart = new Partition
|
||||
{
|
||||
Start = xmlTrk.StartSector, Length = xmlTrk.EndSector - xmlTrk.StartSector + 1,
|
||||
Start = xmlTrk.StartSector, Length = (xmlTrk.EndSector - xmlTrk.StartSector) + 1,
|
||||
Type = xmlTrk.TrackType1.ToString(), Size = xmlTrk.Size, Sequence = xmlTrk.Sequence.TrackNumber
|
||||
};
|
||||
|
||||
@@ -804,19 +805,19 @@ namespace Aaru.Core
|
||||
|
||||
switch(plugin.XmlFsType.Type)
|
||||
{
|
||||
case"Opera":
|
||||
case "Opera":
|
||||
dskType = MediaType.ThreeDO;
|
||||
|
||||
break;
|
||||
case"PC Engine filesystem":
|
||||
case "PC Engine filesystem":
|
||||
dskType = MediaType.SuperCDROM2;
|
||||
|
||||
break;
|
||||
case"Nintendo Wii filesystem":
|
||||
case "Nintendo Wii filesystem":
|
||||
dskType = MediaType.WOD;
|
||||
|
||||
break;
|
||||
case"Nintendo Gamecube filesystem":
|
||||
case "Nintendo Gamecube filesystem":
|
||||
dskType = MediaType.GOD;
|
||||
|
||||
break;
|
||||
@@ -845,8 +846,8 @@ namespace Aaru.Core
|
||||
if(dskType == MediaType.XGD2 &&
|
||||
sidecar.OpticalDisc[0].Track.Length == 1)
|
||||
{
|
||||
ulong blocks = sidecar.OpticalDisc[0].Track[0].EndSector - sidecar.OpticalDisc[0].Track[0].StartSector +
|
||||
1;
|
||||
ulong blocks =
|
||||
(sidecar.OpticalDisc[0].Track[0].EndSector - sidecar.OpticalDisc[0].Track[0].StartSector) + 1;
|
||||
|
||||
if(blocks == 25063 || // Locked (or non compatible drive)
|
||||
blocks == 4229664 || // Xtreme unlock
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Aaru.Core
|
||||
{
|
||||
public partial class Sidecar
|
||||
{
|
||||
readonly ChecksumType[] emptyChecksums;
|
||||
readonly Encoding encoding;
|
||||
readonly FileInfo fi;
|
||||
readonly Guid filterId;
|
||||
@@ -52,7 +53,6 @@ namespace Aaru.Core
|
||||
readonly Checksum imgChkWorker;
|
||||
readonly PluginBase plugins;
|
||||
bool aborted;
|
||||
readonly ChecksumType[] emptyChecksums;
|
||||
FileStream fs;
|
||||
CICMMetadataType sidecar;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Aaru.Core
|
||||
imgChkWorker = new Checksum();
|
||||
aborted = false;
|
||||
|
||||
Checksum emptyChkWorker = new Checksum();
|
||||
var emptyChkWorker = new Checksum();
|
||||
emptyChkWorker.Update(new byte[0]);
|
||||
emptyChecksums = emptyChkWorker.End().ToArray();
|
||||
}
|
||||
@@ -88,9 +88,7 @@ namespace Aaru.Core
|
||||
aborted = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implements creating a metadata sidecar
|
||||
/// </summary>
|
||||
/// <summary>Implements creating a metadata sidecar</summary>
|
||||
/// <returns>The metadata sidecar</returns>
|
||||
public CICMMetadataType Create()
|
||||
{
|
||||
@@ -101,9 +99,11 @@ namespace Aaru.Core
|
||||
long position = 0;
|
||||
UpdateStatus("Hashing image file...");
|
||||
InitProgress();
|
||||
|
||||
while(position < fi.Length - 1048576)
|
||||
{
|
||||
if(aborted) return sidecar;
|
||||
if(aborted)
|
||||
return sidecar;
|
||||
|
||||
data = new byte[1048576];
|
||||
fs.Read(data, 0, 1048576);
|
||||
@@ -135,7 +135,8 @@ namespace Aaru.Core
|
||||
sidecar.AudioMedia = null;
|
||||
sidecar.LinearMedia = null;
|
||||
|
||||
if(aborted) return sidecar;
|
||||
if(aborted)
|
||||
return sidecar;
|
||||
|
||||
switch(image.Info.XmlMediaType)
|
||||
{
|
||||
@@ -145,20 +146,24 @@ namespace Aaru.Core
|
||||
encoding);
|
||||
else
|
||||
{
|
||||
AaruConsole
|
||||
.ErrorWriteLine("The specified image says it contains an optical media but at the same time says it does not support them.");
|
||||
AaruConsole.
|
||||
ErrorWriteLine("The specified image says it contains an optical media but at the same time says it does not support them.");
|
||||
|
||||
AaruConsole.ErrorWriteLine("Please open an issue at Github.");
|
||||
}
|
||||
|
||||
break;
|
||||
case XmlMediaType.BlockMedia:
|
||||
BlockMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
|
||||
|
||||
break;
|
||||
case XmlMediaType.LinearMedia:
|
||||
LinearMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
|
||||
|
||||
break;
|
||||
case XmlMediaType.AudioMedia:
|
||||
AudioMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@ namespace Aaru.Core
|
||||
/// <summary>Loads saved statistics from disk</summary>
|
||||
public static void LoadStats()
|
||||
{
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
if(File.Exists(Path.Combine(Aaru.Settings.Settings.StatsPath, "Statistics.xml")))
|
||||
if(File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")))
|
||||
try
|
||||
{
|
||||
var allStats = new Stats();
|
||||
var xs = new XmlSerializer(allStats.GetType());
|
||||
var sr = new StreamReader(Path.Combine(Aaru.Settings.Settings.StatsPath, "Statistics.xml"));
|
||||
var sr = new StreamReader(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"));
|
||||
allStats = (Stats)xs.Deserialize(sr);
|
||||
sr.Close();
|
||||
|
||||
@@ -467,9 +467,9 @@ namespace Aaru.Core
|
||||
if(string.IsNullOrWhiteSpace(media.type))
|
||||
continue;
|
||||
|
||||
Aaru.Database.Models.Media existing =
|
||||
Database.Models.Media existing =
|
||||
ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real &&
|
||||
c.Synchronized) ?? new Aaru.Database.Models.Media
|
||||
c.Synchronized) ?? new Database.Models.Media
|
||||
{
|
||||
Type = media.type, Real = media.real, Synchronized = true
|
||||
};
|
||||
@@ -479,14 +479,14 @@ namespace Aaru.Core
|
||||
}
|
||||
|
||||
ctx.SaveChanges();
|
||||
File.Delete(Path.Combine(Aaru.Settings.Settings.StatsPath, "Statistics.xml"));
|
||||
File.Delete(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Do not care about it
|
||||
}
|
||||
|
||||
if(Aaru.Settings.Settings.Current.Stats == null)
|
||||
if(Settings.Settings.Current.Stats == null)
|
||||
return;
|
||||
|
||||
ctx.OperatingSystems.Add(new OperatingSystem
|
||||
@@ -506,11 +506,11 @@ namespace Aaru.Core
|
||||
/// <summary>Saves statistics to disk</summary>
|
||||
public static void SaveStats()
|
||||
{
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
ctx.SaveChanges();
|
||||
|
||||
if(Aaru.Settings.Settings.Current.Stats != null &&
|
||||
Aaru.Settings.Settings.Current.Stats.ShareStats)
|
||||
if(Settings.Settings.Current.Stats != null &&
|
||||
Settings.Settings.Current.Stats.ShareStats)
|
||||
SubmitStats();
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ namespace Aaru.Core
|
||||
{
|
||||
var submitThread = new Thread(() =>
|
||||
{
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -746,8 +746,7 @@ namespace Aaru.Core
|
||||
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
|
||||
var request = WebRequest.Create("https://www.aaru.app/api/uploadstatsv2");
|
||||
|
||||
((HttpWebRequest)request).UserAgent =
|
||||
$"Aaru {typeof(Version).Assembly.GetName().Version}";
|
||||
((HttpWebRequest)request).UserAgent = $"Aaru {typeof(Version).Assembly.GetName().Version}";
|
||||
|
||||
request.Method = "POST";
|
||||
request.ContentLength = jsonBytes.Length;
|
||||
@@ -880,9 +879,9 @@ namespace Aaru.Core
|
||||
{
|
||||
if(ctx.Medias.Any(c => !c.Synchronized && c.Type == media && c.Real))
|
||||
{
|
||||
Aaru.Database.Models.Media existing =
|
||||
Database.Models.Media existing =
|
||||
ctx.Medias.FirstOrDefault(c => c.Synchronized && c.Type == media && c.Real) ??
|
||||
new Aaru.Database.Models.Media
|
||||
new Database.Models.Media
|
||||
{
|
||||
Synchronized = true, Type = media, Real = true
|
||||
};
|
||||
@@ -900,9 +899,9 @@ namespace Aaru.Core
|
||||
continue;
|
||||
|
||||
{
|
||||
Aaru.Database.Models.Media existing =
|
||||
Database.Models.Media existing =
|
||||
ctx.Medias.FirstOrDefault(c => c.Synchronized && c.Type == media && !c.Real) ??
|
||||
new Aaru.Database.Models.Media
|
||||
new Database.Models.Media
|
||||
{
|
||||
Synchronized = true, Type = media, Real = false
|
||||
};
|
||||
@@ -1073,7 +1072,7 @@ namespace Aaru.Core
|
||||
}
|
||||
|
||||
IEnumerable<string> statsFiles =
|
||||
Directory.EnumerateFiles(Aaru.Settings.Settings.StatsPath, "PartialStats_*.xml",
|
||||
Directory.EnumerateFiles(Settings.Settings.StatsPath, "PartialStats_*.xml",
|
||||
SearchOption.TopDirectoryOnly);
|
||||
|
||||
foreach(string statsFile in statsFiles)
|
||||
@@ -1153,11 +1152,11 @@ namespace Aaru.Core
|
||||
if(string.IsNullOrWhiteSpace(command))
|
||||
return;
|
||||
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.DeviceStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.DeviceStats)
|
||||
return;
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.Commands.Add(new Command
|
||||
{
|
||||
@@ -1174,11 +1173,11 @@ namespace Aaru.Core
|
||||
if(string.IsNullOrWhiteSpace(filesystem))
|
||||
return;
|
||||
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.FilesystemStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.FilesystemStats)
|
||||
return;
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.Filesystems.Add(new Filesystem
|
||||
{
|
||||
@@ -1195,11 +1194,11 @@ namespace Aaru.Core
|
||||
if(string.IsNullOrWhiteSpace(partition))
|
||||
return;
|
||||
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.PartitionStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.PartitionStats)
|
||||
return;
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.Partitions.Add(new Partition
|
||||
{
|
||||
@@ -1216,11 +1215,11 @@ namespace Aaru.Core
|
||||
if(string.IsNullOrWhiteSpace(filter))
|
||||
return;
|
||||
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.FilterStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.FilterStats)
|
||||
return;
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.Filters.Add(new Filter
|
||||
{
|
||||
@@ -1237,11 +1236,11 @@ namespace Aaru.Core
|
||||
if(string.IsNullOrWhiteSpace(format))
|
||||
return;
|
||||
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.MediaImageStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.MediaImageStats)
|
||||
return;
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.MediaFormats.Add(new MediaFormat
|
||||
{
|
||||
@@ -1255,8 +1254,8 @@ namespace Aaru.Core
|
||||
/// <param name="dev">Device</param>
|
||||
public static void AddDevice(Device dev)
|
||||
{
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.DeviceStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.DeviceStats)
|
||||
return;
|
||||
|
||||
string deviceBus;
|
||||
@@ -1268,7 +1267,7 @@ namespace Aaru.Core
|
||||
else
|
||||
deviceBus = dev.Type.ToString();
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.SeenDevices.Add(new DeviceStat
|
||||
{
|
||||
@@ -1285,13 +1284,13 @@ namespace Aaru.Core
|
||||
/// <param name="real">Set if media was found on a real device, otherwise found on a media image</param>
|
||||
public static void AddMedia(MediaType type, bool real)
|
||||
{
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.MediaStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.MediaStats)
|
||||
return;
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.Medias.Add(new Aaru.Database.Models.Media
|
||||
ctx.Medias.Add(new Database.Models.Media
|
||||
{
|
||||
Real = real, Synchronized = false, Type = type.ToString(), Count = 1
|
||||
});
|
||||
@@ -1303,11 +1302,11 @@ namespace Aaru.Core
|
||||
public static void AddRemote(string serverApplication, string serverVersion, string serverOperatingSystem,
|
||||
string serverOperatingSystemVersion, string serverArchitecture)
|
||||
{
|
||||
if(Aaru.Settings.Settings.Current.Stats == null ||
|
||||
!Aaru.Settings.Settings.Current.Stats.MediaStats)
|
||||
if(Settings.Settings.Current.Stats == null ||
|
||||
!Settings.Settings.Current.Stats.MediaStats)
|
||||
return;
|
||||
|
||||
var ctx = AaruContext.Create(Aaru.Settings.Settings.LocalDbPath);
|
||||
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
ctx.RemoteApplications.Add(new RemoteApplication
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Aaru.Database
|
||||
{
|
||||
public sealed class AaruContext : DbContext
|
||||
{
|
||||
public AaruContext(DbContextOptions options) : base(options) { }
|
||||
public AaruContext(DbContextOptions options) : base(options) {}
|
||||
|
||||
public DbSet<Device> Devices { get; set; }
|
||||
public DbSet<Report> Reports { get; set; }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,47 +9,47 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
migrationBuilder.DropTable("Reports");
|
||||
|
||||
migrationBuilder.CreateTable("Reports",
|
||||
table => new
|
||||
{
|
||||
Id =
|
||||
table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
USBId = table.Column<int>(nullable: true),
|
||||
FireWireId = table.Column<int>(nullable: true),
|
||||
PCMCIAId = table.Column<int>(nullable: true),
|
||||
CompactFlash = table.Column<bool>(nullable: false),
|
||||
ATAId = table.Column<int>(nullable: true),
|
||||
ATAPIId = table.Column<int>(nullable: true),
|
||||
SCSIId = table.Column<int>(nullable: true),
|
||||
MultiMediaCardId = table.Column<int>(nullable: true),
|
||||
SecureDigitalId = table.Column<int>(nullable: true),
|
||||
Manufacturer = table.Column<string>(nullable: true),
|
||||
Model = table.Column<string>(nullable: true),
|
||||
Revision = table.Column<string>(nullable: true),
|
||||
Type = table.Column<int>(nullable: false)
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Devices", x => x.Id);
|
||||
table.ForeignKey("FK_Reports_Ata_ATAId", x => x.ATAId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Reports_Ata_ATAPIId", x => x.ATAPIId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Reports_FireWire_FireWireId", x => x.FireWireId,
|
||||
"FireWire", "Id", onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Reports_MmcSd_MultiMediaCardId",
|
||||
x => x.MultiMediaCardId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Reports_Pcmcia_PCMCIAId", x => x.PCMCIAId, "Pcmcia",
|
||||
"Id", onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Reports_Scsi_SCSIId", x => x.SCSIId, "Scsi", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Reports_MmcSd_SecureDigitalId",
|
||||
x => x.SecureDigitalId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Reports_Usb_USBId", x => x.USBId, "Usb", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
migrationBuilder.CreateTable("Reports", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
USBId = table.Column<int>(nullable: true),
|
||||
FireWireId = table.Column<int>(nullable: true),
|
||||
PCMCIAId = table.Column<int>(nullable: true), CompactFlash = table.Column<bool>(),
|
||||
ATAId = table.Column<int>(nullable: true),
|
||||
ATAPIId = table.Column<int>(nullable: true),
|
||||
SCSIId = table.Column<int>(nullable: true),
|
||||
MultiMediaCardId = table.Column<int>(nullable: true),
|
||||
SecureDigitalId = table.Column<int>(nullable: true),
|
||||
Manufacturer = table.Column<string>(nullable: true), Model = table.Column<string>(nullable: true),
|
||||
Revision = table.Column<string>(nullable: true), Type = table.Column<int>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Devices", x => x.Id);
|
||||
|
||||
table.ForeignKey("FK_Reports_Ata_ATAId", x => x.ATAId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Reports_Ata_ATAPIId", x => x.ATAPIId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Reports_FireWire_FireWireId", x => x.FireWireId, "FireWire", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Reports_MmcSd_MultiMediaCardId", x => x.MultiMediaCardId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Reports_Pcmcia_PCMCIAId", x => x.PCMCIAId, "Pcmcia", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Reports_Scsi_SCSIId", x => x.SCSIId, "Scsi", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Reports_MmcSd_SecureDigitalId", x => x.SecureDigitalId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Reports_Usb_USBId", x => x.USBId, "Usb", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>("Created", "Reports", nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0,
|
||||
@@ -57,48 +57,48 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
migrationBuilder.AddColumn<bool>("Uploaded", "Reports", nullable: false, defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable("Devices",
|
||||
table => new
|
||||
{
|
||||
Id =
|
||||
table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
USBId = table.Column<int>(nullable: true),
|
||||
FireWireId = table.Column<int>(nullable: true),
|
||||
PCMCIAId = table.Column<int>(nullable: true),
|
||||
CompactFlash = table.Column<bool>(nullable: false),
|
||||
ATAId = table.Column<int>(nullable: true),
|
||||
ATAPIId = table.Column<int>(nullable: true),
|
||||
SCSIId = table.Column<int>(nullable: true),
|
||||
MultiMediaCardId = table.Column<int>(nullable: true),
|
||||
SecureDigitalId = table.Column<int>(nullable: true),
|
||||
Manufacturer = table.Column<string>(nullable: true),
|
||||
Model = table.Column<string>(nullable: true),
|
||||
Revision = table.Column<string>(nullable: true),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
LastSynchronized = table.Column<DateTime>(nullable: false)
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Devices", x => x.Id);
|
||||
table.ForeignKey("FK_Devices_Ata_ATAId", x => x.ATAId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Devices_Ata_ATAPIId", x => x.ATAPIId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Devices_FireWire_FireWireId", x => x.FireWireId,
|
||||
"FireWire", "Id", onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Devices_MmcSd_MultiMediaCardId",
|
||||
x => x.MultiMediaCardId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Devices_Pcmcia_PCMCIAId", x => x.PCMCIAId, "Pcmcia",
|
||||
"Id", onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Devices_Scsi_SCSIId", x => x.SCSIId, "Scsi", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Devices_MmcSd_SecureDigitalId",
|
||||
x => x.SecureDigitalId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey("FK_Devices_Usb_USBId", x => x.USBId, "Usb", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
migrationBuilder.CreateTable("Devices", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
USBId = table.Column<int>(nullable: true),
|
||||
FireWireId = table.Column<int>(nullable: true),
|
||||
PCMCIAId = table.Column<int>(nullable: true), CompactFlash = table.Column<bool>(),
|
||||
ATAId = table.Column<int>(nullable: true),
|
||||
ATAPIId = table.Column<int>(nullable: true),
|
||||
SCSIId = table.Column<int>(nullable: true),
|
||||
MultiMediaCardId = table.Column<int>(nullable: true),
|
||||
SecureDigitalId = table.Column<int>(nullable: true),
|
||||
Manufacturer = table.Column<string>(nullable: true), Model = table.Column<string>(nullable: true),
|
||||
Revision = table.Column<string>(nullable: true), Type = table.Column<int>(),
|
||||
LastSynchronized = table.Column<DateTime>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Devices", x => x.Id);
|
||||
|
||||
table.ForeignKey("FK_Devices_Ata_ATAId", x => x.ATAId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Devices_Ata_ATAPIId", x => x.ATAPIId, "Ata", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Devices_FireWire_FireWireId", x => x.FireWireId, "FireWire", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Devices_MmcSd_MultiMediaCardId", x => x.MultiMediaCardId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Devices_Pcmcia_PCMCIAId", x => x.PCMCIAId, "Pcmcia", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Devices_Scsi_SCSIId", x => x.SCSIId, "Scsi", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Devices_MmcSd_SecureDigitalId", x => x.SecureDigitalId, "MmcSd", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
table.ForeignKey("FK_Devices_Usb_USBId", x => x.USBId, "Usb", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex("IX_Devices_ATAId", "Devices", "ATAId");
|
||||
|
||||
|
||||
@@ -6,52 +6,50 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("Commands",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_Commands", x => x.Id); });
|
||||
migrationBuilder.CreateTable("Commands", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true), Synchronized = table.Column<bool>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Commands", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable("Filesystems",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table => { table.PrimaryKey("PK_Filesystems", x => x.Id); });
|
||||
migrationBuilder.CreateTable("Filesystems", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true), Synchronized = table.Column<bool>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Filesystems", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable("Filters",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_Filters", x => x.Id); });
|
||||
migrationBuilder.CreateTable("Filters", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true), Synchronized = table.Column<bool>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Filters", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable("MediaFormats",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table => { table.PrimaryKey("PK_MediaFormats", x => x.Id); });
|
||||
migrationBuilder.CreateTable("MediaFormats", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true), Synchronized = table.Column<bool>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MediaFormats", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable("Partitions",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_Partitions", x => x.Id); });
|
||||
migrationBuilder.CreateTable("Partitions", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true), Synchronized = table.Column<bool>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Partitions", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
|
||||
@@ -4,22 +4,42 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
public partial class MediaStatistics : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("Medias",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Type = table.Column<string>(nullable: true),
|
||||
Real = table.Column<bool>(nullable: false),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_Medias", x => x.Id); });
|
||||
}
|
||||
protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("Medias", table =>
|
||||
new
|
||||
{
|
||||
Id =
|
||||
table.
|
||||
Column
|
||||
<int
|
||||
>().
|
||||
Annotation("Sqlite:Autoincrement",
|
||||
true),
|
||||
Type =
|
||||
table.
|
||||
Column
|
||||
<string
|
||||
>(nullable
|
||||
: true),
|
||||
Real =
|
||||
table.
|
||||
Column
|
||||
<bool
|
||||
>(),
|
||||
Synchronized
|
||||
= table.
|
||||
Column
|
||||
<bool
|
||||
>()
|
||||
}, constraints
|
||||
: table =>
|
||||
{
|
||||
table.
|
||||
PrimaryKey("PK_Medias",
|
||||
x =>
|
||||
x.
|
||||
Id);
|
||||
});
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("Medias");
|
||||
}
|
||||
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Medias");
|
||||
}
|
||||
}
|
||||
@@ -4,25 +4,52 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
public partial class SeenDevicesStatistics : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("SeenDevices",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Manufacturer = table.Column<string>(nullable: true),
|
||||
Model = table.Column<string>(nullable: true),
|
||||
Revision = table.Column<string>(nullable: true),
|
||||
Bus = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table => { table.PrimaryKey("PK_SeenDevices", x => x.Id); });
|
||||
}
|
||||
protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("SeenDevices",
|
||||
table => new
|
||||
{
|
||||
Id = table.
|
||||
Column<
|
||||
int
|
||||
>().
|
||||
Annotation("Sqlite:Autoincrement",
|
||||
true),
|
||||
Manufacturer =
|
||||
table.
|
||||
Column
|
||||
<string
|
||||
>(nullable
|
||||
: true),
|
||||
Model = table.
|
||||
Column<
|
||||
string
|
||||
>(nullable
|
||||
: true),
|
||||
Revision =
|
||||
table.
|
||||
Column
|
||||
<string
|
||||
>(nullable
|
||||
: true),
|
||||
Bus = table.
|
||||
Column<
|
||||
string
|
||||
>(nullable
|
||||
: true),
|
||||
Synchronized =
|
||||
table.
|
||||
Column
|
||||
<bool
|
||||
>()
|
||||
}, constraints:
|
||||
table =>
|
||||
{
|
||||
table.
|
||||
PrimaryKey("PK_SeenDevices",
|
||||
x =>
|
||||
x.
|
||||
Id);
|
||||
});
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("SeenDevices");
|
||||
}
|
||||
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("SeenDevices");
|
||||
}
|
||||
}
|
||||
@@ -4,23 +4,18 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
public partial class OperatingSystemStatistics : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("OperatingSystems",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Version = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table => { table.PrimaryKey("PK_OperatingSystems", x => x.Id); });
|
||||
}
|
||||
protected override void Up(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.CreateTable("OperatingSystems", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true), Version = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OperatingSystems", x => x.Id);
|
||||
});
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
protected override void Down(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.DropTable("OperatingSystems");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,21 +4,35 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
public partial class VersionStatistics : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("Versions",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Value = table.Column<string>(nullable: true),
|
||||
Synchronized = table.Column<bool>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_Versions", x => x.Id); });
|
||||
}
|
||||
protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("Versions",
|
||||
table => new
|
||||
{
|
||||
Id = table.
|
||||
Column<
|
||||
int
|
||||
>().
|
||||
Annotation("Sqlite:Autoincrement",
|
||||
true),
|
||||
Value = table.
|
||||
Column<
|
||||
string
|
||||
>(nullable
|
||||
: true),
|
||||
Synchronized =
|
||||
table.
|
||||
Column
|
||||
<bool
|
||||
>()
|
||||
}, constraints:
|
||||
table =>
|
||||
{
|
||||
table.
|
||||
PrimaryKey("PK_Versions",
|
||||
x =>
|
||||
x.
|
||||
Id);
|
||||
});
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("Versions");
|
||||
}
|
||||
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Versions");
|
||||
}
|
||||
}
|
||||
@@ -15,66 +15,63 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
migrationBuilder.DropColumn("ModeSense2AData", "Mmc");
|
||||
|
||||
migrationBuilder.CreateTable("ModePage_2A",
|
||||
table => new
|
||||
{
|
||||
Id =
|
||||
table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
AccurateCDDA = table.Column<bool>(nullable: false),
|
||||
AudioPlay = table.Column<bool>(nullable: false),
|
||||
BCK = table.Column<bool>(nullable: false),
|
||||
BUF = table.Column<bool>(nullable: false),
|
||||
BufferSize = table.Column<ushort>(nullable: false),
|
||||
C2Pointer = table.Column<bool>(nullable: false),
|
||||
CDDACommand = table.Column<bool>(nullable: false),
|
||||
CMRSupported = table.Column<ushort>(nullable: false),
|
||||
Composite = table.Column<bool>(nullable: false),
|
||||
CurrentSpeed = table.Column<ushort>(nullable: false),
|
||||
CurrentWriteSpeed = table.Column<ushort>(nullable: false),
|
||||
CurrentWriteSpeedSelected = table.Column<ushort>(nullable: false),
|
||||
DeinterlaveSubchannel = table.Column<bool>(nullable: false),
|
||||
DigitalPort1 = table.Column<bool>(nullable: false),
|
||||
DigitalPort2 = table.Column<bool>(nullable: false),
|
||||
Eject = table.Column<bool>(nullable: false),
|
||||
ISRC = table.Column<bool>(nullable: false),
|
||||
LSBF = table.Column<bool>(nullable: false),
|
||||
LeadInPW = table.Column<bool>(nullable: false),
|
||||
Length = table.Column<byte>(nullable: false),
|
||||
LoadingMechanism = table.Column<byte>(nullable: false),
|
||||
Lock = table.Column<bool>(nullable: false),
|
||||
LockState = table.Column<bool>(nullable: false),
|
||||
MaxWriteSpeed = table.Column<ushort>(nullable: false),
|
||||
MaximumSpeed = table.Column<ushort>(nullable: false),
|
||||
Method2 = table.Column<bool>(nullable: false),
|
||||
Mode2Form1 = table.Column<bool>(nullable: false),
|
||||
Mode2Form2 = table.Column<bool>(nullable: false),
|
||||
MultiSession = table.Column<bool>(nullable: false),
|
||||
PS = table.Column<bool>(nullable: false),
|
||||
PreventJumper = table.Column<bool>(nullable: false),
|
||||
RCK = table.Column<bool>(nullable: false),
|
||||
ReadBarcode = table.Column<bool>(nullable: false),
|
||||
ReadCDR = table.Column<bool>(nullable: false),
|
||||
ReadCDRW = table.Column<bool>(nullable: false),
|
||||
ReadDVDR = table.Column<bool>(nullable: false),
|
||||
ReadDVDRAM = table.Column<bool>(nullable: false),
|
||||
ReadDVDROM = table.Column<bool>(nullable: false),
|
||||
RotationControlSelected = table.Column<byte>(nullable: false),
|
||||
SCC = table.Column<bool>(nullable: false),
|
||||
SDP = table.Column<bool>(nullable: false),
|
||||
SSS = table.Column<bool>(nullable: false),
|
||||
SeparateChannelMute = table.Column<bool>(nullable: false),
|
||||
SeparateChannelVolume = table.Column<bool>(nullable: false),
|
||||
Subchannel = table.Column<bool>(nullable: false),
|
||||
SupportedVolumeLevels = table.Column<ushort>(nullable: false),
|
||||
TestWrite = table.Column<bool>(nullable: false),
|
||||
UPC = table.Column<bool>(nullable: false),
|
||||
WriteCDR = table.Column<bool>(nullable: false),
|
||||
WriteCDRW = table.Column<bool>(nullable: false),
|
||||
WriteDVDR = table.Column<bool>(nullable: false),
|
||||
WriteDVDRAM = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table => { table.PrimaryKey("PK_ModePage_2A", x => x.Id); });
|
||||
migrationBuilder.CreateTable("ModePage_2A", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
AccurateCDDA = table.Column<bool>(),
|
||||
AudioPlay = table.Column<bool>(),
|
||||
BCK = table.Column<bool>(), BUF = table.Column<bool>(),
|
||||
BufferSize = table.Column<ushort>(),
|
||||
C2Pointer = table.Column<bool>(),
|
||||
CDDACommand = table.Column<bool>(),
|
||||
CMRSupported = table.Column<ushort>(),
|
||||
Composite = table.Column<bool>(),
|
||||
CurrentSpeed = table.Column<ushort>(),
|
||||
CurrentWriteSpeed = table.Column<ushort>(),
|
||||
CurrentWriteSpeedSelected = table.Column<ushort>(),
|
||||
DeinterlaveSubchannel = table.Column<bool>(),
|
||||
DigitalPort1 = table.Column<bool>(),
|
||||
DigitalPort2 = table.Column<bool>(),
|
||||
Eject = table.Column<bool>(),
|
||||
ISRC = table.Column<bool>(),
|
||||
LSBF = table.Column<bool>(),
|
||||
LeadInPW = table.Column<bool>(),
|
||||
Length = table.Column<byte>(),
|
||||
LoadingMechanism = table.Column<byte>(),
|
||||
Lock = table.Column<bool>(),
|
||||
LockState = table.Column<bool>(),
|
||||
MaxWriteSpeed = table.Column<ushort>(),
|
||||
MaximumSpeed = table.Column<ushort>(),
|
||||
Method2 = table.Column<bool>(),
|
||||
Mode2Form1 = table.Column<bool>(),
|
||||
Mode2Form2 = table.Column<bool>(),
|
||||
MultiSession = table.Column<bool>(),
|
||||
PS = table.Column<bool>(),
|
||||
PreventJumper = table.Column<bool>(),
|
||||
RCK = table.Column<bool>(),
|
||||
ReadBarcode = table.Column<bool>(),
|
||||
ReadCDR = table.Column<bool>(),
|
||||
ReadCDRW = table.Column<bool>(),
|
||||
ReadDVDR = table.Column<bool>(),
|
||||
ReadDVDRAM = table.Column<bool>(),
|
||||
ReadDVDROM = table.Column<bool>(),
|
||||
RotationControlSelected = table.Column<byte>(),
|
||||
SCC = table.Column<bool>(),
|
||||
SDP = table.Column<bool>(), SSS = table.Column<bool>(),
|
||||
SeparateChannelMute = table.Column<bool>(),
|
||||
SeparateChannelVolume = table.Column<bool>(),
|
||||
Subchannel = table.Column<bool>(),
|
||||
SupportedVolumeLevels = table.Column<ushort>(),
|
||||
TestWrite = table.Column<bool>(),
|
||||
UPC = table.Column<bool>(),
|
||||
WriteCDR = table.Column<bool>(),
|
||||
WriteCDRW = table.Column<bool>(),
|
||||
WriteDVDR = table.Column<bool>(),
|
||||
WriteDVDRAM = table.Column<bool>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ModePage_2A", x => x.Id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,31 +7,30 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("UsbVendors",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<ushort>(nullable: false),
|
||||
Vendor = table.Column<string>(nullable: true),
|
||||
AddedWhen = table.Column<DateTime>(nullable: false),
|
||||
ModifiedWhen = table.Column<DateTime>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_UsbVendors", x => x.Id); });
|
||||
migrationBuilder.CreateTable("UsbVendors", table => new
|
||||
{
|
||||
Id = table.Column<ushort>(), Vendor = table.Column<string>(nullable: true),
|
||||
AddedWhen = table.Column<DateTime>(), ModifiedWhen = table.Column<DateTime>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UsbVendors", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable("UsbProducts",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
ProductId = table.Column<ushort>(nullable: false),
|
||||
Product = table.Column<string>(nullable: true),
|
||||
AddedWhen = table.Column<DateTime>(nullable: false),
|
||||
ModifiedWhen = table.Column<DateTime>(nullable: false),
|
||||
VendorId = table.Column<ushort>(nullable: false)
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UsbProducts", x => x.Id);
|
||||
table.ForeignKey("FK_UsbProducts_UsbVendors_VendorId", x => x.VendorId,
|
||||
"UsbVendors", "Id", onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
migrationBuilder.CreateTable("UsbProducts", table => new
|
||||
{
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
ProductId = table.Column<ushort>(),
|
||||
Product = table.Column<string>(nullable: true),
|
||||
AddedWhen = table.Column<DateTime>(),
|
||||
ModifiedWhen = table.Column<DateTime>(),
|
||||
VendorId = table.Column<ushort>()
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UsbProducts", x => x.Id);
|
||||
|
||||
table.ForeignKey("FK_UsbProducts_UsbVendors_VendorId", x => x.VendorId, "UsbVendors", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex("IX_UsbProducts_VendorId", "UsbProducts", "VendorId");
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex("IX_UsbProducts_ProductId", "UsbProducts", "ProductId");
|
||||
migrationBuilder.CreateIndex("IX_UsbProducts_ProductId", "UsbProducts", "ProductId");
|
||||
migrationBuilder.CreateIndex("IX_UsbProducts_ModifiedWhen", "UsbProducts", "ModifiedWhen");
|
||||
migrationBuilder.CreateIndex("IX_UsbVendors_ModifiedWhen", "UsbVendors", "ModifiedWhen");
|
||||
migrationBuilder.CreateIndex("IX_UsbVendors_ModifiedWhen", "UsbVendors", "ModifiedWhen");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex("IX_UsbProducts_ProductId", "UsbProducts");
|
||||
migrationBuilder.DropIndex("IX_UsbProducts_ProductId", "UsbProducts");
|
||||
migrationBuilder.DropIndex("IX_UsbProducts_ModifiedWhen", "UsbProducts");
|
||||
migrationBuilder.DropIndex("IX_UsbVendors_ModifiedWhen", "UsbVendors");
|
||||
migrationBuilder.DropIndex("IX_UsbVendors_ModifiedWhen", "UsbVendors");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,26 +5,61 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
public partial class AddCdOffsets : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("CdOffsets",
|
||||
table => new
|
||||
{
|
||||
Manufacturer = table.Column<string>(nullable: true),
|
||||
Model = table.Column<string>(nullable: true),
|
||||
Offset = table.Column<short>(nullable: false),
|
||||
Submissions = table.Column<int>(nullable: false),
|
||||
Agreement = table.Column<float>(nullable: false),
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
AddedWhen = table.Column<DateTime>(nullable: false),
|
||||
ModifiedWhen = table.Column<DateTime>(nullable: false)
|
||||
}, constraints: table => { table.PrimaryKey("PK_CdOffsets", x => x.Id); });
|
||||
}
|
||||
protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.CreateTable("CdOffsets",
|
||||
table => new
|
||||
{
|
||||
Manufacturer =
|
||||
table.
|
||||
Column
|
||||
<string
|
||||
>(nullable
|
||||
: true),
|
||||
Model = table.
|
||||
Column<
|
||||
string
|
||||
>(nullable
|
||||
: true),
|
||||
Offset =
|
||||
table.
|
||||
Column
|
||||
<short
|
||||
>(),
|
||||
Submissions =
|
||||
table.
|
||||
Column
|
||||
<int
|
||||
>(),
|
||||
Agreement =
|
||||
table.
|
||||
Column
|
||||
<float
|
||||
>(),
|
||||
Id = table.
|
||||
Column<
|
||||
int
|
||||
>().
|
||||
Annotation("Sqlite:Autoincrement",
|
||||
true),
|
||||
AddedWhen =
|
||||
table.
|
||||
Column
|
||||
<DateTime
|
||||
>(),
|
||||
ModifiedWhen =
|
||||
table.
|
||||
Column
|
||||
<DateTime
|
||||
>()
|
||||
}, constraints:
|
||||
table =>
|
||||
{
|
||||
table.
|
||||
PrimaryKey("PK_CdOffsets",
|
||||
x =>
|
||||
x.
|
||||
Id);
|
||||
});
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("CdOffsets");
|
||||
}
|
||||
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("CdOffsets");
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,10 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
public partial class AddOptimalReadMultipleCount : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.AddColumn<int>("OptimalMultipleSectorsRead", "Devices", nullable: false, defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
protected override void Down(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.DropColumn("OptimalMultipleSectorsRead", "Devices");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,21 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
migrationBuilder.RenameTable("DensityCode", newName: "DensityCode_old");
|
||||
|
||||
migrationBuilder.CreateTable("DensityCode",
|
||||
table => new
|
||||
{
|
||||
Code = table.Column<int>(nullable: false, defaultValue: 0),
|
||||
SscSupportedMediaId = table.Column<int>(nullable: true),
|
||||
Id = table.Column<int>()
|
||||
.Annotation("Sqlite:Autoincrement", true)
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DensityCode", x => x.Id);
|
||||
table.ForeignKey("FK_DensityCode_SscSupportedMedia_SscSupportedMediaId",
|
||||
x => x.SscSupportedMediaId, "SscSupportedMedia", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
migrationBuilder.CreateTable("DensityCode", table => new
|
||||
{
|
||||
Code = table.Column<int>(nullable: false, defaultValue: 0),
|
||||
SscSupportedMediaId = table.Column<int>(nullable: true),
|
||||
Id = table.Column<int>().Annotation("Sqlite:Autoincrement", true)
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DensityCode", x => x.Id);
|
||||
|
||||
migrationBuilder
|
||||
.Sql("INSERT INTO DensityCode (Code, SscSupportedMediaId) SELECT Code, SscSupportedMediaId FROM DensityCode_old");
|
||||
table.ForeignKey("FK_DensityCode_SscSupportedMedia_SscSupportedMediaId", x => x.SscSupportedMediaId,
|
||||
"SscSupportedMedia", "Id", onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.
|
||||
Sql("INSERT INTO DensityCode (Code, SscSupportedMediaId) SELECT Code, SscSupportedMediaId FROM DensityCode_old");
|
||||
|
||||
migrationBuilder.DropTable("DensityCode_old");
|
||||
}
|
||||
@@ -33,22 +31,20 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
migrationBuilder.RenameTable("DensityCode", newName: "DensityCode_old");
|
||||
|
||||
migrationBuilder.CreateTable("DensityCode",
|
||||
table => new
|
||||
{
|
||||
Code = table.Column<int>()
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
SscSupportedMediaId = table.Column<int>(nullable: true)
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DensityCode", x => x.Code);
|
||||
table.ForeignKey("FK_DensityCode_SscSupportedMedia_SscSupportedMediaId",
|
||||
x => x.SscSupportedMediaId, "SscSupportedMedia", "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
migrationBuilder.CreateTable("DensityCode", table => new
|
||||
{
|
||||
Code = table.Column<int>().Annotation("Sqlite:Autoincrement", true),
|
||||
SscSupportedMediaId = table.Column<int>(nullable: true)
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DensityCode", x => x.Code);
|
||||
|
||||
migrationBuilder
|
||||
.Sql("INSERT INTO DensityCode (Code, SscSupportedMediaId) SELECT Code, SscSupportedMediaId FROM DensityCode_old");
|
||||
table.ForeignKey("FK_DensityCode_SscSupportedMedia_SscSupportedMediaId", x => x.SscSupportedMediaId,
|
||||
"SscSupportedMedia", "Id", onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.
|
||||
Sql("INSERT INTO DensityCode (Code, SscSupportedMediaId) SELECT Code, SscSupportedMediaId FROM DensityCode_old");
|
||||
|
||||
migrationBuilder.DropTable("DensityCode_old");
|
||||
}
|
||||
|
||||
@@ -4,20 +4,10 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
public partial class AddNameCountModel : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Value",
|
||||
table: "Versions",
|
||||
newName: "Name");
|
||||
}
|
||||
protected override void Up(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.RenameColumn("Value", "Versions", "Name");
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Name",
|
||||
table: "Versions",
|
||||
newName: "Value");
|
||||
}
|
||||
protected override void Down(MigrationBuilder migrationBuilder) =>
|
||||
migrationBuilder.RenameColumn("Name", "Versions", "Value");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1337,8 +1337,7 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", b =>
|
||||
{
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode").WithMany("BlockDescriptors").
|
||||
HasForeignKey("ScsiModeId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode").WithMany("BlockDescriptors").HasForeignKey("ScsiModeId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", b =>
|
||||
@@ -1349,14 +1348,12 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", b =>
|
||||
{
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany().
|
||||
HasForeignKey("FeaturesId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany().HasForeignKey("FeaturesId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Aaru.CommonTypes.Metadata.Scsi", b =>
|
||||
{
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", "ModeSense").WithMany().
|
||||
HasForeignKey("ModeSenseId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", "ModeSense").WithMany().HasForeignKey("ModeSenseId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Mmc", "MultiMediaDevice").WithMany().
|
||||
HasForeignKey("MultiMediaDeviceId");
|
||||
@@ -1372,14 +1369,12 @@ namespace Aaru.Database.Migrations
|
||||
{
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Scsi").WithMany("EVPDPages").HasForeignKey("ScsiId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode").WithMany("ModePages").
|
||||
HasForeignKey("ScsiModeId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode").WithMany("ModePages").HasForeignKey("ScsiModeId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Aaru.CommonTypes.Metadata.SscSupportedMedia", b =>
|
||||
{
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Ssc").WithMany("SupportedMediaTypes").
|
||||
HasForeignKey("SscId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Ssc").WithMany("SupportedMediaTypes").HasForeignKey("SscId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia").WithMany("SupportedMediaTypes").
|
||||
HasForeignKey("TestedSequentialMediaId");
|
||||
@@ -1387,8 +1382,7 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
modelBuilder.Entity("Aaru.CommonTypes.Metadata.SupportedDensity", b =>
|
||||
{
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Ssc").WithMany("SupportedDensities").
|
||||
HasForeignKey("SscId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Ssc").WithMany("SupportedDensities").HasForeignKey("SscId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia").WithMany("SupportedDensities").
|
||||
HasForeignKey("TestedSequentialMediaId");
|
||||
@@ -1400,8 +1394,7 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CHS").WithMany().HasForeignKey("CHSId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CurrentCHS").WithMany().
|
||||
HasForeignKey("CurrentCHSId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CurrentCHS").WithMany().HasForeignKey("CurrentCHSId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Mmc").WithMany("TestedMedia").HasForeignKey("MmcId");
|
||||
|
||||
@@ -1419,8 +1412,7 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI").WithMany().HasForeignKey("ATAPIId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").WithMany().
|
||||
HasForeignKey("FireWireId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").WithMany().HasForeignKey("FireWireId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard").WithMany().
|
||||
HasForeignKey("MultiMediaCardId");
|
||||
@@ -1441,8 +1433,7 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI").WithMany().HasForeignKey("ATAPIId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").WithMany().
|
||||
HasForeignKey("FireWireId");
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").WithMany().HasForeignKey("FireWireId");
|
||||
|
||||
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard").WithMany().
|
||||
HasForeignKey("MultiMediaCardId");
|
||||
@@ -1459,8 +1450,8 @@ namespace Aaru.Database.Migrations
|
||||
|
||||
modelBuilder.Entity("Aaru.Database.Models.UsbProduct", b =>
|
||||
{
|
||||
b.HasOne("Aaru.Database.Models.UsbVendor", "Vendor").WithMany("Products").
|
||||
HasForeignKey("VendorId").OnDelete(DeleteBehavior.Cascade);
|
||||
b.HasOne("Aaru.Database.Models.UsbVendor", "Vendor").WithMany("Products").HasForeignKey("VendorId").
|
||||
OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Aaru.Database.Models
|
||||
{
|
||||
public class CdOffset : CommonTypes.Metadata.CdOffset
|
||||
{
|
||||
public CdOffset() { }
|
||||
public CdOffset() {}
|
||||
|
||||
public CdOffset(string manufacturer, string model, short offset, int submissions, float agreement)
|
||||
{
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class Command : NameCountModel<int> { }
|
||||
public class Command : NameCountModel<int> {}
|
||||
}
|
||||
@@ -38,10 +38,7 @@ namespace Aaru.Database.Models
|
||||
{
|
||||
public class Device : DeviceReportV2
|
||||
{
|
||||
public Device()
|
||||
{
|
||||
LastSynchronized = DateTime.UtcNow;
|
||||
}
|
||||
public Device() => LastSynchronized = DateTime.UtcNow;
|
||||
|
||||
public Device(DeviceReportV2 report)
|
||||
{
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class Filesystem : NameCountModel<int> { }
|
||||
public class Filesystem : NameCountModel<int> {}
|
||||
}
|
||||
@@ -32,5 +32,5 @@
|
||||
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class Filter : NameCountModel<int> { }
|
||||
public class Filter : NameCountModel<int> {}
|
||||
}
|
||||
@@ -32,5 +32,5 @@
|
||||
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class MediaFormat : NameCountModel<int> { }
|
||||
public class MediaFormat : NameCountModel<int> {}
|
||||
}
|
||||
@@ -32,5 +32,5 @@
|
||||
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class OperatingSystem : BaseOperatingSystem { }
|
||||
public class OperatingSystem : BaseOperatingSystem {}
|
||||
}
|
||||
@@ -32,5 +32,5 @@
|
||||
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class Partition : NameCountModel<int> { }
|
||||
public class Partition : NameCountModel<int> {}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class RemoteApplication : BaseOperatingSystem { }
|
||||
public class RemoteApplication : BaseOperatingSystem {}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class RemoteArchitecture : NameCountModel<int> { }
|
||||
public class RemoteArchitecture : NameCountModel<int> {}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class RemoteOperatingSystem : BaseOperatingSystem { }
|
||||
public class RemoteOperatingSystem : BaseOperatingSystem {}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace Aaru.Database.Models
|
||||
{
|
||||
public class UsbProduct
|
||||
{
|
||||
public UsbProduct() { }
|
||||
public UsbProduct() {}
|
||||
|
||||
public UsbProduct(ushort vendorId, ushort id, string product)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Aaru.Database.Models
|
||||
{
|
||||
public class UsbVendor
|
||||
{
|
||||
public UsbVendor() { }
|
||||
public UsbVendor() {}
|
||||
|
||||
public UsbVendor(ushort id, string vendor)
|
||||
{
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
|
||||
namespace Aaru.Database.Models
|
||||
{
|
||||
public class Version : NameCountModel<int> { }
|
||||
public class Version : NameCountModel<int> {}
|
||||
}
|
||||
Submodule Aaru.Decoders updated: 9abc956373...a43b4132ee
@@ -31,10 +31,10 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using Aaru.Devices.FreeBSD;
|
||||
using Aaru.Devices.Windows;
|
||||
using Aaru.CommonTypes.Interop;
|
||||
using Aaru.Decoders.ATA;
|
||||
using Aaru.Devices.FreeBSD;
|
||||
using Aaru.Devices.Windows;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
|
||||
|
||||
@@ -42,9 +42,7 @@ namespace Aaru.Devices
|
||||
{
|
||||
internal static class Command
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends a SCSI command
|
||||
/// </summary>
|
||||
/// <summary>Sends a SCSI command</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="fd">File handle</param>
|
||||
/// <param name="cdb">SCSI CDB</param>
|
||||
@@ -58,20 +56,16 @@ namespace Aaru.Devices
|
||||
/// sense
|
||||
/// </param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendScsiCommand(object fd, byte[] cdb, ref byte[] buffer,
|
||||
out byte[] senseBuffer,
|
||||
uint timeout, ScsiDirection direction, out double duration,
|
||||
out bool sense)
|
||||
internal static int SendScsiCommand(object fd, byte[] cdb, ref byte[] buffer, out byte[] senseBuffer,
|
||||
uint timeout, ScsiDirection direction, out double duration, out bool sense)
|
||||
{
|
||||
var ptId = DetectOS.GetRealPlatformID();
|
||||
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||
|
||||
return SendScsiCommand(ptId, fd, cdb, ref buffer, out senseBuffer, timeout, direction, out duration,
|
||||
out sense);
|
||||
out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a SCSI command
|
||||
/// </summary>
|
||||
/// <summary>Sends a SCSI command</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="ptId">Platform ID for executing the command</param>
|
||||
/// <param name="fd">File handle</param>
|
||||
@@ -86,92 +80,101 @@ namespace Aaru.Devices
|
||||
/// sense
|
||||
/// </param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendScsiCommand(PlatformID ptId, object fd, byte[] cdb,
|
||||
ref byte[] buffer,
|
||||
out byte[] senseBuffer, uint timeout, ScsiDirection direction,
|
||||
out double duration, out bool sense)
|
||||
internal static int SendScsiCommand(PlatformID ptId, object fd, byte[] cdb, ref byte[] buffer,
|
||||
out byte[] senseBuffer, uint timeout, ScsiDirection direction,
|
||||
out double duration, out bool sense)
|
||||
{
|
||||
switch (ptId)
|
||||
switch(ptId)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
{
|
||||
ScsiIoctlDirection dir;
|
||||
|
||||
switch (direction)
|
||||
switch(direction)
|
||||
{
|
||||
case ScsiDirection.In:
|
||||
dir = ScsiIoctlDirection.In;
|
||||
|
||||
break;
|
||||
case ScsiDirection.Out:
|
||||
dir = ScsiIoctlDirection.Out;
|
||||
|
||||
break;
|
||||
default:
|
||||
dir = ScsiIoctlDirection.Unspecified;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return Windows.Command.SendScsiCommand((SafeFileHandle) fd, cdb, ref buffer, out senseBuffer,
|
||||
timeout, dir, out duration, out sense);
|
||||
return Windows.Command.SendScsiCommand((SafeFileHandle)fd, cdb, ref buffer, out senseBuffer,
|
||||
timeout, dir, out duration, out sense);
|
||||
}
|
||||
case PlatformID.Linux:
|
||||
{
|
||||
Linux.ScsiIoctlDirection dir;
|
||||
|
||||
switch (direction)
|
||||
switch(direction)
|
||||
{
|
||||
case ScsiDirection.In:
|
||||
dir = Linux.ScsiIoctlDirection.In;
|
||||
|
||||
break;
|
||||
case ScsiDirection.Out:
|
||||
dir = Linux.ScsiIoctlDirection.Out;
|
||||
|
||||
break;
|
||||
case ScsiDirection.Bidirectional:
|
||||
dir = Linux.ScsiIoctlDirection.Unspecified;
|
||||
|
||||
break;
|
||||
case ScsiDirection.None:
|
||||
dir = Linux.ScsiIoctlDirection.None;
|
||||
|
||||
break;
|
||||
default:
|
||||
dir = Linux.ScsiIoctlDirection.Unknown;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return Linux.Command.SendScsiCommand((int) fd, cdb, ref buffer, out senseBuffer, timeout, dir,
|
||||
out duration, out sense);
|
||||
return Linux.Command.SendScsiCommand((int)fd, cdb, ref buffer, out senseBuffer, timeout, dir,
|
||||
out duration, out sense);
|
||||
}
|
||||
case PlatformID.FreeBSD:
|
||||
{
|
||||
CcbFlags flags = 0;
|
||||
|
||||
switch (direction)
|
||||
switch(direction)
|
||||
{
|
||||
case ScsiDirection.In:
|
||||
flags = CcbFlags.CamDirIn;
|
||||
|
||||
break;
|
||||
case ScsiDirection.Out:
|
||||
flags = CcbFlags.CamDirOut;
|
||||
|
||||
break;
|
||||
case ScsiDirection.Bidirectional:
|
||||
flags = CcbFlags.CamDirBoth;
|
||||
|
||||
break;
|
||||
case ScsiDirection.None:
|
||||
flags = CcbFlags.CamDirNone;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return IntPtr.Size == 8
|
||||
? FreeBSD.Command.SendScsiCommand64((IntPtr) fd, cdb, ref buffer, out senseBuffer,
|
||||
timeout, flags, out duration, out sense)
|
||||
: FreeBSD.Command.SendScsiCommand((IntPtr) fd, cdb, ref buffer, out senseBuffer, timeout,
|
||||
flags, out duration, out sense);
|
||||
? FreeBSD.Command.SendScsiCommand64((IntPtr)fd, cdb, ref buffer, out senseBuffer,
|
||||
timeout, flags, out duration, out sense)
|
||||
: FreeBSD.Command.SendScsiCommand((IntPtr)fd, cdb, ref buffer, out senseBuffer, timeout,
|
||||
flags, out duration, out sense);
|
||||
}
|
||||
default: throw new InvalidOperationException($"Platform {ptId} not yet supported.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in CHS format
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA command in CHS format</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="fd">File handle</param>
|
||||
/// <param name="buffer">Buffer for SCSI command response</param>
|
||||
@@ -185,22 +188,17 @@ namespace Aaru.Devices
|
||||
/// <param name="transferBlocks">Set to <c>true</c> if the transfer length is in block, otherwise it is in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendAtaCommand(object fd, AtaRegistersChs registers,
|
||||
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout,
|
||||
bool transferBlocks, out double duration,
|
||||
out bool sense)
|
||||
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
var ptId = DetectOS.GetRealPlatformID();
|
||||
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||
|
||||
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister,
|
||||
ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in CHS format
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA command in CHS format</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="ptId">Platform ID for executing the command</param>
|
||||
/// <param name="fd">File handle</param>
|
||||
@@ -214,49 +212,44 @@ namespace Aaru.Devices
|
||||
/// <param name="transferRegister">What register contains the transfer length</param>
|
||||
/// <param name="transferBlocks">Set to <c>true</c> if the transfer length is in block, otherwise it is in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendAtaCommand(PlatformID ptId, object fd,
|
||||
AtaRegistersChs registers,
|
||||
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout,
|
||||
bool transferBlocks, out double duration,
|
||||
out bool sense)
|
||||
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersChs registers,
|
||||
out AtaErrorRegistersChs errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
switch (ptId)
|
||||
switch(ptId)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
{
|
||||
if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 &&
|
||||
if((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 &&
|
||||
(Environment.OSVersion.ServicePack == "Service Pack 1" ||
|
||||
Environment.OSVersion.ServicePack == "") ||
|
||||
Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0)
|
||||
Environment.OSVersion.ServicePack == "")) ||
|
||||
(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0))
|
||||
throw new InvalidOperationException("Windows XP or earlier is not supported.");
|
||||
|
||||
// Windows NT 4 or earlier, requires special ATA pass thru SCSI. But Aaru cannot run there (or can it?)
|
||||
if (Environment.OSVersion.Version.Major <= 4)
|
||||
if(Environment.OSVersion.Version.Major <= 4)
|
||||
throw new InvalidOperationException("Windows NT 4.0 or earlier is not supported.");
|
||||
|
||||
return Windows.Command.SendAtaCommand((SafeFileHandle) fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
return Windows.Command.SendAtaCommand((SafeFileHandle)fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
}
|
||||
case PlatformID.Linux:
|
||||
{
|
||||
return Linux.Command.SendAtaCommand((int) fd, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
}
|
||||
case PlatformID.FreeBSD:
|
||||
{
|
||||
return FreeBSD.Command.SendAtaCommand((IntPtr) fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
return FreeBSD.Command.SendAtaCommand((IntPtr)fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
}
|
||||
default: throw new InvalidOperationException($"Platform {ptId} not yet supported.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in CHS format
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA command in CHS format</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="fd">File handle</param>
|
||||
/// <param name="buffer">Buffer for SCSI command response</param>
|
||||
@@ -270,22 +263,17 @@ namespace Aaru.Devices
|
||||
/// <param name="transferBlocks">Set to <c>true</c> if the transfer length is in block, otherwise it is in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendAtaCommand(object fd, AtaRegistersLba28 registers,
|
||||
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout,
|
||||
bool transferBlocks, out double duration,
|
||||
out bool sense)
|
||||
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
var ptId = DetectOS.GetRealPlatformID();
|
||||
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||
|
||||
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister,
|
||||
ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in 28-bit LBA format
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA command in 28-bit LBA format</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="ptId">Platform ID for executing the command</param>
|
||||
/// <param name="fd">File handle</param>
|
||||
@@ -299,49 +287,44 @@ namespace Aaru.Devices
|
||||
/// <param name="transferRegister">What register contains the transfer length</param>
|
||||
/// <param name="transferBlocks">Set to <c>true</c> if the transfer length is in block, otherwise it is in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendAtaCommand(PlatformID ptId, object fd,
|
||||
AtaRegistersLba28 registers,
|
||||
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout,
|
||||
bool transferBlocks, out double duration,
|
||||
out bool sense)
|
||||
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersLba28 registers,
|
||||
out AtaErrorRegistersLba28 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
switch (ptId)
|
||||
switch(ptId)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
{
|
||||
if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 &&
|
||||
if((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 1 &&
|
||||
(Environment.OSVersion.ServicePack == "Service Pack 1" ||
|
||||
Environment.OSVersion.ServicePack == "") ||
|
||||
Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0)
|
||||
Environment.OSVersion.ServicePack == "")) ||
|
||||
(Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 0))
|
||||
throw new InvalidOperationException("Windows XP or earlier is not supported.");
|
||||
|
||||
// Windows NT 4 or earlier, requires special ATA pass thru SCSI. But Aaru cannot run there (or can it?)
|
||||
if (Environment.OSVersion.Version.Major <= 4)
|
||||
if(Environment.OSVersion.Version.Major <= 4)
|
||||
throw new InvalidOperationException("Windows NT 4.0 or earlier is not supported.");
|
||||
|
||||
return Windows.Command.SendAtaCommand((SafeFileHandle) fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
return Windows.Command.SendAtaCommand((SafeFileHandle)fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
}
|
||||
case PlatformID.Linux:
|
||||
{
|
||||
return Linux.Command.SendAtaCommand((int) fd, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
}
|
||||
case PlatformID.FreeBSD:
|
||||
{
|
||||
return FreeBSD.Command.SendAtaCommand((IntPtr) fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
return FreeBSD.Command.SendAtaCommand((IntPtr)fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
}
|
||||
default: throw new InvalidOperationException($"Platform {ptId} not yet supported.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in 48-bit LBA format
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA command in 48-bit LBA format</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="fd">File handle</param>
|
||||
/// <param name="buffer">Buffer for SCSI command response</param>
|
||||
@@ -355,22 +338,17 @@ namespace Aaru.Devices
|
||||
/// <param name="transferBlocks">Set to <c>true</c> if the transfer length is in block, otherwise it is in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendAtaCommand(object fd, AtaRegistersLba48 registers,
|
||||
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout,
|
||||
bool transferBlocks, out double duration,
|
||||
out bool sense)
|
||||
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
var ptId = DetectOS.GetRealPlatformID();
|
||||
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||
|
||||
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister,
|
||||
ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
return SendAtaCommand(ptId, fd, registers, out errorRegisters, protocol, transferRegister, ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA command in 48-bit format
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA command in 48-bit format</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="ptId">Platform ID for executing the command</param>
|
||||
/// <param name="fd">File handle</param>
|
||||
@@ -384,40 +362,35 @@ namespace Aaru.Devices
|
||||
/// <param name="transferRegister">What register contains the transfer length</param>
|
||||
/// <param name="transferBlocks">Set to <c>true</c> if the transfer length is in block, otherwise it is in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendAtaCommand(PlatformID ptId, object fd,
|
||||
AtaRegistersLba48 registers,
|
||||
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout,
|
||||
bool transferBlocks, out double duration,
|
||||
out bool sense)
|
||||
internal static int SendAtaCommand(PlatformID ptId, object fd, AtaRegistersLba48 registers,
|
||||
out AtaErrorRegistersLba48 errorRegisters, AtaProtocol protocol,
|
||||
AtaTransferRegister transferRegister, ref byte[] buffer, uint timeout,
|
||||
bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
switch (ptId)
|
||||
switch(ptId)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
{
|
||||
// No check for Windows version. A 48-bit ATA disk simply does not work on earlier systems
|
||||
return Windows.Command.SendAtaCommand((SafeFileHandle) fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
return Windows.Command.SendAtaCommand((SafeFileHandle)fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
}
|
||||
case PlatformID.Linux:
|
||||
{
|
||||
return Linux.Command.SendAtaCommand((int) fd, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
return Linux.Command.SendAtaCommand((int)fd, registers, out errorRegisters, protocol,
|
||||
transferRegister, ref buffer, timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
}
|
||||
case PlatformID.FreeBSD:
|
||||
{
|
||||
return FreeBSD.Command.SendAtaCommand((IntPtr) fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
return FreeBSD.Command.SendAtaCommand((IntPtr)fd, registers, out errorRegisters, protocol,
|
||||
ref buffer, timeout, out duration, out sense);
|
||||
}
|
||||
default: throw new InvalidOperationException($"Platform {ptId} not yet supported.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a MMC/SD command
|
||||
/// </summary>
|
||||
/// <summary>Sends a MMC/SD command</summary>
|
||||
/// <returns>The result of the command.</returns>
|
||||
/// <param name="fd">File handle</param>
|
||||
/// <param name="command">MMC/SD opcode</param>
|
||||
@@ -433,24 +406,18 @@ namespace Aaru.Devices
|
||||
/// <param name="response">Response registers</param>
|
||||
/// <param name="blockSize">Size of block in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendMmcCommand(object fd, MmcCommands command, bool write,
|
||||
bool isApplication,
|
||||
MmcFlags flags, uint argument, uint blockSize,
|
||||
uint blocks,
|
||||
ref byte[] buffer, out uint[] response, out double duration,
|
||||
out bool sense,
|
||||
uint timeout = 0)
|
||||
internal static int SendMmcCommand(object fd, MmcCommands command, bool write, bool isApplication,
|
||||
MmcFlags flags, uint argument, uint blockSize, uint blocks,
|
||||
ref byte[] buffer, out uint[] response, out double duration, out bool sense,
|
||||
uint timeout = 0)
|
||||
{
|
||||
var ptId = DetectOS.GetRealPlatformID();
|
||||
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||
|
||||
return SendMmcCommand(ptId, (int) fd, command, write, isApplication, flags, argument,
|
||||
blockSize, blocks,
|
||||
ref buffer, out response, out duration, out sense, timeout);
|
||||
return SendMmcCommand(ptId, (int)fd, command, write, isApplication, flags, argument, blockSize, blocks,
|
||||
ref buffer, out response, out duration, out sense, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a MMC/SD command
|
||||
/// </summary>
|
||||
/// <summary>Sends a MMC/SD command</summary>
|
||||
/// <returns>The result of the command.</returns>
|
||||
/// <param name="ptId">Platform ID for executing the command</param>
|
||||
/// <param name="fd">File handle</param>
|
||||
@@ -467,27 +434,24 @@ namespace Aaru.Devices
|
||||
/// <param name="response">Response registers</param>
|
||||
/// <param name="blockSize">Size of block in bytes</param>
|
||||
/// <exception cref="InvalidOperationException">If the specified platform is not supported</exception>
|
||||
internal static int SendMmcCommand(PlatformID ptId, object fd, MmcCommands command,
|
||||
bool write,
|
||||
bool isApplication, MmcFlags flags, uint argument,
|
||||
uint blockSize,
|
||||
uint blocks, ref byte[] buffer, out uint[] response,
|
||||
out double duration,
|
||||
out bool sense, uint timeout = 0)
|
||||
internal static int SendMmcCommand(PlatformID ptId, object fd, MmcCommands command, bool write,
|
||||
bool isApplication, MmcFlags flags, uint argument, uint blockSize,
|
||||
uint blocks, ref byte[] buffer, out uint[] response, out double duration,
|
||||
out bool sense, uint timeout = 0)
|
||||
{
|
||||
switch (ptId)
|
||||
switch(ptId)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
{
|
||||
return Windows.Command.SendMmcCommand((SafeFileHandle) fd, command, write, isApplication, flags,
|
||||
argument, blockSize, blocks, ref buffer, out response,
|
||||
out duration, out sense, timeout);
|
||||
return Windows.Command.SendMmcCommand((SafeFileHandle)fd, command, write, isApplication, flags,
|
||||
argument, blockSize, blocks, ref buffer, out response,
|
||||
out duration, out sense, timeout);
|
||||
}
|
||||
case PlatformID.Linux:
|
||||
{
|
||||
return Linux.Command.SendMmcCommand((int) fd, command, write, isApplication, flags, argument,
|
||||
blockSize, blocks, ref buffer, out response, out duration,
|
||||
out sense, timeout);
|
||||
return Linux.Command.SendMmcCommand((int)fd, command, write, isApplication, flags, argument,
|
||||
blockSize, blocks, ref buffer, out response, out duration,
|
||||
out sense, timeout);
|
||||
}
|
||||
default: throw new InvalidOperationException($"Platform {ptId} not yet supported.");
|
||||
}
|
||||
|
||||
@@ -41,12 +41,16 @@ namespace Aaru.Devices
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBuffer};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadBuffer
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ BUFFER took {0} ms.", duration);
|
||||
@@ -58,10 +62,15 @@ namespace Aaru.Devices
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadBufferDma};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out bool sense);
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadBufferDma
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.NoTransfer,
|
||||
ref buffer, timeout, false, out duration, out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ BUFFER DMA took {0} ms.", duration);
|
||||
@@ -69,29 +78,29 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
||||
uint timeout, out double duration) =>
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
||||
uint timeout, out double duration) =>
|
||||
ReadDma(out buffer, out statusRegisters, true, lba, count, timeout, out duration);
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
||||
byte count, uint timeout, out double duration)
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
||||
byte count, uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
SectorCount = count,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||
SectorCount = count, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
|
||||
AtaTransferRegister.SectorCount,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
|
||||
@@ -99,26 +108,24 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadMultiple,
|
||||
SectorCount = count,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
Command = (byte)AtaCommands.ReadMultiple, SectorCount = count,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000), LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100), LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
|
||||
@@ -126,19 +133,23 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadNativeMaxAddress(out uint lba, out AtaErrorRegistersLba28 statusRegisters, uint timeout,
|
||||
public bool ReadNativeMaxAddress(out uint lba, out AtaErrorRegistersLba28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
lba = 0;
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.ReadNativeMaxAddress};
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadNativeMaxAddress
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
if((statusRegisters.Status & 0x23) == 0)
|
||||
@@ -155,30 +166,30 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
||||
uint timeout, out double duration) =>
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, byte count,
|
||||
uint timeout, out double duration) =>
|
||||
Read(out buffer, out statusRegisters, true, lba, count, timeout, out duration);
|
||||
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
||||
byte count, uint timeout, out double duration)
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
||||
byte count, uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
SectorCount = count,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||
SectorCount = count, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
||||
@@ -186,31 +197,30 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, uint blockSize,
|
||||
uint timeout, out double duration) =>
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba, uint blockSize,
|
||||
uint timeout, out double duration) =>
|
||||
ReadLong(out buffer, out statusRegisters, true, lba, blockSize, timeout, out duration);
|
||||
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry,
|
||||
uint lba,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, bool retry, uint lba,
|
||||
uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[blockSize];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
SectorCount = 1,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||
SectorCount = 1, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1),
|
||||
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
||||
@@ -221,21 +231,21 @@ namespace Aaru.Devices
|
||||
public bool Seek(out AtaErrorRegistersLba28 statusRegisters, uint lba, uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Seek,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
Command = (byte)AtaCommands.Seek, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
||||
|
||||
@@ -37,18 +37,21 @@ namespace Aaru.Devices
|
||||
{
|
||||
public partial class Device
|
||||
{
|
||||
public bool GetNativeMaxAddressExt(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
|
||||
public bool GetNativeMaxAddressExt(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
lba = 0;
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba48 registers =
|
||||
new AtaRegistersLba48 {Command = (byte)AtaCommands.NativeMaxAddress, Feature = 0x0000};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
var registers = new AtaRegistersLba48
|
||||
{
|
||||
Command = (byte)AtaCommands.NativeMaxAddress, Feature = 0x0000
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
if((statusRegisters.Status & 0x23) == 0)
|
||||
@@ -64,24 +67,23 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
|
||||
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||
|
||||
var registers = new AtaRegistersLba48
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadDmaExt,
|
||||
SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
Command = (byte)AtaCommands.ReadDmaExt, SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000), LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
|
||||
AtaTransferRegister.SectorCount,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ DMA EXT took {0} ms.", duration);
|
||||
@@ -89,25 +91,23 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadLog(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
|
||||
ushort pageNumber, ushort count, uint timeout,
|
||||
out double duration)
|
||||
public bool ReadLog(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
|
||||
ushort pageNumber, ushort count, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512 * count];
|
||||
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||
|
||||
var registers = new AtaRegistersLba48
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadLogExt,
|
||||
SectorCount = count,
|
||||
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
|
||||
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||
Command = (byte)AtaCommands.ReadLogExt, SectorCount = count,
|
||||
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100), LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||
};
|
||||
|
||||
registers.LbaLow += logAddress;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ LOG EXT took {0} ms.", duration);
|
||||
@@ -115,24 +115,22 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadLogDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
|
||||
ushort pageNumber, ushort count, uint timeout,
|
||||
out double duration)
|
||||
public bool ReadLogDma(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, byte logAddress,
|
||||
ushort pageNumber, ushort count, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512 * count];
|
||||
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||
|
||||
var registers = new AtaRegistersLba48
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadLogDmaExt,
|
||||
SectorCount = count,
|
||||
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100),
|
||||
LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||
Command = (byte)AtaCommands.ReadLogDmaExt, SectorCount = count,
|
||||
LbaLow = (ushort)((pageNumber & 0xFF) * 0x100), LbaHigh = (ushort)((pageNumber & 0xFF00) / 0x100)
|
||||
};
|
||||
|
||||
registers.LbaLow += logAddress;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
|
||||
AtaTransferRegister.SectorCount,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ LOG DMA EXT took {0} ms.", duration);
|
||||
@@ -140,26 +138,24 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba,
|
||||
ushort count,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
|
||||
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||
|
||||
var registers = new AtaRegistersLba48
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadMultipleExt,
|
||||
SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
Command = (byte)AtaCommands.ReadMultipleExt, SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000), LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ MULTIPLE EXT took {0} ms.", duration);
|
||||
@@ -167,19 +163,23 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadNativeMaxAddress(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
|
||||
public bool ReadNativeMaxAddress(out ulong lba, out AtaErrorRegistersLba48 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
lba = 0;
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba48 registers = new AtaRegistersLba48 {Command = (byte)AtaCommands.ReadNativeMaxAddressExt};
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
var registers = new AtaRegistersLba48
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadNativeMaxAddressExt
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
if((statusRegisters.Status & 0x23) == 0)
|
||||
@@ -195,25 +195,24 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||
uint timeout, out double duration)
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersLba48 statusRegisters, ulong lba, ushort count,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 65536] : new byte[512 * count];
|
||||
AtaRegistersLba48 registers = new AtaRegistersLba48
|
||||
|
||||
var registers = new AtaRegistersLba48
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadExt,
|
||||
SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000),
|
||||
LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
Command = (byte)AtaCommands.ReadExt, SectorCount = count,
|
||||
LbaHigh = (ushort)((lba & 0xFFFF00000000) / 0x100000000),
|
||||
LbaMid = (ushort)((lba & 0xFFFF0000) / 0x10000), LbaLow = (ushort)((lba & 0xFFFF) / 0x1)
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ SECTORS EXT took {0} ms.", duration);
|
||||
|
||||
@@ -37,18 +37,14 @@ namespace Aaru.Devices
|
||||
{
|
||||
public partial class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters) =>
|
||||
AtaIdentify(out buffer, out statusRegisters, Timeout);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device, using default device timeout</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
@@ -56,9 +52,7 @@ namespace Aaru.Devices
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, out double duration) =>
|
||||
AtaIdentify(out buffer, out statusRegisters, Timeout, out duration);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY DEVICE command to the device
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
@@ -66,9 +60,7 @@ namespace Aaru.Devices
|
||||
public bool AtaIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout) =>
|
||||
AtaIdentify(out buffer, out statusRegisters, timeout, out _);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY DEVICE command to the device
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY DEVICE command to the device</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
@@ -78,12 +70,16 @@ namespace Aaru.Devices
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyDevice};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.IdentifyDevice
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "IDENTIFY DEVICE took {0} ms.", duration);
|
||||
@@ -91,30 +87,26 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
|
||||
byte head,
|
||||
byte sector, byte count, uint timeout,
|
||||
out double duration) =>
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
|
||||
byte sector, byte count, uint timeout, out double duration) =>
|
||||
ReadDma(out buffer, out statusRegisters, true, cylinder, head, sector, count, timeout, out duration);
|
||||
|
||||
public bool ReadDma(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
||||
byte head, byte sector, byte count, uint timeout,
|
||||
out double duration)
|
||||
byte head, byte sector, byte count, uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
SectorCount = count,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector,
|
||||
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
|
||||
SectorCount = count, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1), DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector,
|
||||
Command = retry ? (byte)AtaCommands.ReadDmaRetry : (byte)AtaCommands.ReadDma
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma,
|
||||
AtaTransferRegister.SectorCount,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.Dma, AtaTransferRegister.SectorCount,
|
||||
ref buffer, timeout, true, out duration, out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ DMA took {0} ms.", duration);
|
||||
@@ -122,25 +114,22 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
|
||||
byte head, byte sector, byte count,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadMultiple(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
|
||||
byte head, byte sector, byte count, uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.ReadMultiple,
|
||||
SectorCount = count,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
Command = (byte)AtaCommands.ReadMultiple, SectorCount = count,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100), CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F), Sector = sector
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ MULTIPLE took {0} ms.", duration);
|
||||
@@ -149,29 +138,26 @@ namespace Aaru.Devices
|
||||
}
|
||||
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
|
||||
byte sector, byte count, uint timeout,
|
||||
out double duration) =>
|
||||
byte sector, byte count, uint timeout, out double duration) =>
|
||||
Read(out buffer, out statusRegisters, true, cylinder, head, sector, count, timeout, out duration);
|
||||
|
||||
public bool Read(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
||||
byte head, byte sector, byte count, uint timeout,
|
||||
out double duration)
|
||||
byte head, byte sector, byte count, uint timeout, out double duration)
|
||||
{
|
||||
buffer = count == 0 ? new byte[512 * 256] : new byte[512 * count];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read,
|
||||
SectorCount = count,
|
||||
Command = retry ? (byte)AtaCommands.ReadRetry : (byte)AtaCommands.Read, SectorCount = count,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
DeviceHead = (byte)(head & 0x0F), Sector = sector
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ SECTORS took {0} ms.", duration);
|
||||
@@ -179,32 +165,28 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
|
||||
byte head,
|
||||
byte sector, uint blockSize, uint timeout,
|
||||
out double duration) =>
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head,
|
||||
byte sector, uint blockSize, uint timeout, out double duration) =>
|
||||
ReadLong(out buffer, out statusRegisters, true, cylinder, head, sector, blockSize, timeout, out duration);
|
||||
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry,
|
||||
ushort cylinder,
|
||||
byte head, byte sector, uint blockSize,
|
||||
uint timeout, out double duration)
|
||||
public bool ReadLong(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, bool retry, ushort cylinder,
|
||||
byte head, byte sector, uint blockSize, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[blockSize];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong,
|
||||
SectorCount = 1,
|
||||
Command = retry ? (byte)AtaCommands.ReadLongRetry : (byte)AtaCommands.ReadLong, SectorCount = 1,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.SectorCount, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "READ LONG took {0} ms.", duration);
|
||||
@@ -212,22 +194,22 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool Seek(out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, byte sector,
|
||||
uint timeout, out double duration)
|
||||
public bool Seek(out AtaErrorRegistersChs statusRegisters, ushort cylinder, byte head, byte sector,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.Seek,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector
|
||||
Command = (byte)AtaCommands.Seek, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F), Sector = sector
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SEEK took {0} ms.", duration);
|
||||
@@ -236,28 +218,27 @@ namespace Aaru.Devices
|
||||
}
|
||||
|
||||
public bool SetFeatures(out AtaErrorRegistersChs statusRegisters, AtaFeatures feature, uint timeout,
|
||||
out double duration) =>
|
||||
out double duration) =>
|
||||
SetFeatures(out statusRegisters, feature, 0, 0, 0, 0, timeout, out duration);
|
||||
|
||||
public bool SetFeatures(out AtaErrorRegistersChs statusRegisters, AtaFeatures feature, ushort cylinder,
|
||||
byte head, byte sector, byte sectorCount,
|
||||
uint timeout, out double duration)
|
||||
byte head, byte sector, byte sectorCount, uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.SetFeatures,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F),
|
||||
Sector = sector,
|
||||
SectorCount = sectorCount,
|
||||
Feature = (byte)feature
|
||||
Command = (byte)AtaCommands.SetFeatures, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
DeviceHead = (byte)(head & 0x0F), Sector = sector,
|
||||
SectorCount = sectorCount,
|
||||
Feature = (byte)feature
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, true, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SET FEATURES took {0} ms.", duration);
|
||||
|
||||
@@ -37,18 +37,14 @@ namespace Aaru.Devices
|
||||
{
|
||||
public partial class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters) =>
|
||||
AtapiIdentify(out buffer, out statusRegisters, Timeout);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device, using default device timeout</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
@@ -56,9 +52,7 @@ namespace Aaru.Devices
|
||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, out double duration) =>
|
||||
AtapiIdentify(out buffer, out statusRegisters, Timeout, out duration);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
@@ -66,9 +60,7 @@ namespace Aaru.Devices
|
||||
public bool AtapiIdentify(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, uint timeout) =>
|
||||
AtapiIdentify(out buffer, out statusRegisters, timeout, out _);
|
||||
|
||||
/// <summary>
|
||||
/// Sends the ATA IDENTIFY PACKET DEVICE command to the device
|
||||
/// </summary>
|
||||
/// <summary>Sends the ATA IDENTIFY PACKET DEVICE command to the device</summary>
|
||||
/// <returns><c>true</c> if the command failed and <paramref name="statusRegisters" /> contains the error registers.</returns>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
/// <param name="statusRegisters">Status registers.</param>
|
||||
@@ -78,12 +70,16 @@ namespace Aaru.Devices
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersChs registers = new AtaRegistersChs {Command = (byte)AtaCommands.IdentifyPacketDevice};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.IdentifyPacketDevice
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "IDENTIFY PACKET DEVICE took {0} ms.", duration);
|
||||
|
||||
@@ -37,25 +37,25 @@ namespace Aaru.Devices
|
||||
{
|
||||
public partial class Device
|
||||
{
|
||||
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba,
|
||||
uint timeout, out double duration)
|
||||
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, uint lba,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.TranslateSector,
|
||||
DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
Command = (byte)AtaCommands.TranslateSector, DeviceHead = (byte)((lba & 0xF000000) / 0x1000000),
|
||||
LbaHigh = (byte)((lba & 0xFF0000) / 0x10000),
|
||||
LbaMid = (byte)((lba & 0xFF00) / 0x100),
|
||||
LbaLow = (byte)((lba & 0xFF) / 0x1)
|
||||
};
|
||||
|
||||
registers.DeviceHead += 0x40;
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
|
||||
@@ -64,23 +64,21 @@ namespace Aaru.Devices
|
||||
}
|
||||
|
||||
public bool TranslateSector(out byte[] buffer, out AtaErrorRegistersChs statusRegisters, ushort cylinder,
|
||||
byte head, byte sector, uint timeout,
|
||||
out double duration)
|
||||
byte head, byte sector, uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersChs registers = new AtaRegistersChs
|
||||
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.TranslateSector,
|
||||
CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
Sector = sector,
|
||||
DeviceHead = (byte)(head & 0x0F)
|
||||
Command = (byte)AtaCommands.TranslateSector, CylinderHigh = (byte)((cylinder & 0xFF00) / 0x100),
|
||||
CylinderLow = (byte)((cylinder & 0xFF) / 0x1),
|
||||
Sector = sector, DeviceHead = (byte)(head & 0x0F)
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "CFA TRANSLATE SECTOR took {0} ms.", duration);
|
||||
@@ -89,15 +87,19 @@ namespace Aaru.Devices
|
||||
}
|
||||
|
||||
public bool RequestExtendedErrorCode(out byte errorCode, out AtaErrorRegistersLba28 statusRegisters,
|
||||
uint timeout, out double duration)
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28 {Command = (byte)AtaCommands.RequestSense};
|
||||
byte[] buffer = new byte[0];
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.RequestSense
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
errorCode = statusRegisters.Error;
|
||||
|
||||
@@ -38,24 +38,27 @@ namespace Aaru.Devices
|
||||
public partial class Device
|
||||
{
|
||||
public bool EnableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
|
||||
out double duration) =>
|
||||
out double duration) =>
|
||||
CheckMediaCardType(1, out statusRegisters, timeout, out duration);
|
||||
|
||||
public bool DisableMediaCardPassThrough(out AtaErrorRegistersChs statusRegisters, uint timeout,
|
||||
out double duration) =>
|
||||
out double duration) =>
|
||||
CheckMediaCardType(0, out statusRegisters, timeout, out duration);
|
||||
|
||||
public bool CheckMediaCardType(byte feature, out AtaErrorRegistersChs statusRegisters, uint timeout,
|
||||
public bool CheckMediaCardType(byte feature, out AtaErrorRegistersChs statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersChs registers =
|
||||
new AtaRegistersChs {Command = (byte)AtaCommands.CheckMediaCardType, Feature = feature};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
var registers = new AtaRegistersChs
|
||||
{
|
||||
Command = (byte)AtaCommands.CheckMediaCardType, Feature = feature
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "CHECK MEDIA CARD TYPE took {0} ms.", duration);
|
||||
|
||||
@@ -40,18 +40,17 @@ namespace Aaru.Devices
|
||||
public bool SmartDisable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.Disable,
|
||||
LbaHigh = 0xC2,
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.Disable, LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART DISABLE OPERATIONS took {0} ms.", duration);
|
||||
@@ -60,22 +59,20 @@ namespace Aaru.Devices
|
||||
}
|
||||
|
||||
public bool SmartEnableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F,
|
||||
SectorCount = 0xF1
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
|
||||
LbaHigh = 0xC2, LbaMid = 0x4F, SectorCount = 0xF1
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART ENABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
|
||||
@@ -84,21 +81,20 @@ namespace Aaru.Devices
|
||||
}
|
||||
|
||||
public bool SmartDisableAttributeAutosave(out AtaErrorRegistersLba28 statusRegisters, uint timeout,
|
||||
out double duration)
|
||||
out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.EnableDisableAttributeAutosave,
|
||||
LbaHigh = 0xC2, LbaMid = 0x4F
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART DISABLE ATTRIBUTE AUTOSAVE took {0} ms.", duration);
|
||||
@@ -109,18 +105,17 @@ namespace Aaru.Devices
|
||||
public bool SmartEnable(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.Enable,
|
||||
LbaHigh = 0xC2,
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.Enable, LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART ENABLE OPERATIONS took {0} ms.", duration);
|
||||
@@ -128,23 +123,21 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLba28 statusRegisters, byte subcommand,
|
||||
uint timeout, out double duration)
|
||||
public bool SmartExecuteOffLineImmediate(out AtaErrorRegistersLba28 statusRegisters, byte subcommand,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F,
|
||||
LbaLow = subcommand
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ExecuteOfflineImmediate,
|
||||
LbaHigh = 0xC2, LbaMid = 0x4F, LbaLow = subcommand
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART EXECUTE OFF-LINE IMMEDIATE took {0} ms.", duration);
|
||||
@@ -156,18 +149,17 @@ namespace Aaru.Devices
|
||||
out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ReadData,
|
||||
LbaHigh = 0xC2,
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ReadData, LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART READ DATA took {0} ms.", duration);
|
||||
@@ -175,23 +167,21 @@ namespace Aaru.Devices
|
||||
return sense;
|
||||
}
|
||||
|
||||
public bool SmartReadLog(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, byte logAddress,
|
||||
uint timeout, out double duration)
|
||||
public bool SmartReadLog(out byte[] buffer, out AtaErrorRegistersLba28 statusRegisters, byte logAddress,
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
buffer = new byte[512];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ReadLog,
|
||||
LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F,
|
||||
LbaLow = logAddress
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ReadLog, LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F, LbaLow = logAddress
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.PioIn,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART READ LOG took {0} ms.", duration);
|
||||
@@ -202,18 +192,17 @@ namespace Aaru.Devices
|
||||
public bool SmartReturnStatus(out AtaErrorRegistersLba28 statusRegisters, uint timeout, out double duration)
|
||||
{
|
||||
byte[] buffer = new byte[0];
|
||||
AtaRegistersLba28 registers = new AtaRegistersLba28
|
||||
|
||||
var registers = new AtaRegistersLba28
|
||||
{
|
||||
Command = (byte)AtaCommands.Smart,
|
||||
Feature = (byte)AtaSmartSubCommands.ReturnStatus,
|
||||
LbaHigh = 0xC2,
|
||||
Command = (byte)AtaCommands.Smart, Feature = (byte)AtaSmartSubCommands.ReturnStatus, LbaHigh = 0xC2,
|
||||
LbaMid = 0x4F
|
||||
};
|
||||
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false,
|
||||
out duration,
|
||||
LastError = SendAtaCommand(registers, out statusRegisters, AtaProtocol.NonData,
|
||||
AtaTransferRegister.NoTransfer, ref buffer, timeout, false, out duration,
|
||||
out bool sense);
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine("ATA Device", "SMART RETURN STATUS took {0} ms.", duration);
|
||||
|
||||
@@ -39,9 +39,7 @@ namespace Aaru.Devices
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public partial class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends a SCSI command to this device
|
||||
/// </summary>
|
||||
/// <summary>Sends a SCSI command to this device</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="cdb">SCSI CDB</param>
|
||||
/// <param name="buffer">Buffer for SCSI command response</param>
|
||||
@@ -54,19 +52,17 @@ namespace Aaru.Devices
|
||||
/// SCSI sense
|
||||
/// </param>
|
||||
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
ScsiDirection direction, out double duration, out bool sense)
|
||||
ScsiDirection direction, out double duration, out bool sense)
|
||||
{
|
||||
if (!(_remote is null))
|
||||
return _remote.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout,
|
||||
direction, out duration, out sense);
|
||||
if(!(_remote is null))
|
||||
return _remote.SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, direction, out duration,
|
||||
out sense);
|
||||
|
||||
return Command.SendScsiCommand(PlatformId, FileHandle, cdb, ref buffer, out senseBuffer, timeout, direction,
|
||||
out duration, out sense);
|
||||
out duration, out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA/ATAPI command to this device using CHS addressing
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA/ATAPI command to this device using CHS addressing</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="registers">ATA registers.</param>
|
||||
/// <param name="errorRegisters">Status/error registers.</param>
|
||||
@@ -81,26 +77,19 @@ namespace Aaru.Devices
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
|
||||
public int SendAtaCommand(AtaRegistersChs registers, out AtaErrorRegistersChs errorRegisters,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister,
|
||||
ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks,
|
||||
out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
if (!(_remote is null))
|
||||
return _remote.SendAtaCommand(registers, out errorRegisters,
|
||||
protocol, transferRegister,
|
||||
ref buffer,
|
||||
timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
if(!(_remote is null))
|
||||
return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
|
||||
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
|
||||
transferRegister,
|
||||
ref buffer, timeout, transferBlocks, out duration, out sense);
|
||||
transferRegister, ref buffer, timeout, transferBlocks, out duration,
|
||||
out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA/ATAPI command to this device using 28-bit LBA addressing
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA/ATAPI command to this device using 28-bit LBA addressing</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="registers">ATA registers.</param>
|
||||
/// <param name="errorRegisters">Status/error registers.</param>
|
||||
@@ -115,26 +104,19 @@ namespace Aaru.Devices
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
|
||||
public int SendAtaCommand(AtaRegistersLba28 registers, out AtaErrorRegistersLba28 errorRegisters,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister,
|
||||
ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks,
|
||||
out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
if (!(_remote is null))
|
||||
return _remote.SendAtaCommand(registers, out errorRegisters,
|
||||
protocol, transferRegister,
|
||||
ref buffer,
|
||||
timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
if(!(_remote is null))
|
||||
return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
|
||||
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
|
||||
transferRegister,
|
||||
ref buffer, timeout, transferBlocks, out duration, out sense);
|
||||
transferRegister, ref buffer, timeout, transferBlocks, out duration,
|
||||
out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an ATA/ATAPI command to this device using 48-bit LBA addressing
|
||||
/// </summary>
|
||||
/// <summary>Sends an ATA/ATAPI command to this device using 48-bit LBA addressing</summary>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
/// <param name="registers">ATA registers.</param>
|
||||
/// <param name="errorRegisters">Status/error registers.</param>
|
||||
@@ -149,26 +131,19 @@ namespace Aaru.Devices
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
|
||||
public int SendAtaCommand(AtaRegistersLba48 registers, out AtaErrorRegistersLba48 errorRegisters,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister,
|
||||
ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks,
|
||||
out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
if (!(_remote is null))
|
||||
return _remote.SendAtaCommand(registers, out errorRegisters,
|
||||
protocol, transferRegister,
|
||||
ref buffer,
|
||||
timeout, transferBlocks,
|
||||
out duration, out sense);
|
||||
if(!(_remote is null))
|
||||
return _remote.SendAtaCommand(registers, out errorRegisters, protocol, transferRegister, ref buffer,
|
||||
timeout, transferBlocks, out duration, out sense);
|
||||
|
||||
return Command.SendAtaCommand(PlatformId, FileHandle, registers, out errorRegisters, protocol,
|
||||
transferRegister,
|
||||
ref buffer, timeout, transferBlocks, out duration, out sense);
|
||||
transferRegister, ref buffer, timeout, transferBlocks, out duration,
|
||||
out sense);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a MMC/SD command to this device
|
||||
/// </summary>
|
||||
/// <summary>Sends a MMC/SD command to this device</summary>
|
||||
/// <returns>The result of the command.</returns>
|
||||
/// <param name="command">MMC/SD opcode</param>
|
||||
/// <param name="buffer">Buffer for MMC/SD command response</param>
|
||||
@@ -182,69 +157,70 @@ namespace Aaru.Devices
|
||||
/// <param name="argument">Command argument</param>
|
||||
/// <param name="response">Response registers</param>
|
||||
/// <param name="blockSize">Size of block in bytes</param>
|
||||
public int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags,
|
||||
uint argument,
|
||||
uint blockSize, uint blocks, ref byte[] buffer, out uint[] response,
|
||||
out double duration, out bool sense, uint timeout = 0)
|
||||
public int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags, uint argument,
|
||||
uint blockSize, uint blocks, ref byte[] buffer, out uint[] response,
|
||||
out double duration, out bool sense, uint timeout = 0)
|
||||
{
|
||||
switch (command)
|
||||
switch(command)
|
||||
{
|
||||
case MmcCommands.SendCid when cachedCid != null:
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
DateTime start = DateTime.Now;
|
||||
buffer = new byte[cachedCid.Length];
|
||||
Array.Copy(cachedCid, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
var end = DateTime.Now;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case MmcCommands.SendCsd when cachedCid != null:
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
DateTime start = DateTime.Now;
|
||||
buffer = new byte[cachedCsd.Length];
|
||||
Array.Copy(cachedCsd, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
var end = DateTime.Now;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case (MmcCommands) SecureDigitalCommands.SendScr when cachedScr != null:
|
||||
case (MmcCommands)SecureDigitalCommands.SendScr when cachedScr != null:
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
DateTime start = DateTime.Now;
|
||||
buffer = new byte[cachedScr.Length];
|
||||
Array.Copy(cachedScr, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
var end = DateTime.Now;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case (MmcCommands) SecureDigitalCommands.SendOperatingCondition when cachedOcr != null:
|
||||
case MmcCommands.SendOpCond when cachedOcr != null:
|
||||
case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when cachedOcr != null:
|
||||
case MmcCommands.SendOpCond when cachedOcr != null:
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
DateTime start = DateTime.Now;
|
||||
buffer = new byte[cachedOcr.Length];
|
||||
Array.Copy(cachedOcr, buffer, buffer.Length);
|
||||
response = new uint[4];
|
||||
sense = false;
|
||||
var end = DateTime.Now;
|
||||
sense = false;
|
||||
DateTime end = DateTime.Now;
|
||||
duration = (end - start).TotalMilliseconds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(_remote is null))
|
||||
return _remote.SendMmcCommand(command, write, isApplication, flags,
|
||||
argument,
|
||||
blockSize, blocks, ref buffer, out response,
|
||||
out duration, out sense, timeout);
|
||||
if(!(_remote is null))
|
||||
return _remote.SendMmcCommand(command, write, isApplication, flags, argument, blockSize, blocks,
|
||||
ref buffer, out response, out duration, out sense, timeout);
|
||||
|
||||
return Command.SendMmcCommand(PlatformId, FileHandle, command, write, isApplication, flags, argument,
|
||||
blockSize, blocks, ref buffer, out response, out duration, out sense,
|
||||
timeout);
|
||||
blockSize, blocks, ref buffer, out response, out duration, out sense,
|
||||
timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,10 +86,10 @@ namespace Aaru.Devices
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
{
|
||||
FileHandle = Windows.Extern.CreateFile(devicePath, FileAccess.GenericRead | FileAccess.GenericWrite,
|
||||
FileShare.Read | FileShare.Write,
|
||||
IntPtr.Zero,
|
||||
FileMode.OpenExisting, FileAttributes.Normal, IntPtr.Zero);
|
||||
FileHandle = Extern.CreateFile(devicePath, FileAccess.GenericRead | FileAccess.GenericWrite,
|
||||
FileShare.Read | FileShare.Write,
|
||||
IntPtr.Zero,
|
||||
FileMode.OpenExisting, FileAttributes.Normal, IntPtr.Zero);
|
||||
|
||||
if(((SafeFileHandle)FileHandle).IsInvalid)
|
||||
{
|
||||
@@ -184,10 +184,10 @@ namespace Aaru.Devices
|
||||
int error = 0;
|
||||
|
||||
bool hasError = !Extern.DeviceIoControlStorageQuery((SafeFileHandle)FileHandle,
|
||||
WindowsIoctl.IoctlStorageQueryProperty,
|
||||
ref query, (uint)Marshal.SizeOf(query),
|
||||
descriptorPtr, 1000, ref returned,
|
||||
IntPtr.Zero);
|
||||
WindowsIoctl.IoctlStorageQueryProperty,
|
||||
ref query, (uint)Marshal.SizeOf(query),
|
||||
descriptorPtr, 1000, ref returned,
|
||||
IntPtr.Zero);
|
||||
|
||||
if(hasError)
|
||||
error = Marshal.GetLastWin32Error();
|
||||
@@ -440,7 +440,7 @@ namespace Aaru.Devices
|
||||
if(cachedScr != null)
|
||||
{
|
||||
Type = DeviceType.SecureDigital;
|
||||
CID decoded = Aaru.Decoders.SecureDigital.Decoders.DecodeCID(cachedCid);
|
||||
CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(cachedCid);
|
||||
Manufacturer = VendorString.Prettify(decoded.Manufacturer);
|
||||
Model = decoded.ProductName;
|
||||
|
||||
|
||||
@@ -40,35 +40,37 @@ namespace Aaru.Devices
|
||||
public partial class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// Releases unmanaged resources and performs other cleanup operations before the
|
||||
/// <see cref="Device" /> is reclaimed by garbage collection.
|
||||
/// Releases unmanaged resources and performs other cleanup operations before the <see cref="Device" /> is
|
||||
/// reclaimed by garbage collection.
|
||||
/// </summary>
|
||||
~Device()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
~Device() => Close();
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (_remote != null)
|
||||
if(_remote != null)
|
||||
{
|
||||
_remote.Close();
|
||||
_remote.Disconnect();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileHandle == null) return;
|
||||
if(FileHandle == null)
|
||||
return;
|
||||
|
||||
switch (PlatformId)
|
||||
switch(PlatformId)
|
||||
{
|
||||
case PlatformID.Win32NT:
|
||||
(FileHandle as SafeFileHandle)?.Close();
|
||||
|
||||
break;
|
||||
case PlatformID.Linux:
|
||||
Extern.close((int) FileHandle);
|
||||
Extern.close((int)FileHandle);
|
||||
|
||||
break;
|
||||
case PlatformID.FreeBSD:
|
||||
FreeBSD.Extern.cam_close_device((IntPtr) FileHandle);
|
||||
FreeBSD.Extern.cam_close_device((IntPtr)FileHandle);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user