Add recursiveness to BigEndianMarshal thanks to @darkstar suggestions.

This commit is contained in:
2018-03-08 20:00:01 +00:00
parent 868dda6cfe
commit 328aaa1dc9
6 changed files with 427 additions and 365 deletions

View File

@@ -47,9 +47,9 @@ namespace DiscImageChef.Filesystems
const uint RBF_CNYS = 0x7A757243;
public FileSystemType XmlFsType { get; private set; }
public Encoding Encoding { get; private set; }
public string Name => "OS-9 Random Block File Plugin";
public Guid Id => new Guid("E864E45B-0B52-4D29-A858-7BDFA9199FB2");
public Encoding Encoding { get; private set; }
public string Name => "OS-9 Random Block File Plugin";
public Guid Id => new Guid("E864E45B-0B52-4D29-A858-7BDFA9199FB2");
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
@@ -85,13 +85,13 @@ namespace DiscImageChef.Filesystems
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
Encoding encoding)
Encoding encoding)
{
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
information = "";
if(imagePlugin.Info.SectorSize < 256) return;
RBF_IdSector rbfSb = new RBF_IdSector();
RBF_IdSector rbfSb = new RBF_IdSector();
RBF_NewIdSector rbf9000Sb = new RBF_NewIdSector();
foreach(ulong location in new[] {0, 4, 15})
@@ -102,7 +102,7 @@ namespace DiscImageChef.Filesystems
byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
if(sector.Length < Marshal.SizeOf(rbfSb)) return;
rbfSb = BigEndianMarshal.ByteArrayToStructureBigEndian<RBF_IdSector>(sector);
rbfSb = BigEndianMarshal.ByteArrayToStructureBigEndian<RBF_IdSector>(sector);
rbf9000Sb = BigEndianMarshal.ByteArrayToStructureBigEndian<RBF_NewIdSector>(sector);
DicConsole.DebugWriteLine("RBF plugin",
@@ -114,7 +114,8 @@ namespace DiscImageChef.Filesystems
if(rbfSb.dd_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_SYNC && rbf9000Sb.rid_sync != RBF_CNYS) return;
if(rbf9000Sb.rid_sync == RBF_CNYS) rbf9000Sb = BigEndianMarshal.SwapStructureMembersEndian(rbf9000Sb);
if(rbf9000Sb.rid_sync == RBF_CNYS)
rbf9000Sb = (RBF_NewIdSector)BigEndianMarshal.SwapStructureMembersEndian(rbf9000Sb);
StringBuilder sb = new StringBuilder();
@@ -134,7 +135,7 @@ namespace DiscImageChef.Filesystems
sb.AppendLine((rbf9000Sb.rid_format & 0x02) == 0x02
? "Disk is double density"
: "Disk is single density");
if((rbf9000Sb.rid_format & 0x10) == 0x10) sb.AppendLine("Disk is 384 TPI");
if((rbf9000Sb.rid_format & 0x10) == 0x10) sb.AppendLine("Disk is 384 TPI");
else if((rbf9000Sb.rid_format & 0x08) == 0x08) sb.AppendLine("Disk is 192 TPI");
else if((rbf9000Sb.rid_format & 0x04) == 0x04) sb.AppendLine("Disk is 96 TPI or 135 TPI");
else sb.AppendLine("Disk is 48 TPI");
@@ -156,16 +157,16 @@ namespace DiscImageChef.Filesystems
XmlFsType = new FileSystemType
{
Type = "OS-9 Random Block File",
Bootable = rbf9000Sb.rid_bootfile > 0,
ClusterSize = rbf9000Sb.rid_blocksize,
Clusters = rbf9000Sb.rid_totblocks,
CreationDate = DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime),
CreationDateSpecified = true,
ModificationDate = DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime),
Type = "OS-9 Random Block File",
Bootable = rbf9000Sb.rid_bootfile > 0,
ClusterSize = rbf9000Sb.rid_blocksize,
Clusters = rbf9000Sb.rid_totblocks,
CreationDate = DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime),
CreationDateSpecified = true,
ModificationDate = DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime),
ModificationDateSpecified = true,
VolumeName = StringHandlers.CToString(rbf9000Sb.rid_name, Encoding),
VolumeSerial = $"{rbf9000Sb.rid_diskid:X8}"
VolumeName = StringHandlers.CToString(rbf9000Sb.rid_name, Encoding),
VolumeSerial = $"{rbf9000Sb.rid_diskid:X8}"
};
}
else
@@ -180,7 +181,7 @@ namespace DiscImageChef.Filesystems
// TODO: Convert to flags?
sb.AppendLine((rbfSb.dd_fmt & 0x01) == 0x01 ? "Disk is double sided" : "Disk is single sided");
sb.AppendLine((rbfSb.dd_fmt & 0x02) == 0x02 ? "Disk is double density" : "Disk is single density");
if((rbfSb.dd_fmt & 0x10) == 0x10) sb.AppendLine("Disk is 384 TPI");
if((rbfSb.dd_fmt & 0x10) == 0x10) sb.AppendLine("Disk is 384 TPI");
else if((rbfSb.dd_fmt & 0x08) == 0x08) sb.AppendLine("Disk is 192 TPI");
else if((rbfSb.dd_fmt & 0x04) == 0x04) sb.AppendLine("Disk is 96 TPI or 135 TPI");
else sb.AppendLine("Disk is 48 TPI");
@@ -201,14 +202,14 @@ namespace DiscImageChef.Filesystems
XmlFsType = new FileSystemType
{
Type = "OS-9 Random Block File",
Bootable = LSNToUInt32(rbfSb.dd_bt) > 0 && rbfSb.dd_bsz > 0,
ClusterSize = rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize),
Clusters = LSNToUInt32(rbfSb.dd_tot),
CreationDate = DateHandlers.Os9ToDateTime(rbfSb.dd_dat),
Type = "OS-9 Random Block File",
Bootable = LSNToUInt32(rbfSb.dd_bt) > 0 && rbfSb.dd_bsz > 0,
ClusterSize = rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize),
Clusters = LSNToUInt32(rbfSb.dd_tot),
CreationDate = DateHandlers.Os9ToDateTime(rbfSb.dd_dat),
CreationDateSpecified = true,
VolumeName = StringHandlers.CToString(rbfSb.dd_nam, Encoding),
VolumeSerial = $"{rbfSb.dd_dsk:X4}"
VolumeName = StringHandlers.CToString(rbfSb.dd_nam, Encoding),
VolumeSerial = $"{rbfSb.dd_dsk:X4}"
};
}
@@ -229,7 +230,8 @@ namespace DiscImageChef.Filesystems
struct RBF_IdSector
{
/// <summary>Sectors on disk</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] dd_tot;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] dd_tot;
/// <summary>Tracks</summary>
public byte dd_tks;
/// <summary>Bytes in allocation map</summary>
@@ -237,7 +239,8 @@ namespace DiscImageChef.Filesystems
/// <summary>Sectors per cluster</summary>
public ushort dd_bit;
/// <summary>LSN of root directory</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] dd_dir;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] dd_dir;
/// <summary>Owner ID</summary>
public ushort dd_own;
/// <summary>Attributes</summary>
@@ -251,15 +254,19 @@ namespace DiscImageChef.Filesystems
/// <summary>Reserved</summary>
public ushort dd_res;
/// <summary>LSN of boot file</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] dd_bt;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] dd_bt;
/// <summary>Size of boot file</summary>
public ushort dd_bsz;
/// <summary>Creation date</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public byte[] dd_dat;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] dd_dat;
/// <summary>Volume name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] dd_nam;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] dd_nam;
/// <summary>Path options</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] dd_opt;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] dd_opt;
/// <summary>Reserved</summary>
public byte reserved;
/// <summary>Magic number</summary>
@@ -318,11 +325,13 @@ namespace DiscImageChef.Filesystems
/// <summary>Last write time for this structure</summary>
public uint rid_mtime;
/// <summary>Volume name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] rid_name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] rid_name;
/// <summary>Endian flag</summary>
public byte rid_endflag;
/// <summary>Padding</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] rid_unused2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] rid_unused2;
/// <summary>Parity</summary>
public uint rid_parity;
}

