public bool Identify(IMediaImage imagePlugin, Partition partition) { if (imagePlugin.Info.SectorSize < 512) { return(false); } uint sbAddr = REISER_SUPER_OFFSET / imagePlugin.Info.SectorSize; if (sbAddr == 0) { sbAddr = 1; } Reiser_Superblock reiserSb = new Reiser_Superblock(); uint sbSize = (uint)(Marshal.SizeOf(reiserSb) / imagePlugin.Info.SectorSize); if (Marshal.SizeOf(reiserSb) % imagePlugin.Info.SectorSize != 0) { sbSize++; } if (partition.Start + sbAddr + sbSize >= partition.End) { return(false); } byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); if (sector.Length < Marshal.SizeOf(reiserSb)) { return(false); } IntPtr sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(reiserSb)); Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(reiserSb)); reiserSb = (Reiser_Superblock)Marshal.PtrToStructure(sbPtr, typeof(Reiser_Superblock)); Marshal.FreeHGlobal(sbPtr); return(Reiser35_Magic.SequenceEqual(reiserSb.magic) || Reiser36_Magic.SequenceEqual(reiserSb.magic) || ReiserJr_Magic.SequenceEqual(reiserSb.magic)); }
public bool Identify(IMediaImage imagePlugin, Partition partition) { if (imagePlugin.Info.SectorSize < 512) { return(false); } uint sbAddr = REISER_SUPER_OFFSET / imagePlugin.Info.SectorSize; if (sbAddr == 0) { sbAddr = 1; } uint sbSize = (uint)(Marshal.SizeOf <Reiser_Superblock>() / imagePlugin.Info.SectorSize); if (Marshal.SizeOf <Reiser_Superblock>() % imagePlugin.Info.SectorSize != 0) { sbSize++; } if (partition.Start + sbAddr + sbSize >= partition.End) { return(false); } byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); if (sector.Length < Marshal.SizeOf <Reiser_Superblock>()) { return(false); } Reiser_Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian <Reiser_Superblock>(sector); return(reiser35_magic.SequenceEqual(reiserSb.magic) || reiser36_magic.SequenceEqual(reiserSb.magic) || reiserJr_magic.SequenceEqual(reiserSb.magic)); }
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; } uint sbAddr = REISER_SUPER_OFFSET / imagePlugin.Info.SectorSize; if (sbAddr == 0) { sbAddr = 1; } uint sbSize = (uint)(Marshal.SizeOf <Reiser_Superblock>() / imagePlugin.Info.SectorSize); if (Marshal.SizeOf <Reiser_Superblock>() % imagePlugin.Info.SectorSize != 0) { sbSize++; } byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); if (sector.Length < Marshal.SizeOf <Reiser_Superblock>()) { return; } Reiser_Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian <Reiser_Superblock>(sector); if (!reiser35_magic.SequenceEqual(reiserSb.magic) && !reiser36_magic.SequenceEqual(reiserSb.magic) && !reiserJr_magic.SequenceEqual(reiserSb.magic)) { return; } var sb = new StringBuilder(); if (reiser35_magic.SequenceEqual(reiserSb.magic)) { sb.AppendLine("Reiser 3.5 filesystem"); } else if (reiser36_magic.SequenceEqual(reiserSb.magic)) { sb.AppendLine("Reiser 3.6 filesystem"); } else if (reiserJr_magic.SequenceEqual(reiserSb.magic)) { sb.AppendLine("Reiser Jr. filesystem"); } sb.AppendFormat("Volume has {0} blocks with {1} blocks free", reiserSb.block_count, reiserSb.free_blocks). AppendLine(); sb.AppendFormat("{0} bytes per block", reiserSb.blocksize).AppendLine(); sb.AppendFormat("Root directory resides on block {0}", reiserSb.root_block).AppendLine(); if (reiserSb.umount_state == 2) { sb.AppendLine("Volume has not been cleanly umounted"); } sb.AppendFormat("Volume last checked on {0}", DateHandlers.UnixUnsignedToDateTime(reiserSb.last_check)). AppendLine(); if (reiserSb.version >= 2) { sb.AppendFormat("Volume UUID: {0}", reiserSb.uuid).AppendLine(); sb.AppendFormat("Volume name: {0}", Encoding.GetString(reiserSb.label)).AppendLine(); } information = sb.ToString(); XmlFsType = new FileSystemType(); if (reiser35_magic.SequenceEqual(reiserSb.magic)) { XmlFsType.Type = "Reiser 3.5 filesystem"; } else if (reiser36_magic.SequenceEqual(reiserSb.magic)) { XmlFsType.Type = "Reiser 3.6 filesystem"; } else if (reiserJr_magic.SequenceEqual(reiserSb.magic)) { XmlFsType.Type = "Reiser Jr. filesystem"; } XmlFsType.ClusterSize = reiserSb.blocksize; XmlFsType.Clusters = reiserSb.block_count; XmlFsType.FreeClusters = reiserSb.free_blocks; XmlFsType.FreeClustersSpecified = true; XmlFsType.Dirty = reiserSb.umount_state == 2; if (reiserSb.version < 2) { return; } XmlFsType.VolumeName = Encoding.GetString(reiserSb.label); XmlFsType.VolumeSerial = reiserSb.uuid.ToString(); }