mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Aaru.Filesystems] Reformat and cleanup.
This commit is contained in:
@@ -51,8 +51,10 @@ namespace Aaru.Filesystems;
|
||||
*/
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements detection for the Zettabyte File System (ZFS)</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"),
|
||||
SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
public sealed partial class ZFS
|
||||
{
|
||||
const ulong ZEC_MAGIC = 0x0210DA7AB10C7A11;
|
||||
|
||||
@@ -51,21 +51,45 @@ namespace Aaru.Filesystems;
|
||||
*/
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements detection for the Zettabyte File System (ZFS)</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"),
|
||||
SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
public sealed partial class ZFS
|
||||
{
|
||||
#region Nested type: NVS_DataTypes
|
||||
|
||||
enum NVS_DataTypes : uint
|
||||
{
|
||||
DATA_TYPE_UNKNOWN = 0, DATA_TYPE_BOOLEAN, DATA_TYPE_BYTE,
|
||||
DATA_TYPE_INT16, DATA_TYPE_UINT16, DATA_TYPE_INT32,
|
||||
DATA_TYPE_UINT32, DATA_TYPE_INT64, DATA_TYPE_UINT64,
|
||||
DATA_TYPE_STRING, DATA_TYPE_BYTE_ARRAY, DATA_TYPE_INT16_ARRAY,
|
||||
DATA_TYPE_UINT16_ARRAY, DATA_TYPE_INT32_ARRAY, DATA_TYPE_UINT32_ARRAY,
|
||||
DATA_TYPE_INT64_ARRAY, DATA_TYPE_UINT64_ARRAY, DATA_TYPE_STRING_ARRAY,
|
||||
DATA_TYPE_HRTIME, DATA_TYPE_NVLIST, DATA_TYPE_NVLIST_ARRAY,
|
||||
DATA_TYPE_BOOLEAN_VALUE, DATA_TYPE_INT8, DATA_TYPE_UINT8,
|
||||
DATA_TYPE_BOOLEAN_ARRAY, DATA_TYPE_INT8_ARRAY, DATA_TYPE_UINT8_ARRAY,
|
||||
DATA_TYPE_UNKNOWN = 0,
|
||||
DATA_TYPE_BOOLEAN,
|
||||
DATA_TYPE_BYTE,
|
||||
DATA_TYPE_INT16,
|
||||
DATA_TYPE_UINT16,
|
||||
DATA_TYPE_INT32,
|
||||
DATA_TYPE_UINT32,
|
||||
DATA_TYPE_INT64,
|
||||
DATA_TYPE_UINT64,
|
||||
DATA_TYPE_STRING,
|
||||
DATA_TYPE_BYTE_ARRAY,
|
||||
DATA_TYPE_INT16_ARRAY,
|
||||
DATA_TYPE_UINT16_ARRAY,
|
||||
DATA_TYPE_INT32_ARRAY,
|
||||
DATA_TYPE_UINT32_ARRAY,
|
||||
DATA_TYPE_INT64_ARRAY,
|
||||
DATA_TYPE_UINT64_ARRAY,
|
||||
DATA_TYPE_STRING_ARRAY,
|
||||
DATA_TYPE_HRTIME,
|
||||
DATA_TYPE_NVLIST,
|
||||
DATA_TYPE_NVLIST_ARRAY,
|
||||
DATA_TYPE_BOOLEAN_VALUE,
|
||||
DATA_TYPE_INT8,
|
||||
DATA_TYPE_UINT8,
|
||||
DATA_TYPE_BOOLEAN_ARRAY,
|
||||
DATA_TYPE_INT8_ARRAY,
|
||||
DATA_TYPE_UINT8_ARRAY,
|
||||
DATA_TYPE_DOUBLE
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -55,13 +55,15 @@ namespace Aaru.Filesystems;
|
||||
*/
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements detection for the Zettabyte File System (ZFS)</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"),
|
||||
SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
public sealed partial class ZFS
|
||||
{
|
||||
static bool DecodeNvList(byte[] nvlist, out Dictionary<string, NVS_Item> decodedNvList)
|
||||
{
|
||||
byte[] tmp = new byte[nvlist.Length - 4];
|
||||
var tmp = new byte[nvlist.Length - 4];
|
||||
Array.Copy(nvlist, 4, tmp, 0, nvlist.Length - 4);
|
||||
bool xdr = nvlist[0] == 1;
|
||||
bool littleEndian = nvlist[1] == 1;
|
||||
@@ -81,7 +83,7 @@ public sealed partial class ZFS
|
||||
if(!xdr)
|
||||
return false;
|
||||
|
||||
int offset = 8;
|
||||
var offset = 8;
|
||||
|
||||
while(offset < nvlist.Length)
|
||||
{
|
||||
@@ -97,13 +99,13 @@ public sealed partial class ZFS
|
||||
offset += 4;
|
||||
item.decodedSize = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
offset += 4;
|
||||
uint nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
var nameLength = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
offset += 4;
|
||||
|
||||
if(nameLength % 4 > 0)
|
||||
nameLength += 4 - (nameLength % 4);
|
||||
nameLength += 4 - nameLength % 4;
|
||||
|
||||
byte[] nameBytes = new byte[nameLength];
|
||||
var nameBytes = new byte[nameLength];
|
||||
Array.Copy(nvlist, offset, nameBytes, 0, nameLength);
|
||||
item.name = StringHandlers.CToString(nameBytes);
|
||||
offset += (int)nameLength;
|
||||
@@ -126,11 +128,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_BOOLEAN_VALUE:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
bool[] boolArray = new bool[item.elements];
|
||||
var boolArray = new bool[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
boolArray[i] = temp > 0;
|
||||
offset += 4;
|
||||
}
|
||||
@@ -139,7 +141,7 @@ public sealed partial class ZFS
|
||||
}
|
||||
else
|
||||
{
|
||||
uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
item.value = temp > 0;
|
||||
offset += 4;
|
||||
}
|
||||
@@ -151,7 +153,7 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT8_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
byte[] byteArray = new byte[item.elements];
|
||||
var byteArray = new byte[item.elements];
|
||||
Array.Copy(nvlist, offset, byteArray, 0, item.elements);
|
||||
offset += (int)item.elements;
|
||||
|
||||
@@ -170,11 +172,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_DOUBLE:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
double[] doubleArray = new double[item.elements];
|
||||
var doubleArray = new double[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
double temp = BigEndianBitConverter.ToDouble(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToDouble(nvlist, offset);
|
||||
doubleArray[i] = temp;
|
||||
offset += 8;
|
||||
}
|
||||
@@ -191,9 +193,9 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_HRTIME:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
DateTime[] hrtimeArray = new DateTime[item.elements];
|
||||
var hrtimeArray = new DateTime[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
DateTime temp =
|
||||
DateHandlers.UnixHrTimeToDateTime(BigEndianBitConverter.ToUInt64(nvlist, offset));
|
||||
@@ -216,11 +218,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT16_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
short[] shortArray = new short[item.elements];
|
||||
var shortArray = new short[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
short temp = BigEndianBitConverter.ToInt16(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToInt16(nvlist, offset);
|
||||
shortArray[i] = temp;
|
||||
offset += 4;
|
||||
}
|
||||
@@ -238,11 +240,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT32_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
int[] intArray = new int[item.elements];
|
||||
var intArray = new int[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
int temp = BigEndianBitConverter.ToInt32(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToInt32(nvlist, offset);
|
||||
intArray[i] = temp;
|
||||
offset += 4;
|
||||
}
|
||||
@@ -260,11 +262,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT64_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
long[] longArray = new long[item.elements];
|
||||
var longArray = new long[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
long temp = BigEndianBitConverter.ToInt64(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToInt64(nvlist, offset);
|
||||
longArray[i] = temp;
|
||||
offset += 8;
|
||||
}
|
||||
@@ -282,11 +284,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT8_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
sbyte[] sbyteArray = new sbyte[item.elements];
|
||||
var sbyteArray = new sbyte[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
sbyte temp = (sbyte)nvlist[offset];
|
||||
var temp = (sbyte)nvlist[offset];
|
||||
sbyteArray[i] = temp;
|
||||
offset++;
|
||||
}
|
||||
@@ -294,7 +296,7 @@ public sealed partial class ZFS
|
||||
item.value = sbyteArray;
|
||||
|
||||
if(sbyteArray.Length % 4 > 0)
|
||||
offset += 4 - (sbyteArray.Length % 4);
|
||||
offset += 4 - sbyteArray.Length % 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -307,13 +309,13 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_STRING_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
string[] stringArray = new string[item.elements];
|
||||
var stringArray = new string[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
uint strLength = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
var strLength = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
offset += 4;
|
||||
byte[] strBytes = new byte[strLength];
|
||||
var strBytes = new byte[strLength];
|
||||
Array.Copy(nvlist, offset, strBytes, 0, strLength);
|
||||
stringArray[i] = StringHandlers.CToString(strBytes);
|
||||
offset += (int)strLength;
|
||||
@@ -326,9 +328,9 @@ public sealed partial class ZFS
|
||||
}
|
||||
else
|
||||
{
|
||||
uint strLength = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
var strLength = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
offset += 4;
|
||||
byte[] strBytes = new byte[strLength];
|
||||
var strBytes = new byte[strLength];
|
||||
Array.Copy(nvlist, offset, strBytes, 0, strLength);
|
||||
item.value = StringHandlers.CToString(strBytes);
|
||||
offset += (int)strLength;
|
||||
@@ -342,11 +344,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT16_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
ushort[] ushortArray = new ushort[item.elements];
|
||||
var ushortArray = new ushort[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
ushort temp = BigEndianBitConverter.ToUInt16(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToUInt16(nvlist, offset);
|
||||
ushortArray[i] = temp;
|
||||
offset += 4;
|
||||
}
|
||||
@@ -364,11 +366,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT32_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
uint[] uintArray = new uint[item.elements];
|
||||
var uintArray = new uint[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
uintArray[i] = temp;
|
||||
offset += 4;
|
||||
}
|
||||
@@ -386,11 +388,11 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT64_ARRAY:
|
||||
if(item.elements > 1)
|
||||
{
|
||||
ulong[] ulongArray = new ulong[item.elements];
|
||||
var ulongArray = new ulong[item.elements];
|
||||
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
ulong temp = BigEndianBitConverter.ToUInt64(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToUInt64(nvlist, offset);
|
||||
ulongArray[i] = temp;
|
||||
offset += 8;
|
||||
}
|
||||
@@ -408,7 +410,7 @@ public sealed partial class ZFS
|
||||
if(item.elements > 1)
|
||||
goto default;
|
||||
|
||||
byte[] subListBytes = new byte[item.encodedSize - (offset - currOff)];
|
||||
var subListBytes = new byte[item.encodedSize - (offset - currOff)];
|
||||
Array.Copy(nvlist, offset, subListBytes, 0, subListBytes.Length);
|
||||
|
||||
if(DecodeNvList(subListBytes, out Dictionary<string, NVS_Item> subList, true, littleEndian))
|
||||
@@ -420,7 +422,7 @@ public sealed partial class ZFS
|
||||
|
||||
break;
|
||||
default:
|
||||
byte[] unknown = new byte[item.encodedSize - (offset - currOff)];
|
||||
var unknown = new byte[item.encodedSize - (offset - currOff)];
|
||||
Array.Copy(nvlist, offset, unknown, 0, unknown.Length);
|
||||
item.value = unknown;
|
||||
offset = (int)(currOff + item.encodedSize);
|
||||
@@ -453,8 +455,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_BOOLEAN_ARRAY:
|
||||
case NVS_DataTypes.DATA_TYPE_BOOLEAN_VALUE:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((bool[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (bool)item.value).AppendLine();
|
||||
|
||||
@@ -464,24 +468,30 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT8:
|
||||
case NVS_DataTypes.DATA_TYPE_UINT8_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((byte[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (byte)item.value).AppendLine();
|
||||
|
||||
break;
|
||||
case NVS_DataTypes.DATA_TYPE_DOUBLE:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((double[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (double)item.value).AppendLine();
|
||||
|
||||
break;
|
||||
case NVS_DataTypes.DATA_TYPE_HRTIME:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((DateTime[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (DateTime)item.value).AppendLine();
|
||||
|
||||
@@ -489,8 +499,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT16:
|
||||
case NVS_DataTypes.DATA_TYPE_INT16_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((short[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (short)item.value).AppendLine();
|
||||
|
||||
@@ -498,8 +510,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT32:
|
||||
case NVS_DataTypes.DATA_TYPE_INT32_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((int[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (int)item.value).AppendLine();
|
||||
|
||||
@@ -507,8 +521,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT64:
|
||||
case NVS_DataTypes.DATA_TYPE_INT64_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((long[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (long)item.value).AppendLine();
|
||||
|
||||
@@ -516,8 +532,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_INT8:
|
||||
case NVS_DataTypes.DATA_TYPE_INT8_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((sbyte[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (sbyte)item.value).AppendLine();
|
||||
|
||||
@@ -525,8 +543,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_STRING:
|
||||
case NVS_DataTypes.DATA_TYPE_STRING_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((string[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (string)item.value).AppendLine();
|
||||
|
||||
@@ -534,8 +554,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT16:
|
||||
case NVS_DataTypes.DATA_TYPE_UINT16_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((ushort[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (ushort)item.value).AppendLine();
|
||||
|
||||
@@ -543,8 +565,10 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT32:
|
||||
case NVS_DataTypes.DATA_TYPE_UINT32_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((uint[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (uint)item.value).AppendLine();
|
||||
|
||||
@@ -552,29 +576,41 @@ public sealed partial class ZFS
|
||||
case NVS_DataTypes.DATA_TYPE_UINT64:
|
||||
case NVS_DataTypes.DATA_TYPE_UINT64_ARRAY:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((ulong[])item.value)[i]).AppendLine();
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("{0} = {1}", item.name, (ulong)item.value).AppendLine();
|
||||
|
||||
break;
|
||||
case NVS_DataTypes.DATA_TYPE_NVLIST:
|
||||
if(item.elements == 1)
|
||||
{
|
||||
sb.AppendFormat("{0} =\n{1}", item.name, PrintNvList((Dictionary<string, NVS_Item>)item.value)).
|
||||
AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat(Localization._0_equals_1_elements_nvlist_array_unable_to_print, item.name,
|
||||
item.elements).AppendLine();
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
{
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
{
|
||||
sb.AppendFormat(Localization._0_1_equals_unknown_data_type_2, item.name, i, item.dataType).
|
||||
AppendLine();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat(Localization._0_equals_unknown_data_type_1, item.name, item.dataType).
|
||||
AppendLine();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -58,10 +58,14 @@ namespace Aaru.Filesystems;
|
||||
*/
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements detection for the Zettabyte File System (ZFS)</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"),
|
||||
SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
public sealed partial class ZFS
|
||||
{
|
||||
#region IFilesystem Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
||||
{
|
||||
@@ -150,7 +154,8 @@ public sealed partial class ZFS
|
||||
if(errno != ErrorNumber.NoError)
|
||||
return;
|
||||
|
||||
sb.AppendLine(!DecodeNvList(nvlist, out Dictionary<string, NVS_Item> decodedNvList) ? "Could not decode nvlist"
|
||||
sb.AppendLine(!DecodeNvList(nvlist, out Dictionary<string, NVS_Item> decodedNvList)
|
||||
? "Could not decode nvlist"
|
||||
: PrintNvList(decodedNvList));
|
||||
|
||||
information = sb.ToString();
|
||||
@@ -169,4 +174,6 @@ public sealed partial class ZFS
|
||||
if(decodedNvList.TryGetValue("pool_guid", out tmpObj))
|
||||
metadata.VolumeSetIdentifier = $"{(ulong)tmpObj.value}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -52,47 +52,24 @@ namespace Aaru.Filesystems;
|
||||
*/
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements detection for the Zettabyte File System (ZFS)</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"),
|
||||
SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
public sealed partial class ZFS
|
||||
{
|
||||
struct ZIO_Checksum
|
||||
#region Nested type: DVA
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct DVA
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public ulong[] word;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly ulong[] word;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// There is an empty ZIO at sector 16 or sector 31, with magic and checksum, to detect it is really ZFS I
|
||||
/// suppose.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct ZIO_Empty
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 472)]
|
||||
public readonly byte[] empty;
|
||||
public readonly ulong magic;
|
||||
public readonly ZIO_Checksum checksum;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>This structure indicates which encoding method and endianness is used to encode the nvlist</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct NVS_Method
|
||||
{
|
||||
public readonly byte encoding;
|
||||
public readonly byte endian;
|
||||
public readonly byte reserved1;
|
||||
public readonly byte reserved2;
|
||||
}
|
||||
|
||||
/// <summary>This structure gives information about the encoded nvlist</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct NVS_XDR_Header
|
||||
{
|
||||
public readonly NVS_Method encodingAndEndian;
|
||||
public readonly uint version;
|
||||
public readonly uint flags;
|
||||
}
|
||||
#region Nested type: NVS_Item
|
||||
|
||||
/// <summary>This represent an encoded nvpair (an item of an nvlist)</summary>
|
||||
struct NVS_Item
|
||||
@@ -111,13 +88,37 @@ public sealed partial class ZFS
|
||||
public object value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: NVS_Method
|
||||
|
||||
/// <summary>This structure indicates which encoding method and endianness is used to encode the nvlist</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct DVA
|
||||
struct NVS_Method
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public readonly ulong[] word;
|
||||
public readonly byte encoding;
|
||||
public readonly byte endian;
|
||||
public readonly byte reserved1;
|
||||
public readonly byte reserved2;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: NVS_XDR_Header
|
||||
|
||||
/// <summary>This structure gives information about the encoded nvlist</summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct NVS_XDR_Header
|
||||
{
|
||||
public readonly NVS_Method encodingAndEndian;
|
||||
public readonly uint version;
|
||||
public readonly uint flags;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: SPA_BlockPointer
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct SPA_BlockPointer
|
||||
{
|
||||
@@ -137,6 +138,10 @@ public sealed partial class ZFS
|
||||
public readonly ZIO_Checksum checksum;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: ZFS_Uberblock
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct ZFS_Uberblock
|
||||
{
|
||||
@@ -148,4 +153,33 @@ public sealed partial class ZFS
|
||||
public readonly SPA_BlockPointer mosPtr;
|
||||
public readonly ulong softwareVersion;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: ZIO_Checksum
|
||||
|
||||
struct ZIO_Checksum
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public ulong[] word;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: ZIO_Empty
|
||||
|
||||
/// <summary>
|
||||
/// There is an empty ZIO at sector 16 or sector 31, with magic and checksum, to detect it is really ZFS I
|
||||
/// suppose.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct ZIO_Empty
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 472)]
|
||||
public readonly byte[] empty;
|
||||
public readonly ulong magic;
|
||||
public readonly ZIO_Checksum checksum;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -53,14 +53,22 @@ namespace Aaru.Filesystems;
|
||||
*/
|
||||
/// <inheritdoc />
|
||||
/// <summary>Implements detection for the Zettabyte File System (ZFS)</summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"),
|
||||
SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
|
||||
public sealed partial class ZFS : IFilesystem
|
||||
{
|
||||
#region IFilesystem Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => Localization.ZFS_Name;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Guid Id => new("0750014F-A714-4692-A369-E23F6EC3659C");
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Author => Authors.NataliaPortillo;
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user