diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml index 062826aa8..35b58cce0 100644 --- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml +++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml @@ -1310,6 +1310,7 @@ + diff --git a/DiscImageChef.Filesystems/AppleCommon/Enums.cs b/DiscImageChef.Filesystems/AppleCommon/Enums.cs new file mode 100644 index 000000000..d55c5a359 --- /dev/null +++ b/DiscImageChef.Filesystems/AppleCommon/Enums.cs @@ -0,0 +1,49 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleHFS.cs +// Author(s) : Natalia Portillo +// +// 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 . +// +// ---------------------------------------------------------------------------- +// 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 + } + } +} \ No newline at end of file diff --git a/DiscImageChef.Filesystems/AppleHFS/Info.cs b/DiscImageChef.Filesystems/AppleHFS/Info.cs index 7f9f1ab09..1bf9cab02 100644 --- a/DiscImageChef.Filesystems/AppleHFS/Info.cs +++ b/DiscImageChef.Filesystems/AppleHFS/Info.cs @@ -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; diff --git a/DiscImageChef.Filesystems/AppleHFS/Structs.cs b/DiscImageChef.Filesystems/AppleHFS/Structs.cs index d12433c9b..34f879c4d 100644 --- a/DiscImageChef.Filesystems/AppleHFS/Structs.cs +++ b/DiscImageChef.Filesystems/AppleHFS/Structs.cs @@ -49,7 +49,7 @@ namespace DiscImageChef.Filesystems /// 0x006, Volume last modification date public readonly uint drLsMod; /// 0x00A, Volume attributes - public readonly ushort drAtrb; + public readonly AppleCommon.VolumeAttributes drAtrb; /// 0x00C, Files in root directory public readonly ushort drNmFls; /// 0x00E, Start 512-byte sector of volume bitmap diff --git a/DiscImageChef.Filesystems/AppleMFS/Info.cs b/DiscImageChef.Filesystems/AppleMFS/Info.cs index 9ba50418a..4645cd06b 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Info.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Info.cs @@ -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(); diff --git a/DiscImageChef.Filesystems/AppleMFS/Structs.cs b/DiscImageChef.Filesystems/AppleMFS/Structs.cs index 2fc3567ad..fe4112722 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Structs.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Structs.cs @@ -51,7 +51,7 @@ namespace DiscImageChef.Filesystems.AppleMFS /// 0x006, Volume last backup date public uint drLsBkUp; /// 0x00A, Volume attributes - public ushort drAtrb; + public AppleCommon.VolumeAttributes drAtrb; /// 0x00C, Volume number of files public ushort drNmFls; /// 0x00E, First directory sector diff --git a/DiscImageChef.Filesystems/AppleMFS/Super.cs b/DiscImageChef.Filesystems/AppleMFS/Super.cs index 08c103f65..169e30ed1 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Super.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Super.cs @@ -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); diff --git a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj index 8e3bc3970..6c850d72a 100644 --- a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj +++ b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj @@ -55,6 +55,7 @@ +