public bool Identify(IMediaImage imagePlugin, Partition partition) { if (imagePlugin.Info.SectorSize < 512) { return(false); } for (ulong location = 0; location <= 8; location++) { Locus_Superblock locusSb = new Locus_Superblock(); uint sbSize = (uint)(Marshal.SizeOf(locusSb) / imagePlugin.Info.SectorSize); if (Marshal.SizeOf(locusSb) % imagePlugin.Info.SectorSize != 0) { sbSize++; } if (partition.Start + location + sbSize >= imagePlugin.Info.Sectors) { break; } byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); if (sector.Length < Marshal.SizeOf(locusSb)) { return(false); } IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(locusSb)); Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(locusSb)); locusSb = (Locus_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Locus_Superblock)); Marshal.FreeHGlobal(sbPtr); DicConsole.DebugWriteLine("Locus plugin", "magic at {1} = 0x{0:X8}", locusSb.s_magic, location); if (locusSb.s_magic == LOCUS_MAGIC || locusSb.s_magic == LOCUS_CIGAM || locusSb.s_magic == LOCUS_MAGIC_OLD || locusSb.s_magic == LOCUS_CIGAM_OLD) { return(true); } } return(false); }
public bool Identify(IMediaImage imagePlugin, Partition partition) { if (imagePlugin.Info.SectorSize < 512) { return(false); } for (ulong location = 0; location <= 8; location++) { uint sbSize = (uint)(Marshal.SizeOf <Locus_Superblock>() / imagePlugin.Info.SectorSize); if (Marshal.SizeOf <Locus_Superblock>() % imagePlugin.Info.SectorSize != 0) { sbSize++; } if (partition.Start + location + sbSize >= imagePlugin.Info.Sectors) { break; } byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); if (sector.Length < Marshal.SizeOf <Locus_Superblock>()) { return(false); } Locus_Superblock locusSb = Marshal.ByteArrayToStructureLittleEndian <Locus_Superblock>(sector); AaruConsole.DebugWriteLine("Locus plugin", "magic at {1} = 0x{0:X8}", locusSb.s_magic, location); if (locusSb.s_magic == LOCUS_MAGIC || locusSb.s_magic == LOCUS_CIGAM || locusSb.s_magic == LOCUS_MAGIC_OLD || locusSb.s_magic == LOCUS_CIGAM_OLD) { return(true); } } return(false); }
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); information = ""; if (imagePlugin.Info.SectorSize < 512) { return; } Locus_Superblock locusSb = new Locus_Superblock(); byte[] sector = null; for (ulong location = 0; location <= 8; location++) { uint sbSize = (uint)(Marshal.SizeOf <Locus_Superblock>() / imagePlugin.Info.SectorSize); if (Marshal.SizeOf <Locus_Superblock>() % imagePlugin.Info.SectorSize != 0) { sbSize++; } sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); if (sector.Length < Marshal.SizeOf <Locus_Superblock>()) { return; } locusSb = Marshal.ByteArrayToStructureLittleEndian <Locus_Superblock>(sector); if (locusSb.s_magic == LOCUS_MAGIC || locusSb.s_magic == LOCUS_CIGAM || locusSb.s_magic == LOCUS_MAGIC_OLD || locusSb.s_magic == LOCUS_CIGAM_OLD) { break; } } // We don't care about old version for information if (locusSb.s_magic != LOCUS_MAGIC && locusSb.s_magic != LOCUS_CIGAM && locusSb.s_magic != LOCUS_MAGIC_OLD && locusSb.s_magic != LOCUS_CIGAM_OLD) { return; } // Numerical arrays are not important for information so no need to swap them if (locusSb.s_magic == LOCUS_CIGAM || locusSb.s_magic == LOCUS_CIGAM_OLD) { locusSb = Marshal.ByteArrayToStructureBigEndian <Locus_Superblock>(sector); locusSb.s_flags = (LocusFlags)Swapping.Swap((ushort)locusSb.s_flags); } StringBuilder sb = new StringBuilder(); sb.AppendLine(locusSb.s_magic == LOCUS_MAGIC_OLD ? "Locus filesystem (old)" : "Locus filesystem"); int blockSize = locusSb.s_version == LocusVersion.SB_SB4096 ? 4096 : 1024; string s_fsmnt = StringHandlers.CToString(locusSb.s_fsmnt, Encoding); string s_fpack = StringHandlers.CToString(locusSb.s_fpack, Encoding); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_magic = 0x{0:X8}", locusSb.s_magic); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_gfs = {0}", locusSb.s_gfs); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fsize = {0}", locusSb.s_fsize); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_lwm = {0}", locusSb.s_lwm); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_hwm = {0}", locusSb.s_hwm); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_llst = {0}", locusSb.s_llst); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fstore = {0}", locusSb.s_fstore); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_time = {0}", locusSb.s_time); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_tfree = {0}", locusSb.s_tfree); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_isize = {0}", locusSb.s_isize); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_nfree = {0}", locusSb.s_nfree); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_flags = {0}", locusSb.s_flags); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_tinode = {0}", locusSb.s_tinode); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_lasti = {0}", locusSb.s_lasti); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_nbehind = {0}", locusSb.s_nbehind); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_gfspack = {0}", locusSb.s_gfspack); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_ninode = {0}", locusSb.s_ninode); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_flock = {0}", locusSb.s_flock); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_ilock = {0}", locusSb.s_ilock); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_fmod = {0}", locusSb.s_fmod); DicConsole.DebugWriteLine("Locus plugin", "LocusSb.s_version = {0}", locusSb.s_version); sb.AppendFormat("Superblock last modified on {0}", DateHandlers.UnixToDateTime(locusSb.s_time)) .AppendLine(); sb.AppendFormat("Volume has {0} blocks of {1} bytes each (total {2} bytes)", locusSb.s_fsize, blockSize, locusSb.s_fsize * blockSize).AppendLine(); sb.AppendFormat("{0} blocks free ({1} bytes)", locusSb.s_tfree, locusSb.s_tfree * blockSize).AppendLine(); sb.AppendFormat("I-node list uses {0} blocks", locusSb.s_isize).AppendLine(); sb.AppendFormat("{0} free inodes", locusSb.s_tinode).AppendLine(); sb.AppendFormat("Next free inode search will start at inode {0}", locusSb.s_lasti).AppendLine(); sb.AppendFormat("There are an estimate of {0} free inodes before next search start", locusSb.s_nbehind) .AppendLine(); if (locusSb.s_flags.HasFlag(LocusFlags.SB_RDONLY)) { sb.AppendLine("Read-only volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN)) { sb.AppendLine("Clean volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY)) { sb.AppendLine("Dirty volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_RMV)) { sb.AppendLine("Removable volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_PRIMPACK)) { sb.AppendLine("This is the primary pack"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_REPLTYPE)) { sb.AppendLine("Replicated volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_USER)) { sb.AppendLine("User replicated volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_BACKBONE)) { sb.AppendLine("Backbone volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_NFS)) { sb.AppendLine("NFS volume"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_BYHAND)) { sb.AppendLine("Volume inhibits automatic fsck"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_NOSUID)) { sb.AppendLine("Set-uid/set-gid is disabled"); } if (locusSb.s_flags.HasFlag(LocusFlags.SB_SYNCW)) { sb.AppendLine("Volume uses synchronous writes"); } sb.AppendFormat("Volume label: {0}", s_fsmnt).AppendLine(); sb.AppendFormat("Physical volume name: {0}", s_fpack).AppendLine(); sb.AppendFormat("Global File System number: {0}", locusSb.s_gfs).AppendLine(); sb.AppendFormat("Global File System pack number {0}", locusSb.s_gfspack).AppendLine(); information = sb.ToString(); XmlFsType = new FileSystemType { Type = "Locus filesystem", ClusterSize = (uint)blockSize, Clusters = (ulong)locusSb.s_fsize, // Sometimes it uses one, or the other. Use the bigger VolumeName = string.IsNullOrEmpty(s_fsmnt) ? s_fpack : s_fsmnt, ModificationDate = DateHandlers.UnixToDateTime(locusSb.s_time), ModificationDateSpecified = true, Dirty = !locusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN) || locusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY), FreeClusters = (ulong)locusSb.s_tfree, FreeClustersSpecified = true }; }