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:
@@ -67,11 +67,9 @@ namespace DiscImageChef.Filesystems
|
||||
/* 28: magic [0] */
|
||||
public uint sb_magic;
|
||||
/* 32: name of filesystem */
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
||||
public byte[] sb_fname;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] sb_fname;
|
||||
/* 38: name of filesystem pack */
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
||||
public byte[] sb_fpack;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] sb_fpack;
|
||||
/* 44: bitmap size (in bytes) */
|
||||
public int sb_bmsize;
|
||||
/* 48: total free data blocks */
|
||||
@@ -85,8 +83,7 @@ namespace DiscImageChef.Filesystems
|
||||
/* 64: last allocated inode */
|
||||
public int sb_lastinode;
|
||||
/* 68: unused */
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
|
||||
public byte[] sb_spare;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public byte[] sb_spare;
|
||||
/* 88: checksum (all above) */
|
||||
public uint sb_checksum;
|
||||
}
|
||||
@@ -105,26 +102,21 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
Name = "Extent File System Plugin";
|
||||
PluginUUID = new Guid("52A43F90-9AF3-4391-ADFE-65598DEEABAB");
|
||||
if(encoding == null)
|
||||
CurrentEncoding = Encoding.GetEncoding("iso-8859-15");
|
||||
else
|
||||
CurrentEncoding = encoding;
|
||||
if(encoding == null) CurrentEncoding = Encoding.GetEncoding("iso-8859-15");
|
||||
else CurrentEncoding = encoding;
|
||||
}
|
||||
|
||||
public EFS(ImagePlugins.ImagePlugin imagePlugin, Partition partition, Encoding encoding)
|
||||
{
|
||||
Name = "Extent File System Plugin";
|
||||
PluginUUID = new Guid("52A43F90-9AF3-4391-ADFE-65598DEEABAB");
|
||||
if(encoding == null)
|
||||
CurrentEncoding = Encoding.GetEncoding("iso-8859-15");
|
||||
else
|
||||
CurrentEncoding = encoding;
|
||||
if(encoding == null) CurrentEncoding = Encoding.GetEncoding("iso-8859-15");
|
||||
else CurrentEncoding = encoding;
|
||||
}
|
||||
|
||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
||||
{
|
||||
if(imagePlugin.GetSectorSize() < 512)
|
||||
return false;
|
||||
if(imagePlugin.GetSectorSize() < 512) return false;
|
||||
|
||||
// Misaligned
|
||||
if(imagePlugin.ImageInfo.xmlMediaType == ImagePlugins.XmlMediaType.OpticalDisc)
|
||||
@@ -132,12 +124,10 @@ namespace DiscImageChef.Filesystems
|
||||
EFS_Superblock efs_sb = new EFS_Superblock();
|
||||
|
||||
uint sbSize = (uint)((Marshal.SizeOf(efs_sb) + 0x200) / imagePlugin.GetSectorSize());
|
||||
if((Marshal.SizeOf(efs_sb) + 0x200) % imagePlugin.GetSectorSize() != 0)
|
||||
sbSize++;
|
||||
if((Marshal.SizeOf(efs_sb) + 0x200) % imagePlugin.GetSectorSize() != 0) sbSize++;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(efs_sb))
|
||||
return false;
|
||||
if(sector.Length < Marshal.SizeOf(efs_sb)) return false;
|
||||
|
||||
byte[] sbpiece = new byte[Marshal.SizeOf(efs_sb)];
|
||||
|
||||
@@ -145,39 +135,37 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
efs_sb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sbpiece);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 0x200, efs_sb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})",
|
||||
0x200, efs_sb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
|
||||
if(efs_sb.sb_magic == EFS_Magic || efs_sb.sb_magic == EFS_Magic_New)
|
||||
return true;
|
||||
if(efs_sb.sb_magic == EFS_Magic || efs_sb.sb_magic == EFS_Magic_New) return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
EFS_Superblock efsSb = new EFS_Superblock();
|
||||
|
||||
uint sbSize = (uint)(Marshal.SizeOf(efsSb) / imagePlugin.GetSectorSize());
|
||||
if(Marshal.SizeOf(efsSb) % imagePlugin.GetSectorSize() != 0)
|
||||
sbSize++;
|
||||
if(Marshal.SizeOf(efsSb) % imagePlugin.GetSectorSize() != 0) sbSize++;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + 1, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(efsSb))
|
||||
return false;
|
||||
if(sector.Length < Marshal.SizeOf(efsSb)) return false;
|
||||
|
||||
efsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1, efsSb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1,
|
||||
efsSb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
|
||||
if(efsSb.sb_magic == EFS_Magic || efsSb.sb_magic == EFS_Magic_New)
|
||||
return true;
|
||||
if(efsSb.sb_magic == EFS_Magic || efsSb.sb_magic == EFS_Magic_New) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, Partition partition, out string information)
|
||||
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, Partition partition,
|
||||
out string information)
|
||||
{
|
||||
information = "";
|
||||
if(imagePlugin.GetSectorSize() < 512)
|
||||
return;
|
||||
if(imagePlugin.GetSectorSize() < 512) return;
|
||||
|
||||
EFS_Superblock efsSb = new EFS_Superblock();
|
||||
|
||||
@@ -185,12 +173,10 @@ namespace DiscImageChef.Filesystems
|
||||
if(imagePlugin.ImageInfo.xmlMediaType == ImagePlugins.XmlMediaType.OpticalDisc)
|
||||
{
|
||||
uint sbSize = (uint)((Marshal.SizeOf(efsSb) + 0x400) / imagePlugin.GetSectorSize());
|
||||
if((Marshal.SizeOf(efsSb) + 0x400) % imagePlugin.GetSectorSize() != 0)
|
||||
sbSize++;
|
||||
if((Marshal.SizeOf(efsSb) + 0x400) % imagePlugin.GetSectorSize() != 0) sbSize++;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(efsSb))
|
||||
return;
|
||||
if(sector.Length < Marshal.SizeOf(efsSb)) return;
|
||||
|
||||
byte[] sbpiece = new byte[Marshal.SizeOf(efsSb)];
|
||||
|
||||
@@ -198,31 +184,29 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
efsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sbpiece);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 0x200, efsSb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})",
|
||||
0x200, efsSb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint sbSize = (uint)(Marshal.SizeOf(efsSb) / imagePlugin.GetSectorSize());
|
||||
if(Marshal.SizeOf(efsSb) % imagePlugin.GetSectorSize() != 0)
|
||||
sbSize++;
|
||||
if(Marshal.SizeOf(efsSb) % imagePlugin.GetSectorSize() != 0) sbSize++;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + 1, sbSize);
|
||||
if(sector.Length < Marshal.SizeOf(efsSb))
|
||||
return;
|
||||
if(sector.Length < Marshal.SizeOf(efsSb)) return;
|
||||
|
||||
efsSb = BigEndianMarshal.ByteArrayToStructureBigEndian<EFS_Superblock>(sector);
|
||||
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1, efsSb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
DicConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1,
|
||||
efsSb.sb_magic, EFS_Magic, EFS_Magic_New);
|
||||
}
|
||||
|
||||
if(efsSb.sb_magic != EFS_Magic && efsSb.sb_magic != EFS_Magic_New)
|
||||
return;
|
||||
if(efsSb.sb_magic != EFS_Magic && efsSb.sb_magic != EFS_Magic_New) return;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("SGI extent filesystem");
|
||||
if(efsSb.sb_magic == EFS_Magic_New)
|
||||
sb.AppendLine("New version");
|
||||
if(efsSb.sb_magic == EFS_Magic_New) sb.AppendLine("New version");
|
||||
sb.AppendFormat("Filesystem size: {0} basic blocks", efsSb.sb_size).AppendLine();
|
||||
sb.AppendFormat("First cylinder group starts at block {0}", efsSb.sb_firstcg).AppendLine();
|
||||
sb.AppendFormat("Cylinder group size: {0} basic blocks", efsSb.sb_cgfsize).AppendLine();
|
||||
@@ -234,14 +218,11 @@ namespace DiscImageChef.Filesystems
|
||||
sb.AppendFormat("{0} bytes on bitmap", efsSb.sb_bmsize).AppendLine();
|
||||
sb.AppendFormat("{0} free blocks", efsSb.sb_tfree).AppendLine();
|
||||
sb.AppendFormat("{0} free inodes", efsSb.sb_tinode).AppendLine();
|
||||
if(efsSb.sb_bmblock > 0)
|
||||
sb.AppendFormat("Bitmap resides at block {0}", efsSb.sb_bmblock).AppendLine();
|
||||
if(efsSb.sb_bmblock > 0) sb.AppendFormat("Bitmap resides at block {0}", efsSb.sb_bmblock).AppendLine();
|
||||
if(efsSb.sb_replsb > 0)
|
||||
sb.AppendFormat("Replacement superblock resides at block {0}", efsSb.sb_replsb).AppendLine();
|
||||
if(efsSb.sb_lastinode > 0)
|
||||
sb.AppendFormat("Last inode allocated: {0}", efsSb.sb_lastinode).AppendLine();
|
||||
if(efsSb.sb_dirty > 0)
|
||||
sb.AppendLine("Volume is dirty");
|
||||
if(efsSb.sb_lastinode > 0) sb.AppendFormat("Last inode allocated: {0}", efsSb.sb_lastinode).AppendLine();
|
||||
if(efsSb.sb_dirty > 0) sb.AppendLine("Volume is dirty");
|
||||
sb.AppendFormat("Checksum: 0x{0:X8}", efsSb.sb_checksum).AppendLine();
|
||||
sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(efsSb.sb_fname, CurrentEncoding)).AppendLine();
|
||||
sb.AppendFormat("Volume pack: {0}", StringHandlers.CToString(efsSb.sb_fpack, CurrentEncoding)).AppendLine();
|
||||
|
||||
Reference in New Issue
Block a user