mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Reformat code.
This commit is contained in:
@@ -50,6 +50,7 @@ namespace DiscImageChef.PartPlugins
|
||||
const ushort disktabStart = 0xB4;
|
||||
// 180
|
||||
const ushort disktabEntrySize = 0x2C;
|
||||
|
||||
// 44
|
||||
public NeXTDisklabel()
|
||||
{
|
||||
@@ -57,7 +58,8 @@ namespace DiscImageChef.PartPlugins
|
||||
PluginUUID = new Guid("246A6D93-4F1A-1F8A-344D-50187A5513A9");
|
||||
}
|
||||
|
||||
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<CommonTypes.Partition> partitions, ulong sectorOffset)
|
||||
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin,
|
||||
out List<CommonTypes.Partition> partitions, ulong sectorOffset)
|
||||
{
|
||||
bool magic_found = false;
|
||||
byte[] label_sector;
|
||||
@@ -65,10 +67,8 @@ namespace DiscImageChef.PartPlugins
|
||||
uint magic;
|
||||
uint sector_size;
|
||||
|
||||
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448)
|
||||
sector_size = 2048;
|
||||
else
|
||||
sector_size = imagePlugin.GetSectorSize();
|
||||
if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048;
|
||||
else sector_size = imagePlugin.GetSectorSize();
|
||||
|
||||
partitions = new List<CommonTypes.Partition>();
|
||||
|
||||
@@ -76,11 +76,10 @@ namespace DiscImageChef.PartPlugins
|
||||
|
||||
ulong label_position = 0;
|
||||
|
||||
foreach(ulong i in new ulong[]{0, 4, 15, 16})
|
||||
foreach(ulong i in new ulong[] {0, 4, 15, 16})
|
||||
{
|
||||
if(i + sectorOffset >= imagePlugin.GetSectors())
|
||||
break;
|
||||
|
||||
if(i + sectorOffset >= imagePlugin.GetSectors()) break;
|
||||
|
||||
label_sector = imagePlugin.ReadSector(i + sectorOffset);
|
||||
magic = BigEndianBitConverter.ToUInt32(label_sector, 0x00);
|
||||
if(magic == NEXT_MAGIC1 || magic == NEXT_MAGIC2 || magic == NEXT_MAGIC3)
|
||||
@@ -91,12 +90,10 @@ namespace DiscImageChef.PartPlugins
|
||||
}
|
||||
}
|
||||
|
||||
if(!magic_found)
|
||||
return false;
|
||||
if(!magic_found) return false;
|
||||
|
||||
uint sectors_to_read = 7680 / imagePlugin.ImageInfo.sectorSize;
|
||||
if(7680 % imagePlugin.ImageInfo.sectorSize > 0)
|
||||
sectors_to_read++;
|
||||
if(7680 % imagePlugin.ImageInfo.sectorSize > 0) sectors_to_read++;
|
||||
|
||||
label_sector = imagePlugin.ReadSectors(label_position, sectors_to_read);
|
||||
|
||||
@@ -109,11 +106,14 @@ namespace DiscImageChef.PartPlugins
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_version = 0x{0:X8}", label.dl_version);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_label_blkno = {0}", label.dl_label_blkno);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_size = {0}", label.dl_size);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_label = \"{0}\"", StringHandlers.CToString(label.dl_label));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_label = \"{0}\"",
|
||||
StringHandlers.CToString(label.dl_label));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_flags = {0}", label.dl_flags);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_tag = 0x{0:X8}", label.dl_tag);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_name = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_name));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_type = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_type));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_name = \"{0}\"",
|
||||
StringHandlers.CToString(label.dl_dt.d_name));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_type = \"{0}\"",
|
||||
StringHandlers.CToString(label.dl_dt.d_type));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_secsize = {0}", label.dl_dt.d_secsize);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ntracks = {0}", label.dl_dt.d_ntracks);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_nsectors = {0}", label.dl_dt.d_nsectors);
|
||||
@@ -125,10 +125,14 @@ namespace DiscImageChef.PartPlugins
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ag_size = {0}", label.dl_dt.d_ag_size);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ag_alts = {0}", label.dl_dt.d_ag_alts);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_ag_off = {0}", label.dl_dt.d_ag_off);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[0] = {0}", label.dl_dt.d_boot0_blkno[0]);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[1] = {0}", label.dl_dt.d_boot0_blkno[1]);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_bootfile = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_bootfile));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_hostname = \"{0}\"", StringHandlers.CToString(label.dl_dt.d_hostname));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[0] = {0}",
|
||||
label.dl_dt.d_boot0_blkno[0]);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_boot0_blkno[1] = {0}",
|
||||
label.dl_dt.d_boot0_blkno[1]);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_bootfile = \"{0}\"",
|
||||
StringHandlers.CToString(label.dl_dt.d_bootfile));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_hostname = \"{0}\"",
|
||||
StringHandlers.CToString(label.dl_dt.d_hostname));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_rootpartition = {0}", label.dl_dt.d_rootpartition);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_rwpartition = {0}", label.dl_dt.d_rwpartition);
|
||||
|
||||
@@ -137,32 +141,47 @@ namespace DiscImageChef.PartPlugins
|
||||
byte[] part_b = new byte[44];
|
||||
Array.Copy(label_sector, 44 + 146 + 44 * i, part_b, 0, 44);
|
||||
label.dl_dt.d_partitions[i] = BigEndianMarshal.ByteArrayToStructureBigEndian<NeXTEntry>(part_b);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_base = {1}", i, label.dl_dt.d_partitions[i].p_base);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i, label.dl_dt.d_partitions[i].p_size);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_bsize = {1}", i, label.dl_dt.d_partitions[i].p_bsize);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_fsize = {1}", i, label.dl_dt.d_partitions[i].p_fsize);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_opt = {1}", i, label.dl_dt.d_partitions[i].p_opt);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_cpg = {1}", i, label.dl_dt.d_partitions[i].p_cpg);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_density = {1}", i, label.dl_dt.d_partitions[i].p_density);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_minfree = {1}", i, label.dl_dt.d_partitions[i].p_minfree);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_newfs = {1}", i, label.dl_dt.d_partitions[i].p_newfs);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_mountpt = \"{1}\"", i, StringHandlers.CToString(label.dl_dt.d_partitions[i].p_mountpt));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_automnt = {1}", i, label.dl_dt.d_partitions[i].p_automnt);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_type = \"{1}\"", i, StringHandlers.CToString(label.dl_dt.d_partitions[i].p_type));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_base = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_base);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_size);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_bsize = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_bsize);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_fsize = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_fsize);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_opt = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_opt);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_cpg = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_cpg);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_density = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_density);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_minfree = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_minfree);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_newfs = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_newfs);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_mountpt = \"{1}\"", i,
|
||||
StringHandlers.CToString(label.dl_dt.d_partitions[i].p_mountpt));
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_automnt = {1}", i,
|
||||
label.dl_dt.d_partitions[i].p_automnt);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_type = \"{1}\"", i,
|
||||
StringHandlers.CToString(label.dl_dt.d_partitions[i].p_type));
|
||||
|
||||
if(label.dl_dt.d_partitions[i].p_size > 0 && label.dl_dt.d_partitions[i].p_base >= 0 && label.dl_dt.d_partitions[i].p_bsize >= 0)
|
||||
if(label.dl_dt.d_partitions[i].p_size > 0 && label.dl_dt.d_partitions[i].p_base >= 0 &&
|
||||
label.dl_dt.d_partitions[i].p_bsize >= 0)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
CommonTypes.Partition part = new CommonTypes.Partition()
|
||||
{
|
||||
Size = (ulong)(label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize),
|
||||
Offset = (ulong)((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * label.dl_dt.d_secsize),
|
||||
Offset =
|
||||
(ulong)((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * label.dl_dt.d_secsize),
|
||||
Type = StringHandlers.CToString(label.dl_dt.d_partitions[i].p_type),
|
||||
Sequence = (ulong)i,
|
||||
Name = StringHandlers.CToString(label.dl_dt.d_partitions[i].p_mountpt),
|
||||
Length = (ulong)((label.dl_dt.d_partitions[i].p_size * label.dl_dt.d_secsize) / sector_size),
|
||||
Start = (ulong)(((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) * label.dl_dt.d_secsize) / sector_size),
|
||||
Start = (ulong)(((label.dl_dt.d_partitions[i].p_base + label.dl_dt.d_front) *
|
||||
label.dl_dt.d_secsize) / sector_size),
|
||||
Scheme = Name
|
||||
};
|
||||
|
||||
@@ -171,20 +190,19 @@ namespace DiscImageChef.PartPlugins
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "Partition bigger than device, reducing...");
|
||||
part.Length = imagePlugin.ImageInfo.sectors - part.Start;
|
||||
part.Size = part.Length * sector_size;
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i, part.Length);
|
||||
DicConsole.DebugWriteLine("NeXT Plugin", "label.dl_dt.d_partitions[{0}].p_size = {1}", i,
|
||||
part.Length);
|
||||
}
|
||||
|
||||
sb.AppendFormat("{0} bytes per block", label.dl_dt.d_partitions[i].p_bsize).AppendLine();
|
||||
sb.AppendFormat("{0} bytes per fragment", label.dl_dt.d_partitions[i].p_fsize).AppendLine();
|
||||
if(label.dl_dt.d_partitions[i].p_opt == 's')
|
||||
sb.AppendLine("Space optimized");
|
||||
else if(label.dl_dt.d_partitions[i].p_opt == 't')
|
||||
sb.AppendLine("Time optimized");
|
||||
else
|
||||
sb.AppendFormat("Unknown optimization {0:X2}", label.dl_dt.d_partitions[i].p_opt).AppendLine();
|
||||
if(label.dl_dt.d_partitions[i].p_opt == 's') sb.AppendLine("Space optimized");
|
||||
else if(label.dl_dt.d_partitions[i].p_opt == 't') sb.AppendLine("Time optimized");
|
||||
else sb.AppendFormat("Unknown optimization {0:X2}", label.dl_dt.d_partitions[i].p_opt).AppendLine();
|
||||
sb.AppendFormat("{0} cylinders per group", label.dl_dt.d_partitions[i].p_cpg).AppendLine();
|
||||
sb.AppendFormat("{0} bytes per inode", label.dl_dt.d_partitions[i].p_density).AppendLine();
|
||||
sb.AppendFormat("{0}% of space must be free at minimum", label.dl_dt.d_partitions[i].p_minfree).AppendLine();
|
||||
sb.AppendFormat("{0}% of space must be free at minimum", label.dl_dt.d_partitions[i].p_minfree)
|
||||
.AppendLine();
|
||||
if(label.dl_dt.d_partitions[i].p_newfs != 1)
|
||||
sb.AppendLine("Filesystem should be formatted at start");
|
||||
if(label.dl_dt.d_partitions[i].p_automnt == 1)
|
||||
@@ -212,8 +230,7 @@ namespace DiscImageChef.PartPlugins
|
||||
/// <summary>Device size in blocks</summary>
|
||||
public int dl_size;
|
||||
/// <summary>Device name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
|
||||
public byte[] dl_label;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] dl_label;
|
||||
/// <summary>Device flags</summary>
|
||||
public uint dl_flags;
|
||||
/// <summary>Device tag</summary>
|
||||
@@ -237,8 +254,7 @@ namespace DiscImageChef.PartPlugins
|
||||
/// <summary>Device size in blocks</summary>
|
||||
public int dl_size;
|
||||
/// <summary>Device name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
|
||||
public byte[] dl_label;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] dl_label;
|
||||
/// <summary>Device flags</summary>
|
||||
public uint dl_flags;
|
||||
/// <summary>Device tag</summary>
|
||||
@@ -246,8 +262,7 @@ namespace DiscImageChef.PartPlugins
|
||||
/// <summary>Device info and partitions</summary>
|
||||
public NeXTDiskTab dl_dt;
|
||||
/// <summary>Bad sector table</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1670)]
|
||||
public int[] dl_bad;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1670)] public int[] dl_bad;
|
||||
/// <summary>Checksum</summary>
|
||||
public ushort dl_checksum;
|
||||
}
|
||||
@@ -259,11 +274,9 @@ namespace DiscImageChef.PartPlugins
|
||||
public struct NeXTDiskTab
|
||||
{
|
||||
/// <summary>Drive name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
|
||||
public byte[] d_name;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] d_name;
|
||||
/// <summary>Drive type</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
|
||||
public byte[] d_type;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] d_type;
|
||||
/// <summary>Sector size</summary>
|
||||
public int d_secsize;
|
||||
/// <summary>tracks/cylinder</summary>
|
||||
@@ -287,21 +300,17 @@ namespace DiscImageChef.PartPlugins
|
||||
/// <summary>sector offset to first alternate</summary>
|
||||
public short d_ag_off;
|
||||
/// <summary>"blk 0" boot locations</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public int[] d_boot0_blkno;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public int[] d_boot0_blkno;
|
||||
/// <summary>default bootfile</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
|
||||
public byte[] d_bootfile;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] d_bootfile;
|
||||
/// <summary>host name</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
||||
public byte[] d_hostname;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] d_hostname;
|
||||
/// <summary>root partition</summary>
|
||||
public byte d_rootpartition;
|
||||
/// <summary>r/w partition</summary>
|
||||
public byte d_rwpartition;
|
||||
/// <summary>partitions</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public NeXTEntry[] d_partitions;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public NeXTEntry[] d_partitions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -329,13 +338,11 @@ namespace DiscImageChef.PartPlugins
|
||||
/// <summary>Should newfs be run on first start?</summary>
|
||||
public byte p_newfs;
|
||||
/// <summary>Mount point or empty if mount where you want</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public byte[] p_mountpt;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] p_mountpt;
|
||||
/// <summary>Should automount</summary>
|
||||
public byte p_automnt;
|
||||
/// <summary>Filesystem type, always "4.3BSD"?</summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] p_type;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] p_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user