View File

@@ -49,9 +49,9 @@ namespace DiscImageChef
public static T ByteArrayToStructureBigEndian<T>(byte[] bytes) where T : struct
{
GCHandle ptr = GCHandle.Alloc(bytes, GCHandleType.Pinned);
T str = (T)Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
T str = (T)Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(T));
ptr.Free();
return SwapStructureMembersEndian(str);
return (T)SwapStructureMembersEndian(str);
}
/// <summary>
@@ -60,67 +60,82 @@ namespace DiscImageChef
/// </summary>
/// <returns>The structure with its members endian swapped.</returns>
/// <param name="str">The structure.</param>
/// <typeparam name="T">Structure type.</typeparam>
public static T SwapStructureMembersEndian<T>(T str) where T : struct
public static object SwapStructureMembersEndian(object str)
{
Type t = str.GetType();
Type t = str.GetType();
FieldInfo[] fieldInfo = t.GetFields();
foreach(FieldInfo fi in fieldInfo)
if(fi.FieldType == typeof(short))
{
short int16 = (short)fi.GetValue(str);
short int16 = (short)fi.GetValue(str);
byte[] int16_b = BitConverter.GetBytes(int16);
byte[] int16_r = int16_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToInt16(int16_r, 0));
fi.SetValue(str, BitConverter.ToInt16(int16_r, 0));
}
else if(fi.FieldType == typeof(int))
{
int int32 = (int)fi.GetValue(str);
int int32 = (int)fi.GetValue(str);
byte[] int32_b = BitConverter.GetBytes(int32);
byte[] int32_r = int32_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToInt32(int32_r, 0));
fi.SetValue(str, BitConverter.ToInt32(int32_r, 0));
}
else if(fi.FieldType == typeof(long))
{
long int64 = (long)fi.GetValue(str);
long int64 = (long)fi.GetValue(str);
byte[] int64_b = BitConverter.GetBytes(int64);
byte[] int64_r = int64_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToInt64(int64_r, 0));
fi.SetValue(str, BitConverter.ToInt64(int64_r, 0));
}
else if(fi.FieldType == typeof(ushort))
{
ushort uint16 = (ushort)fi.GetValue(str);
ushort uint16 = (ushort)fi.GetValue(str);
byte[] uint16_b = BitConverter.GetBytes(uint16);
byte[] uint16_r = uint16_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToUInt16(uint16_r, 0));
fi.SetValue(str, BitConverter.ToUInt16(uint16_r, 0));
}
else if(fi.FieldType == typeof(uint))
{
uint uint32 = (uint)fi.GetValue(str);
uint uint32 = (uint)fi.GetValue(str);
byte[] uint32_b = BitConverter.GetBytes(uint32);
byte[] uint32_r = uint32_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToUInt32(uint32_r, 0));
fi.SetValue(str, BitConverter.ToUInt32(uint32_r, 0));
}
else if(fi.FieldType == typeof(ulong))
{
ulong uint64 = (ulong)fi.GetValue(str);
ulong uint64 = (ulong)fi.GetValue(str);
byte[] uint64_b = BitConverter.GetBytes(uint64);
byte[] uint64_r = uint64_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToUInt64(uint64_r, 0));
fi.SetValue(str, BitConverter.ToUInt64(uint64_r, 0));
}
else if(fi.FieldType == typeof(float))
{
float flt = (float)fi.GetValue(str);
float flt = (float)fi.GetValue(str);
byte[] flt_b = BitConverter.GetBytes(flt);
byte[] flt_r = flt_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToSingle(flt_r, 0));
fi.SetValue(str, BitConverter.ToSingle(flt_r, 0));
}
else if(fi.FieldType == typeof(double))
{
double dbl = (double)fi.GetValue(str);
double dbl = (double)fi.GetValue(str);
byte[] dbl_b = BitConverter.GetBytes(dbl);
byte[] dbl_r = dbl_b.Reverse().ToArray();
fi.SetValueDirect(__makeref(str), BitConverter.ToDouble(dbl_r, 0));
fi.SetValue(str, BitConverter.ToDouble(dbl_r, 0));
}
else if(fi.FieldType == typeof(byte) || fi.FieldType == typeof(sbyte))
{
// Do nothing, can't byteswap them!
}
else if(fi.FieldType == typeof(Guid))
{
// TODO: Swap GUID
}
// TODO: Swap arrays and enums
else if(fi.FieldType.IsValueType && !fi.FieldType.IsEnum && !fi.FieldType.IsArray)
{
object obj = fi.GetValue(str);
Type ty = obj.GetType();
object strc = SwapStructureMembersEndian(obj);
fi.SetValue(str, strc);
}
return str;

View File

