mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Adds support for big-endian squashfs.
This commit is contained in:
@@ -88,6 +88,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
/// Identifier for Squash
|
/// Identifier for Squash
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const uint Squash_MAGIC = 0x73717368;
|
const uint Squash_MAGIC = 0x73717368;
|
||||||
|
const uint Squash_CIGAM = 0x68737173;
|
||||||
|
|
||||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd)
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd)
|
||||||
{
|
{
|
||||||
@@ -98,23 +99,37 @@ namespace DiscImageChef.Filesystems
|
|||||||
|
|
||||||
uint magic = BitConverter.ToUInt32(sector, 0x00);
|
uint magic = BitConverter.ToUInt32(sector, 0x00);
|
||||||
|
|
||||||
return magic == Squash_MAGIC;
|
return magic == Squash_MAGIC || magic == Squash_CIGAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information)
|
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information)
|
||||||
{
|
{
|
||||||
byte[] sector = imagePlugin.ReadSector(partitionStart);
|
byte[] sector = imagePlugin.ReadSector(partitionStart);
|
||||||
|
uint magic = BitConverter.ToUInt32(sector, 0x00);
|
||||||
|
|
||||||
SquashSuperBlock sqSb = new SquashSuperBlock();
|
SquashSuperBlock sqSb = new SquashSuperBlock();
|
||||||
IntPtr sqSbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sqSb));
|
bool littleEndian = true;
|
||||||
Marshal.Copy(sector, 0, sqSbPtr, Marshal.SizeOf(sqSb));
|
|
||||||
sqSb = (SquashSuperBlock)Marshal.PtrToStructure(sqSbPtr, typeof(SquashSuperBlock));
|
if(magic == Squash_MAGIC)
|
||||||
Marshal.FreeHGlobal(sqSbPtr);
|
{
|
||||||
|
IntPtr sqSbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sqSb));
|
||||||
|
Marshal.Copy(sector, 0, sqSbPtr, Marshal.SizeOf(sqSb));
|
||||||
|
sqSb = (SquashSuperBlock)Marshal.PtrToStructure(sqSbPtr, typeof(SquashSuperBlock));
|
||||||
|
Marshal.FreeHGlobal(sqSbPtr);
|
||||||
|
}
|
||||||
|
else if(magic == Squash_CIGAM)
|
||||||
|
{
|
||||||
|
sqSb = BigEndianMarshal.ByteArrayToStructureBigEndian<SquashSuperBlock>(sector);
|
||||||
|
littleEndian = false;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder sbInformation = new StringBuilder();
|
StringBuilder sbInformation = new StringBuilder();
|
||||||
|
|
||||||
sbInformation.AppendLine("Squash file system");
|
sbInformation.AppendLine("Squash file system");
|
||||||
|
if(littleEndian)
|
||||||
|
sbInformation.AppendLine("Little-endian");
|
||||||
|
else
|
||||||
|
sbInformation.AppendLine("Big-endian");
|
||||||
sbInformation.AppendFormat("Volume version {0}.{1}", sqSb.s_major, sqSb.s_minor).AppendLine();
|
sbInformation.AppendFormat("Volume version {0}.{1}", sqSb.s_major, sqSb.s_minor).AppendLine();
|
||||||
sbInformation.AppendFormat("Volume has {0} bytes", sqSb.bytes_used).AppendLine();
|
sbInformation.AppendFormat("Volume has {0} bytes", sqSb.bytes_used).AppendLine();
|
||||||
sbInformation.AppendFormat("Volume has {0} bytes per block", sqSb.block_size).AppendLine();
|
sbInformation.AppendFormat("Volume has {0} bytes per block", sqSb.block_size).AppendLine();
|
||||||
|
|||||||
Reference in New Issue
Block a user