mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General cleanup and refactor.
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -41,8 +43,6 @@ using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
using Schemas;
|
||||
|
||||
namespace Aaru.Filesystems;
|
||||
|
||||
/*
|
||||
* The ZFS on-disk structure is quite undocumented, so this has been checked using several test images and reading the comments and headers (but not the code)
|
||||
* of ZFS-On-Linux.
|
||||
@@ -130,8 +130,7 @@ public sealed class ZFS : IFilesystem
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
||||
Encoding encoding)
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
||||
{
|
||||
// ZFS is always UTF-8
|
||||
Encoding = Encoding.UTF8;
|
||||
@@ -183,8 +182,8 @@ public sealed class ZFS : IFilesystem
|
||||
if(errno != ErrorNumber.NoError)
|
||||
return;
|
||||
|
||||
sb.AppendLine(!DecodeNvList(nvlist, out Dictionary<string, NVS_Item> decodedNvList)
|
||||
? "Could not decode nvlist" : PrintNvList(decodedNvList));
|
||||
sb.AppendLine(!DecodeNvList(nvlist, out Dictionary<string, NVS_Item> decodedNvList) ? "Could not decode nvlist"
|
||||
: PrintNvList(decodedNvList));
|
||||
|
||||
information = sb.ToString();
|
||||
|
||||
@@ -205,7 +204,7 @@ public sealed class ZFS : IFilesystem
|
||||
|
||||
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;
|
||||
@@ -214,8 +213,7 @@ public sealed class ZFS : IFilesystem
|
||||
}
|
||||
|
||||
// TODO: Decode native nvlist
|
||||
static bool DecodeNvList(byte[] nvlist, out Dictionary<string, NVS_Item> decodedNvList, bool xdr,
|
||||
bool littleEndian)
|
||||
static bool DecodeNvList(byte[] nvlist, out Dictionary<string, NVS_Item> decodedNvList, bool xdr, bool littleEndian)
|
||||
{
|
||||
decodedNvList = new Dictionary<string, NVS_Item>();
|
||||
|
||||
@@ -226,7 +224,7 @@ public sealed class ZFS : IFilesystem
|
||||
if(!xdr)
|
||||
return false;
|
||||
|
||||
int offset = 8;
|
||||
var offset = 8;
|
||||
|
||||
while(offset < nvlist.Length)
|
||||
{
|
||||
@@ -242,13 +240,13 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
@@ -271,11 +269,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -284,7 +282,7 @@ public sealed class ZFS : IFilesystem
|
||||
}
|
||||
else
|
||||
{
|
||||
uint temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
var temp = BigEndianBitConverter.ToUInt32(nvlist, offset);
|
||||
item.value = temp > 0;
|
||||
offset += 4;
|
||||
}
|
||||
@@ -296,7 +294,7 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
|
||||
@@ -315,11 +313,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -336,9 +334,9 @@ public sealed class ZFS : IFilesystem
|
||||
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));
|
||||
@@ -351,8 +349,7 @@ public sealed class ZFS : IFilesystem
|
||||
}
|
||||
else
|
||||
{
|
||||
item.value =
|
||||
DateHandlers.UnixHrTimeToDateTime(BigEndianBitConverter.ToUInt64(nvlist, offset));
|
||||
item.value = DateHandlers.UnixHrTimeToDateTime(BigEndianBitConverter.ToUInt64(nvlist, offset));
|
||||
|
||||
offset += 8;
|
||||
}
|
||||
@@ -362,11 +359,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -384,11 +381,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -406,11 +403,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -428,11 +425,11 @@ public sealed class ZFS : IFilesystem
|
||||
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++;
|
||||
}
|
||||
@@ -440,7 +437,7 @@ public sealed class ZFS : IFilesystem
|
||||
item.value = sbyteArray;
|
||||
|
||||
if(sbyteArray.Length % 4 > 0)
|
||||
offset += 4 - (sbyteArray.Length % 4);
|
||||
offset += 4 - sbyteArray.Length % 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -453,13 +450,13 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
@@ -472,9 +469,9 @@ public sealed class ZFS : IFilesystem
|
||||
}
|
||||
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;
|
||||
@@ -488,11 +485,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -510,11 +507,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -532,11 +529,11 @@ public sealed class ZFS : IFilesystem
|
||||
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;
|
||||
}
|
||||
@@ -554,7 +551,7 @@ public sealed class ZFS : IFilesystem
|
||||
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))
|
||||
@@ -566,7 +563,7 @@ public sealed class ZFS : IFilesystem
|
||||
|
||||
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);
|
||||
@@ -599,7 +596,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -610,7 +607,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -618,7 +615,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -626,9 +623,8 @@ public sealed class ZFS : IFilesystem
|
||||
break;
|
||||
case NVS_DataTypes.DATA_TYPE_HRTIME:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = {2}", item.name, i, ((DateTime[])item.value)[i]).
|
||||
AppendLine();
|
||||
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();
|
||||
|
||||
@@ -636,7 +632,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -645,7 +641,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -654,7 +650,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -663,7 +659,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -672,7 +668,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -681,7 +677,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -690,7 +686,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -699,7 +695,7 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
@@ -707,8 +703,8 @@ public sealed class ZFS : IFilesystem
|
||||
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();
|
||||
sb.AppendFormat("{0} =\n{1}", item.name, PrintNvList((Dictionary<string, NVS_Item>)item.value)).
|
||||
AppendLine();
|
||||
else
|
||||
sb.AppendFormat("{0} = {1} elements nvlist[], unable to print", item.name, item.elements).
|
||||
AppendLine();
|
||||
@@ -716,7 +712,7 @@ public sealed class ZFS : IFilesystem
|
||||
break;
|
||||
default:
|
||||
if(item.elements > 1)
|
||||
for(int i = 0; i < item.elements; i++)
|
||||
for(var i = 0; i < item.elements; i++)
|
||||
sb.AppendFormat("{0}[{1}] = Unknown data type {2}", item.name, i, item.dataType).
|
||||
AppendLine();
|
||||
else
|
||||
@@ -769,15 +765,33 @@ public sealed class ZFS : IFilesystem
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user