@@ -52,7 +52,7 @@ namespace DiscImageChef.Partitions
readonly uint[] labelOffsets = {0, 9, 64, 128, 516};
public string Name => "BSD disklabel";
public Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
public Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
public bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
{
@@ -60,8 +60,8 @@ namespace DiscImageChef.Partitions
uint run = (MAX_LABEL_SIZE + labelOffsets.Last()) / imagePlugin.Info.SectorSize;
if((MAX_LABEL_SIZE + labelOffsets.Last()) % imagePlugin.Info.SectorSize > 0) run++;
DiskLabel dl = new DiskLabel();
bool found = false;
DiskLabel dl = new DiskLabel();
bool found = false;
foreach(ulong location in labelLocations)
{
@@ -90,44 +90,46 @@ namespace DiscImageChef.Partitions
if(dl.d_magic == DISKCIGAM && dl.d_magic2 == DISKCIGAM) dl = SwapDiskLabel(dl);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_type = {0}", dl.d_type);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_type = {0}", dl.d_type);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_subtype = {0}", dl.d_subtype);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_typename = {0}", StringHandlers.CToString(dl.d_typename));
DicConsole.DebugWriteLine("BSD plugin", "dl.d_packname = {0}", StringHandlers.CToString(dl.d_packname));
DicConsole.DebugWriteLine("BSD plugin", "dl.d_secsize = {0}", dl.d_secsize);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_nsectors = {0}", dl.d_nsectors);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_ntracks = {0}", dl.d_ntracks);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_ncylinders = {0}", dl.d_ncylinders);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_secpercyl = {0}", dl.d_secpercyl);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_secperunit = {0}", dl.d_secperunit);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_typename = {0}",
StringHandlers.CToString(dl.d_typename));
DicConsole.DebugWriteLine("BSD plugin", "dl.d_packname = {0}",
StringHandlers.CToString(dl.d_packname));
DicConsole.DebugWriteLine("BSD plugin", "dl.d_secsize = {0}", dl.d_secsize);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_nsectors = {0}", dl.d_nsectors);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_ntracks = {0}", dl.d_ntracks);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_ncylinders = {0}", dl.d_ncylinders);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_secpercyl = {0}", dl.d_secpercyl);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_secperunit = {0}", dl.d_secperunit);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_sparespertrack = {0}", dl.d_sparespertrack);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_sparespercyl = {0}", dl.d_sparespercyl);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_acylinders = {0}", dl.d_acylinders);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_rpm = {0}", dl.d_rpm);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_interleave = {0}", dl.d_interleave);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_trackskew = {0}", dl.d_trackskew);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_cylskeew = {0}", dl.d_cylskeew);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_headswitch = {0}", dl.d_headswitch);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_trkseek = {0}", dl.d_trkseek);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_flags = {0}", dl.d_flags);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[0] = {0}", dl.d_drivedata[0]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[1] = {0}", dl.d_drivedata[1]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[2] = {0}", dl.d_drivedata[2]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[3] = {0}", dl.d_drivedata[3]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[4] = {0}", dl.d_drivedata[4]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[0] = {0}", dl.d_spare[0]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[1] = {0}", dl.d_spare[1]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[2] = {0}", dl.d_spare[2]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[3] = {0}", dl.d_spare[3]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[4] = {0}", dl.d_spare[4]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_magic2 = 0x{0:X8}", dl.d_magic2);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_checksum = 0x{0:X8}", dl.d_checksum);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_npartitions = {0}", dl.d_npartitions);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_bbsize = {0}", dl.d_bbsize);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_sbsize = {0}", dl.d_sbsize);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_sparespercyl = {0}", dl.d_sparespercyl);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_acylinders = {0}", dl.d_acylinders);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_rpm = {0}", dl.d_rpm);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_interleave = {0}", dl.d_interleave);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_trackskew = {0}", dl.d_trackskew);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_cylskeew = {0}", dl.d_cylskeew);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_headswitch = {0}", dl.d_headswitch);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_trkseek = {0}", dl.d_trkseek);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_flags = {0}", dl.d_flags);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[0] = {0}", dl.d_drivedata[0]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[1] = {0}", dl.d_drivedata[1]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[2] = {0}", dl.d_drivedata[2]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[3] = {0}", dl.d_drivedata[3]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_drivedata[4] = {0}", dl.d_drivedata[4]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[0] = {0}", dl.d_spare[0]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[1] = {0}", dl.d_spare[1]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[2] = {0}", dl.d_spare[2]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[3] = {0}", dl.d_spare[3]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_spare[4] = {0}", dl.d_spare[4]);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_magic2 = 0x{0:X8}", dl.d_magic2);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_checksum = 0x{0:X8}", dl.d_checksum);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_npartitions = {0}", dl.d_npartitions);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_bbsize = {0}", dl.d_bbsize);
DicConsole.DebugWriteLine("BSD plugin", "dl.d_sbsize = {0}", dl.d_sbsize);
ulong counter = 0;
bool addSectorOffset = false;
ulong counter = 0;
bool addSectorOffset = false;
for(int i = 0; i < dl.d_npartitions && i < 22; i++)
{
@@ -138,23 +140,25 @@ namespace DiscImageChef.Partitions
dl.d_partitions[i].p_fstype, fsTypeToString(dl.d_partitions[i].p_fstype));
Partition part = new Partition
{
Start = dl.d_partitions[i].p_offset * dl.d_secsize / imagePlugin.Info.SectorSize,
Offset = dl.d_partitions[i].p_offset * dl.d_secsize,
Length = dl.d_partitions[i].p_size * dl.d_secsize / imagePlugin.Info.SectorSize,
Size = dl.d_partitions[i].p_size * dl.d_secsize,
Type = fsTypeToString(dl.d_partitions[i].p_fstype),
Start = dl.d_partitions[i].p_offset * dl.d_secsize / imagePlugin.Info.SectorSize,
Offset = dl.d_partitions[i].p_offset * dl.d_secsize,
Length = dl.d_partitions[i].p_size * dl.d_secsize / imagePlugin.Info.SectorSize,
Size = dl.d_partitions[i].p_size * dl.d_secsize,
Type = fsTypeToString(dl.d_partitions[i].p_fstype),
Sequence = counter,
Scheme = Name
Scheme = Name
};
if(dl.d_partitions[i].p_fstype == fsType.Unused) continue;
// Crude and dirty way to know if the disklabel is relative to its parent partition...
if(dl.d_partitions[i].p_offset < sectorOffset && !addSectorOffset) addSectorOffset = true;
if(addSectorOffset)
{
part.Start += sectorOffset;
part.Start += sectorOffset;
part.Offset += sectorOffset * imagePlugin.Info.SectorSize;
}
DicConsole.DebugWriteLine("BSD plugin", "part.start = {0}", part.Start);
DicConsole.DebugWriteLine("BSD plugin", "Adding it...");
partitions.Add(part);
@@ -168,54 +172,55 @@ namespace DiscImageChef.Partitions
{
switch(typ)
{
case fsType.Unused: return "Unused entry";
case fsType.Swap: return "Swap partition";
case fsType.V6: return "UNIX 6th Edition";
case fsType.V7: return "UNIX 7th Edition";
case fsType.Unused: return "Unused entry";
case fsType.Swap: return "Swap partition";
case fsType.V6: return "UNIX 6th Edition";
case fsType.V7: return "UNIX 7th Edition";
case fsType.SystemV: return "UNIX System V";
case fsType.V7_1K: return "UNIX 7th Edition with 1K blocks";
case fsType.V8: return "UNIX 8th Edition with 4K blocks";
case fsType.BSDFFS: return "4.2BSD Fast File System";
case fsType.BSDLFS: return "4.4LFS";
case fsType.HPFS: return "HPFS";
case fsType.V7_1K: return "UNIX 7th Edition with 1K blocks";
case fsType.V8: return "UNIX 8th Edition with 4K blocks";
case fsType.BSDFFS: return "4.2BSD Fast File System";
case fsType.BSDLFS: return "4.4LFS";
case fsType.HPFS: return "HPFS";
case fsType.ISO9660: return "ISO9660";
case fsType.Boot:
case fsType.SysVBoot: return "Boot";
case fsType.AFFS: return "Amiga FFS";
case fsType.HFS: return "Apple HFS";
case fsType.ADVfs: return "Digital Advanced File System";
case fsType.LSMpublic: return "Digital LSM Public Region";
case fsType.AFFS: return "Amiga FFS";
case fsType.HFS: return "Apple HFS";
case fsType.ADVfs: return "Digital Advanced File System";
case fsType.LSMpublic: return "Digital LSM Public Region";
case fsType.LSMprivate: return "Digital LSM Private Region";
case fsType.LSMsimple: return "Digital LSM Simple Disk";
case fsType.CCD: return "Concatenated disk";
case fsType.JFS2: return "IBM JFS2";
case fsType.HAMMER: return "Hammer";
case fsType.HAMMER2: return "Hammer2";
case fsType.UDF: return "UDF";
case fsType.EFS: return "EFS";
case fsType.ZFS: return "ZFS";
case fsType.NANDFS: return "FreeBSD nandfs";
case fsType.MSDOS: return "FAT";
case fsType.Other: return "Other or unknown";
default: return "Unknown";
case fsType.LSMsimple: return "Digital LSM Simple Disk";
case fsType.CCD: return "Concatenated disk";
case fsType.JFS2: return "IBM JFS2";
case fsType.HAMMER: return "Hammer";
case fsType.HAMMER2: return "Hammer2";
case fsType.UDF: return "UDF";
case fsType.EFS: return "EFS";
case fsType.ZFS: return "ZFS";
case fsType.NANDFS: return "FreeBSD nandfs";
case fsType.MSDOS: return "FAT";
case fsType.Other: return "Other or unknown";
default: return "Unknown";
}
}
static DiskLabel GetDiskLabel(byte[] disklabel)
{
GCHandle handle = GCHandle.Alloc(disklabel, GCHandleType.Pinned);
DiskLabel dl = (DiskLabel)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(DiskLabel));
GCHandle handle = GCHandle.Alloc(disklabel, GCHandleType.Pinned);
DiskLabel dl = (DiskLabel)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(DiskLabel));
handle.Free();
return dl;
}
static DiskLabel SwapDiskLabel(DiskLabel disklabel)
{
DiskLabel dl = BigEndianMarshal.SwapStructureMembersEndian(disklabel);
DiskLabel dl =
(DiskLabel)BigEndianMarshal.SwapStructureMembersEndian(disklabel);
for(int i = 0; i < dl.d_drivedata.Length; i++) dl.d_drivedata[i] = Swapping.Swap(dl.d_drivedata[i]);
for(int i = 0; i < dl.d_spare.Length; i++) dl.d_spare[i] = Swapping.Swap(dl.d_spare[i]);
for(int i = 0; i < dl.d_spare.Length; i++) dl.d_spare[i] = Swapping.Swap(dl.d_spare[i]);
for(int i = 0; i < dl.d_partitions.Length; i++)
dl.d_partitions[i] = BigEndianMarshal.SwapStructureMembersEndian(dl.d_partitions[i]);
dl.d_partitions[i] = (BSDPartition)BigEndianMarshal.SwapStructureMembersEndian(dl.d_partitions[i]);
return dl;
}
@@ -382,9 +387,11 @@ namespace DiscImageChef.Partitions
/// <summary>Disk subtype</summary>
public ushort d_subtype;
/// <summary>Type name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] d_typename;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] d_typename;
/// <summary>Pack identifier</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] d_packname;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] d_packname;
/// <summary>Bytes per sector</summary>
public uint d_secsize;
/// <summary>Sectors per track</summary>
@@ -420,9 +427,11 @@ namespace DiscImageChef.Partitions
/// </summary>
public dFlags d_flags;
/// <summary>Drive-specific information</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public uint[] d_drivedata;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public uint[] d_drivedata;
/// <summary>Reserved</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public uint[] d_spare;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public uint[] d_spare;
/// <summary><see cref="DISKMAGIC" /> again</summary>
public uint d_magic2;
/// <summary>XOR of data</summary>
@@ -434,7 +443,8 @@ namespace DiscImageChef.Partitions
/// <summary>Maximum size of superblock in bytes</summary>
public uint d_sbsize;
/// <summary>Partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)] public BSDPartition[] d_partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)]
public BSDPartition[] d_partitions;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]

