From 91b383f5d540969921b231a5059502911ea88260 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 25 Jul 2017 22:23:51 +0100 Subject: [PATCH] Added support for misaligned filesystems on optical media. --- DiscImageChef.Filesystems/MinixFS.cs | 40 +++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/DiscImageChef.Filesystems/MinixFS.cs b/DiscImageChef.Filesystems/MinixFS.cs index 43d52ba64..95cda6efe 100644 --- a/DiscImageChef.Filesystems/MinixFS.cs +++ b/DiscImageChef.Filesystems/MinixFS.cs @@ -80,11 +80,28 @@ namespace DiscImageChef.Filesystems public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition) { - if((2 + partition.Start) >= partition.End) + uint sector = 2; + uint offset = 0; + + if(imagePlugin.ImageInfo.xmlMediaType == ImagePlugins.XmlMediaType.OpticalDisc) + { + sector = 0; + offset = 0x400; + } + + if((sector + partition.Start) >= partition.End) return false; ushort magic; - byte[] minix_sb_sector = imagePlugin.ReadSector(2 + partition.Start); + byte[] minix_sb_sector = imagePlugin.ReadSector(sector + partition.Start); + + // Optical media + if(offset > 0) + { + byte[] tmp = new byte[0x200]; + Array.Copy(minix_sb_sector, offset, tmp, 0, 0x200); + minix_sb_sector = tmp; + } magic = BitConverter.ToUInt16(minix_sb_sector, 0x010); // Here should reside magic number on Minix v1 & V2 @@ -105,11 +122,28 @@ namespace DiscImageChef.Filesystems StringBuilder sb = new StringBuilder(); + uint sector = 2; + uint offset = 0; + + if(imagePlugin.ImageInfo.xmlMediaType == ImagePlugins.XmlMediaType.OpticalDisc) + { + sector = 0; + offset = 0x400; + } + bool minix3 = false; int filenamesize; string minixVersion; ushort magic; - byte[] minix_sb_sector = imagePlugin.ReadSector(2 + partition.Start); + byte[] minix_sb_sector = imagePlugin.ReadSector(sector + partition.Start); + + // Optical media + if(offset > 0) + { + byte[] tmp = new byte[0x200]; + Array.Copy(minix_sb_sector, offset, tmp, 0, 0x200); + minix_sb_sector = tmp; + } magic = BitConverter.ToUInt16(minix_sb_sector, 0x018);