Added support for Plan9 partition tables.

This commit is contained in:
2017-08-07 16:15:28 +01:00
parent 6c43d0c40f
commit 01656b767b
3 changed files with 53 additions and 3 deletions

View File

@@ -55,6 +55,7 @@
<Compile Include="Xbox.cs" /> <Compile Include="Xbox.cs" />
<Compile Include="UNIX.cs" /> <Compile Include="UNIX.cs" />
<Compile Include="XENIX.cs" /> <Compile Include="XENIX.cs" />
<Compile Include="Plan9.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>
@@ -96,7 +97,7 @@
<inheritsSet /> <inheritsSet />
<inheritsScope /> <inheritsScope />
</TextStylePolicy> </TextStylePolicy>
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceAfterControlFlowStatementKeyword="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" scope="text/x-csharp"> <CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp">
<inheritsSet /> <inheritsSet />
<inheritsScope /> <inheritsScope />
</CSharpFormattingPolicy> </CSharpFormattingPolicy>

View File

@@ -30,12 +30,60 @@
// Copyright © 2011-2017 Natalia Portillo // Copyright © 2011-2017 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
namespace DiscImageChef.Partitions using System.Collections.Generic;
using DiscImageChef.CommonTypes;
namespace DiscImageChef.PartPlugins
{ {
public class Plan9 // This is the most stupid or the most intelligent partition scheme ever done, pick or take
// At sector 1 from offset, text resides (yes, TEXT) in following format:
// "part type start end\n"
// One line per partition, start and end relative to offset
// e.g.: "part nvram 10110 10112\npart fossil 10112 3661056\n"
public class Plan9 : PartPlugin
{ {
public Plan9() public Plan9()
{ {
Name = "Plan9 partition table";
PluginUUID = new Guid("F0BF4FFC-056E-4E7C-8B65-4EAEE250ADD9");
}
public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List<Partition> partitions, ulong sectorOffset)
{
partitions = new List<Partition>();
byte[] sector = imagePlugin.ReadSector(sectorOffset + 1);
// While all of Plan9 is supposedly UTF-8, it uses ASCII strcmp for reading its partition table
string[] really = StringHandlers.CToString(sector).Split(new[] {'\n'});
foreach(string part in really)
{
if(part.Length < 5 || part.Substring(0, 5) != "part ")
break;
string[] tokens = part.Split(new[] { ' ' });
if(tokens.Length != 4)
break;
if(!ulong.TryParse(tokens[2], out ulong start) ||
!ulong.TryParse(tokens[3], out ulong end))
break;
Partition _part = new Partition
{
Length = (end - start) + 1,
Offset = (start + sectorOffset) * imagePlugin.GetSectorSize(),
Scheme = Name,
Sequence = (ulong)partitions.Count,
Size = ((end - start) + 1) * imagePlugin.GetSectorSize(),
Start = start + sectorOffset,
Type = tokens[1]
};
partitions.Add(_part);
}
return partitions.Count>0;
} }
} }
} }

View File

@@ -85,6 +85,7 @@ Supported partitioning schemes
* Minix subpartitions inside MBR * Minix subpartitions inside MBR
* NEC PC9800 partitions * NEC PC9800 partitions
* NeXT disklabel * NeXT disklabel
* Plan9 partition table
* Rio Karma partitions * Rio Karma partitions
* SGI volume headers * SGI volume headers
* Solaris slices inside MBR * Solaris slices inside MBR