View File

@@ -45,14 +45,14 @@ namespace DiscImageChef.Partitions
const uint X68K_MAGIC = 0x5836384B;
public string Name => "Human 68k partitions";
public Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
public Guid Id => new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
public bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
{
partitions = new List<Partition>();
byte[] sector;
ulong sectsPerUnit;
ulong sectsPerUnit;
DicConsole.DebugWriteLine("Human68k plugin", "sectorSize = {0}", imagePlugin.Info.SectorSize);
@@ -61,15 +61,15 @@ namespace DiscImageChef.Partitions
switch(imagePlugin.Info.SectorSize)
{
case 256:
sector = imagePlugin.ReadSector(4 + sectorOffset);
sector = imagePlugin.ReadSector(4 + sectorOffset);
sectsPerUnit = 1;
break;
case 512:
sector = imagePlugin.ReadSector(4 + sectorOffset);
sector = imagePlugin.ReadSector(4 + sectorOffset);
sectsPerUnit = 2;
break;
case 1024:
sector = imagePlugin.ReadSector(2 + sectorOffset);
sector = imagePlugin.ReadSector(2 + sectorOffset);
sectsPerUnit = 1;
break;
default: return false;
@@ -82,10 +82,10 @@ namespace DiscImageChef.Partitions
if(table.magic != X68K_MAGIC) return false;
for(int i = 0; i < table.entries.Length; i++)
table.entries[i] = BigEndianMarshal.SwapStructureMembersEndian(table.entries[i]);
table.entries[i] = (X68kEntry)BigEndianMarshal.SwapStructureMembersEndian(table.entries[i]);
DicConsole.DebugWriteLine("Human68k plugin", "table.size = {0:X4}", table.size);
DicConsole.DebugWriteLine("Human68k plugin", "table.size2 = {0:X4}", table.size2);
DicConsole.DebugWriteLine("Human68k plugin", "table.size = {0:X4}", table.size);
DicConsole.DebugWriteLine("Human68k plugin", "table.size2 = {0:X4}", table.size2);
DicConsole.DebugWriteLine("Human68k plugin", "table.unknown = {0:X4}", table.unknown);
ulong counter = 0;
@@ -95,20 +95,20 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Human68k plugin", "entry.name = {0}",
StringHandlers.CToString(entry.name, Encoding.GetEncoding(932)));
DicConsole.DebugWriteLine("Human68k plugin", "entry.stateStart = {0}", entry.stateStart);
DicConsole.DebugWriteLine("Human68k plugin", "entry.length = {0}", entry.length);
DicConsole.DebugWriteLine("Human68k plugin", "entry.length = {0}", entry.length);
DicConsole.DebugWriteLine("Human68k plugin", "sectsPerUnit = {0} {1}", sectsPerUnit,
imagePlugin.Info.SectorSize);
Partition part = new Partition
{
Start = (entry.stateStart & 0xFFFFFF) * sectsPerUnit,
Length = entry.length * sectsPerUnit,
Type = StringHandlers.CToString(entry.name, Encoding.GetEncoding(932)),
Start = (entry.stateStart & 0xFFFFFF) * sectsPerUnit,
Length = entry.length * sectsPerUnit,
Type = StringHandlers.CToString(entry.name, Encoding.GetEncoding(932)),
Sequence = counter,
Scheme = Name
Scheme = Name
};
part.Offset = part.Start * (ulong)sector.Length;
part.Size = part.Length * (ulong)sector.Length;
part.Offset = part.Start * (ulong)sector.Length;
part.Size = part.Length * (ulong)sector.Length;
if(entry.length <= 0) continue;
partitions.Add(part);
@@ -125,13 +125,15 @@ namespace DiscImageChef.Partitions
public uint size;
public uint size2;
public uint unknown;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public X68kEntry[] entries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public X68kEntry[] entries;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct X68kEntry
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] name;
public uint stateStart;
public uint length;
}

View File

