Move Apple HFS and MFS volume attributes to common class.

This commit is contained in:
2020-02-19 01:57:39 +00:00
parent eea9150b27
commit 93e704e5ed
8 changed files with 86 additions and 16 deletions

View File

@@ -1310,6 +1310,7 @@
<e p="AmigaDOS.cs" t="Include" />
<e p="AppleCommon" t="Include">
<e p="Consts.cs" t="Include" />
<e p="Enums.cs" t="Include" />
<e p="Info.cs" t="Include" />
<e p="Structs.cs" t="Include" />
</e>

View File

@@ -0,0 +1,49 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : AppleHFS.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Apple Hierarchical File System plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Identifies the Apple Hierarchical File System and shows information.
//
// --[ 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-2020 Natalia Portillo
// ****************************************************************************/
using System;
namespace DiscImageChef.Filesystems
{
// Information from Inside Macintosh
// https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf
internal static partial class AppleCommon
{
[Flags]
internal enum VolumeAttributes : ushort
{
HardwareLock = 0x80, Unmounted = 0x100, SparedBadBlocks = 0x200,
DoesNotNeedCache = 0x400, BootInconsistent = 0x800, ReusedIds = 0x1000,
Journaled = 0x2000, Inconsistent = 0x4000, SoftwareLock = 0x8000
}
}
}

View File

@@ -165,30 +165,31 @@ namespace DiscImageChef.Filesystems
else
sb.AppendLine("Volume has never been backed up");
if((mdb.drAtrb & 0x80) == 0x80)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.HardwareLock))
sb.AppendLine("Volume is locked by hardware.");
sb.AppendLine((mdb.drAtrb & 0x100) == 0x100 ? "Volume was unmonted." : "Volume is mounted.");
sb.AppendLine(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Unmounted) ? "Volume was unmonted."
: "Volume is mounted.");
if((mdb.drAtrb & 0x200) == 0x200)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.SparedBadBlocks))
sb.AppendLine("Volume has spared bad blocks.");
if((mdb.drAtrb & 0x400) == 0x400)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.DoesNotNeedCache))
sb.AppendLine("Volume does not need cache.");
if((mdb.drAtrb & 0x800) == 0x800)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.BootInconsistent))
sb.AppendLine("Boot volume is inconsistent.");
if((mdb.drAtrb & 0x1000) == 0x1000)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.ReusedIds))
sb.AppendLine("There are reused CNIDs.");
if((mdb.drAtrb & 0x2000) == 0x2000)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Journaled))
sb.AppendLine("Volume is journaled.");
if((mdb.drAtrb & 0x4000) == 0x4000)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Inconsistent))
sb.AppendLine("Volume is seriously inconsistent.");
if((mdb.drAtrb & 0x8000) == 0x8000)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.SoftwareLock))
sb.AppendLine("Volume is locked by software.");
sb.AppendFormat("{0} files on root directory", mdb.drNmFls).AppendLine();
@@ -274,7 +275,7 @@ namespace DiscImageChef.Filesystems
XmlFsType.CreationDateSpecified = true;
}
XmlFsType.Dirty = (mdb.drAtrb & 0x100) != 0x100;
XmlFsType.Dirty = !mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Unmounted);
XmlFsType.Files = mdb.drFilCnt;
XmlFsType.FilesSpecified = true;
XmlFsType.FreeClusters = mdb.drFreeBks;

View File

@@ -49,7 +49,7 @@ namespace DiscImageChef.Filesystems
/// <summary>0x006, Volume last modification date</summary>
public readonly uint drLsMod;
/// <summary>0x00A, Volume attributes</summary>
public readonly ushort drAtrb;
public readonly AppleCommon.VolumeAttributes drAtrb;
/// <summary>0x00C, Files in root directory</summary>
public readonly ushort drNmFls;
/// <summary>0x00E, Start 512-byte sector of volume bitmap</summary>

View File

@@ -77,7 +77,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
mdb.drCrDate = BigEndianBitConverter.ToUInt32(mdbSector, 0x002);
mdb.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbSector, 0x006);
mdb.drAtrb = BigEndianBitConverter.ToUInt16(mdbSector, 0x00A);
mdb.drAtrb = (AppleCommon.VolumeAttributes)BigEndianBitConverter.ToUInt16(mdbSector, 0x00A);
mdb.drNmFls = BigEndianBitConverter.ToUInt16(mdbSector, 0x00C);
mdb.drDirSt = BigEndianBitConverter.ToUInt16(mdbSector, 0x00E);
mdb.drBlLen = BigEndianBitConverter.ToUInt16(mdbSector, 0x010);
@@ -98,10 +98,28 @@ namespace DiscImageChef.Filesystems.AppleMFS
sb.AppendFormat("Creation date: {0}", DateHandlers.MacToDateTime(mdb.drCrDate)).AppendLine();
sb.AppendFormat("Last backup date: {0}", DateHandlers.MacToDateTime(mdb.drLsBkUp)).AppendLine();
if((mdb.drAtrb & 0x80) == 0x80)
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.HardwareLock))
sb.AppendLine("Volume is locked by hardware.");
if((mdb.drAtrb & 0x8000) == 0x8000)
sb.AppendLine(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Unmounted) ? "Volume was unmonted."
: "Volume is mounted.");
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.SparedBadBlocks))
sb.AppendLine("Volume has spared bad blocks.");
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.DoesNotNeedCache))
sb.AppendLine("Volume does not need cache.");
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.BootInconsistent))
sb.AppendLine("Boot volume is inconsistent.");
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.ReusedIds))
sb.AppendLine("There are reused CNIDs.");
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.Inconsistent))
sb.AppendLine("Volume is seriously inconsistent.");
if(mdb.drAtrb.HasFlag(AppleCommon.VolumeAttributes.SoftwareLock))
sb.AppendLine("Volume is locked by software.");
sb.AppendFormat("{0} files on volume", mdb.drNmFls).AppendLine();

View File

@@ -51,7 +51,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
/// <summary>0x006, Volume last backup date</summary>
public uint drLsBkUp;
/// <summary>0x00A, Volume attributes</summary>
public ushort drAtrb;
public AppleCommon.VolumeAttributes drAtrb;
/// <summary>0x00C, Volume number of files</summary>
public ushort drNmFls;
/// <summary>0x00E, First directory sector</summary>

View File

@@ -69,7 +69,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
volMDB.drCrDate = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x002);
volMDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x006);
volMDB.drAtrb = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00A);
volMDB.drAtrb = (AppleCommon.VolumeAttributes)BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00A);
volMDB.drNmFls = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00C);
volMDB.drDirSt = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00E);
volMDB.drBlLen = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x010);

View File

@@ -55,6 +55,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AppleCommon\Consts.cs" />
<Compile Include="AppleCommon\Enums.cs" />
<Compile Include="AppleCommon\Info.cs" />
<Compile Include="AppleCommon\Structs.cs" />
<Compile Include="AppleHFS\AppleHFS.cs" />