Finally got correct partition types.

This commit is contained in:
2017-08-17 02:16:34 +01:00
parent 3d8f64ab68
commit 71f1ccb3dd
3 changed files with 105 additions and 39 deletions

View File

@@ -0,0 +1,41 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : IMD.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Component
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2017 Natalia Portillo
// ****************************************************************************/
using System;
namespace DiscImageChef.DiscImages
{
public class IMD
{
public IMD()
{
}
}
}

View File

@@ -100,7 +100,7 @@ namespace DiscImageChef.PartPlugins
Partition part = new Partition
{
Start = Helpers.CHS.ToLBA(entry.dp_scyl, entry.dp_shd, (uint)(entry.dp_ssect + 1), imagePlugin.ImageInfo.heads, imagePlugin.ImageInfo.sectorsPerTrack),
Type = string.Format("{0}", ((entry.dp_sid & 0x7F) << 8) | (entry.dp_mid & 0x7F)),
Type = DecodePC98Sid(entry.dp_sid),
Name = StringHandlers.CToString(entry.dp_name, Encoding.GetEncoding(932)).Trim(),
Sequence = counter,
Scheme = Name
@@ -131,6 +131,35 @@ namespace DiscImageChef.PartPlugins
return partitions.Count > 0;
}
static string DecodePC98Sid(byte sid)
{
switch(sid & 0x7F)
{
case 0x01:
return "FAT12";
case 0x04:
return "PC-UX";
case 0x06:
return "N88-BASIC(86)";
// Supposedly for FAT16 < 32 MiB, seen in bigger partitions
case 0x11:
case 0x21:
return "FAT16";
case 0x28:
case 0x41:
case 0x48:
return "Windows Volume Set";
case 0x44:
return "FreeBSD";
case 0x61:
return "FAT32";
case 0x62:
return "Linux";
default:
return "Unknown";
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct PC98Table
{
@@ -143,14 +172,10 @@ namespace DiscImageChef.PartPlugins
{
/// <summary>
/// Some ID, if 0x80 bit is set, it is bootable
/// 386BSD sets it to 0x14
/// Apparently 0x20 means DOS 5 and 0x01 means 1st boot option
/// </summary>
public byte dp_mid;
/// <summary>
/// Some ID, if 0x80 bit is set, it is active
/// 386BSD sets it to 0x44
/// Apparently 0x21 means DOS 5
/// </summary>
public byte dp_sid;
public byte dp_dum1;

View File

@@ -58,52 +58,52 @@ namespace DiscImageChef.Tests.Partitions
readonly Partition[][] wanted = {
// NEC MS-DOS 3.30 (256Mb HDD)
new []{
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "288", Length = 19536, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "288", Length = 39336, Sequence = 1, Start = 20064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4385", Length = 59136, Sequence = 2, Start = 59664 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4384", Length = 78936, Sequence = 3, Start = 119064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4384", Length = 118536, Sequence = 4, Start = 198264 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4384", Length = 197736, Sequence = 5, Start = 317064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4386", Length = 237336, Sequence = 6, Start = 515064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4384", Length = 245256, Sequence = 7, Start = 752664 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT12", Length = 19536, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT12", Length = 39336, Sequence = 1, Start = 20064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 59136, Sequence = 2, Start = 59664 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 78936, Sequence = 3, Start = 119064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 118536, Sequence = 4, Start = 198264 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 197736, Sequence = 5, Start = 317064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 237336, Sequence = 6, Start = 515064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 245256, Sequence = 7, Start = 752664 },
},
// NEC MS-DOS 3.30 (80Mb HDD)
new []{
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4384", Length = 59136, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4384", Length = 158136, Sequence = 1, Start = 59664 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "4385", Length = 94776, Sequence = 2, Start = 218064 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 59136, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 158136, Sequence = 1, Start = 59664 },
new Partition{ Description = null, Name = "MS-DOS 3.30", Type = "FAT16", Length = 94776, Sequence = 2, Start = 218064 },
},
// Epson MS-DOS 3.30
new []{
new Partition{ Description = null, Name = "NamenameName", Type = "288", Length = 35639, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "12BitFAT", Type = "288", Length = 59399, Sequence = 1, Start = 35904 },
new Partition{ Description = null, Name = "16BitFAT", Type = "4385", Length = 79199, Sequence = 2, Start = 95304 },
new Partition{ Description = null, Name = "PartLblMaxNameXX", Type = "4384", Length = 118799, Sequence = 3, Start = 174504 },
new Partition{ Description = null, Name = "BigFAT12", Type = "288", Length = 158399, Sequence = 4, Start = 293304 },
new Partition{ Description = null, Name = "Lalalalalalalala", Type = "4386", Length = 197999, Sequence = 5, Start = 451704 },
new Partition{ Description = null, Name = "MS-DOS Ver 5.0", Type = "4384", Length = 237599, Sequence = 6, Start = 649704 },
new Partition{ Description = null, Name = "MS-DOS Ver 5.0", Type = "4387", Length = 118799, Sequence = 7, Start = 887304 },
new Partition{ Description = null, Name = "NamenameName", Type = "FAT12", Length = 35639, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "12BitFAT", Type = "FAT12", Length = 59399, Sequence = 1, Start = 35904 },
new Partition{ Description = null, Name = "16BitFAT", Type = "FAT16", Length = 79199, Sequence = 2, Start = 95304 },
new Partition{ Description = null, Name = "PartLblMaxNameXX", Type = "FAT16", Length = 118799, Sequence = 3, Start = 174504 },
new Partition{ Description = null, Name = "BigFAT12", Type = "FAT12", Length = 158399, Sequence = 4, Start = 293304 },
new Partition{ Description = null, Name = "Lalalalalalalala", Type = "FAT16", Length = 197999, Sequence = 5, Start = 451704 },
new Partition{ Description = null, Name = "MS-DOS Ver 5.0", Type = "FAT16", Length = 237599, Sequence = 6, Start = 649704 },
new Partition{ Description = null, Name = "MS-DOS Ver 5.0", Type = "FAT16", Length = 118799, Sequence = 7, Start = 887304 },
},
// NEC MS-DOS 5.00
new []{
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "288", Length = 28512, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "4384", Length = 49104, Sequence = 1, Start = 29040 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "4385", Length = 93984, Sequence = 2, Start = 78408 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "4384", Length = 122760, Sequence = 3, Start = 172656 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "4386", Length = 163680, Sequence = 4, Start = 295680 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "4387", Length = 204600, Sequence = 5, Start = 459624 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "4384", Length = 204600, Sequence = 6, Start = 664488 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "4388", Length = 139128, Sequence = 7, Start = 869352 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT12", Length = 28512, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT16", Length = 49104, Sequence = 1, Start = 29040 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT16", Length = 93984, Sequence = 2, Start = 78408 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT16", Length = 122760, Sequence = 3, Start = 172656 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT16", Length = 163680, Sequence = 4, Start = 295680 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT16", Length = 204600, Sequence = 5, Start = 459624 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT16", Length = 204600, Sequence = 6, Start = 664488 },
new Partition{ Description = null, Name = "MS-DOS 5.00", Type = "FAT16", Length = 139128, Sequence = 7, Start = 869352 },
},
// NEC MS-DOS 6.20
new []{
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "4384", Length = 61248, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "4385", Length = 81840, Sequence = 1, Start = 61776 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "4384", Length = 122760, Sequence = 2, Start = 143880 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "4384", Length = 163680, Sequence = 3, Start = 266904 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "290", Length = 20328, Sequence = 4, Start = 430848 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "4387", Length = 245520, Sequence = 5, Start = 451440 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "4384", Length = 315216, Sequence = 6, Start = 697224 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "FAT16", Length = 61248, Sequence = 0, Start = 264 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "FAT16", Length = 81840, Sequence = 1, Start = 61776 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "FAT16", Length = 122760, Sequence = 2, Start = 143880 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "FAT16", Length = 163680, Sequence = 3, Start = 266904 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "FAT12", Length = 20328, Sequence = 4, Start = 430848 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "FAT16", Length = 245520, Sequence = 5, Start = 451440 },
new Partition{ Description = null, Name = "MS-DOS 6.20", Type = "FAT16", Length = 315216, Sequence = 6, Start = 697224 },
},
};