Пример #1
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;

            if (partition.Start + bootSectors >= partition.End)
            {
                return(false);
            }

            byte[] sector = imagePlugin.ReadSector(partition.Start + bootSectors);
            if (sector.Length < 512)
            {
                return(false);
            }

            JfsSuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian <JfsSuperBlock>(sector);

            return(jfsSb.s_magic == JFS_MAGIC);
        }
Пример #2
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;

            if (partition.Start + bootSectors >= partition.End)
            {
                return(false);
            }

            byte[] sector = imagePlugin.ReadSector(partition.Start + bootSectors);
            if (sector.Length < 512)
            {
                return(false);
            }

            JfsSuperBlock jfsSb = new JfsSuperBlock();
            IntPtr        sbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(jfsSb));

            Marshal.Copy(sector, 0, sbPtr, Marshal.SizeOf(jfsSb));
            jfsSb = (JfsSuperBlock)Marshal.PtrToStructure(sbPtr, typeof(JfsSuperBlock));
            Marshal.FreeHGlobal(sbPtr);

            return(jfsSb.s_magic == JFS_MAGIC);
        }
Пример #3
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("iso-8859-15");
            information = "";
            var  sb          = new StringBuilder();
            uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;

            byte[] sector = imagePlugin.ReadSector(partition.Start + bootSectors);

            if (sector.Length < 512)
            {
                return;
            }

            JfsSuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian <JfsSuperBlock>(sector);

            sb.AppendLine("JFS filesystem");
            sb.AppendFormat("Version {0}", jfsSb.s_version).AppendLine();
            sb.AppendFormat("{0} blocks of {1} bytes", jfsSb.s_size, jfsSb.s_bsize).AppendLine();
            sb.AppendFormat("{0} blocks per allocation group", jfsSb.s_agsize).AppendLine();

            if (jfsSb.s_flags.HasFlag(JfsFlags.Unicode))
            {
                sb.AppendLine("Volume uses Unicode for directory entries");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.RemountRO))
            {
                sb.AppendLine("Volume remounts read-only on error");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.Continue))
            {
                sb.AppendLine("Volume continues on error");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.Panic))
            {
                sb.AppendLine("Volume panics on error");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.UserQuota))
            {
                sb.AppendLine("Volume has user quotas enabled");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.GroupQuota))
            {
                sb.AppendLine("Volume has group quotas enabled");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.NoJournal))
            {
                sb.AppendLine("Volume is not using any journal");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.Discard))
            {
                sb.AppendLine("Volume sends TRIM/UNMAP commands to underlying device");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.GroupCommit))
            {
                sb.AppendLine("Volume commits in groups of 1");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.LazyCommit))
            {
                sb.AppendLine("Volume commits lazy");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.Temporary))
            {
                sb.AppendLine("Volume does not commit to log");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.InlineLog))
            {
                sb.AppendLine("Volume has log withing itself");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.InlineMoving))
            {
                sb.AppendLine("Volume has log withing itself and is moving it out");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.BadSAIT))
            {
                sb.AppendLine("Volume has bad current secondary ait");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.Sparse))
            {
                sb.AppendLine("Volume supports sparse files");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.DASDEnabled))
            {
                sb.AppendLine("Volume has DASD limits enabled");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.DASDPrime))
            {
                sb.AppendLine("Volume primes DASD on boot");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.SwapBytes))
            {
                sb.AppendLine("Volume is in a big-endian system");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.DirIndex))
            {
                sb.AppendLine("Volume has presistent indexes");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.Linux))
            {
                sb.AppendLine("Volume supports Linux");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.DFS))
            {
                sb.AppendLine("Volume supports DCE DFS LFS");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.OS2))
            {
                sb.AppendLine("Volume supports OS/2, and is case insensitive");
            }

            if (jfsSb.s_flags.HasFlag(JfsFlags.AIX))
            {
                sb.AppendLine("Volume supports AIX");
            }

            if (jfsSb.s_state != 0)
            {
                sb.AppendLine("Volume is dirty");
            }

            sb.AppendFormat("Volume was last updated on {0}",
                            DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec)).
            AppendLine();

            if (jfsSb.s_version == 1)
            {
                sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(jfsSb.s_fpack, Encoding)).AppendLine();
            }
            else
            {
                sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(jfsSb.s_label, Encoding)).AppendLine();
            }

            sb.AppendFormat("Volume UUID: {0}", jfsSb.s_uuid).AppendLine();

            XmlFsType = new FileSystemType
            {
                Type       = "JFS filesystem", Clusters = jfsSb.s_size, ClusterSize = jfsSb.s_bsize,
                Bootable   = true,
                VolumeName =
                    StringHandlers.CToString(jfsSb.s_version == 1 ? jfsSb.s_fpack : jfsSb.s_label, Encoding),
                VolumeSerial     = $"{jfsSb.s_uuid}",
                ModificationDate =
                    DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec),
                ModificationDateSpecified = true
            };

            if (jfsSb.s_state != 0)
            {
                XmlFsType.Dirty = true;
            }

            information = sb.ToString();
        }