@@ -49,7 +49,7 @@ namespace DiscImageChef.Partitions
const int SGI_MAGIC = 0x0BE5A941;
public string Name => "SGI Disk Volume Header";
public Guid Id => new Guid("AEF5AB45-4880-4CE8-8735-F0A402E2E5F2");
public Guid Id => new Guid("AEF5AB45-4880-4CE8-8735-F0A402E2E5F2");
public bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
{
@@ -60,11 +60,9 @@ namespace DiscImageChef.Partitions
SGILabel dvh = BigEndianMarshal.ByteArrayToStructureBigEndian<SGILabel>(sector);
for(int i = 0; i < dvh.volume.Length; i++)
dvh.volume[i] = BigEndianMarshal.SwapStructureMembersEndian(dvh.volume[i]);
dvh.volume[i] = (SGIVolume)BigEndianMarshal.SwapStructureMembersEndian(dvh.volume[i]);
for(int i = 0; i < dvh.partitions.Length; i++)
dvh.partitions[i] = BigEndianMarshal.SwapStructureMembersEndian(dvh.partitions[i]);
dvh.device_params = BigEndianMarshal.SwapStructureMembersEndian(dvh.device_params);
dvh.partitions[i] = (SGIPartition)BigEndianMarshal.SwapStructureMembersEndian(dvh.partitions[i]);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.magic = 0x{0:X8} (should be 0x{1:X8})", dvh.magic,
SGI_MAGIC);
@@ -80,13 +78,13 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_gap2 = {0}", dvh.device_params.dp_gap2);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_spares_cyl = {0}",
dvh.device_params.dp_spares_cyl);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cyls = {0}", dvh.device_params.dp_cyls);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_shd0 = {0}", dvh.device_params.dp_shd0);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cyls = {0}", dvh.device_params.dp_cyls);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_shd0 = {0}", dvh.device_params.dp_shd0);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_trks0 = {0}", dvh.device_params.dp_trks0);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_ctq_depth = {0}",
dvh.device_params.dp_ctq_depth);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_cylshi = {0}", dvh.device_params.dp_cylshi);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secs = {0}", dvh.device_params.dp_secs);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secs = {0}", dvh.device_params.dp_secs);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_secbytes = {0}",
dvh.device_params.dp_secbytes);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_interleave = {0}",
@@ -96,11 +94,11 @@ namespace DiscImageChef.Partitions
dvh.device_params.dp_datarate);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_nretries = {0}",
dvh.device_params.dp_nretries);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_mspw = {0}", dvh.device_params.dp_mspw);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap1 = {0}", dvh.device_params.dp_xgap1);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xsync = {0}", dvh.device_params.dp_xsync);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xrdly = {0}", dvh.device_params.dp_xrdly);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap2 = {0}", dvh.device_params.dp_xgap2);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_mspw = {0}", dvh.device_params.dp_mspw);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap1 = {0}", dvh.device_params.dp_xgap1);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xsync = {0}", dvh.device_params.dp_xsync);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xrdly = {0}", dvh.device_params.dp_xrdly);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xgap2 = {0}", dvh.device_params.dp_xgap2);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xrgate = {0}", dvh.device_params.dp_xrgate);
DicConsole.DebugWriteLine("SGIVH plugin", "dvh.device_params.dp_xwcont = {0}", dvh.device_params.dp_xwcont);
@@ -118,15 +116,19 @@ namespace DiscImageChef.Partitions
Partition part = new Partition
{
Start = dvh.partitions[i].first_block * dvh.device_params.dp_secbytes / imagePlugin.Info.SectorSize,
Offset = dvh.partitions[i].first_block * dvh.device_params.dp_secbytes,
Length = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes / imagePlugin.Info.SectorSize,
Size = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes,
Type = TypeToString(dvh.partitions[i].type),
Start = dvh.partitions[i].first_block * dvh.device_params.dp_secbytes /
imagePlugin.Info.SectorSize,
Offset = dvh.partitions[i].first_block *
dvh.device_params.dp_secbytes,
Length = dvh.partitions[i].num_blocks * dvh.device_params.dp_secbytes /
imagePlugin.Info.SectorSize,
Size = dvh.partitions[i].num_blocks *
dvh.device_params.dp_secbytes,
Type = TypeToString(dvh.partitions[i].type),
Sequence = counter,
Scheme = Name
Scheme = Name
};
if(part.Size <= 0 || dvh.partitions[i].type == SGIType.Header ||
if(part.Size <= 0 || dvh.partitions[i].type == SGIType.Header ||
dvh.partitions[i].type == SGIType.Volume) continue;
partitions.Add(part);
@@ -140,24 +142,24 @@ namespace DiscImageChef.Partitions
{
switch(typ)
{
case SGIType.Header: return "Volume header";
case SGIType.TrkRepl: return "Track replacements";
case SGIType.SecRepl: return "Sector replacements";
case SGIType.Swap: return "Raw data (swap)";
case SGIType.Bsd: return "4.2BSD Fast File System";
case SGIType.SystemV: return "UNIX System V";
case SGIType.Volume: return "Whole device";
case SGIType.EFS: return "EFS";
case SGIType.Lvol: return "Logical volume";
case SGIType.Rlvol: return "Raw logical volume";
case SGIType.XFS: return "XFS";
case SGIType.Xlvol: return "XFS log device";
case SGIType.Rxlvol: return "XLV volume";
case SGIType.Xvm: return "SGI XVM";
case SGIType.Header: return "Volume header";
case SGIType.TrkRepl: return "Track replacements";
case SGIType.SecRepl: return "Sector replacements";
case SGIType.Swap: return "Raw data (swap)";
case SGIType.Bsd: return "4.2BSD Fast File System";
case SGIType.SystemV: return "UNIX System V";
case SGIType.Volume: return "Whole device";
case SGIType.EFS: return "EFS";
case SGIType.Lvol: return "Logical volume";
case SGIType.Rlvol: return "Raw logical volume";
case SGIType.XFS: return "XFS";
case SGIType.Xlvol: return "XFS log device";
case SGIType.Rxlvol: return "XLV volume";
case SGIType.Xvm: return "SGI XVM";
case SGIType.LinuxSwap: return "Linux swap";
case SGIType.Linux: return "Linux";
case SGIType.Linux: return "Linux";
case SGIType.LinuxRAID: return "Linux RAID";
default: return "Unknown";
default: return "Unknown";
}
}
@@ -171,13 +173,16 @@ namespace DiscImageChef.Partitions
/// <summary></summary>
public short swap_part_num;
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] boot_file;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] boot_file;
/// <summary></summary>
public SGIDeviceParameters device_params;
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] public SGIVolume[] volume;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
public SGIVolume[] volume;
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public SGIPartition[] partitions;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public SGIPartition[] partitions;
/// <summary></summary>
public uint csum;
/// <summary></summary>
@@ -188,7 +193,8 @@ namespace DiscImageChef.Partitions
struct SGIVolume
{
/// <summary></summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] name;
/// <summary></summary>
public uint block_num;
/// <summary></summary>
@@ -197,22 +203,22 @@ namespace DiscImageChef.Partitions
enum SGIType : uint
{
Header = 0,
TrkRepl = 1,
SecRepl = 2,
Swap = 3,
Bsd = 4,
SystemV = 5,
Volume = 6,
EFS = 7,
Lvol = 8,
Rlvol = 9,
XFS = 0xA,
Xlvol = 0xB,
Rxlvol = 0xC,
Xvm = 0x0D,
Header = 0,
TrkRepl = 1,
SecRepl = 2,
Swap = 3,
Bsd = 4,
SystemV = 5,
Volume = 6,
EFS = 7,
Lvol = 8,
Rlvol = 9,
XFS = 0xA,
Xlvol = 0xB,
Rxlvol = 0xC,
Xvm = 0x0D,
LinuxSwap = 0x82,
Linux = 0x83,
Linux = 0x83,
LinuxRAID = 0xFD
}
@@ -229,23 +235,23 @@ namespace DiscImageChef.Partitions
struct SGIDeviceParameters
{
public byte dp_skew;
public byte dp_gap1;
public byte dp_gap2;
public byte dp_spares_cyl;
public byte dp_skew;
public byte dp_gap1;
public byte dp_gap2;
public byte dp_spares_cyl;
public ushort dp_cyls;
public ushort dp_shd0;
public ushort dp_trks0;
public byte dp_ctq_depth;
public byte dp_cylshi;
public byte dp_ctq_depth;
public byte dp_cylshi;
public ushort dp_unused;
public ushort dp_secs;
public ushort dp_secbytes;
public ushort dp_interleave;
public uint dp_flags;
public uint dp_datarate;
public uint dp_nretries;
public uint dp_mspw;
public uint dp_flags;
public uint dp_datarate;
public uint dp_nretries;
public uint dp_mspw;
public ushort dp_xgap1;
public ushort dp_xsync;
public ushort dp_xrdly;

View File

@@ -65,13 +65,13 @@ namespace DiscImageChef.Partitions
/// <summary>Size of padding in SunOS disk label</summary>
const int LEN_DKL_PAD = DK_LABEL_SIZE - (LEN_DKL_ASCII + NDKMAP * 8 + 14 * 2);
/// <summary>Size of padding in Solaris disk label with 8 partitions</summary>
const int LEN_DKL_PAD8 = DK_LABEL_SIZE - (LEN_DKL_ASCII + 136 + // sizeof(dk_vtoc8)
NDKMAP * 8 + 14 * 2 + 2 * 2);
const int LEN_DKL_PAD16 = DK_LABEL_SIZE - (456 + // sizeof(dk_vtoc16)
const int LEN_DKL_PAD8 = DK_LABEL_SIZE - (LEN_DKL_ASCII + 136 + // sizeof(dk_vtoc8)
NDKMAP * 8 + 14 * 2 + 2 * 2);
const int LEN_DKL_PAD16 = DK_LABEL_SIZE - (456 + // sizeof(dk_vtoc16)
4 * 4 + 12 * 2 + 2 * 2);
public string Name => "Sun Disklabel";
public Guid Id => new Guid("50F35CC4-8375-4445-8DCB-1BA550C931A3");
public Guid Id => new Guid("50F35CC4-8375-4445-8DCB-1BA550C931A3");
public bool GetInformation(IMediaImage imagePlugin, out List<Partition> partitions, ulong sectorOffset)
{
@@ -85,42 +85,44 @@ namespace DiscImageChef.Partitions
byte[] sunSector = imagePlugin.ReadSector(sectorOffset);
GCHandle handle = GCHandle.Alloc(sunSector, GCHandleType.Pinned);
dk_label dkl = (dk_label)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label));
dk_label8 dkl8 = (dk_label8)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label8));
dk_label16 dkl16 = (dk_label16)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label16));
GCHandle handle = GCHandle.Alloc(sunSector, GCHandleType.Pinned);
dk_label dkl = (dk_label)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label));
dk_label8 dkl8 = (dk_label8)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label8));
dk_label16 dkl16 = (dk_label16)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label16));
handle.Free();
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_magic = 0x{0:X4}", dkl.dkl_magic);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_sanity = 0x{0:X8}", dkl8.dkl_vtoc.v_sanity);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_magic = 0x{0:X4}", dkl.dkl_magic);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_sanity = 0x{0:X8}", dkl8.dkl_vtoc.v_sanity);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_sanity = 0x{0:X8}", dkl16.dkl_vtoc.v_sanity);
if(dkl.dkl_magic == DKL_MAGIC || dkl.dkl_magic == DKL_CIGAM)
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl16 = true;
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS)
useDkl16 = true;
else if(dkl8.dkl_vtoc.v_sanity == VTOC_SANE || dkl8.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl8 = true;
else useDkl = true;
else useDkl = true;
if(!useDkl && !useDkl8 && !useDkl16)
{
sunSector = imagePlugin.ReadSector(sectorOffset + 1);
handle = GCHandle.Alloc(sunSector, GCHandleType.Pinned);
dkl = (dk_label)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label));
dkl8 = (dk_label8)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label8));
dkl16 = (dk_label16)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label16));
dkl = (dk_label)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label));
dkl8 = (dk_label8)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label8));
dkl16 = (dk_label16)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(dk_label16));
handle.Free();
if(dkl.dkl_magic == DKL_MAGIC || dkl.dkl_magic == DKL_CIGAM)
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl16 = true;
if(dkl16.dkl_vtoc.v_sanity == VTOC_SANE || dkl16.dkl_vtoc.v_sanity == VTOC_ENAS)
useDkl16 = true;
else if(dkl8.dkl_vtoc.v_sanity == VTOC_SANE || dkl8.dkl_vtoc.v_sanity == VTOC_ENAS) useDkl8 = true;
else useDkl = true;
else useDkl = true;
}
if(!useDkl && !useDkl8 && !useDkl16) return false;
if(useDkl16 && dkl16.dkl_magic == DKL_CIGAM) dkl16 = SwapDiskLabel(dkl16);
else if(useDkl8 && dkl8.dkl_magic == DKL_CIGAM) dkl8 = SwapDiskLabel(dkl8);
else if(useDkl && dkl.dkl_magic == DKL_CIGAM) dkl = SwapDiskLabel(dkl);
if(useDkl16 && dkl16.dkl_magic == DKL_CIGAM) dkl16 = SwapDiskLabel(dkl16);
else if(useDkl8 && dkl8.dkl_magic == DKL_CIGAM) dkl8 = SwapDiskLabel(dkl8);
else if(useDkl && dkl.dkl_magic == DKL_CIGAM) dkl = SwapDiskLabel(dkl);
if(useDkl)
{
@@ -128,18 +130,18 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_asciilabel = \"{0}\"",
StringHandlers.CToString(dkl.dkl_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_rpm = {0}", dkl.dkl_rpm);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_pcyl = {0}", dkl.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_apc = {0}", dkl.dkl_apc);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_gap1 = {0}", dkl.dkl_gap1);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_gap2 = {0}", dkl.dkl_gap2);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_rpm = {0}", dkl.dkl_rpm);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_pcyl = {0}", dkl.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_apc = {0}", dkl.dkl_apc);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_gap1 = {0}", dkl.dkl_gap1);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_gap2 = {0}", dkl.dkl_gap2);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_intrlv = {0}", dkl.dkl_intrlv);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_ncyl = {0}", dkl.dkl_ncyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_acyl = {0}", dkl.dkl_acyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_nhead = {0}", dkl.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_nsect = {0}", dkl.dkl_nsect);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_bhead = {0}", dkl.dkl_bhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_ppart = {0}", dkl.dkl_ppart);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_ncyl = {0}", dkl.dkl_ncyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_acyl = {0}", dkl.dkl_acyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_nhead = {0}", dkl.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_nsect = {0}", dkl.dkl_nsect);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_bhead = {0}", dkl.dkl_bhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_ppart = {0}", dkl.dkl_ppart);
for(int i = 0; i < NDKMAP; i++)
{
DicConsole.DebugWriteLine("Sun plugin", "dkl.dkl_map[{0}].dkl_cylno = {1}", i,
@@ -157,15 +159,14 @@ namespace DiscImageChef.Partitions
{
Partition part = new Partition
{
Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
Length =
(ulong)(dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.Info.SectorSize),
Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
Length = (ulong)(dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.Info.SectorSize),
Sequence = (ulong)i,
Offset =
((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * DK_LABEL_SIZE,
Start = ((ulong)dkl.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) *
DK_LABEL_SIZE / imagePlugin.Info.SectorSize,
Type = "SunOS partition",
Type = "SunOS partition",
Scheme = Name
};
if(part.Start < imagePlugin.Info.Sectors && part.End <= imagePlugin.Info.Sectors)
@@ -181,22 +182,22 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_version = {0}", dkl8.dkl_vtoc.v_version);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_volume = \"{0}\"",
StringHandlers.CToString(dkl8.dkl_vtoc.v_volume));
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_nparts = {0}", dkl8.dkl_vtoc.v_nparts);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_nparts = {0}", dkl8.dkl_vtoc.v_nparts);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_vtoc.v_sanity = 0x{0:X8}", dkl8.dkl_vtoc.v_sanity);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_write_reinstruct = {0}", dkl8.dkl_write_reinstruct);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_read_reinstruct = {0}", dkl8.dkl_read_reinstruct);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_rpm = {0}", dkl8.dkl_rpm);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_pcyl = {0}", dkl8.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_apc = {0}", dkl8.dkl_apc);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs1 = {0}", dkl8.dkl_obs1);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs2 = {0}", dkl8.dkl_obs2);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_intrlv = {0}", dkl8.dkl_intrlv);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_ncyl = {0}", dkl8.dkl_ncyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_acyl = {0}", dkl8.dkl_acyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_nhead = {0}", dkl8.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_nsect = {0}", dkl8.dkl_nsect);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs3 = {0}", dkl8.dkl_obs3);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs4 = {0}", dkl8.dkl_obs4);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_write_reinstruct = {0}", dkl8.dkl_write_reinstruct);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_read_reinstruct = {0}", dkl8.dkl_read_reinstruct);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_rpm = {0}", dkl8.dkl_rpm);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_pcyl = {0}", dkl8.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_apc = {0}", dkl8.dkl_apc);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs1 = {0}", dkl8.dkl_obs1);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs2 = {0}", dkl8.dkl_obs2);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_intrlv = {0}", dkl8.dkl_intrlv);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_ncyl = {0}", dkl8.dkl_ncyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_acyl = {0}", dkl8.dkl_acyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_nhead = {0}", dkl8.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_nsect = {0}", dkl8.dkl_nsect);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs3 = {0}", dkl8.dkl_obs3);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_obs4 = {0}", dkl8.dkl_obs4);
for(int i = 0; i < NDKMAP; i++)
{
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_map[{0}].dkl_cylno = {1}", i,
@@ -213,18 +214,18 @@ namespace DiscImageChef.Partitions
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_magic = 0x{0:X4}", dkl8.dkl_magic);
DicConsole.DebugWriteLine("Sun plugin", "dkl8.dkl_cksum = 0x{0:X4}", dkl8.dkl_cksum);
DicConsole.DebugWriteLine("Sun plugin", "sectorsPerCylinder = {0}", sectorsPerCylinder);
DicConsole.DebugWriteLine("Sun plugin", "sectorsPerCylinder = {0}", sectorsPerCylinder);
if(dkl8.dkl_vtoc.v_nparts > NDKMAP) return false;
for(int i = 0; i < dkl8.dkl_vtoc.v_nparts; i++)
if(dkl8.dkl_map[i].dkl_nblk > 0 && dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
if(dkl8.dkl_map[i].dkl_nblk > 0 && dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
Partition part = new Partition
{
Description = SunFlagsToString(dkl8.dkl_vtoc.v_part[i].p_flag),
Size = (ulong)dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
Size = (ulong)dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
Length =
(ulong)(dkl8.dkl_map[i].dkl_nblk * DK_LABEL_SIZE / imagePlugin.Info.SectorSize),
Sequence = (ulong)i,
@@ -232,7 +233,7 @@ namespace DiscImageChef.Partitions
((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) * DK_LABEL_SIZE,
Start = ((ulong)dkl8.dkl_map[i].dkl_cylno * sectorsPerCylinder + sectorOffset) *
DK_LABEL_SIZE / imagePlugin.Info.SectorSize,
Type = SunIdToString(dkl8.dkl_vtoc.v_part[i].p_tag),
Type = SunIdToString(dkl8.dkl_vtoc.v_part[i].p_tag),
Scheme = Name
};
if(dkl8.dkl_vtoc.v_timestamp[i] != 0)
@@ -246,25 +247,25 @@ namespace DiscImageChef.Partitions
else
{
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_sanity = 0x{0:X8}", dkl16.dkl_vtoc.v_sanity);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_version = {0}", dkl16.dkl_vtoc.v_version);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_version = {0}", dkl16.dkl_vtoc.v_version);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_volume = \"{0}\"",
StringHandlers.CToString(dkl16.dkl_vtoc.v_volume));
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_sectorsz = {0}", dkl16.dkl_vtoc.v_sectorsz);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_nparts = {0}", dkl16.dkl_vtoc.v_nparts);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_nparts = {0}", dkl16.dkl_vtoc.v_nparts);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_asciilabel = \"{0}\"",
StringHandlers.CToString(dkl16.dkl_vtoc.v_asciilabel));
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_pcyl = {0}", dkl16.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_ncyl = {0}", dkl16.dkl_ncyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_acyl = {0}", dkl16.dkl_acyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_bcyl = {0}", dkl16.dkl_bcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_nhead = {0}", dkl16.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_nsect = {0}", dkl16.dkl_nsect);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_intrlv = {0}", dkl16.dkl_intrlv);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_skew = {0}", dkl16.dkl_skew);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_apc = {0}", dkl16.dkl_apc);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_rpm = {0}", dkl16.dkl_rpm);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_pcyl = {0}", dkl16.dkl_pcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_ncyl = {0}", dkl16.dkl_ncyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_acyl = {0}", dkl16.dkl_acyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_bcyl = {0}", dkl16.dkl_bcyl);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_nhead = {0}", dkl16.dkl_nhead);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_nsect = {0}", dkl16.dkl_nsect);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_intrlv = {0}", dkl16.dkl_intrlv);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_skew = {0}", dkl16.dkl_skew);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_apc = {0}", dkl16.dkl_apc);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_rpm = {0}", dkl16.dkl_rpm);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_write_reinstruct = {0}", dkl16.dkl_write_reinstruct);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_read_reinstruct = {0}", dkl16.dkl_read_reinstruct);
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_read_reinstruct = {0}", dkl16.dkl_read_reinstruct);
for(int i = 0; i < NDKMAP16; i++)
{
DicConsole.DebugWriteLine("Sun plugin", "dkl16.dkl_vtoc.v_part[{0}].p_start = {1}", i,
@@ -286,12 +287,12 @@ namespace DiscImageChef.Partitions
for(int i = 0; i < dkl16.dkl_vtoc.v_nparts; i++)
if(dkl16.dkl_vtoc.v_part[i].p_size > 0 && dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
Partition part = new Partition
{
Description = SunFlagsToString(dkl16.dkl_vtoc.v_part[i].p_flag),
Size = (ulong)dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz,
Size = (ulong)dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz,
Length =
(ulong)(dkl16.dkl_vtoc.v_part[i].p_size * dkl16.dkl_vtoc.v_sectorsz /
imagePlugin.Info.SectorSize),
@@ -300,7 +301,7 @@ namespace DiscImageChef.Partitions
((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) * dkl16.dkl_vtoc.v_sectorsz,
Start = ((ulong)dkl16.dkl_vtoc.v_part[i].p_start + sectorOffset) *
dkl16.dkl_vtoc.v_sectorsz / imagePlugin.Info.SectorSize,
Type = SunIdToString(dkl16.dkl_vtoc.v_part[i].p_tag),
Type = SunIdToString(dkl16.dkl_vtoc.v_part[i].p_tag),
Scheme = Name
};
if(dkl16.dkl_vtoc.v_timestamp[i] != 0)
@@ -317,9 +318,9 @@ namespace DiscImageChef.Partitions
static dk_label SwapDiskLabel(dk_label label)
{
DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label");
dk_label lebal = BigEndianMarshal.SwapStructureMembersEndian(label);
dk_label lebal = (dk_label)BigEndianMarshal.SwapStructureMembersEndian(label);
for(int i = 0; i < label.dkl_map.Length; i++)
lebal.dkl_map[i] = BigEndianMarshal.SwapStructureMembersEndian(label.dkl_map[i]);
lebal.dkl_map[i] = (dk_map)BigEndianMarshal.SwapStructureMembersEndian(label.dkl_map[i]);
return lebal;
}
@@ -327,17 +328,17 @@ namespace DiscImageChef.Partitions
static dk_label8 SwapDiskLabel(dk_label8 label)
{
DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label8");
dk_label8 lebal = BigEndianMarshal.SwapStructureMembersEndian(label);
lebal.dkl_vtoc = BigEndianMarshal.SwapStructureMembersEndian(label.dkl_vtoc);
dk_label8 lebal = (dk_label8)BigEndianMarshal.SwapStructureMembersEndian(label);
for(int i = 0; i < label.dkl_map.Length; i++)
lebal.dkl_map[i] = BigEndianMarshal.SwapStructureMembersEndian(label.dkl_map[i]);
lebal.dkl_map[i] = (dk_map)BigEndianMarshal.SwapStructureMembersEndian(label.dkl_map[i]);
for(int i = 0; i < label.dkl_vtoc.v_bootinfo.Length; i++)
lebal.dkl_vtoc.v_bootinfo[i] = Swapping.Swap(label.dkl_vtoc.v_bootinfo[i]);
for(int i = 0; i < label.dkl_vtoc.v_part.Length; i++)
{
lebal.dkl_vtoc.v_part[i].p_flag = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
lebal.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
lebal.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
}
for(int i = 0; i < label.dkl_vtoc.v_timestamp.Length; i++)
lebal.dkl_vtoc.v_timestamp[i] = Swapping.Swap(label.dkl_vtoc.v_timestamp[i]);
for(int i = 0; i < label.dkl_vtoc.v_reserved.Length; i++)
@@ -349,17 +350,17 @@ namespace DiscImageChef.Partitions
static dk_label16 SwapDiskLabel(dk_label16 label)
{
DicConsole.DebugWriteLine("Sun plugin", "Swapping dk_label16");
dk_label16 lebal = BigEndianMarshal.SwapStructureMembersEndian(label);
lebal.dkl_vtoc = BigEndianMarshal.SwapStructureMembersEndian(label.dkl_vtoc);
dk_label16 lebal = (dk_label16)BigEndianMarshal.SwapStructureMembersEndian(label);
for(int i = 0; i < label.dkl_vtoc.v_bootinfo.Length; i++)
lebal.dkl_vtoc.v_bootinfo[i] = Swapping.Swap(label.dkl_vtoc.v_bootinfo[i]);
for(int i = 0; i < label.dkl_vtoc.v_part.Length; i++)
{
lebal.dkl_vtoc.v_part[i].p_flag = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
lebal.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
lebal.dkl_vtoc.v_part[i].p_size = Swapping.Swap(label.dkl_vtoc.v_part[i].p_size);
lebal.dkl_vtoc.v_part[i].p_flag = (SunFlags)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_flag);
lebal.dkl_vtoc.v_part[i].p_tag = (SunTag)Swapping.Swap((ushort)label.dkl_vtoc.v_part[i].p_tag);
lebal.dkl_vtoc.v_part[i].p_size = Swapping.Swap(label.dkl_vtoc.v_part[i].p_size);
lebal.dkl_vtoc.v_part[i].p_start = Swapping.Swap(label.dkl_vtoc.v_part[i].p_start);
}
for(int i = 0; i < label.dkl_vtoc.v_timestamp.Length; i++)
lebal.dkl_vtoc.v_timestamp[i] = Swapping.Swap(label.dkl_vtoc.v_timestamp[i]);
for(int i = 0; i < label.dkl_vtoc.v_reserved.Length; i++)
@@ -380,66 +381,66 @@ namespace DiscImageChef.Partitions
{
switch(id)
{
case SunTag.Linux: return "Linux";
case SunTag.LinuxRaid: return "Linux RAID";
case SunTag.LinuxSwap: return "Linux swap";
case SunTag.LVM: return "LVM";
case SunTag.SunBoot: return "Sun boot";
case SunTag.SunEmpty: return "Empty";
case SunTag.SunHome: return "Sun /home";
case SunTag.SunRoot: return "Sun /";
case SunTag.SunStand: return "Sun /stand";
case SunTag.SunSwap: return "Sun swap";
case SunTag.SunUsr: return "Sun /usr";
case SunTag.SunVar: return "Sun /var";
case SunTag.SunWholeDisk: return "Whole disk";
case SunTag.SunAlt: return "Replacement sectors";
case SunTag.SunCache: return "Sun cachefs";
case SunTag.SunReserved: return "Reserved for SMI";
case SunTag.VxVmPublic: return "Veritas public";
case SunTag.VxVmPrivate: return "Veritas private";
case SunTag.NetBSD: return "NetBSD";
case SunTag.FreeBSD_Swap: return "FreeBSD swap";
case SunTag.FreeBSD_UFS: return "FreeBSD";
case SunTag.FreeBSD_Vinum: return "Vinum";
case SunTag.FreeBSD_ZFS: return "FreeBSD ZFS";
case SunTag.Linux: return "Linux";
case SunTag.LinuxRaid: return "Linux RAID";
case SunTag.LinuxSwap: return "Linux swap";
case SunTag.LVM: return "LVM";
case SunTag.SunBoot: return "Sun boot";
case SunTag.SunEmpty: return "Empty";
case SunTag.SunHome: return "Sun /home";
case SunTag.SunRoot: return "Sun /";
case SunTag.SunStand: return "Sun /stand";
case SunTag.SunSwap: return "Sun swap";
case SunTag.SunUsr: return "Sun /usr";
case SunTag.SunVar: return "Sun /var";
case SunTag.SunWholeDisk: return "Whole disk";
case SunTag.SunAlt: return "Replacement sectors";
case SunTag.SunCache: return "Sun cachefs";
case SunTag.SunReserved: return "Reserved for SMI";
case SunTag.VxVmPublic: return "Veritas public";
case SunTag.VxVmPrivate: return "Veritas private";
case SunTag.NetBSD: return "NetBSD";
case SunTag.FreeBSD_Swap: return "FreeBSD swap";
case SunTag.FreeBSD_UFS: return "FreeBSD";
case SunTag.FreeBSD_Vinum: return "Vinum";
case SunTag.FreeBSD_ZFS: return "FreeBSD ZFS";
case SunTag.FreeBSD_NANDFS: return "FreeBSD nandfs";
default: return "Unknown";
default: return "Unknown";
}
}
enum SunTag : ushort
{
SunEmpty = 0x0000,
SunBoot = 0x0001,
SunRoot = 0x0002,
SunSwap = 0x0003,
SunUsr = 0x0004,
SunWholeDisk = 0x0005,
SunStand = 0x0006,
SunVar = 0x0007,
SunHome = 0x0008,
SunAlt = 0x0009,
SunCache = 0x000A,
SunReserved = 0x000B,
VxVmPublic = 0x000E,
VxVmPrivate = 0x000F,
LinuxSwap = 0x0082,
Linux = 0x0083,
LVM = 0x008E,
LinuxRaid = 0x00FD,
NetBSD = 0x00FF,
FreeBSD_Swap = 0x0901,
FreeBSD_UFS = 0x0902,
FreeBSD_Vinum = 0x0903,
FreeBSD_ZFS = 0x0904,
SunEmpty = 0x0000,
SunBoot = 0x0001,
SunRoot = 0x0002,
SunSwap = 0x0003,
SunUsr = 0x0004,
SunWholeDisk = 0x0005,
SunStand = 0x0006,
SunVar = 0x0007,
SunHome = 0x0008,
SunAlt = 0x0009,
SunCache = 0x000A,
SunReserved = 0x000B,
VxVmPublic = 0x000E,
VxVmPrivate = 0x000F,
LinuxSwap = 0x0082,
Linux = 0x0083,
LVM = 0x008E,
LinuxRaid = 0x00FD,
NetBSD = 0x00FF,
FreeBSD_Swap = 0x0901,
FreeBSD_UFS = 0x0902,
FreeBSD_Vinum = 0x0903,
FreeBSD_ZFS = 0x0904,
FreeBSD_NANDFS = 0x0905
}
[Flags]
enum SunFlags : ushort
{
NoMount = 0x0001,
NoMount = 0x0001,
ReadOnly = 0x0010
}
@@ -458,9 +459,11 @@ namespace DiscImageChef.Partitions
struct dk_label
{
/// <summary>Informative string</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)] public byte[] dkl_asciilabel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)]
public byte[] dkl_asciilabel;
/// <summary>Padding</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD)] public byte[] dkl_pad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD)]
public byte[] dkl_pad;
/// <summary>rotations per minute</summary>
public ushort dkl_rpm;
/// <summary># physical cylinders</summary>
@@ -486,7 +489,8 @@ namespace DiscImageChef.Partitions
/// <summary>physical partition #</summary>
public ushort dkl_ppart;
/// <summary>Logical partitions</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public dk_map[] dkl_map;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public dk_map[] dkl_map;
/// <summary>identifies this label format</summary>
public ushort dkl_magic;
/// <summary>xor checksum of sector</summary>
@@ -523,53 +527,65 @@ namespace DiscImageChef.Partitions
/// <summary> layout version</summary>
public uint v_version;
/// <summary> volume name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)] public byte[] v_volume;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)]
public byte[] v_volume;
/// <summary> number of partitions </summary>
public ushort v_nparts;
/// <summary> partition hdrs, sec 2</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public dk_map2[] v_part;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public dk_map2[] v_part;
/// <summary>Alignment</summary>
public ushort padding;
/// <summary> info needed by mboot</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] v_bootinfo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] v_bootinfo;
/// <summary> to verify vtoc sanity</summary>
public uint v_sanity;
/// <summary> free space</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public uint[] v_reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public uint[] v_reserved;
/// <summary> partition timestamp</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public int[] v_timestamp;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public int[] v_timestamp;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct dk_vtoc16
{
/// <summary>info needed by mboot</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint[] v_bootinfo;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public uint[] v_bootinfo;
/// <summary>to verify vtoc sanity</summary>
public uint v_sanity;
/// <summary>layout version</summary>
public uint v_version;
/// <summary>volume name</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)] public byte[] v_volume;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_VVOL)]
public byte[] v_volume;
/// <summary>sector size in bytes</summary>
public ushort v_sectorsz;
/// <summary>number of partitions</summary>
public ushort v_nparts;
/// <summary>free space</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public uint[] v_reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
public uint[] v_reserved;
/// <summary>partition headers</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)] public dkl_partition[] v_part;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)]
public dkl_partition[] v_part;
/// <summary>partition timestamp</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)] public int[] v_timestamp;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP16)]
public int[] v_timestamp;
/// <summary>for compatibility</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)] public byte[] v_asciilabel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)]
public byte[] v_asciilabel;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct dk_label8
{
/// <summary>for compatibility</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)] public byte[] dkl_asciilabel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_ASCII)]
public byte[] dkl_asciilabel;
/// <summary>vtoc inclusions from AT&amp;T SVr4</summary>
public dk_vtoc8 dkl_vtoc;
/// <summary># sectors to skip, writes</summary>
@@ -577,7 +593,8 @@ namespace DiscImageChef.Partitions
/// <summary># sectors to skip, reads</summary>
public ushort dkl_read_reinstruct;
/// <summary>unused part of 512 bytes</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD8)] public byte[] dkl_pad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD8)]
public byte[] dkl_pad;
/// <summary>rotations per minute</summary>
public ushort dkl_rpm;
/// <summary># physical cylinders</summary>
@@ -603,7 +620,8 @@ namespace DiscImageChef.Partitions
/// <summary>obsolete</summary>
public ushort dkl_obs4;
/// <summary>logical partition headers</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)] public dk_map[] dkl_map;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDKMAP)]
public dk_map[] dkl_map;
/// <summary>identifies this label format</summary>
public ushort dkl_magic;
/// <summary>xor checksum of sector</summary>
@@ -640,9 +658,11 @@ namespace DiscImageChef.Partitions
/// <summary># sectors to skip, reads </summary>
public ushort dkl_read_reinstruct;
/// <summary>for compatible expansion</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public ushort[] dkl_extra;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public ushort[] dkl_extra;
/// <summary>unused part of 512 bytes</summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD16)] public byte[] dkl_pad;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LEN_DKL_PAD16)]
public byte[] dkl_pad;
/// <summary>identifies this label format</summary>
public ushort dkl_magic;
/// <summary>xor checksum of sector</summary>