diff --git a/Aaru.Filesystems/AODOS/AODOS.cs b/Aaru.Filesystems/AODOS/AODOS.cs new file mode 100644 index 000000000..8a0019990 --- /dev/null +++ b/Aaru.Filesystems/AODOS/AODOS.cs @@ -0,0 +1,56 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : AODOS.cs +// Author(s) : Natalia Portillo +// +// Component : Commodore file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the AO-DOS 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information has been extracted looking at available disk images +// This may be missing fields, or not, I don't know russian so any help is appreciated +/// +/// Implements detection of the AO-DOS filesystem +public sealed partial class AODOS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public string Name => Localization.AODOS_Name; + /// + public Guid Id => new("668E5039-9DDD-442A-BE1B-A315D6E38E26"); + /// + public Encoding Encoding { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AODOS/Consts.cs b/Aaru.Filesystems/AODOS/Consts.cs new file mode 100644 index 000000000..a83a737f0 --- /dev/null +++ b/Aaru.Filesystems/AODOS/Consts.cs @@ -0,0 +1,46 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Commodore file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the AO-DOS 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information has been extracted looking at available disk images +// This may be missing fields, or not, I don't know russian so any help is appreciated +/// +/// Implements detection of the AO-DOS filesystem +public sealed partial class AODOS +{ + const string FS_TYPE = "aodos"; + readonly byte[] _identifier = + { + 0x20, 0x41, 0x4F, 0x2D, 0x44, 0x4F, 0x53, 0x20 + }; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AODOS.cs b/Aaru.Filesystems/AODOS/Info.cs similarity index 73% rename from Aaru.Filesystems/AODOS.cs rename to Aaru.Filesystems/AODOS/Info.cs index c13a7e347..a800f384c 100644 --- a/Aaru.Filesystems/AODOS.cs +++ b/Aaru.Filesystems/AODOS/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : AODOS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Commodore file system plugin. @@ -30,16 +30,13 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -47,24 +44,8 @@ namespace Aaru.Filesystems; // This may be missing fields, or not, I don't know russian so any help is appreciated /// /// Implements detection of the AO-DOS filesystem -public sealed class AODOS : IFilesystem +public sealed partial class AODOS { - const string FS_TYPE = "aodos"; - readonly byte[] _identifier = - { - 0x20, 0x41, 0x4F, 0x2D, 0x44, 0x4F, 0x53, 0x20 - }; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public string Name => Localization.AODOS_Name; - /// - public Guid Id => new("668E5039-9DDD-442A-BE1B-A315D6E38E26"); - /// - public Encoding Encoding { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -128,25 +109,4 @@ public sealed class AODOS : IFilesystem information = sbInformation.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct BootBlock - { - /// A NOP opcode - public readonly byte nop; - /// A branch to real bootloader - public readonly ushort branch; - /// Unused - public readonly byte unused; - /// " AO-DOS " - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] identifier; - /// Volume label - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] volumeLabel; - /// How many files are present in disk - public readonly ushort files; - /// How many sectors are used - public readonly ushort usedSectors; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/AODOS/Structs.cs b/Aaru.Filesystems/AODOS/Structs.cs new file mode 100644 index 000000000..510e732e3 --- /dev/null +++ b/Aaru.Filesystems/AODOS/Structs.cs @@ -0,0 +1,63 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Commodore file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the AO-DOS 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information has been extracted looking at available disk images +// This may be missing fields, or not, I don't know russian so any help is appreciated +/// +/// Implements detection of the AO-DOS filesystem +public sealed partial class AODOS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct BootBlock + { + /// A NOP opcode + public readonly byte nop; + /// A branch to real bootloader + public readonly ushort branch; + /// Unused + public readonly byte unused; + /// " AO-DOS " + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] identifier; + /// Volume label + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] volumeLabel; + /// How many files are present in disk + public readonly ushort files; + /// How many sectors are used + public readonly ushort usedSectors; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/APFS/APFS.cs b/Aaru.Filesystems/APFS/APFS.cs new file mode 100644 index 000000000..c6a0a85b2 --- /dev/null +++ b/Aaru.Filesystems/APFS/APFS.cs @@ -0,0 +1,52 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : APFS.cs +// Author(s) : Natalia Portillo +// +// Component : Apple filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Apple File System (APFS) +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class APFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.APFS_Name; + /// + public Guid Id => new("A4060F9D-2909-42E2-9D95-DB31FA7EA797"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/APFS/Consts.cs b/Aaru.Filesystems/APFS/Consts.cs new file mode 100644 index 000000000..adc91f051 --- /dev/null +++ b/Aaru.Filesystems/APFS/Consts.cs @@ -0,0 +1,41 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Apple filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Apple File System (APFS) +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class APFS +{ + const uint APFS_CONTAINER_MAGIC = 0x4253584E; // "NXSB" + const uint APFS_VOLUME_MAGIC = 0x42535041; // "APSB" + const string FS_TYPE = "apfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/APFS.cs b/Aaru.Filesystems/APFS/Info.cs similarity index 73% rename from Aaru.Filesystems/APFS.cs rename to Aaru.Filesystems/APFS/Info.cs index 9116a9769..2ad8dc77a 100644 --- a/Aaru.Filesystems/APFS.cs +++ b/Aaru.Filesystems/APFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : APFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Apple filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Apple filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,37 +26,21 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; +using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Apple File System (APFS) [SuppressMessage("ReSharper", "UnusedMember.Local")] -public sealed class APFS : IFilesystem +public sealed partial class APFS { - const uint APFS_CONTAINER_MAGIC = 0x4253584E; // "NXSB" - const uint APFS_VOLUME_MAGIC = 0x42535041; // "APSB" - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.APFS_Name; - /// - public Guid Id => new("A4060F9D-2909-42E2-9D95-DB31FA7EA797"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -133,18 +113,4 @@ public sealed class APFS : IFilesystem Type = FS_TYPE }; } - - const string FS_TYPE = "apfs"; - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct ContainerSuperBlock - { - public readonly ulong unknown1; // Varies between copies of the superblock - public readonly ulong unknown2; - public readonly ulong unknown3; // Varies by 1 between copies of the superblock - public readonly ulong unknown4; - public readonly uint magic; - public readonly uint blockSize; - public readonly ulong containerBlocks; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/APFS/Structs.cs b/Aaru.Filesystems/APFS/Structs.cs new file mode 100644 index 000000000..7aafba092 --- /dev/null +++ b/Aaru.Filesystems/APFS/Structs.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Apple filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Apple File System (APFS) +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class APFS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct ContainerSuperBlock + { + public readonly ulong unknown1; // Varies between copies of the superblock + public readonly ulong unknown2; + public readonly ulong unknown3; // Varies by 1 between copies of the superblock + public readonly ulong unknown4; + public readonly uint magic; + public readonly uint blockSize; + public readonly ulong containerBlocks; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Aaru.Filesystems.csproj.DotSettings b/Aaru.Filesystems/Aaru.Filesystems.csproj.DotSettings index e7d8621d0..f8e79355e 100644 --- a/Aaru.Filesystems/Aaru.Filesystems.csproj.DotSettings +++ b/Aaru.Filesystems/Aaru.Filesystems.csproj.DotSettings @@ -1,16 +1,57 @@  - True + True + True + True + True + True True True + True True + True + True + True + True True + True + True + True + True + True + True + True + True True True + True + True + True + True True True True + True + True True True \ No newline at end of file + x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=locus/@EntryIndexedValue">True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True \ No newline at end of file diff --git a/Aaru.Filesystems/Acorn/Acorn.cs b/Aaru.Filesystems/Acorn/Acorn.cs new file mode 100644 index 000000000..c02f15d1a --- /dev/null +++ b/Aaru.Filesystems/Acorn/Acorn.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Acorn.cs +// Author(s) : Natalia Portillo +// +// Component : Acorn filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Acorn's Advanced Data Filing System (ADFS) +public sealed partial class AcornADFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public string Name => Localization.AcornADFS_Name; + /// + public Guid Id => new("BAFC1E50-9C64-4CD3-8400-80628CC27AFA"); + /// + public Encoding Encoding { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Acorn/Consts.cs b/Aaru.Filesystems/Acorn/Consts.cs new file mode 100644 index 000000000..c64e446ea --- /dev/null +++ b/Aaru.Filesystems/Acorn/Consts.cs @@ -0,0 +1,54 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Acorn filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Acorn's Advanced Data Filing System (ADFS) +public sealed partial class AcornADFS +{ + /// Location for boot block, in bytes + const ulong BOOT_BLOCK_LOCATION = 0xC00; + /// Size of boot block, in bytes + const uint BOOT_BLOCK_SIZE = 0x200; + /// Location of new directory, in bytes + const ulong NEW_DIRECTORY_LOCATION = 0x400; + /// Location of old directory, in bytes + const ulong OLD_DIRECTORY_LOCATION = 0x200; + /// Size of old directory + const uint OLD_DIRECTORY_SIZE = 1280; + /// Size of new directory + const uint NEW_DIRECTORY_SIZE = 2048; + + /// New directory format magic number, "Nick" + const uint NEW_DIR_MAGIC = 0x6B63694E; + /// Old directory format magic number, "Hugo" + const uint OLD_DIR_MAGIC = 0x6F677548; + + const string FS_TYPE = "adfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Acorn/Helpers.cs b/Aaru.Filesystems/Acorn/Helpers.cs new file mode 100644 index 000000000..fdc93d629 --- /dev/null +++ b/Aaru.Filesystems/Acorn/Helpers.cs @@ -0,0 +1,114 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Helpers.cs +// Author(s) : Natalia Portillo +// +// Component : Acorn filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Collections.Generic; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Acorn's Advanced Data Filing System (ADFS) +public sealed partial class AcornADFS +{ + static byte AcornMapChecksum(byte[] data, int length) + { + int sum = 0; + int carry = 0; + + if(length > data.Length) + length = data.Length; + + // ADC r0, r0, r1 + // MOVS r0, r0, LSL #24 + // MOV r0, r0, LSR #24 + for(int i = length - 1; i >= 0; i--) + { + sum += data[i] + carry; + + if(sum > 0xFF) + { + carry = 1; + sum &= 0xFF; + } + else + carry = 0; + } + + return (byte)(sum & 0xFF); + } + + static byte NewMapChecksum(byte[] mapBase) + { + uint rover; + uint sumVector0 = 0; + uint sumVector1 = 0; + uint sumVector2 = 0; + uint sumVector3 = 0; + + for(rover = (uint)(mapBase.Length - 4); rover > 0; rover -= 4) + { + sumVector0 += mapBase[rover + 0] + (sumVector3 >> 8); + sumVector3 &= 0xff; + sumVector1 += mapBase[rover + 1] + (sumVector0 >> 8); + sumVector0 &= 0xff; + sumVector2 += mapBase[rover + 2] + (sumVector1 >> 8); + sumVector1 &= 0xff; + sumVector3 += mapBase[rover + 3] + (sumVector2 >> 8); + sumVector2 &= 0xff; + } + + /* + Don't add the check byte when calculating its value + */ + sumVector0 += sumVector3 >> 8; + sumVector1 += mapBase[1] + (sumVector0 >> 8); + sumVector2 += mapBase[2] + (sumVector1 >> 8); + sumVector3 += mapBase[3] + (sumVector2 >> 8); + + return (byte)((sumVector0 ^ sumVector1 ^ sumVector2 ^ sumVector3) & 0xff); + } + + // TODO: This is not correct... + static byte AcornDirectoryChecksum(IList data, int length) + { + uint sum = 0; + + if(length > data.Count) + length = data.Count; + + // EOR r0, r1, r0, ROR #13 + for(int i = 0; i < length; i++) + { + uint carry = sum & 0x1FFF; + sum >>= 13; + sum ^= data[i]; + sum += carry << 19; + } + + return (byte)(((sum & 0xFF000000) >> 24) ^ ((sum & 0xFF0000) >> 16) ^ ((sum & 0xFF00) >> 8) ^ (sum & 0xFF)); + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Acorn.cs b/Aaru.Filesystems/Acorn/Info.cs similarity index 71% rename from Aaru.Filesystems/Acorn.cs rename to Aaru.Filesystems/Acorn/Info.cs index 7bf69c2b0..d960fbf7d 100644 --- a/Aaru.Filesystems/Acorn.cs +++ b/Aaru.Filesystems/Acorn/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Acorn.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Acorn filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Acorn filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,8 +27,6 @@ // ****************************************************************************/ using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -40,45 +34,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of Acorn's Advanced Data Filing System (ADFS) -public sealed class AcornADFS : IFilesystem +public sealed partial class AcornADFS { - /// Location for boot block, in bytes - const ulong BOOT_BLOCK_LOCATION = 0xC00; - /// Size of boot block, in bytes - const uint BOOT_BLOCK_SIZE = 0x200; - /// Location of new directory, in bytes - const ulong NEW_DIRECTORY_LOCATION = 0x400; - /// Location of old directory, in bytes - const ulong OLD_DIRECTORY_LOCATION = 0x200; - /// Size of old directory - const uint OLD_DIRECTORY_SIZE = 1280; - /// Size of new directory - const uint NEW_DIRECTORY_SIZE = 2048; - - /// New directory format magic number, "Nick" - const uint NEW_DIR_MAGIC = 0x6B63694E; - /// Old directory format magic number, "Hugo" - const uint OLD_DIR_MAGIC = 0x6F677548; - - const string FS_TYPE = "adfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public string Name => Localization.AcornADFS_Name; - /// - public Guid Id => new("BAFC1E50-9C64-4CD3-8400-80628CC27AFA"); - /// - public Encoding Encoding { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - // TODO: BBC Master hard disks are untested... /// public bool Identify(IMediaImage imagePlugin, Partition partition) @@ -604,239 +566,4 @@ public sealed class AcornADFS : IFilesystem XmlFsType.ClusterSize = (uint)(1 << drSb.log2secsize); XmlFsType.Type = FS_TYPE; } - - static byte AcornMapChecksum(byte[] data, int length) - { - int sum = 0; - int carry = 0; - - if(length > data.Length) - length = data.Length; - - // ADC r0, r0, r1 - // MOVS r0, r0, LSL #24 - // MOV r0, r0, LSR #24 - for(int i = length - 1; i >= 0; i--) - { - sum += data[i] + carry; - - if(sum > 0xFF) - { - carry = 1; - sum &= 0xFF; - } - else - carry = 0; - } - - return (byte)(sum & 0xFF); - } - - static byte NewMapChecksum(byte[] mapBase) - { - uint rover; - uint sumVector0 = 0; - uint sumVector1 = 0; - uint sumVector2 = 0; - uint sumVector3 = 0; - - for(rover = (uint)(mapBase.Length - 4); rover > 0; rover -= 4) - { - sumVector0 += mapBase[rover + 0] + (sumVector3 >> 8); - sumVector3 &= 0xff; - sumVector1 += mapBase[rover + 1] + (sumVector0 >> 8); - sumVector0 &= 0xff; - sumVector2 += mapBase[rover + 2] + (sumVector1 >> 8); - sumVector1 &= 0xff; - sumVector3 += mapBase[rover + 3] + (sumVector2 >> 8); - sumVector2 &= 0xff; - } - - /* - Don't add the check byte when calculating its value - */ - sumVector0 += sumVector3 >> 8; - sumVector1 += mapBase[1] + (sumVector0 >> 8); - sumVector2 += mapBase[2] + (sumVector1 >> 8); - sumVector3 += mapBase[3] + (sumVector2 >> 8); - - return (byte)((sumVector0 ^ sumVector1 ^ sumVector2 ^ sumVector3) & 0xff); - } - - // TODO: This is not correct... - static byte AcornDirectoryChecksum(IList data, int length) - { - uint sum = 0; - - if(length > data.Count) - length = data.Count; - - // EOR r0, r1, r0, ROR #13 - for(int i = 0; i < length; i++) - { - uint carry = sum & 0x1FFF; - sum >>= 13; - sum ^= data[i]; - sum += carry << 19; - } - - return (byte)(((sum & 0xFF000000) >> 24) ^ ((sum & 0xFF0000) >> 16) ^ ((sum & 0xFF00) >> 8) ^ (sum & 0xFF)); - } - - /// Boot block, used in hard disks and ADFS-F and higher. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct BootBlock - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1C0)] - public readonly byte[] spare; - public readonly DiscRecord discRecord; - public readonly byte flags; - public readonly ushort startCylinder; - public readonly byte checksum; - } - - /// Disc record, used in hard disks and ADFS-E and higher. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DiscRecord - { - public readonly byte log2secsize; - public readonly byte spt; - public readonly byte heads; - public readonly byte density; - public readonly byte idlen; - public readonly byte log2bpmb; - public readonly byte skew; - public readonly byte bootoption; - public readonly byte lowsector; - public readonly byte nzones; - public readonly ushort zone_spare; - public readonly uint root; - public readonly uint disc_size; - public readonly ushort disc_id; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - public readonly byte[] disc_name; - public readonly uint disc_type; - public readonly uint disc_size_high; - public readonly byte flags; - public readonly byte nzones_high; - public readonly uint format_version; - public readonly uint root_size; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] reserved; - } - - /// Free block map, sector 0, used in ADFS-S, ADFS-L, ADFS-M and ADFS-D - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct OldMapSector0 - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 82 * 3)] - public readonly byte[] freeStart; - public readonly byte reserved; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] - public readonly byte[] name; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] size; - public readonly byte checksum; - } - - /// Free block map, sector 1, used in ADFS-S, ADFS-L, ADFS-M and ADFS-D - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct OldMapSector1 - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 82 * 3)] - public readonly byte[] freeStart; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] - public readonly byte[] name; - public readonly ushort discId; - public readonly byte boot; - public readonly byte freeEnd; - public readonly byte checksum; - } - - /// Free block map, sector 0, used in ADFS-E - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct NewMap - { - public readonly byte zoneChecksum; - public readonly ushort freeLink; - public readonly byte crossChecksum; - public readonly DiscRecord discRecord; - } - - /// Directory header, common to "old" and "new" directories - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DirectoryHeader - { - public readonly byte masterSequence; - public readonly uint magic; - } - - /// Directory header, common to "old" and "new" directories - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DirectoryEntry - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - public readonly byte[] name; - public readonly uint load; - public readonly uint exec; - public readonly uint length; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] address; - public readonly byte atts; - } - - /// Directory tail, new format - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct NewDirectoryTail - { - public readonly byte lastMark; - public readonly ushort reserved; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] parent; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 19)] - public readonly byte[] title; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - public readonly byte[] name; - public readonly byte endMasSeq; - public readonly uint magic; - public readonly byte checkByte; - } - - /// Directory tail, old format - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct OldDirectoryTail - { - public readonly byte lastMark; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - public readonly byte[] name; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] parent; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 19)] - public readonly byte[] title; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] - public readonly byte[] reserved; - public readonly byte endMasSeq; - public readonly uint magic; - public readonly byte checkByte; - } - - /// Directory, old format - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct OldDirectory - { - public readonly DirectoryHeader header; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 47)] - public readonly DirectoryEntry[] entries; - public readonly OldDirectoryTail tail; - } - - /// Directory, new format - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct NewDirectory - { - public readonly DirectoryHeader header; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 77)] - public readonly DirectoryEntry[] entries; - public readonly NewDirectoryTail tail; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Acorn/Structs.cs b/Aaru.Filesystems/Acorn/Structs.cs new file mode 100644 index 000000000..3898f2f1d --- /dev/null +++ b/Aaru.Filesystems/Acorn/Structs.cs @@ -0,0 +1,193 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Acorn filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Acorn's Advanced Data Filing System (ADFS) +public sealed partial class AcornADFS +{ + /// Boot block, used in hard disks and ADFS-F and higher. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct BootBlock + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x1C0)] + public readonly byte[] spare; + public readonly DiscRecord discRecord; + public readonly byte flags; + public readonly ushort startCylinder; + public readonly byte checksum; + } + + /// Disc record, used in hard disks and ADFS-E and higher. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct DiscRecord + { + public readonly byte log2secsize; + public readonly byte spt; + public readonly byte heads; + public readonly byte density; + public readonly byte idlen; + public readonly byte log2bpmb; + public readonly byte skew; + public readonly byte bootoption; + public readonly byte lowsector; + public readonly byte nzones; + public readonly ushort zone_spare; + public readonly uint root; + public readonly uint disc_size; + public readonly ushort disc_id; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] + public readonly byte[] disc_name; + public readonly uint disc_type; + public readonly uint disc_size_high; + public readonly byte flags; + public readonly byte nzones_high; + public readonly uint format_version; + public readonly uint root_size; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] reserved; + } + + /// Free block map, sector 0, used in ADFS-S, ADFS-L, ADFS-M and ADFS-D + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct OldMapSector0 + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 82 * 3)] + public readonly byte[] freeStart; + public readonly byte reserved; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] + public readonly byte[] name; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] size; + public readonly byte checksum; + } + + /// Free block map, sector 1, used in ADFS-S, ADFS-L, ADFS-M and ADFS-D + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct OldMapSector1 + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 82 * 3)] + public readonly byte[] freeStart; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] + public readonly byte[] name; + public readonly ushort discId; + public readonly byte boot; + public readonly byte freeEnd; + public readonly byte checksum; + } + + /// Free block map, sector 0, used in ADFS-E + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct NewMap + { + public readonly byte zoneChecksum; + public readonly ushort freeLink; + public readonly byte crossChecksum; + public readonly DiscRecord discRecord; + } + + /// Directory header, common to "old" and "new" directories + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct DirectoryHeader + { + public readonly byte masterSequence; + public readonly uint magic; + } + + /// Directory header, common to "old" and "new" directories + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct DirectoryEntry + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] + public readonly byte[] name; + public readonly uint load; + public readonly uint exec; + public readonly uint length; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] address; + public readonly byte atts; + } + + /// Directory tail, new format + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct NewDirectoryTail + { + public readonly byte lastMark; + public readonly ushort reserved; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] parent; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 19)] + public readonly byte[] title; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] + public readonly byte[] name; + public readonly byte endMasSeq; + public readonly uint magic; + public readonly byte checkByte; + } + + /// Directory tail, old format + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct OldDirectoryTail + { + public readonly byte lastMark; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] + public readonly byte[] name; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] parent; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 19)] + public readonly byte[] title; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + public readonly byte[] reserved; + public readonly byte endMasSeq; + public readonly uint magic; + public readonly byte checkByte; + } + + /// Directory, old format + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct OldDirectory + { + public readonly DirectoryHeader header; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 47)] + public readonly DirectoryEntry[] entries; + public readonly OldDirectoryTail tail; + } + + /// Directory, new format + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct NewDirectory + { + public readonly DirectoryHeader header; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 77)] + public readonly DirectoryEntry[] entries; + public readonly NewDirectoryTail tail; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/AmigaDOS/AmigaDOS.cs b/Aaru.Filesystems/AmigaDOS/AmigaDOS.cs new file mode 100644 index 000000000..2aabec274 --- /dev/null +++ b/Aaru.Filesystems/AmigaDOS/AmigaDOS.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : AmigaDOS.cs +// Author(s) : Natalia Portillo +// +// Component : Amiga Fast File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Amiga Fast File System (AFFS) +public sealed partial class AmigaDOSPlugin : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public string Name => Localization.AmigaDOSPlugin_Name; + /// + public Guid Id => new("3c882400-208c-427d-a086-9119852a1bc7"); + /// + public Encoding Encoding { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AmigaDOS/Consts.cs b/Aaru.Filesystems/AmigaDOS/Consts.cs new file mode 100644 index 000000000..6649eece1 --- /dev/null +++ b/Aaru.Filesystems/AmigaDOS/Consts.cs @@ -0,0 +1,45 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Amiga Fast File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Amiga Fast File System (AFFS) +public sealed partial class AmigaDOSPlugin +{ + const uint FFS_MASK = 0x444F5300; + const uint MUFS_MASK = 0x6D754600; + + const uint TYPE_HEADER = 2; + const uint SUBTYPE_ROOT = 1; + + const string FS_TYPE_OFS = "aofs"; + const string FS_TYPE_FFS = "affs"; + const string FS_TYPE_OFS2 = "aofs2"; + const string FS_TYPE_FFS2 = "affs2"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AmigaDOS/Helpers.cs b/Aaru.Filesystems/AmigaDOS/Helpers.cs new file mode 100644 index 000000000..c3c3873c4 --- /dev/null +++ b/Aaru.Filesystems/AmigaDOS/Helpers.cs @@ -0,0 +1,76 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Helpers.cs +// Author(s) : Natalia Portillo +// +// Component : Amiga Fast File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using Aaru.Helpers; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Amiga Fast File System (AFFS) +public sealed partial class AmigaDOSPlugin +{ + static RootBlock MarshalRootBlock(byte[] block) + { + byte[] tmp = new byte[228]; + Array.Copy(block, 0, tmp, 0, 24); + Array.Copy(block, block.Length - 200, tmp, 28, 200); + RootBlock root = Marshal.ByteArrayToStructureBigEndian(tmp); + root.hashTable = new uint[(block.Length - 224) / 4]; + + for(int i = 0; i < root.hashTable.Length; i++) + root.hashTable[i] = BigEndianBitConverter.ToUInt32(block, 24 + (i * 4)); + + return root; + } + + static uint AmigaChecksum(byte[] data) + { + uint sum = 0; + + for(int i = 0; i < data.Length; i += 4) + sum += (uint)((data[i] << 24) + (data[i + 1] << 16) + (data[i + 2] << 8) + data[i + 3]); + + return (uint)-sum; + } + + static uint AmigaBootChecksum(byte[] data) + { + uint sum = 0; + + for(int i = 0; i < data.Length; i += 4) + { + uint psum = sum; + + if((sum += (uint)((data[i] << 24) + (data[i + 1] << 16) + (data[i + 2] << 8) + data[i + 3])) < psum) + sum++; + } + + return ~sum; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/AmigaDOS.cs b/Aaru.Filesystems/AmigaDOS/Info.cs similarity index 70% rename from Aaru.Filesystems/AmigaDOS.cs rename to Aaru.Filesystems/AmigaDOS/Info.cs index fa91e076a..d2f9ee024 100644 --- a/Aaru.Filesystems/AmigaDOS.cs +++ b/Aaru.Filesystems/AmigaDOS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : AmigaDOS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Amiga Fast File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Amiga Fast File System and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,7 +28,6 @@ using System; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.Checksums; using Aaru.CommonTypes; @@ -41,36 +36,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of Amiga Fast File System (AFFS) -public sealed class AmigaDOSPlugin : IFilesystem +public sealed partial class AmigaDOSPlugin { - const uint FFS_MASK = 0x444F5300; - const uint MUFS_MASK = 0x6D754600; - - const uint TYPE_HEADER = 2; - const uint SUBTYPE_ROOT = 1; - - const string FS_TYPE_OFS = "aofs"; - const string FS_TYPE_FFS = "affs"; - const string FS_TYPE_OFS2 = "aofs2"; - const string FS_TYPE_FFS2 = "affs2"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public string Name => Localization.AmigaDOSPlugin_Name; - /// - public Guid Id => new("3c882400-208c-427d-a086-9119852a1bc7"); - /// - public Encoding Encoding { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -409,123 +381,4 @@ public sealed class AmigaDOSPlugin : IFilesystem // Useful as a serial XmlFsType.VolumeSerial = $"{rootBlk.checksum:X8}"; } - - static RootBlock MarshalRootBlock(byte[] block) - { - byte[] tmp = new byte[228]; - Array.Copy(block, 0, tmp, 0, 24); - Array.Copy(block, block.Length - 200, tmp, 28, 200); - RootBlock root = Marshal.ByteArrayToStructureBigEndian(tmp); - root.hashTable = new uint[(block.Length - 224) / 4]; - - for(int i = 0; i < root.hashTable.Length; i++) - root.hashTable[i] = BigEndianBitConverter.ToUInt32(block, 24 + (i * 4)); - - return root; - } - - static uint AmigaChecksum(byte[] data) - { - uint sum = 0; - - for(int i = 0; i < data.Length; i += 4) - sum += (uint)((data[i] << 24) + (data[i + 1] << 16) + (data[i + 2] << 8) + data[i + 3]); - - return (uint)-sum; - } - - static uint AmigaBootChecksum(byte[] data) - { - uint sum = 0; - - for(int i = 0; i < data.Length; i += 4) - { - uint psum = sum; - - if((sum += (uint)((data[i] << 24) + (data[i + 1] << 16) + (data[i + 2] << 8) + data[i + 3])) < psum) - sum++; - } - - return ~sum; - } - - /// Boot block, first 2 sectors - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BootBlock - { - /// Offset 0x00, "DOSx" disk type - public readonly uint diskType; - /// Offset 0x04, Checksum - public readonly uint checksum; - /// Offset 0x08, Pointer to root block, mostly invalid - public readonly uint root_ptr; - /// Offset 0x0C, Boot code, til completion. Size is intentionally incorrect to allow marshaling to work. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] - public byte[] bootCode; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RootBlock - { - /// Offset 0x00, block type, value = T_HEADER (2) - public uint type; - /// Offset 0x04, unused - public readonly uint headerKey; - /// Offset 0x08, unused - public readonly uint highSeq; - /// Offset 0x0C, longs used by hash table - public uint hashTableSize; - /// Offset 0x10, unused - public readonly uint firstData; - /// Offset 0x14, Rootblock checksum - public uint checksum; - /// - /// Offset 0x18, Hashtable, size = (block size / 4) - 56 or size = hashTableSize. Size intentionally bad to allow - /// marshalling to work. - /// - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] - public uint[] hashTable; - /// Offset 0x18+hashTableSize*4+0, bitmap flag, 0xFFFFFFFF if valid - public readonly uint bitmapFlag; - /// Offset 0x18+hashTableSize*4+4, bitmap pages, 25 entries - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 25)] - public readonly uint[] bitmapPages; - /// Offset 0x18+hashTableSize*4+104, pointer to bitmap extension block - public readonly uint bitmapExtensionBlock; - /// Offset 0x18+hashTableSize*4+108, last root alteration days since 1978/01/01 - public readonly uint rDays; - /// Offset 0x18+hashTableSize*4+112, last root alteration minutes past midnight - public readonly uint rMins; - /// Offset 0x18+hashTableSize*4+116, last root alteration ticks (1/50 secs) - public readonly uint rTicks; - /// Offset 0x18+hashTableSize*4+120, disk name, pascal string, 31 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)] - public readonly byte[] diskName; - /// Offset 0x18+hashTableSize*4+151, unused - public readonly byte padding; - /// Offset 0x18+hashTableSize*4+152, unused - public readonly uint reserved1; - /// Offset 0x18+hashTableSize*4+156, unused - public readonly uint reserved2; - /// Offset 0x18+hashTableSize*4+160, last disk alteration days since 1978/01/01 - public readonly uint vDays; - /// Offset 0x18+hashTableSize*4+164, last disk alteration minutes past midnight - public readonly uint vMins; - /// Offset 0x18+hashTableSize*4+168, last disk alteration ticks (1/50 secs) - public readonly uint vTicks; - /// Offset 0x18+hashTableSize*4+172, filesystem creation days since 1978/01/01 - public readonly uint cDays; - /// Offset 0x18+hashTableSize*4+176, filesystem creation minutes since 1978/01/01 - public readonly uint cMins; - /// Offset 0x18+hashTableSize*4+180, filesystem creation ticks since 1978/01/01 - public readonly uint cTicks; - /// Offset 0x18+hashTableSize*4+184, unused - public readonly uint nextHash; - /// Offset 0x18+hashTableSize*4+188, unused - public readonly uint parentDir; - /// Offset 0x18+hashTableSize*4+192, first directory cache block - public readonly uint extension; - /// Offset 0x18+hashTableSize*4+196, block secondary type = ST_ROOT (1) - public uint sec_type; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/AmigaDOS/Structs.cs b/Aaru.Filesystems/AmigaDOS/Structs.cs new file mode 100644 index 000000000..d6644c808 --- /dev/null +++ b/Aaru.Filesystems/AmigaDOS/Structs.cs @@ -0,0 +1,116 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Amiga Fast File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Amiga Fast File System (AFFS) +public sealed partial class AmigaDOSPlugin +{ + /// Boot block, first 2 sectors + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct BootBlock + { + /// Offset 0x00, "DOSx" disk type + public readonly uint diskType; + /// Offset 0x04, Checksum + public readonly uint checksum; + /// Offset 0x08, Pointer to root block, mostly invalid + public readonly uint root_ptr; + /// Offset 0x0C, Boot code, til completion. Size is intentionally incorrect to allow marshaling to work. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] + public byte[] bootCode; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct RootBlock + { + /// Offset 0x00, block type, value = T_HEADER (2) + public uint type; + /// Offset 0x04, unused + public readonly uint headerKey; + /// Offset 0x08, unused + public readonly uint highSeq; + /// Offset 0x0C, longs used by hash table + public uint hashTableSize; + /// Offset 0x10, unused + public readonly uint firstData; + /// Offset 0x14, Rootblock checksum + public uint checksum; + /// + /// Offset 0x18, Hashtable, size = (block size / 4) - 56 or size = hashTableSize. Size intentionally bad to allow + /// marshalling to work. + /// + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] + public uint[] hashTable; + /// Offset 0x18+hashTableSize*4+0, bitmap flag, 0xFFFFFFFF if valid + public readonly uint bitmapFlag; + /// Offset 0x18+hashTableSize*4+4, bitmap pages, 25 entries + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 25)] + public readonly uint[] bitmapPages; + /// Offset 0x18+hashTableSize*4+104, pointer to bitmap extension block + public readonly uint bitmapExtensionBlock; + /// Offset 0x18+hashTableSize*4+108, last root alteration days since 1978/01/01 + public readonly uint rDays; + /// Offset 0x18+hashTableSize*4+112, last root alteration minutes past midnight + public readonly uint rMins; + /// Offset 0x18+hashTableSize*4+116, last root alteration ticks (1/50 secs) + public readonly uint rTicks; + /// Offset 0x18+hashTableSize*4+120, disk name, pascal string, 31 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)] + public readonly byte[] diskName; + /// Offset 0x18+hashTableSize*4+151, unused + public readonly byte padding; + /// Offset 0x18+hashTableSize*4+152, unused + public readonly uint reserved1; + /// Offset 0x18+hashTableSize*4+156, unused + public readonly uint reserved2; + /// Offset 0x18+hashTableSize*4+160, last disk alteration days since 1978/01/01 + public readonly uint vDays; + /// Offset 0x18+hashTableSize*4+164, last disk alteration minutes past midnight + public readonly uint vMins; + /// Offset 0x18+hashTableSize*4+168, last disk alteration ticks (1/50 secs) + public readonly uint vTicks; + /// Offset 0x18+hashTableSize*4+172, filesystem creation days since 1978/01/01 + public readonly uint cDays; + /// Offset 0x18+hashTableSize*4+176, filesystem creation minutes since 1978/01/01 + public readonly uint cMins; + /// Offset 0x18+hashTableSize*4+180, filesystem creation ticks since 1978/01/01 + public readonly uint cTicks; + /// Offset 0x18+hashTableSize*4+184, unused + public readonly uint nextHash; + /// Offset 0x18+hashTableSize*4+188, unused + public readonly uint parentDir; + /// Offset 0x18+hashTableSize*4+192, first directory cache block + public readonly uint extension; + /// Offset 0x18+hashTableSize*4+196, block secondary type = ST_ROOT (1) + public uint sec_type; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/AppleCommon/Consts.cs b/Aaru.Filesystems/AppleCommon/Consts.cs index 32e5b1307..0a839636d 100644 --- a/Aaru.Filesystems/AppleCommon/Consts.cs +++ b/Aaru.Filesystems/AppleCommon/Consts.cs @@ -7,10 +7,6 @@ // // Component : Common Apple file systems. // -// --[ Description ] ---------------------------------------------------------- -// -// Common Apple file systems constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleCommon/Enums.cs b/Aaru.Filesystems/AppleCommon/Enums.cs index 5f51f2583..89ebdefca 100644 --- a/Aaru.Filesystems/AppleCommon/Enums.cs +++ b/Aaru.Filesystems/AppleCommon/Enums.cs @@ -7,10 +7,6 @@ // // Component : Common Apple file systems. // -// --[ Description ] ---------------------------------------------------------- -// -// Common Apple file systems enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleCommon/Info.cs b/Aaru.Filesystems/AppleCommon/Info.cs index 1d2bca6fb..e495ef3c5 100644 --- a/Aaru.Filesystems/AppleCommon/Info.cs +++ b/Aaru.Filesystems/AppleCommon/Info.cs @@ -7,10 +7,6 @@ // // Component : Common Apple file systems. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Macintosh Boot Block information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleCommon/Structs.cs b/Aaru.Filesystems/AppleCommon/Structs.cs index 719f11a58..ffb3d4048 100644 --- a/Aaru.Filesystems/AppleCommon/Structs.cs +++ b/Aaru.Filesystems/AppleCommon/Structs.cs @@ -7,10 +7,6 @@ // // Component : Common Apple file systems. // -// --[ Description ] ---------------------------------------------------------- -// -// Common Apple file systems structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleDOS/AppleDOS.cs b/Aaru.Filesystems/AppleDOS/AppleDOS.cs index 6cbb6e6b1..2a761e25c 100644 --- a/Aaru.Filesystems/AppleDOS/AppleDOS.cs +++ b/Aaru.Filesystems/AppleDOS/AppleDOS.cs @@ -7,10 +7,6 @@ // // Component : Apple DOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Constructors and common variables for the Apple DOS filesystem plugin. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleDOS/File.cs b/Aaru.Filesystems/AppleDOS/File.cs index 0b9add2bd..8fa7bfe87 100644 --- a/Aaru.Filesystems/AppleDOS/File.cs +++ b/Aaru.Filesystems/AppleDOS/File.cs @@ -7,10 +7,6 @@ // // Component : Apple DOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleDOS/Info.cs b/Aaru.Filesystems/AppleDOS/Info.cs index 45079c4c8..85bb347e8 100644 --- a/Aaru.Filesystems/AppleDOS/Info.cs +++ b/Aaru.Filesystems/AppleDOS/Info.cs @@ -7,10 +7,6 @@ // // Component : Apple DOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Apple DOS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleDOS/Structs.cs b/Aaru.Filesystems/AppleDOS/Structs.cs index fc351eac0..20c1e971a 100644 --- a/Aaru.Filesystems/AppleDOS/Structs.cs +++ b/Aaru.Filesystems/AppleDOS/Structs.cs @@ -7,10 +7,6 @@ // // Component : Apple DOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple DOS filesystem structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleDOS/Super.cs b/Aaru.Filesystems/AppleDOS/Super.cs index d889ff368..51e4dc93c 100644 --- a/Aaru.Filesystems/AppleDOS/Super.cs +++ b/Aaru.Filesystems/AppleDOS/Super.cs @@ -7,10 +7,6 @@ // // Component : Apple DOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles mounting and umounting the Apple DOS filesystem. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleHFS/Consts.cs b/Aaru.Filesystems/AppleHFS/Consts.cs index 5e450b58a..49e643916 100644 --- a/Aaru.Filesystems/AppleHFS/Consts.cs +++ b/Aaru.Filesystems/AppleHFS/Consts.cs @@ -7,10 +7,6 @@ // // Component : Apple Hierarchical File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Hierarchical File System constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleHFS/Enums.cs b/Aaru.Filesystems/AppleHFS/Enums.cs index dc568976d..158ab4ab2 100644 --- a/Aaru.Filesystems/AppleHFS/Enums.cs +++ b/Aaru.Filesystems/AppleHFS/Enums.cs @@ -7,10 +7,6 @@ // // Component : Apple Hierarchical File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Hierarchical File System enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleHFS/Info.cs b/Aaru.Filesystems/AppleHFS/Info.cs index 3debda809..21624fb41 100644 --- a/Aaru.Filesystems/AppleHFS/Info.cs +++ b/Aaru.Filesystems/AppleHFS/Info.cs @@ -7,10 +7,6 @@ // // 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 diff --git a/Aaru.Filesystems/AppleHFS/Structs.cs b/Aaru.Filesystems/AppleHFS/Structs.cs index c2e854aae..e823a86fb 100644 --- a/Aaru.Filesystems/AppleHFS/Structs.cs +++ b/Aaru.Filesystems/AppleHFS/Structs.cs @@ -7,10 +7,6 @@ // // Component : Apple Hierarchical File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Hierarchical File System structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleHFSPlus/AppleHFSPlus.cs b/Aaru.Filesystems/AppleHFSPlus/AppleHFSPlus.cs new file mode 100644 index 000000000..6c4b03e43 --- /dev/null +++ b/Aaru.Filesystems/AppleHFSPlus/AppleHFSPlus.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : AppleHFSPlus.cs +// Author(s) : Natalia Portillo +// +// Component : Apple Hierarchical File System Plus plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html +/// +/// Implements detection of Apple Hierarchical File System Plus (HFS+) +public sealed partial class AppleHFSPlus : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.AppleHFSPlus_Name; + /// + public Guid Id => new("36405F8D-0D26-6EBE-436F-62F0586B4F08"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AppleHFSPlus/Consts.cs b/Aaru.Filesystems/AppleHFSPlus/Consts.cs new file mode 100644 index 000000000..b76ed89bb --- /dev/null +++ b/Aaru.Filesystems/AppleHFSPlus/Consts.cs @@ -0,0 +1,38 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Apple Hierarchical File System Plus plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html +/// +/// Implements detection of Apple Hierarchical File System Plus (HFS+) +public sealed partial class AppleHFSPlus +{ + const string FS_TYPE_HFSP = "hfsplus"; + const string FS_TYPE_HFSX = "hfsx"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AppleHFSPlus/Info.cs b/Aaru.Filesystems/AppleHFSPlus/Info.cs new file mode 100644 index 000000000..21c20f8ac --- /dev/null +++ b/Aaru.Filesystems/AppleHFSPlus/Info.cs @@ -0,0 +1,313 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Info.cs +// Author(s) : Natalia Portillo +// +// Component : Apple Hierarchical File System Plus plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.Helpers; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html +/// +/// Implements detection of Apple Hierarchical File System Plus (HFS+) +public sealed partial class AppleHFSPlus +{ + /// + public bool Identify(IMediaImage imagePlugin, Partition partition) + { + if(2 + partition.Start >= partition.End) + return false; + + ulong hfspOffset; + + uint sectorsToRead = 0x800 / imagePlugin.Info.SectorSize; + + if(0x800 % imagePlugin.Info.SectorSize > 0) + sectorsToRead++; + + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector); + + if(errno != ErrorNumber.NoError) + return false; + + if(vhSector.Length < 0x800) + return false; + + ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); + + if(drSigWord == AppleCommon.HFS_MAGIC) // "BD" + { + drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x47C); // Read embedded HFS+ signature + + if(drSigWord == AppleCommon.HFSP_MAGIC) // "H+" + { + // ReSharper disable once InconsistentNaming + ushort xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); + + uint drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); + + ushort drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); + + hfspOffset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.Info.SectorSize); + } + else + hfspOffset = 0; + } + else + hfspOffset = 0; + + errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, sectorsToRead, + out vhSector); // Read volume header + + if(errno != ErrorNumber.NoError) + return false; + + drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); + + return drSigWord is AppleCommon.HFSP_MAGIC or AppleCommon.HFSX_MAGIC; + } + + /// + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) + { + Encoding = Encoding.BigEndianUnicode; + information = ""; + + var vh = new VolumeHeader(); + + ulong hfspOffset; + bool wrapped; + + uint sectorsToRead = 0x800 / imagePlugin.Info.SectorSize; + + if(0x800 % imagePlugin.Info.SectorSize > 0) + sectorsToRead++; + + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector); + + if(errno != ErrorNumber.NoError) + return; + + ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); + + if(drSigWord == AppleCommon.HFS_MAGIC) // "BD" + { + drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x47C); // Read embedded HFS+ signature + + if(drSigWord == AppleCommon.HFSP_MAGIC) // "H+" + { + // ReSharper disable once InconsistentNaming + ushort xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); + + uint drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); + + ushort drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); + + hfspOffset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.Info.SectorSize); + wrapped = true; + } + else + { + hfspOffset = 0; + wrapped = false; + } + } + else + { + hfspOffset = 0; + wrapped = false; + } + + errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, sectorsToRead, + out vhSector); // Read volume header + + if(errno != ErrorNumber.NoError) + return; + + vh.signature = BigEndianBitConverter.ToUInt16(vhSector, 0x400); + + if(vh.signature != AppleCommon.HFSP_MAGIC && + vh.signature != AppleCommon.HFSX_MAGIC) + return; + + var sb = new StringBuilder(); + + switch(vh.signature) + { + case 0x482B: + sb.AppendLine(Localization.HFS_filesystem); + + break; + case 0x4858: + sb.AppendLine(Localization.HFSX_filesystem); + + break; + } + + if(wrapped) + sb.AppendLine(Localization.Volume_is_wrapped_inside_an_HFS_volume); + + byte[] tmp = new byte[0x400]; + Array.Copy(vhSector, 0x400, tmp, 0, 0x400); + vhSector = tmp; + + vh = Marshal.ByteArrayToStructureBigEndian(vhSector); + + if(vh.version is 4 or 5) + { + sb.AppendFormat(Localization.Filesystem_version_is_0, vh.version).AppendLine(); + + if((vh.attributes & 0x80) == 0x80) + sb.AppendLine(Localization.Volume_is_locked_on_hardware); + + if((vh.attributes & 0x100) == 0x100) + sb.AppendLine(Localization.Volume_is_unmounted); + + if((vh.attributes & 0x200) == 0x200) + sb.AppendLine(Localization.There_are_bad_blocks_in_the_extents_file); + + if((vh.attributes & 0x400) == 0x400) + sb.AppendLine(Localization.Volume_does_not_require_cache); + + if((vh.attributes & 0x800) == 0x800) + sb.AppendLine(Localization.Volume_state_is_inconsistent); + + if((vh.attributes & 0x1000) == 0x1000) + sb.AppendLine(Localization.There_are_reused_CNIDs); + + if((vh.attributes & 0x2000) == 0x2000) + sb.AppendLine(Localization.Volume_is_journaled); + + if((vh.attributes & 0x8000) == 0x8000) + sb.AppendLine(Localization.Volume_is_locked_on_software); + + sb.AppendFormat(Localization.Implementation_that_last_mounted_the_volume_0, + Encoding.ASCII.GetString(vh.lastMountedVersion)).AppendLine(); + + if((vh.attributes & 0x2000) == 0x2000) + sb.AppendFormat(Localization.Journal_starts_at_allocation_block_0, vh.journalInfoBlock).AppendLine(); + + sb.AppendFormat(Localization.Creation_date_0, DateHandlers.MacToDateTime(vh.createDate)).AppendLine(); + + sb.AppendFormat(Localization.Last_modification_date_0, DateHandlers.MacToDateTime(vh.modifyDate)). + AppendLine(); + + if(vh.backupDate > 0) + sb.AppendFormat(Localization.Last_backup_date_0, DateHandlers.MacToDateTime(vh.backupDate)). + AppendLine(); + else + sb.AppendLine(Localization.Volume_has_never_been_backed_up); + + if(vh.backupDate > 0) + sb.AppendFormat(Localization.Last_check_date_0, DateHandlers.MacToDateTime(vh.checkedDate)). + AppendLine(); + else + sb.AppendLine(Localization.Volume_has_never_been_checked_up); + + sb.AppendFormat(Localization._0_files_on_volume, vh.fileCount).AppendLine(); + sb.AppendFormat(Localization._0_folders_on_volume, vh.folderCount).AppendLine(); + sb.AppendFormat(Localization._0_bytes_per_allocation_block, vh.blockSize).AppendLine(); + sb.AppendFormat(Localization._0_allocation_blocks, vh.totalBlocks).AppendLine(); + sb.AppendFormat(Localization._0_free_blocks, vh.freeBlocks).AppendLine(); + sb.AppendFormat(Localization.Next_allocation_block_0, vh.nextAllocation).AppendLine(); + sb.AppendFormat(Localization.Resource_fork_clump_size_0_bytes, vh.rsrcClumpSize).AppendLine(); + sb.AppendFormat(Localization.Data_fork_clump_size_0_bytes, vh.dataClumpSize).AppendLine(); + sb.AppendFormat(Localization.Next_unused_CNID_0, vh.nextCatalogID).AppendLine(); + sb.AppendFormat(Localization.Volume_has_been_mounted_writable_0_times, vh.writeCount).AppendLine(); + sb.AppendFormat(Localization.Allocation_File_is_0_bytes, vh.allocationFile_logicalSize).AppendLine(); + sb.AppendFormat(Localization.Extents_File_is_0_bytes, vh.extentsFile_logicalSize).AppendLine(); + sb.AppendFormat(Localization.Catalog_File_is_0_bytes, vh.catalogFile_logicalSize).AppendLine(); + sb.AppendFormat(Localization.Attributes_File_is_0_bytes, vh.attributesFile_logicalSize).AppendLine(); + sb.AppendFormat(Localization.Startup_File_is_0_bytes, vh.startupFile_logicalSize).AppendLine(); + sb.AppendLine(Localization.Finder_info); + sb.AppendFormat(Localization.CNID_of_bootable_system_directory_0, vh.drFndrInfo0).AppendLine(); + sb.AppendFormat(Localization.CNID_of_first_run_application_directory_0, vh.drFndrInfo1).AppendLine(); + sb.AppendFormat(Localization.CNID_of_previously_opened_directory_0, vh.drFndrInfo2).AppendLine(); + sb.AppendFormat(Localization.CNID_of_bootable_Mac_OS_8_or_9_directory_0, vh.drFndrInfo3).AppendLine(); + sb.AppendFormat(Localization.CNID_of_bootable_Mac_OS_X_directory_0, vh.drFndrInfo5).AppendLine(); + + if(vh.drFndrInfo6 != 0 && + vh.drFndrInfo7 != 0) + sb.AppendFormat(Localization.Mac_OS_X_Volume_ID_0_1, vh.drFndrInfo6, vh.drFndrInfo7).AppendLine(); + + XmlFsType = new FileSystemType(); + + if(vh.backupDate > 0) + { + XmlFsType.BackupDate = DateHandlers.MacToDateTime(vh.backupDate); + XmlFsType.BackupDateSpecified = true; + } + + XmlFsType.Bootable |= vh.drFndrInfo0 != 0 || vh.drFndrInfo3 != 0 || vh.drFndrInfo5 != 0; + XmlFsType.Clusters = vh.totalBlocks; + XmlFsType.ClusterSize = vh.blockSize; + + if(vh.createDate > 0) + { + XmlFsType.CreationDate = DateHandlers.MacToDateTime(vh.createDate); + XmlFsType.CreationDateSpecified = true; + } + + XmlFsType.Dirty = (vh.attributes & 0x100) != 0x100; + XmlFsType.Files = vh.fileCount; + XmlFsType.FilesSpecified = true; + XmlFsType.FreeClusters = vh.freeBlocks; + XmlFsType.FreeClustersSpecified = true; + + if(vh.modifyDate > 0) + { + XmlFsType.ModificationDate = DateHandlers.MacToDateTime(vh.modifyDate); + XmlFsType.ModificationDateSpecified = true; + } + + XmlFsType.Type = vh.signature switch + { + 0x482B => FS_TYPE_HFSP, + 0x4858 => FS_TYPE_HFSX, + _ => XmlFsType.Type + }; + + if(vh.drFndrInfo6 != 0 && + vh.drFndrInfo7 != 0) + XmlFsType.VolumeSerial = $"{vh.drFndrInfo6:X8}{vh.drFndrInfo7:X8}"; + + XmlFsType.SystemIdentifier = Encoding.ASCII.GetString(vh.lastMountedVersion); + } + else + { + sb.AppendFormat(Localization.Filesystem_version_is_0, vh.version).AppendLine(); + sb.AppendLine(Localization.This_version_is_not_supported_yet); + } + + information = sb.ToString(); + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/AppleHFSPlus.cs b/Aaru.Filesystems/AppleHFSPlus/Structs.cs similarity index 55% rename from Aaru.Filesystems/AppleHFSPlus.cs rename to Aaru.Filesystems/AppleHFSPlus/Structs.cs index 968593c83..5965bd604 100644 --- a/Aaru.Filesystems/AppleHFSPlus.cs +++ b/Aaru.Filesystems/AppleHFSPlus/Structs.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : AppleHFSPlus.cs +// Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : Apple Hierarchical File System Plus plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Apple Hierarchical File System Plus and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,306 +26,15 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; -using System.Text; -using Aaru.CommonTypes; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; -using Aaru.Helpers; -using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; // Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html /// /// Implements detection of Apple Hierarchical File System Plus (HFS+) -public sealed class AppleHFSPlus : IFilesystem +public sealed partial class AppleHFSPlus { - const string FS_TYPE_HFSP = "hfsplus"; - const string FS_TYPE_HFSX = "hfsx"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.AppleHFSPlus_Name; - /// - public Guid Id => new("36405F8D-0D26-6EBE-436F-62F0586B4F08"); - /// - public string Author => Authors.NataliaPortillo; - - /// - public bool Identify(IMediaImage imagePlugin, Partition partition) - { - if(2 + partition.Start >= partition.End) - return false; - - ulong hfspOffset; - - uint sectorsToRead = 0x800 / imagePlugin.Info.SectorSize; - - if(0x800 % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; - - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector); - - if(errno != ErrorNumber.NoError) - return false; - - if(vhSector.Length < 0x800) - return false; - - ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); - - if(drSigWord == AppleCommon.HFS_MAGIC) // "BD" - { - drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x47C); // Read embedded HFS+ signature - - if(drSigWord == AppleCommon.HFSP_MAGIC) // "H+" - { - // ReSharper disable once InconsistentNaming - ushort xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); - - uint drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); - - ushort drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); - - hfspOffset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.Info.SectorSize); - } - else - hfspOffset = 0; - } - else - hfspOffset = 0; - - errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, sectorsToRead, - out vhSector); // Read volume header - - if(errno != ErrorNumber.NoError) - return false; - - drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); - - return drSigWord is AppleCommon.HFSP_MAGIC or AppleCommon.HFSX_MAGIC; - } - - /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) - { - Encoding = Encoding.BigEndianUnicode; - information = ""; - - var vh = new VolumeHeader(); - - ulong hfspOffset; - bool wrapped; - - uint sectorsToRead = 0x800 / imagePlugin.Info.SectorSize; - - if(0x800 % imagePlugin.Info.SectorSize > 0) - sectorsToRead++; - - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sectorsToRead, out byte[] vhSector); - - if(errno != ErrorNumber.NoError) - return; - - ushort drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x400); - - if(drSigWord == AppleCommon.HFS_MAGIC) // "BD" - { - drSigWord = BigEndianBitConverter.ToUInt16(vhSector, 0x47C); // Read embedded HFS+ signature - - if(drSigWord == AppleCommon.HFSP_MAGIC) // "H+" - { - // ReSharper disable once InconsistentNaming - ushort xdrStABNt = BigEndianBitConverter.ToUInt16(vhSector, 0x47E); - - uint drAlBlkSiz = BigEndianBitConverter.ToUInt32(vhSector, 0x414); - - ushort drAlBlSt = BigEndianBitConverter.ToUInt16(vhSector, 0x41C); - - hfspOffset = (ulong)(((drAlBlSt * 512) + (xdrStABNt * drAlBlkSiz)) / imagePlugin.Info.SectorSize); - wrapped = true; - } - else - { - hfspOffset = 0; - wrapped = false; - } - } - else - { - hfspOffset = 0; - wrapped = false; - } - - errno = imagePlugin.ReadSectors(partition.Start + hfspOffset, sectorsToRead, - out vhSector); // Read volume header - - if(errno != ErrorNumber.NoError) - return; - - vh.signature = BigEndianBitConverter.ToUInt16(vhSector, 0x400); - - if(vh.signature != AppleCommon.HFSP_MAGIC && - vh.signature != AppleCommon.HFSX_MAGIC) - return; - - var sb = new StringBuilder(); - - switch(vh.signature) - { - case 0x482B: - sb.AppendLine(Localization.HFS_filesystem); - - break; - case 0x4858: - sb.AppendLine(Localization.HFSX_filesystem); - - break; - } - - if(wrapped) - sb.AppendLine(Localization.Volume_is_wrapped_inside_an_HFS_volume); - - byte[] tmp = new byte[0x400]; - Array.Copy(vhSector, 0x400, tmp, 0, 0x400); - vhSector = tmp; - - vh = Marshal.ByteArrayToStructureBigEndian(vhSector); - - if(vh.version is 4 or 5) - { - sb.AppendFormat(Localization.Filesystem_version_is_0, vh.version).AppendLine(); - - if((vh.attributes & 0x80) == 0x80) - sb.AppendLine(Localization.Volume_is_locked_on_hardware); - - if((vh.attributes & 0x100) == 0x100) - sb.AppendLine(Localization.Volume_is_unmounted); - - if((vh.attributes & 0x200) == 0x200) - sb.AppendLine(Localization.There_are_bad_blocks_in_the_extents_file); - - if((vh.attributes & 0x400) == 0x400) - sb.AppendLine(Localization.Volume_does_not_require_cache); - - if((vh.attributes & 0x800) == 0x800) - sb.AppendLine(Localization.Volume_state_is_inconsistent); - - if((vh.attributes & 0x1000) == 0x1000) - sb.AppendLine(Localization.There_are_reused_CNIDs); - - if((vh.attributes & 0x2000) == 0x2000) - sb.AppendLine(Localization.Volume_is_journaled); - - if((vh.attributes & 0x8000) == 0x8000) - sb.AppendLine(Localization.Volume_is_locked_on_software); - - sb.AppendFormat(Localization.Implementation_that_last_mounted_the_volume_0, - Encoding.ASCII.GetString(vh.lastMountedVersion)).AppendLine(); - - if((vh.attributes & 0x2000) == 0x2000) - sb.AppendFormat(Localization.Journal_starts_at_allocation_block_0, vh.journalInfoBlock).AppendLine(); - - sb.AppendFormat(Localization.Creation_date_0, DateHandlers.MacToDateTime(vh.createDate)).AppendLine(); - - sb.AppendFormat(Localization.Last_modification_date_0, DateHandlers.MacToDateTime(vh.modifyDate)). - AppendLine(); - - if(vh.backupDate > 0) - sb.AppendFormat(Localization.Last_backup_date_0, DateHandlers.MacToDateTime(vh.backupDate)). - AppendLine(); - else - sb.AppendLine(Localization.Volume_has_never_been_backed_up); - - if(vh.backupDate > 0) - sb.AppendFormat(Localization.Last_check_date_0, DateHandlers.MacToDateTime(vh.checkedDate)). - AppendLine(); - else - sb.AppendLine(Localization.Volume_has_never_been_checked_up); - - sb.AppendFormat(Localization._0_files_on_volume, vh.fileCount).AppendLine(); - sb.AppendFormat(Localization._0_folders_on_volume, vh.folderCount).AppendLine(); - sb.AppendFormat(Localization._0_bytes_per_allocation_block, vh.blockSize).AppendLine(); - sb.AppendFormat(Localization._0_allocation_blocks, vh.totalBlocks).AppendLine(); - sb.AppendFormat(Localization._0_free_blocks, vh.freeBlocks).AppendLine(); - sb.AppendFormat(Localization.Next_allocation_block_0, vh.nextAllocation).AppendLine(); - sb.AppendFormat(Localization.Resource_fork_clump_size_0_bytes, vh.rsrcClumpSize).AppendLine(); - sb.AppendFormat(Localization.Data_fork_clump_size_0_bytes, vh.dataClumpSize).AppendLine(); - sb.AppendFormat(Localization.Next_unused_CNID_0, vh.nextCatalogID).AppendLine(); - sb.AppendFormat(Localization.Volume_has_been_mounted_writable_0_times, vh.writeCount).AppendLine(); - sb.AppendFormat(Localization.Allocation_File_is_0_bytes, vh.allocationFile_logicalSize).AppendLine(); - sb.AppendFormat(Localization.Extents_File_is_0_bytes, vh.extentsFile_logicalSize).AppendLine(); - sb.AppendFormat(Localization.Catalog_File_is_0_bytes, vh.catalogFile_logicalSize).AppendLine(); - sb.AppendFormat(Localization.Attributes_File_is_0_bytes, vh.attributesFile_logicalSize).AppendLine(); - sb.AppendFormat(Localization.Startup_File_is_0_bytes, vh.startupFile_logicalSize).AppendLine(); - sb.AppendLine(Localization.Finder_info); - sb.AppendFormat(Localization.CNID_of_bootable_system_directory_0, vh.drFndrInfo0).AppendLine(); - sb.AppendFormat(Localization.CNID_of_first_run_application_directory_0, vh.drFndrInfo1).AppendLine(); - sb.AppendFormat(Localization.CNID_of_previously_opened_directory_0, vh.drFndrInfo2).AppendLine(); - sb.AppendFormat(Localization.CNID_of_bootable_Mac_OS_8_or_9_directory_0, vh.drFndrInfo3).AppendLine(); - sb.AppendFormat(Localization.CNID_of_bootable_Mac_OS_X_directory_0, vh.drFndrInfo5).AppendLine(); - - if(vh.drFndrInfo6 != 0 && - vh.drFndrInfo7 != 0) - sb.AppendFormat(Localization.Mac_OS_X_Volume_ID_0_1, vh.drFndrInfo6, vh.drFndrInfo7).AppendLine(); - - XmlFsType = new FileSystemType(); - - if(vh.backupDate > 0) - { - XmlFsType.BackupDate = DateHandlers.MacToDateTime(vh.backupDate); - XmlFsType.BackupDateSpecified = true; - } - - XmlFsType.Bootable |= vh.drFndrInfo0 != 0 || vh.drFndrInfo3 != 0 || vh.drFndrInfo5 != 0; - XmlFsType.Clusters = vh.totalBlocks; - XmlFsType.ClusterSize = vh.blockSize; - - if(vh.createDate > 0) - { - XmlFsType.CreationDate = DateHandlers.MacToDateTime(vh.createDate); - XmlFsType.CreationDateSpecified = true; - } - - XmlFsType.Dirty = (vh.attributes & 0x100) != 0x100; - XmlFsType.Files = vh.fileCount; - XmlFsType.FilesSpecified = true; - XmlFsType.FreeClusters = vh.freeBlocks; - XmlFsType.FreeClustersSpecified = true; - - if(vh.modifyDate > 0) - { - XmlFsType.ModificationDate = DateHandlers.MacToDateTime(vh.modifyDate); - XmlFsType.ModificationDateSpecified = true; - } - - XmlFsType.Type = vh.signature switch - { - 0x482B => FS_TYPE_HFSP, - 0x4858 => FS_TYPE_HFSX, - _ => XmlFsType.Type - }; - - if(vh.drFndrInfo6 != 0 && - vh.drFndrInfo7 != 0) - XmlFsType.VolumeSerial = $"{vh.drFndrInfo6:X8}{vh.drFndrInfo7:X8}"; - - XmlFsType.SystemIdentifier = Encoding.ASCII.GetString(vh.lastMountedVersion); - } - else - { - sb.AppendFormat(Localization.Filesystem_version_is_0, vh.version).AppendLine(); - sb.AppendLine(Localization.This_version_is_not_supported_yet); - } - - information = sb.ToString(); - } - /// HFS+ Volume Header, should be at offset 0x0400 bytes in volume with a size of 532 bytes [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VolumeHeader diff --git a/Aaru.Filesystems/AppleMFS/AppleMFS.cs b/Aaru.Filesystems/AppleMFS/AppleMFS.cs index 5d1b581e0..ba99ced7d 100644 --- a/Aaru.Filesystems/AppleMFS/AppleMFS.cs +++ b/Aaru.Filesystems/AppleMFS/AppleMFS.cs @@ -7,10 +7,6 @@ // // Component : Apple Macintosh File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Constructors and common variables for the Apple Macintosh File System plugin. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleMFS/Consts.cs b/Aaru.Filesystems/AppleMFS/Consts.cs index e3c19ddfc..791016916 100644 --- a/Aaru.Filesystems/AppleMFS/Consts.cs +++ b/Aaru.Filesystems/AppleMFS/Consts.cs @@ -7,10 +7,6 @@ // // Component : Apple Macintosh File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Macintosh File System constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleMFS/Dir.cs b/Aaru.Filesystems/AppleMFS/Dir.cs index a2b18aee3..33ac51a8b 100644 --- a/Aaru.Filesystems/AppleMFS/Dir.cs +++ b/Aaru.Filesystems/AppleMFS/Dir.cs @@ -7,10 +7,6 @@ // // Component : Apple Macintosh File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle the Apple Macintosh File System directory. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleMFS/File.cs b/Aaru.Filesystems/AppleMFS/File.cs index 85e526b52..5be9c219f 100644 --- a/Aaru.Filesystems/AppleMFS/File.cs +++ b/Aaru.Filesystems/AppleMFS/File.cs @@ -7,10 +7,6 @@ // // Component : Apple Macintosh File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleMFS/Info.cs b/Aaru.Filesystems/AppleMFS/Info.cs index dd64f55a7..342bcee20 100644 --- a/Aaru.Filesystems/AppleMFS/Info.cs +++ b/Aaru.Filesystems/AppleMFS/Info.cs @@ -7,10 +7,6 @@ // // Component : Apple Macintosh File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Apple Macintosh File System and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleMFS/Structs.cs b/Aaru.Filesystems/AppleMFS/Structs.cs index 32411f586..b0e48b0e4 100644 --- a/Aaru.Filesystems/AppleMFS/Structs.cs +++ b/Aaru.Filesystems/AppleMFS/Structs.cs @@ -7,10 +7,6 @@ // // Component : Apple Macintosh File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Macintosh File System structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs index 9853422e9..cf7a43c1e 100644 --- a/Aaru.Filesystems/AppleMFS/Super.cs +++ b/Aaru.Filesystems/AppleMFS/Super.cs @@ -7,10 +7,6 @@ // // Component : Apple Macintosh File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles mounting and umounting the Apple Macintosh File System. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/AtheOS/AtheOS.cs b/Aaru.Filesystems/AtheOS/AtheOS.cs new file mode 100644 index 000000000..bc7843df7 --- /dev/null +++ b/Aaru.Filesystems/AtheOS/AtheOS.cs @@ -0,0 +1,52 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Atheos.cs +// Author(s) : Natalia Portillo +// +// Component : Atheos filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the AtheOS filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class AtheOS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.AtheOS_Name; + /// + public Guid Id => new("AAB2C4F1-DC07-49EE-A948-576CC51B58C5"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AtheOS/Consts.cs b/Aaru.Filesystems/AtheOS/Consts.cs new file mode 100644 index 000000000..57163fd59 --- /dev/null +++ b/Aaru.Filesystems/AtheOS/Consts.cs @@ -0,0 +1,48 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Atheos filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the AtheOS filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class AtheOS +{ + // Little endian constants (that is, as read by .NET :p) + const uint AFS_MAGIC1 = 0x41465331; + const uint AFS_MAGIC2 = 0xDD121031; + const uint AFS_MAGIC3 = 0x15B6830E; + + // Common constants + const uint AFS_SUPERBLOCK_SIZE = 1024; + const uint AFS_BOOTBLOCK_SIZE = AFS_SUPERBLOCK_SIZE; + + const string FS_TYPE = "atheos"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/AtheOS.cs b/Aaru.Filesystems/AtheOS/Info.cs similarity index 59% rename from Aaru.Filesystems/AtheOS.cs rename to Aaru.Filesystems/AtheOS/Info.cs index 18510ef9b..cbe8e5b4b 100644 --- a/Aaru.Filesystems/AtheOS.cs +++ b/Aaru.Filesystems/AtheOS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Atheos.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Atheos filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Atheos filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,42 +28,20 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection for the AtheOS filesystem [SuppressMessage("ReSharper", "UnusedMember.Local")] -public sealed class AtheOS : IFilesystem +public sealed partial class AtheOS { - // Little endian constants (that is, as read by .NET :p) - const uint AFS_MAGIC1 = 0x41465331; - const uint AFS_MAGIC2 = 0xDD121031; - const uint AFS_MAGIC3 = 0x15B6830E; - - // Common constants - const uint AFS_SUPERBLOCK_SIZE = 1024; - const uint AFS_BOOTBLOCK_SIZE = AFS_SUPERBLOCK_SIZE; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.AtheOS_Name; - /// - public Guid Id => new("AAB2C4F1-DC07-49EE-A948-576CC51B58C5"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -182,73 +156,4 @@ public sealed class AtheOS : IFilesystem VolumeName = StringHandlers.CToString(afsSb.name, Encoding) }; } - - const string FS_TYPE = "atheos"; - - /// Be superblock - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - /// 0x000, Volume name, 32 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] name; - /// 0x020, "AFS1", 0x41465331 - public readonly uint magic1; - /// 0x024, "BIGE", 0x42494745 - public readonly uint fs_byte_order; - /// 0x028, Bytes per block - public readonly uint block_size; - /// 0x02C, 1 << block_shift == block_size - public readonly uint block_shift; - /// 0x030, Blocks in volume - public readonly long num_blocks; - /// 0x038, Used blocks in volume - public readonly long used_blocks; - /// 0x040, Bytes per inode - public readonly int inode_size; - /// 0x044, 0xDD121031 - public readonly uint magic2; - /// 0x048, Blocks per allocation group - public readonly int blocks_per_ag; - /// 0x04C, 1 << ag_shift == blocks_per_ag - public readonly int ag_shift; - /// 0x050, Allocation groups in volume - public readonly int num_ags; - /// 0x054, 0x434c454e if clean, 0x44495254 if dirty - public readonly uint flags; - /// 0x058, Allocation group of journal - public readonly int log_blocks_ag; - /// 0x05C, Start block of journal, inside ag - public readonly ushort log_blocks_start; - /// 0x05E, Length in blocks of journal, inside ag - public readonly ushort log_blocks_len; - /// 0x060, Start of journal - public readonly long log_start; - /// 0x068, Valid block logs - public readonly int log_valid_blocks; - /// 0x06C, Log size - public readonly int log_size; - /// 0x070, 0x15B6830E - public readonly uint magic3; - /// 0x074, Allocation group where root folder's i-node resides - public readonly int root_dir_ag; - /// 0x078, Start in ag of root folder's i-node - public readonly ushort root_dir_start; - /// 0x07A, As this is part of inode_addr, this is 1 - public readonly ushort root_dir_len; - /// 0x07C, Allocation group where pending-delete-files' i-node resides - public readonly int deleted_ag; - /// 0x080, Start in ag of pending-delete-files' i-node - public readonly ushort deleted_start; - /// 0x082, As this is part of inode_addr, this is 1 - public readonly ushort deleted_len; - /// 0x084, Allocation group where indices' i-node resides - public readonly int indices_ag; - /// 0x088, Start in ag of indices' i-node - public readonly ushort indices_start; - /// 0x08A, As this is part of inode_addr, this is 1 - public readonly ushort indices_len; - /// 0x08C, Size of bootloader - public readonly int boot_size; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/AtheOS/Structs.cs b/Aaru.Filesystems/AtheOS/Structs.cs new file mode 100644 index 000000000..6dc4b4112 --- /dev/null +++ b/Aaru.Filesystems/AtheOS/Structs.cs @@ -0,0 +1,105 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Atheos filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the AtheOS filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class AtheOS +{ + /// Be superblock + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + /// 0x000, Volume name, 32 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] name; + /// 0x020, "AFS1", 0x41465331 + public readonly uint magic1; + /// 0x024, "BIGE", 0x42494745 + public readonly uint fs_byte_order; + /// 0x028, Bytes per block + public readonly uint block_size; + /// 0x02C, 1 << block_shift == block_size + public readonly uint block_shift; + /// 0x030, Blocks in volume + public readonly long num_blocks; + /// 0x038, Used blocks in volume + public readonly long used_blocks; + /// 0x040, Bytes per inode + public readonly int inode_size; + /// 0x044, 0xDD121031 + public readonly uint magic2; + /// 0x048, Blocks per allocation group + public readonly int blocks_per_ag; + /// 0x04C, 1 << ag_shift == blocks_per_ag + public readonly int ag_shift; + /// 0x050, Allocation groups in volume + public readonly int num_ags; + /// 0x054, 0x434c454e if clean, 0x44495254 if dirty + public readonly uint flags; + /// 0x058, Allocation group of journal + public readonly int log_blocks_ag; + /// 0x05C, Start block of journal, inside ag + public readonly ushort log_blocks_start; + /// 0x05E, Length in blocks of journal, inside ag + public readonly ushort log_blocks_len; + /// 0x060, Start of journal + public readonly long log_start; + /// 0x068, Valid block logs + public readonly int log_valid_blocks; + /// 0x06C, Log size + public readonly int log_size; + /// 0x070, 0x15B6830E + public readonly uint magic3; + /// 0x074, Allocation group where root folder's i-node resides + public readonly int root_dir_ag; + /// 0x078, Start in ag of root folder's i-node + public readonly ushort root_dir_start; + /// 0x07A, As this is part of inode_addr, this is 1 + public readonly ushort root_dir_len; + /// 0x07C, Allocation group where pending-delete-files' i-node resides + public readonly int deleted_ag; + /// 0x080, Start in ag of pending-delete-files' i-node + public readonly ushort deleted_start; + /// 0x082, As this is part of inode_addr, this is 1 + public readonly ushort deleted_len; + /// 0x084, Allocation group where indices' i-node resides + public readonly int indices_ag; + /// 0x088, Start in ag of indices' i-node + public readonly ushort indices_start; + /// 0x08A, As this is part of inode_addr, this is 1 + public readonly ushort indices_len; + /// 0x08C, Size of bootloader + public readonly int boot_size; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/BFS/BFS.cs b/Aaru.Filesystems/BFS/BFS.cs new file mode 100644 index 000000000..b4452e479 --- /dev/null +++ b/Aaru.Filesystems/BFS/BFS.cs @@ -0,0 +1,53 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : BFS.cs +// Author(s) : Natalia Portillo +// +// Component : BeOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from Practical Filesystem Design, ISBN 1-55860-497-9 +/// +/// Implements detection of the Be (new) filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class BeFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.BeFS_Name; + /// + public Guid Id => new("dc8572b3-b6ad-46e4-8de9-cbe123ff6672"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/BFS/Consts.cs b/Aaru.Filesystems/BFS/Consts.cs new file mode 100644 index 000000000..6da2a9067 --- /dev/null +++ b/Aaru.Filesystems/BFS/Consts.cs @@ -0,0 +1,54 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : BeOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from Practical Filesystem Design, ISBN 1-55860-497-9 +/// +/// Implements detection of the Be (new) filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class BeFS +{ + // Little endian constants (that is, as read by .NET :p) + const uint BEFS_MAGIC1 = 0x42465331; + const uint BEFS_MAGIC2 = 0xDD121031; + const uint BEFS_MAGIC3 = 0x15B6830E; + const uint BEFS_ENDIAN = 0x42494745; + + // Big endian constants + const uint BEFS_CIGAM1 = 0x31534642; + const uint BEFS_NAIDNE = 0x45474942; + + // Common constants + const uint BEFS_CLEAN = 0x434C454E; + const uint BEFS_DIRTY = 0x44495254; + + const string FS_TYPE = "befs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/BFS.cs b/Aaru.Filesystems/BFS/Info.cs similarity index 69% rename from Aaru.Filesystems/BFS.cs rename to Aaru.Filesystems/BFS/Info.cs index f268c0002..803ddba4f 100644 --- a/Aaru.Filesystems/BFS.cs +++ b/Aaru.Filesystems/BFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : BFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : BeOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the BeOS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,14 +28,12 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -47,33 +41,8 @@ namespace Aaru.Filesystems; /// /// Implements detection of the Be (new) filesystem [SuppressMessage("ReSharper", "UnusedMember.Local")] -public sealed class BeFS : IFilesystem +public sealed partial class BeFS { - // Little endian constants (that is, as read by .NET :p) - const uint BEFS_MAGIC1 = 0x42465331; - const uint BEFS_MAGIC2 = 0xDD121031; - const uint BEFS_MAGIC3 = 0x15B6830E; - const uint BEFS_ENDIAN = 0x42494745; - - // Big endian constants - const uint BEFS_CIGAM1 = 0x31534642; - const uint BEFS_NAIDNE = 0x45474942; - - // Common constants - const uint BEFS_CLEAN = 0x434C454E; - const uint BEFS_DIRTY = 0x44495254; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.BeFS_Name; - /// - public Guid Id => new("dc8572b3-b6ad-46e4-8de9-cbe123ff6672"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -259,63 +228,4 @@ public sealed class BeFS : IFilesystem VolumeName = StringHandlers.CToString(besb.name, Encoding) }; } - - const string FS_TYPE = "befs"; - - /// Be superblock - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock - { - /// 0x000, Volume name, 32 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] name; - /// 0x020, "BFS1", 0x42465331 - public uint magic1; - /// 0x024, "BIGE", 0x42494745 - public readonly uint fs_byte_order; - /// 0x028, Bytes per block - public readonly uint block_size; - /// 0x02C, 1 << block_shift == block_size - public readonly uint block_shift; - /// 0x030, Blocks in volume - public readonly long num_blocks; - /// 0x038, Used blocks in volume - public readonly long used_blocks; - /// 0x040, Bytes per inode - public readonly int inode_size; - /// 0x044, 0xDD121031 - public readonly uint magic2; - /// 0x048, Blocks per allocation group - public readonly int blocks_per_ag; - /// 0x04C, 1 << ag_shift == blocks_per_ag - public readonly int ag_shift; - /// 0x050, Allocation groups in volume - public readonly int num_ags; - /// 0x054, 0x434c454e if clean, 0x44495254 if dirty - public readonly uint flags; - /// 0x058, Allocation group of journal - public readonly int log_blocks_ag; - /// 0x05C, Start block of journal, inside ag - public readonly ushort log_blocks_start; - /// 0x05E, Length in blocks of journal, inside ag - public readonly ushort log_blocks_len; - /// 0x060, Start of journal - public readonly long log_start; - /// 0x068, End of journal - public readonly long log_end; - /// 0x070, 0x15B6830E - public readonly uint magic3; - /// 0x074, Allocation group where root folder's i-node resides - public readonly int root_dir_ag; - /// 0x078, Start in ag of root folder's i-node - public readonly ushort root_dir_start; - /// 0x07A, As this is part of inode_addr, this is 1 - public readonly ushort root_dir_len; - /// 0x07C, Allocation group where indices' i-node resides - public readonly int indices_ag; - /// 0x080, Start in ag of indices' i-node - public readonly ushort indices_start; - /// 0x082, As this is part of inode_addr, this is 1 - public readonly ushort indices_len; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/BFS/Structs.cs b/Aaru.Filesystems/BFS/Structs.cs new file mode 100644 index 000000000..b25c63c1f --- /dev/null +++ b/Aaru.Filesystems/BFS/Structs.cs @@ -0,0 +1,96 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : BeOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from Practical Filesystem Design, ISBN 1-55860-497-9 +/// +/// Implements detection of the Be (new) filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class BeFS +{ + /// Be superblock + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct SuperBlock + { + /// 0x000, Volume name, 32 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] name; + /// 0x020, "BFS1", 0x42465331 + public uint magic1; + /// 0x024, "BIGE", 0x42494745 + public readonly uint fs_byte_order; + /// 0x028, Bytes per block + public readonly uint block_size; + /// 0x02C, 1 << block_shift == block_size + public readonly uint block_shift; + /// 0x030, Blocks in volume + public readonly long num_blocks; + /// 0x038, Used blocks in volume + public readonly long used_blocks; + /// 0x040, Bytes per inode + public readonly int inode_size; + /// 0x044, 0xDD121031 + public readonly uint magic2; + /// 0x048, Blocks per allocation group + public readonly int blocks_per_ag; + /// 0x04C, 1 << ag_shift == blocks_per_ag + public readonly int ag_shift; + /// 0x050, Allocation groups in volume + public readonly int num_ags; + /// 0x054, 0x434c454e if clean, 0x44495254 if dirty + public readonly uint flags; + /// 0x058, Allocation group of journal + public readonly int log_blocks_ag; + /// 0x05C, Start block of journal, inside ag + public readonly ushort log_blocks_start; + /// 0x05E, Length in blocks of journal, inside ag + public readonly ushort log_blocks_len; + /// 0x060, Start of journal + public readonly long log_start; + /// 0x068, End of journal + public readonly long log_end; + /// 0x070, 0x15B6830E + public readonly uint magic3; + /// 0x074, Allocation group where root folder's i-node resides + public readonly int root_dir_ag; + /// 0x078, Start in ag of root folder's i-node + public readonly ushort root_dir_start; + /// 0x07A, As this is part of inode_addr, this is 1 + public readonly ushort root_dir_len; + /// 0x07C, Allocation group where indices' i-node resides + public readonly int indices_ag; + /// 0x080, Start in ag of indices' i-node + public readonly ushort indices_start; + /// 0x082, As this is part of inode_addr, this is 1 + public readonly ushort indices_len; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/BTRFS/BTRFS.cs b/Aaru.Filesystems/BTRFS/BTRFS.cs new file mode 100644 index 000000000..7e7ddbf16 --- /dev/null +++ b/Aaru.Filesystems/BTRFS/BTRFS.cs @@ -0,0 +1,54 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : BTRFS.cs +// Author(s) : Natalia Portillo +// +// Component : B-tree file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the B-tree 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the b-tree filesystem (btrfs) +public sealed partial class BTRFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.BTRFS_Name; + /// + public Guid Id => new("C904CF15-5222-446B-B7DB-02EAC5D781B3"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/BTRFS/Consts.cs b/Aaru.Filesystems/BTRFS/Consts.cs new file mode 100644 index 000000000..cb31055e7 --- /dev/null +++ b/Aaru.Filesystems/BTRFS/Consts.cs @@ -0,0 +1,43 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : B-tree file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the B-tree 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the b-tree filesystem (btrfs) +public sealed partial class BTRFS +{ + /// BTRFS magic "_BHRfS_M" + const ulong BTRFS_MAGIC = 0x4D5F53665248425F; + + const string FS_TYPE = "btrfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/BTRFS.cs b/Aaru.Filesystems/BTRFS/Info.cs similarity index 77% rename from Aaru.Filesystems/BTRFS.cs rename to Aaru.Filesystems/BTRFS/Info.cs index 9485809eb..993cae38c 100644 --- a/Aaru.Filesystems/BTRFS.cs +++ b/Aaru.Filesystems/BTRFS/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : BTRFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : B-tree file system plugin. @@ -30,38 +30,20 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Console; +using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the b-tree filesystem (btrfs) -public sealed class BTRFS : IFilesystem +public sealed partial class BTRFS { - /// BTRFS magic "_BHRfS_M" - const ulong BTRFS_MAGIC = 0x4D5F53665248425F; - - const string FS_TYPE = "btrfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.BTRFS_Name; - /// - public Guid Id => new("C904CF15-5222-446B-B7DB-02EAC5D781B3"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -214,65 +196,4 @@ public sealed class BTRFS : IFilesystem XmlFsType.FreeClusters = XmlFsType.Clusters - (btrfsSb.bytes_used / btrfsSb.sectorsize); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)] - public readonly byte[] checksum; - public readonly Guid uuid; - public readonly ulong pba; - public readonly ulong flags; - public readonly ulong magic; - public readonly ulong generation; - public readonly ulong root_lba; - public readonly ulong chunk_lba; - public readonly ulong log_lba; - public readonly ulong log_root_transid; - public readonly ulong total_bytes; - public readonly ulong bytes_used; - public readonly ulong root_dir_objectid; - public readonly ulong num_devices; - public readonly uint sectorsize; - public readonly uint nodesize; - public readonly uint leafsize; - public readonly uint stripesize; - public readonly uint n; - public readonly ulong chunk_root_generation; - public readonly ulong compat_flags; - public readonly ulong compat_ro_flags; - public readonly ulong incompat_flags; - public readonly ushort csum_type; - public readonly byte root_level; - public readonly byte chunk_root_level; - public readonly byte log_root_level; - public readonly DevItem dev_item; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)] - public readonly string label; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x100)] - public readonly byte[] reserved; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x800)] - public readonly byte[] chunkpairs; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4D5)] - public readonly byte[] unused; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DevItem - { - public readonly ulong id; - public readonly ulong bytes; - public readonly ulong used; - public readonly uint optimal_align; - public readonly uint optimal_width; - public readonly uint minimal_size; - public readonly ulong type; - public readonly ulong generation; - public readonly ulong start_offset; - public readonly uint dev_group; - public readonly byte seek_speed; - public readonly byte bandwidth; - public readonly Guid device_uuid; - public readonly Guid uuid; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/BTRFS/Structs.cs b/Aaru.Filesystems/BTRFS/Structs.cs new file mode 100644 index 000000000..9264c9001 --- /dev/null +++ b/Aaru.Filesystems/BTRFS/Structs.cs @@ -0,0 +1,102 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : B-tree file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the B-tree 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the b-tree filesystem (btrfs) +public sealed partial class BTRFS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)] + public readonly byte[] checksum; + public readonly Guid uuid; + public readonly ulong pba; + public readonly ulong flags; + public readonly ulong magic; + public readonly ulong generation; + public readonly ulong root_lba; + public readonly ulong chunk_lba; + public readonly ulong log_lba; + public readonly ulong log_root_transid; + public readonly ulong total_bytes; + public readonly ulong bytes_used; + public readonly ulong root_dir_objectid; + public readonly ulong num_devices; + public readonly uint sectorsize; + public readonly uint nodesize; + public readonly uint leafsize; + public readonly uint stripesize; + public readonly uint n; + public readonly ulong chunk_root_generation; + public readonly ulong compat_flags; + public readonly ulong compat_ro_flags; + public readonly ulong incompat_flags; + public readonly ushort csum_type; + public readonly byte root_level; + public readonly byte chunk_root_level; + public readonly byte log_root_level; + public readonly DevItem dev_item; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)] + public readonly string label; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x100)] + public readonly byte[] reserved; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x800)] + public readonly byte[] chunkpairs; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x4D5)] + public readonly byte[] unused; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct DevItem + { + public readonly ulong id; + public readonly ulong bytes; + public readonly ulong used; + public readonly uint optimal_align; + public readonly uint optimal_width; + public readonly uint minimal_size; + public readonly ulong type; + public readonly ulong generation; + public readonly ulong start_offset; + public readonly uint dev_group; + public readonly byte seek_speed; + public readonly byte bandwidth; + public readonly Guid device_uuid; + public readonly Guid uuid; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/CBM/CBM.cs b/Aaru.Filesystems/CBM/CBM.cs new file mode 100644 index 000000000..53bbc5167 --- /dev/null +++ b/Aaru.Filesystems/CBM/CBM.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : CBM.cs +// Author(s) : Natalia Portillo +// +// Component : Commodore file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem used in 8-bit Commodore microcomputers +public sealed partial class CBM : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public string Name => Localization.CBM_Name; + /// + public Guid Id => new("D104744E-A376-450C-BAC0-1347C93F983B"); + /// + public Encoding Encoding { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/CBM/Consts.cs b/Aaru.Filesystems/CBM/Consts.cs new file mode 100644 index 000000000..14239a8c3 --- /dev/null +++ b/Aaru.Filesystems/CBM/Consts.cs @@ -0,0 +1,36 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Commodore file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem used in 8-bit Commodore microcomputers +public sealed partial class CBM +{ + const string FS_TYPE = "cbmfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/CBM.cs b/Aaru.Filesystems/CBM/Info.cs similarity index 62% rename from Aaru.Filesystems/CBM.cs rename to Aaru.Filesystems/CBM/Info.cs index c331a4598..8a766b1e1 100644 --- a/Aaru.Filesystems/CBM.cs +++ b/Aaru.Filesystems/CBM/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : CBM.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Commodore file system plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Commodore file system and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -40,26 +35,13 @@ using Aaru.Helpers; using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the filesystem used in 8-bit Commodore microcomputers -public sealed class CBM : IFilesystem +public sealed partial class CBM { - const string FS_TYPE = "cbmfs"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public string Name => Localization.CBM_Name; - /// - public Guid Id => new("D104744E-A376-450C-BAC0-1347C93F983B"); - /// - public Encoding Encoding { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -190,75 +172,4 @@ public sealed class CBM : IFilesystem information = sbInformation.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct BAM - { - /// Track where directory starts - public readonly byte directoryTrack; - /// Sector where directory starts - public readonly byte directorySector; - /// Disk DOS version, 0x41 - public readonly byte dosVersion; - /// Set to 0x80 if 1571, 0x00 if not - public readonly byte doubleSided; - /// Block allocation map - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 140)] - public readonly byte[] bam; - /// Disk name - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] name; - /// Filled with 0xA0 - public readonly ushort fill1; - /// Disk ID - public readonly ushort diskId; - /// Filled with 0xA0 - public readonly byte fill2; - /// DOS type - public readonly ushort dosType; - /// Filled with 0xA0 - public readonly uint fill3; - /// Unused - public readonly byte unused1; - /// Block allocation map for Dolphin DOS extended tracks - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly byte[] dolphinBam; - /// Block allocation map for Speed DOS extended tracks - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly byte[] speedBam; - /// Unused - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] - public readonly byte[] unused2; - /// Free sector count for second side in 1571 - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] - public readonly byte[] freeCount; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Header - { - /// Track where directory starts - public readonly byte directoryTrack; - /// Sector where directory starts - public readonly byte directorySector; - /// Disk DOS version, 0x44 - public readonly byte diskDosVersion; - /// Unusued - public readonly byte unused1; - /// Disk name - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] name; - /// Filled with 0xA0 - public readonly ushort fill1; - /// Disk ID - public readonly ushort diskId; - /// Filled with 0xA0 - public readonly byte fill2; - /// DOS version ('3') - public readonly byte dosVersion; - /// Disk version ('D') - public readonly byte diskVersion; - /// Filled with 0xA0 - public readonly short fill3; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/CBM/Structs.cs b/Aaru.Filesystems/CBM/Structs.cs new file mode 100644 index 000000000..7f145f9f9 --- /dev/null +++ b/Aaru.Filesystems/CBM/Structs.cs @@ -0,0 +1,107 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Commodore file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem used in 8-bit Commodore microcomputers +public sealed partial class CBM +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct BAM + { + /// Track where directory starts + public readonly byte directoryTrack; + /// Sector where directory starts + public readonly byte directorySector; + /// Disk DOS version, 0x41 + public readonly byte dosVersion; + /// Set to 0x80 if 1571, 0x00 if not + public readonly byte doubleSided; + /// Block allocation map + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 140)] + public readonly byte[] bam; + /// Disk name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] name; + /// Filled with 0xA0 + public readonly ushort fill1; + /// Disk ID + public readonly ushort diskId; + /// Filled with 0xA0 + public readonly byte fill2; + /// DOS type + public readonly ushort dosType; + /// Filled with 0xA0 + public readonly uint fill3; + /// Unused + public readonly byte unused1; + /// Block allocation map for Dolphin DOS extended tracks + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly byte[] dolphinBam; + /// Block allocation map for Speed DOS extended tracks + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly byte[] speedBam; + /// Unused + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] + public readonly byte[] unused2; + /// Free sector count for second side in 1571 + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] + public readonly byte[] freeCount; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Header + { + /// Track where directory starts + public readonly byte directoryTrack; + /// Sector where directory starts + public readonly byte directorySector; + /// Disk DOS version, 0x44 + public readonly byte diskDosVersion; + /// Unusued + public readonly byte unused1; + /// Disk name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] name; + /// Filled with 0xA0 + public readonly ushort fill1; + /// Disk ID + public readonly ushort diskId; + /// Filled with 0xA0 + public readonly byte fill2; + /// DOS version ('3') + public readonly byte dosVersion; + /// Disk version ('D') + public readonly byte diskVersion; + /// Filled with 0xA0 + public readonly short fill3; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/CPM/File.cs b/Aaru.Filesystems/CPM/File.cs index f67c8f417..c7bd5f280 100644 --- a/Aaru.Filesystems/CPM/File.cs +++ b/Aaru.Filesystems/CPM/File.cs @@ -7,10 +7,6 @@ // // Component : CP/M filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Cram/Consts.cs b/Aaru.Filesystems/Cram/Consts.cs new file mode 100644 index 000000000..c9d3f07d7 --- /dev/null +++ b/Aaru.Filesystems/Cram/Consts.cs @@ -0,0 +1,45 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Cram file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the CRAM filesystem +[SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class Cram +{ + /// Identifier for Cram + const uint CRAM_MAGIC = 0x28CD3D45; + const uint CRAM_CIGAM = 0x453DCD28; + + const string FS_TYPE = "cramfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Cram/Cram.cs b/Aaru.Filesystems/Cram/Cram.cs new file mode 100644 index 000000000..82b6f082c --- /dev/null +++ b/Aaru.Filesystems/Cram/Cram.cs @@ -0,0 +1,54 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Cram.cs +// Author(s) : Natalia Portillo +// +// Component : Cram file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the CRAM filesystem +[SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class Cram : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.Cram_Name; + /// + public Guid Id => new("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Cram/Enums.cs b/Aaru.Filesystems/Cram/Enums.cs new file mode 100644 index 000000000..3b5cc1fdd --- /dev/null +++ b/Aaru.Filesystems/Cram/Enums.cs @@ -0,0 +1,45 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : Cram file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the CRAM filesystem +[SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class Cram +{ + enum CramCompression : ushort + { + Zlib = 1, Lzma = 2, Lzo = 3, + Xz = 4, Lz4 = 5 + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Cram.cs b/Aaru.Filesystems/Cram/Info.cs similarity index 73% rename from Aaru.Filesystems/Cram.cs rename to Aaru.Filesystems/Cram/Info.cs index 8da437986..0188b17ab 100644 --- a/Aaru.Filesystems/Cram.cs +++ b/Aaru.Filesystems/Cram/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Cram.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Cram file system plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Cram file system and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -34,37 +30,20 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the CRAM filesystem [SuppressMessage("ReSharper", "UnusedType.Local")] -public sealed class Cram : IFilesystem +public sealed partial class Cram { - /// Identifier for Cram - const uint CRAM_MAGIC = 0x28CD3D45; - const uint CRAM_CIGAM = 0x453DCD28; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.Cram_Name; - /// - public Guid Id => new("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -135,29 +114,4 @@ public sealed class Cram : IFilesystem FreeClustersSpecified = true }; } - - const string FS_TYPE = "cramfs"; - - enum CramCompression : ushort - { - Zlib = 1, Lzma = 2, Lzo = 3, - Xz = 4, Lz4 = 5 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - public readonly uint magic; - public readonly uint size; - public readonly uint flags; - public readonly uint future; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] signature; - public readonly uint crc; - public readonly uint edition; - public readonly uint blocks; - public readonly uint files; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] name; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Cram/Structs.cs b/Aaru.Filesystems/Cram/Structs.cs new file mode 100644 index 000000000..04ab69a1c --- /dev/null +++ b/Aaru.Filesystems/Cram/Structs.cs @@ -0,0 +1,57 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Cram file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the CRAM filesystem +[SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class Cram +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + public readonly uint magic; + public readonly uint size; + public readonly uint flags; + public readonly uint future; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] signature; + public readonly uint crc; + public readonly uint edition; + public readonly uint blocks; + public readonly uint files; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] name; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ECMA67/Consts.cs b/Aaru.Filesystems/ECMA67/Consts.cs new file mode 100644 index 000000000..cef72aecf --- /dev/null +++ b/Aaru.Filesystems/ECMA67/Consts.cs @@ -0,0 +1,44 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : ECMA-67 plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the ECMA-67 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem described in ECMA-67 +public sealed partial class ECMA67 +{ + const string FS_TYPE = "ecma67"; + readonly byte[] _magic = + { + 0x56, 0x4F, 0x4C + }; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ECMA67/ECMA67.cs b/Aaru.Filesystems/ECMA67/ECMA67.cs new file mode 100644 index 000000000..763771970 --- /dev/null +++ b/Aaru.Filesystems/ECMA67/ECMA67.cs @@ -0,0 +1,54 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : ECMA67.cs +// Author(s) : Natalia Portillo +// +// Component : ECMA-67 plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the ECMA-67 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem described in ECMA-67 +public sealed partial class ECMA67 : IFilesystem +{ + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.ECMA67_Name; + /// + public Guid Id => new("62A2D44A-CBC1-4377-B4B6-28C5C92034A1"); + /// + public FileSystemType XmlFsType { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ECMA67.cs b/Aaru.Filesystems/ECMA67/Info.cs similarity index 65% rename from Aaru.Filesystems/ECMA67.cs rename to Aaru.Filesystems/ECMA67/Info.cs index 7a74bea90..c94d46e97 100644 --- a/Aaru.Filesystems/ECMA67.cs +++ b/Aaru.Filesystems/ECMA67/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : ECMA67.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : ECMA-67 plugin. @@ -30,39 +30,20 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; +using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the filesystem described in ECMA-67 -public sealed class ECMA67 : IFilesystem +public sealed partial class ECMA67 { - const string FS_TYPE = "ecma67"; - readonly byte[] _magic = - { - 0x56, 0x4F, 0x4C - }; - - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.ECMA67_Name; - /// - public Guid Id => new("62A2D44A-CBC1-4377-B4B6-28C5C92034A1"); - /// - public FileSystemType XmlFsType { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -116,31 +97,4 @@ public sealed class ECMA67 : IFilesystem information = sbInformation.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct VolumeLabel - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] labelIdentifier; - public readonly byte labelNumber; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] volumeIdentifier; - public readonly byte volumeAccessibility; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 26)] - public readonly byte[] reserved1; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] - public readonly byte[] owner; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly byte[] reserved2; - public readonly byte surface; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] reserved3; - public readonly byte recordLength; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] reserved4; - public readonly byte fileLabelAllocation; - public readonly byte labelStandardVersion; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)] - public readonly byte[] reserved5; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/ECMA67/Structs.cs b/Aaru.Filesystems/ECMA67/Structs.cs new file mode 100644 index 000000000..2805ccde0 --- /dev/null +++ b/Aaru.Filesystems/ECMA67/Structs.cs @@ -0,0 +1,67 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : ECMA-67 plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the ECMA-67 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem described in ECMA-67 +public sealed partial class ECMA67 +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct VolumeLabel + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] labelIdentifier; + public readonly byte labelNumber; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] volumeIdentifier; + public readonly byte volumeAccessibility; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 26)] + public readonly byte[] reserved1; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + public readonly byte[] owner; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly byte[] reserved2; + public readonly byte surface; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] reserved3; + public readonly byte recordLength; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly byte[] reserved4; + public readonly byte fileLabelAllocation; + public readonly byte labelStandardVersion; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)] + public readonly byte[] reserved5; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/EFS/Consts.cs b/Aaru.Filesystems/EFS/Consts.cs new file mode 100644 index 000000000..6b0dd4317 --- /dev/null +++ b/Aaru.Filesystems/EFS/Consts.cs @@ -0,0 +1,39 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Extent File System plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements identification for the SGI Extent FileSystem +public sealed partial class EFS +{ + const uint EFS_MAGIC = 0x00072959; + const uint EFS_MAGIC_NEW = 0x0007295A; + + const string FS_TYPE = "efs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/EFS/EFS.cs b/Aaru.Filesystems/EFS/EFS.cs new file mode 100644 index 000000000..a74a52c77 --- /dev/null +++ b/Aaru.Filesystems/EFS/EFS.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : EFS.cs +// Author(s) : Natalia Portillo +// +// Component : Extent File System plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements identification for the SGI Extent FileSystem +public sealed partial class EFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.EFS_Name; + /// + public Guid Id => new("52A43F90-9AF3-4391-ADFE-65598DEEABAB"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/EFS.cs b/Aaru.Filesystems/EFS/Info.cs similarity index 75% rename from Aaru.Filesystems/EFS.cs rename to Aaru.Filesystems/EFS/Info.cs index b2caa0e4b..259b87506 100644 --- a/Aaru.Filesystems/EFS.cs +++ b/Aaru.Filesystems/EFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : EFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Extent File System plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Extent File System and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,8 +27,6 @@ // ****************************************************************************/ using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -40,30 +34,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements identification for the SGI Extent FileSystem -public sealed class EFS : IFilesystem +public sealed partial class EFS { - const uint EFS_MAGIC = 0x00072959; - const uint EFS_MAGIC_NEW = 0x0007295A; - - const string FS_TYPE = "efs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.EFS_Name; - /// - public Guid Id => new("52A43F90-9AF3-4391-ADFE-65598DEEABAB"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -237,54 +214,4 @@ public sealed class EFS : IFilesystem CreationDateSpecified = true }; } - - [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - readonly struct Superblock - { - /* 0: fs size incl. bb 0 (in bb) */ - public readonly int sb_size; - /* 4: first cg offset (in bb) */ - public readonly int sb_firstcg; - /* 8: cg size (in bb) */ - public readonly int sb_cgfsize; - /* 12: inodes/cg (in bb) */ - public readonly short sb_cgisize; - /* 14: geom: sectors/track */ - public readonly short sb_sectors; - /* 16: geom: heads/cylinder (unused) */ - public readonly short sb_heads; - /* 18: num of cg's in the filesystem */ - public readonly short sb_ncg; - /* 20: non-0 indicates fsck required */ - public readonly short sb_dirty; - /* 22: */ - public readonly short sb_pad0; - /* 24: superblock ctime */ - public readonly int sb_time; - /* 28: magic [0] */ - public readonly uint sb_magic; - /* 32: name of filesystem */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] sb_fname; - /* 38: name of filesystem pack */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] sb_fpack; - /* 44: bitmap size (in bytes) */ - public readonly int sb_bmsize; - /* 48: total free data blocks */ - public readonly int sb_tfree; - /* 52: total free inodes */ - public readonly int sb_tinode; - /* 56: bitmap offset (grown fs) */ - public readonly int sb_bmblock; - /* 62: repl. superblock offset */ - public readonly int sb_replsb; - /* 64: last allocated inode */ - public readonly int sb_lastinode; - /* 68: unused */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly byte[] sb_spare; - /* 88: checksum (all above) */ - public readonly uint sb_checksum; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/EFS/Structs.cs b/Aaru.Filesystems/EFS/Structs.cs new file mode 100644 index 000000000..70de67fcc --- /dev/null +++ b/Aaru.Filesystems/EFS/Structs.cs @@ -0,0 +1,87 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Extent File System plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements identification for the SGI Extent FileSystem +public sealed partial class EFS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] + readonly struct Superblock + { + /* 0: fs size incl. bb 0 (in bb) */ + public readonly int sb_size; + /* 4: first cg offset (in bb) */ + public readonly int sb_firstcg; + /* 8: cg size (in bb) */ + public readonly int sb_cgfsize; + /* 12: inodes/cg (in bb) */ + public readonly short sb_cgisize; + /* 14: geom: sectors/track */ + public readonly short sb_sectors; + /* 16: geom: heads/cylinder (unused) */ + public readonly short sb_heads; + /* 18: num of cg's in the filesystem */ + public readonly short sb_ncg; + /* 20: non-0 indicates fsck required */ + public readonly short sb_dirty; + /* 22: */ + public readonly short sb_pad0; + /* 24: superblock ctime */ + public readonly int sb_time; + /* 28: magic [0] */ + public readonly uint sb_magic; + /* 32: name of filesystem */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] sb_fname; + /* 38: name of filesystem pack */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] sb_fpack; + /* 44: bitmap size (in bytes) */ + public readonly int sb_bmsize; + /* 48: total free data blocks */ + public readonly int sb_tfree; + /* 52: total free inodes */ + public readonly int sb_tinode; + /* 56: bitmap offset (grown fs) */ + public readonly int sb_bmblock; + /* 62: repl. superblock offset */ + public readonly int sb_replsb; + /* 64: last allocated inode */ + public readonly int sb_lastinode; + /* 68: unused */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly byte[] sb_spare; + /* 88: checksum (all above) */ + public readonly uint sb_checksum; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/F2FS/Consts.cs b/Aaru.Filesystems/F2FS/Consts.cs new file mode 100644 index 000000000..d95f22724 --- /dev/null +++ b/Aaru.Filesystems/F2FS/Consts.cs @@ -0,0 +1,48 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : F2FS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Flash-Friendly File System (F2FS) +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class F2FS +{ + // ReSharper disable InconsistentNaming + const uint F2FS_MAGIC = 0xF2F52010; + const uint F2FS_SUPER_OFFSET = 1024; + const uint F2FS_MIN_SECTOR = 512; + const uint F2FS_MAX_SECTOR = 4096; + const uint F2FS_BLOCK_SIZE = 4096; + + // ReSharper restore InconsistentNaming + + const string FS_TYPE = "f2fs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/F2FS/F2FS.cs b/Aaru.Filesystems/F2FS/F2FS.cs new file mode 100644 index 000000000..0afd66962 --- /dev/null +++ b/Aaru.Filesystems/F2FS/F2FS.cs @@ -0,0 +1,52 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : F2FS.cs +// Author(s) : Natalia Portillo +// +// Component : F2FS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Flash-Friendly File System (F2FS) +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class F2FS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.F2FS_Name; + /// + public Guid Id => new("82B0920F-5F0D-4063-9F57-ADE0AE02ECE5"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/F2FS.cs b/Aaru.Filesystems/F2FS/Info.cs similarity index 60% rename from Aaru.Filesystems/F2FS.cs rename to Aaru.Filesystems/F2FS/Info.cs index e476fc1ae..331cd2715 100644 --- a/Aaru.Filesystems/F2FS.cs +++ b/Aaru.Filesystems/F2FS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : F2FS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : F2FS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the F2FS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,44 +26,21 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Flash-Friendly File System (F2FS) [SuppressMessage("ReSharper", "UnusedMember.Local")] -public sealed class F2FS : IFilesystem +public sealed partial class F2FS { - // ReSharper disable InconsistentNaming - const uint F2FS_MAGIC = 0xF2F52010; - const uint F2FS_SUPER_OFFSET = 1024; - const uint F2FS_MIN_SECTOR = 512; - const uint F2FS_MAX_SECTOR = 4096; - const uint F2FS_BLOCK_SIZE = 4096; - - // ReSharper restore InconsistentNaming - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.F2FS_Name; - /// - public Guid Id => new("82B0920F-5F0D-4063-9F57-ADE0AE02ECE5"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -173,69 +146,4 @@ public sealed class F2FS : IFilesystem VolumeSerial = f2fsSb.uuid.ToString() }; } - - const string FS_TYPE = "f2fs"; - - [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - readonly struct Superblock - { - public readonly uint magic; - public readonly ushort major_ver; - public readonly ushort minor_ver; - public readonly uint log_sectorsize; - public readonly uint log_sectors_per_block; - public readonly uint log_blocksize; - public readonly uint log_blocks_per_seg; - public readonly uint segs_per_sec; - public readonly uint secs_per_zone; - public readonly uint checksum_offset; - public readonly ulong block_count; - public readonly uint section_count; - public readonly uint segment_count; - public readonly uint segment_count_ckpt; - public readonly uint segment_count_sit; - public readonly uint segment_count_nat; - public readonly uint segment_count_ssa; - public readonly uint segment_count_main; - public readonly uint segment0_blkaddr; - public readonly uint cp_blkaddr; - public readonly uint sit_blkaddr; - public readonly uint nat_blkaddr; - public readonly uint ssa_blkaddr; - public readonly uint main_blkaddr; - public readonly uint root_ino; - public readonly uint node_ino; - public readonly uint meta_ino; - public readonly Guid uuid; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)] - public readonly byte[] volume_name; - public readonly uint extension_count; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list1; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list2; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list3; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list4; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list5; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list6; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list7; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] extension_list8; - public readonly uint cp_payload; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] - public readonly byte[] version; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] - public readonly byte[] init_version; - public readonly uint feature; - public readonly byte encryption_level; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] encrypt_pw_salt; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 871)] - public readonly byte[] reserved; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/F2FS/Structs.cs b/Aaru.Filesystems/F2FS/Structs.cs new file mode 100644 index 000000000..2e09de738 --- /dev/null +++ b/Aaru.Filesystems/F2FS/Structs.cs @@ -0,0 +1,102 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : F2FS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Flash-Friendly File System (F2FS) +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class F2FS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] + readonly struct Superblock + { + public readonly uint magic; + public readonly ushort major_ver; + public readonly ushort minor_ver; + public readonly uint log_sectorsize; + public readonly uint log_sectors_per_block; + public readonly uint log_blocksize; + public readonly uint log_blocks_per_seg; + public readonly uint segs_per_sec; + public readonly uint secs_per_zone; + public readonly uint checksum_offset; + public readonly ulong block_count; + public readonly uint section_count; + public readonly uint segment_count; + public readonly uint segment_count_ckpt; + public readonly uint segment_count_sit; + public readonly uint segment_count_nat; + public readonly uint segment_count_ssa; + public readonly uint segment_count_main; + public readonly uint segment0_blkaddr; + public readonly uint cp_blkaddr; + public readonly uint sit_blkaddr; + public readonly uint nat_blkaddr; + public readonly uint ssa_blkaddr; + public readonly uint main_blkaddr; + public readonly uint root_ino; + public readonly uint node_ino; + public readonly uint meta_ino; + public readonly Guid uuid; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)] + public readonly byte[] volume_name; + public readonly uint extension_count; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list1; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list2; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list3; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list4; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list5; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list6; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list7; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] extension_list8; + public readonly uint cp_payload; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] + public readonly byte[] version; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] + public readonly byte[] init_version; + public readonly uint feature; + public readonly byte encryption_level; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] encrypt_pw_salt; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 871)] + public readonly byte[] reserved; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 21957eb76..7ad87fd4a 100644 --- a/Aaru.Filesystems/FAT/BPB.cs +++ b/Aaru.Filesystems/FAT/BPB.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Microsoft FAT Boot Parameter Block variant. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/Consts.cs b/Aaru.Filesystems/FAT/Consts.cs index abb81fea9..7a8ccdec5 100644 --- a/Aaru.Filesystems/FAT/Consts.cs +++ b/Aaru.Filesystems/FAT/Consts.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Microsoft FAT filesystem constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index cecc1ba67..eac0fc242 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle Microsoft FAT filesystem directories. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/FAT.cs b/Aaru.Filesystems/FAT/FAT.cs index 39a0aa12d..95d021ef0 100644 --- a/Aaru.Filesystems/FAT/FAT.cs +++ b/Aaru.Filesystems/FAT/FAT.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Microsoft FAT filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index 3f0ada16b..1708d1cf0 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/Info.cs b/Aaru.Filesystems/FAT/Info.cs index 1b76e11fd..8593e40ad 100644 --- a/Aaru.Filesystems/FAT/Info.cs +++ b/Aaru.Filesystems/FAT/Info.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Microsoft FAT filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/Structs.cs b/Aaru.Filesystems/FAT/Structs.cs index 6c0465e2c..8aa94b8a2 100644 --- a/Aaru.Filesystems/FAT/Structs.cs +++ b/Aaru.Filesystems/FAT/Structs.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Microsoft FAT filesystem structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs index 1a750446e..3005e2d9d 100644 --- a/Aaru.Filesystems/FAT/Super.cs +++ b/Aaru.Filesystems/FAT/Super.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles mounting and umounting the Microsoft FAT filesystem. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs index 48e5c348a..7ee8cd118 100644 --- a/Aaru.Filesystems/FAT/Xattr.cs +++ b/Aaru.Filesystems/FAT/Xattr.cs @@ -7,10 +7,6 @@ // // Component : Microsoft FAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle Microsoft FAT extended attributes. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FATX/Consts.cs b/Aaru.Filesystems/FATX/Consts.cs index 24a1c3228..fffe52c3d 100644 --- a/Aaru.Filesystems/FATX/Consts.cs +++ b/Aaru.Filesystems/FATX/Consts.cs @@ -7,10 +7,6 @@ // // Component : FATX filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// FATX filesystem constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index 0436adb1d..d7d16cbce 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -7,10 +7,6 @@ // // Component : FATX filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to show the FATX directories. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FATX/FATX.cs b/Aaru.Filesystems/FATX/FATX.cs index e86cb790c..5c102eb3f 100644 --- a/Aaru.Filesystems/FATX/FATX.cs +++ b/Aaru.Filesystems/FATX/FATX.cs @@ -7,10 +7,6 @@ // // Component : FATX filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Constructors and common variables for the FATX filesystem plugin. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs index 842a5fad6..549401717 100644 --- a/Aaru.Filesystems/FATX/File.cs +++ b/Aaru.Filesystems/FATX/File.cs @@ -7,10 +7,6 @@ // // Component : FATX filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FATX/Info.cs b/Aaru.Filesystems/FATX/Info.cs index 5ab9f4dc4..bf8789a8b 100644 --- a/Aaru.Filesystems/FATX/Info.cs +++ b/Aaru.Filesystems/FATX/Info.cs @@ -7,10 +7,6 @@ // // Component : FATX filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the FATX filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FATX/Structs.cs b/Aaru.Filesystems/FATX/Structs.cs index 5fbfb35e3..2b12e739d 100644 --- a/Aaru.Filesystems/FATX/Structs.cs +++ b/Aaru.Filesystems/FATX/Structs.cs @@ -7,10 +7,6 @@ // // Component : FATX filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// FATX filesystem structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index f277f0c98..0574b8537 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -7,10 +7,6 @@ // // Component : FATX filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles mounting and umounting the FATX filesystem. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/FFS/Consts.cs b/Aaru.Filesystems/FFS/Consts.cs new file mode 100644 index 000000000..913c8c5ae --- /dev/null +++ b/Aaru.Filesystems/FFS/Consts.cs @@ -0,0 +1,86 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : BSD Fast File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using time_t = System.Int32; +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + +// Using information from Linux kernel headers +/// +/// Implements detection of BSD Fast File System (FFS, aka UNIX File System) +[SuppressMessage("ReSharper", "InconsistentNaming")] +public sealed partial class FFSPlugin +{ + const uint block_size = 8192; + + // FreeBSD specifies starts at byte offsets 0, 8192, 65536 and 262144, but in other cases it's following sectors + // Without bootcode + const ulong sb_start_floppy = 0; + + // With bootcode + const ulong sb_start_boot = 1; + + // Dunno, longer boot code + const ulong sb_start_long_boot = 8; + + // Found on AT&T for MD-2D floppieslzio + const ulong sb_start_att_dsdd = 14; + + // Found on hard disks (Atari UNIX e.g.) + const ulong sb_start_piggy = 32; + + // MAGICs + // UFS magic + const uint UFS_MAGIC = 0x00011954; + + // Big-endian UFS magic + const uint UFS_CIGAM = 0x54190100; + + // BorderWare UFS + const uint UFS_MAGIC_BW = 0x0F242697; + + // Big-endian BorderWare UFS + const uint UFS_CIGAM_BW = 0x9726240F; + + // UFS2 magic + const uint UFS2_MAGIC = 0x19540119; + + // Big-endian UFS2 magic + const uint UFS2_CIGAM = 0x19015419; + + // Incomplete newfs + const uint UFS_BAD_MAGIC = 0x19960408; + + // Big-endian incomplete newfs + const uint UFS_BAD_CIGAM = 0x08049619; + + const string FS_TYPE_UFS = "ufs"; + const string FS_TYPE_UFS2 = "ufs2"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/FFS/FFS.cs b/Aaru.Filesystems/FFS/FFS.cs new file mode 100644 index 000000000..763305e96 --- /dev/null +++ b/Aaru.Filesystems/FFS/FFS.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : FFS.cs +// Author(s) : Natalia Portillo +// +// Component : BSD Fast File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; +using time_t = System.Int32; +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + +// Using information from Linux kernel headers +/// +/// Implements detection of BSD Fast File System (FFS, aka UNIX File System) +[SuppressMessage("ReSharper", "InconsistentNaming")] +public sealed partial class FFSPlugin : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.FFSPlugin_Name; + /// + public Guid Id => new("CC90D342-05DB-48A8-988C-C1FE000034A3"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/FFS.cs b/Aaru.Filesystems/FFS/Info.cs similarity index 65% rename from Aaru.Filesystems/FFS.cs rename to Aaru.Filesystems/FFS/Info.cs index 3aae04e90..277e1b8c1 100644 --- a/Aaru.Filesystems/FFS.cs +++ b/Aaru.Filesystems/FFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : FFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : BSD Fast File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the BSD Fast File System and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -33,7 +29,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -41,7 +36,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; using time_t = System.Int32; using ufs_daddr_t = System.Int32; @@ -51,62 +45,8 @@ namespace Aaru.Filesystems; /// /// Implements detection of BSD Fast File System (FFS, aka UNIX File System) [SuppressMessage("ReSharper", "InconsistentNaming")] -public sealed class FFSPlugin : IFilesystem +public sealed partial class FFSPlugin { - const uint block_size = 8192; - - // FreeBSD specifies starts at byte offsets 0, 8192, 65536 and 262144, but in other cases it's following sectors - // Without bootcode - const ulong sb_start_floppy = 0; - - // With bootcode - const ulong sb_start_boot = 1; - - // Dunno, longer boot code - const ulong sb_start_long_boot = 8; - - // Found on AT&T for MD-2D floppieslzio - const ulong sb_start_att_dsdd = 14; - - // Found on hard disks (Atari UNIX e.g.) - const ulong sb_start_piggy = 32; - - // MAGICs - // UFS magic - const uint UFS_MAGIC = 0x00011954; - - // Big-endian UFS magic - const uint UFS_CIGAM = 0x54190100; - - // BorderWare UFS - const uint UFS_MAGIC_BW = 0x0F242697; - - // Big-endian BorderWare UFS - const uint UFS_CIGAM_BW = 0x9726240F; - - // UFS2 magic - const uint UFS2_MAGIC = 0x19540119; - - // Big-endian UFS2 magic - const uint UFS2_CIGAM = 0x19015419; - - // Incomplete newfs - const uint UFS_BAD_MAGIC = 0x19960408; - - // Big-endian incomplete newfs - const uint UFS_BAD_CIGAM = 0x08049619; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.FFSPlugin_Name; - /// - public Guid Id => new("CC90D342-05DB-48A8-988C-C1FE000034A3"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -152,9 +92,6 @@ public sealed class FFSPlugin : IFilesystem } } - const string FS_TYPE_UFS = "ufs"; - const string FS_TYPE_UFS2 = "ufs2"; - /// public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { @@ -606,255 +543,4 @@ public sealed class FFSPlugin : IFilesystem information = sbInformation.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct csum - { - /// number of directories - public int cs_ndir; - /// number of free blocks - public int cs_nbfree; - /// number of free inodes - public int cs_nifree; - /// number of free frags - public int cs_nffree; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct csum_total - { - /// number of directories - public long cs_ndir; - /// number of free blocks - public long cs_nbfree; - /// number of free inodes - public long cs_nifree; - /// number of free frags - public long cs_nffree; - /// number of free clusters - public long cs_numclusters; - /// future expansion - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly long[] cs_spare; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock - { - /// linked list of file systems - public readonly uint fs_link; - /// used for incore super blocks on Sun: uint fs_rolled; // logging only: fs fully rolled - public readonly uint fs_rlink; - /// addr of super-block in filesys - public readonly int fs_sblkno; - /// offset of cyl-block in filesys - public readonly int fs_cblkno; - /// offset of inode-blocks in filesys - public readonly int fs_iblkno; - /// offset of first data after cg - public readonly int fs_dblkno; - /// cylinder group offset in cylinder - public readonly int fs_old_cgoffset; - /// used to calc mod fs_ntrak - public readonly int fs_old_cgmask; - /// last time written - public readonly int fs_old_time; - /// number of blocks in fs - public readonly int fs_old_size; - /// number of data blocks in fs - public readonly int fs_old_dsize; - /// number of cylinder groups - public readonly int fs_ncg; - /// size of basic blocks in fs - public readonly int fs_bsize; - /// size of frag blocks in fs - public readonly int fs_fsize; - /// number of frags in a block in fs - public readonly int fs_frag; - /* these are configuration parameters */ - /// minimum percentage of free blocks - public readonly int fs_minfree; - /// num of ms for optimal next block - public readonly int fs_old_rotdelay; - /// disk revolutions per second - public readonly int fs_old_rps; - /* these fields can be computed from the others */ - /// ``blkoff'' calc of blk offsets - public readonly int fs_bmask; - /// ``fragoff'' calc of frag offsets - public readonly int fs_fmask; - /// ``lblkno'' calc of logical blkno - public readonly int fs_bshift; - /// ``numfrags'' calc number of frags - public readonly int fs_fshift; - /* these are configuration parameters */ - /// max number of contiguous blks - public readonly int fs_maxcontig; - /// max number of blks per cyl group - public readonly int fs_maxbpg; - /* these fields can be computed from the others */ - /// block to frag shift - public readonly int fs_fragshift; - /// fsbtodb and dbtofsb shift constant - public readonly int fs_fsbtodb; - /// actual size of super block - public readonly int fs_sbsize; - /// csum block offset - public readonly int fs_csmask; - /// csum block number - public readonly int fs_csshift; - /// value of NINDIR - public readonly int fs_nindir; - /// value of INOPB - public readonly uint fs_inopb; - /// value of NSPF - public readonly int fs_old_nspf; - /* yet another configuration parameter */ - /// optimization preference, see below On SVR: int fs_state; // file system state - public readonly int fs_optim; - /// # sectors/track including spares - public readonly int fs_old_npsect; - /// hardware sector interleave - public readonly int fs_old_interleave; - /// sector 0 skew, per track On A/UX: int fs_state; // file system state - public readonly int fs_old_trackskew; - /// unique filesystem id On old: int fs_headswitch; // head switch time, usec - public readonly int fs_id_1; - /// unique filesystem id On old: int fs_trkseek; // track-to-track seek, usec - public readonly int fs_id_2; - /* sizes determined by number of cylinder groups and their sizes */ - /// blk addr of cyl grp summary area - public readonly int fs_old_csaddr; - /// size of cyl grp summary area - public readonly int fs_cssize; - /// cylinder group size - public readonly int fs_cgsize; - /* these fields are derived from the hardware */ - /// tracks per cylinder - public readonly int fs_old_ntrak; - /// sectors per track - public readonly int fs_old_nsect; - /// sectors per cylinder - public readonly int fs_old_spc; - /* this comes from the disk driver partitioning */ - /// cylinders in filesystem - public readonly int fs_old_ncyl; - /* these fields can be computed from the others */ - /// cylinders per group - public readonly int fs_old_cpg; - /// inodes per group - public readonly int fs_ipg; - /// blocks per group * fs_frag - public readonly int fs_fpg; - /* this data must be re-computed after crashes */ - /// cylinder summary information - public csum fs_old_cstotal; - /* these fields are cleared at mount time */ - /// super block modified flag - public readonly sbyte fs_fmod; - /// filesystem is clean flag - public readonly sbyte fs_clean; - /// mounted read-only flag - public readonly sbyte fs_ronly; - /// old FS_ flags - public readonly sbyte fs_old_flags; - /// name mounted on - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 468)] - public readonly byte[] fs_fsmnt; - /// volume name - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] fs_volname; - /// system-wide uid - public readonly ulong fs_swuid; - /// due to alignment of fs_swuid - public readonly int fs_pad; - /* these fields retain the current block allocation info */ - /// last cg searched - public readonly int fs_cgrotor; - /// padding; was list of fs_cs buffers - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] - public readonly uint[] fs_ocsp; - /// (u) # of contig. allocated dirs - public readonly uint fs_contigdirs; - /// (u) cg summary info buffer - public readonly uint fs_csp; - /// (u) max cluster in each cyl group - public readonly uint fs_maxcluster; - /// (u) used by snapshots to track fs - public readonly uint fs_active; - /// cyl per cycle in postbl - public readonly int fs_old_cpc; - /// maximum blocking factor permitted - public readonly int fs_maxbsize; - /// number of unreferenced inodes - public readonly long fs_unrefs; - /// size of underlying GEOM provider - public readonly long fs_providersize; - /// size of area reserved for metadata - public readonly long fs_metaspace; - /// old rotation block list head - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] - public readonly long[] fs_sparecon64; - /// byte offset of standard superblock - public readonly long fs_sblockloc; - /// (u) cylinder summary information - public csum_total fs_cstotal; - /// last time written - public readonly long fs_time; - /// number of blocks in fs - public readonly long fs_size; - /// number of data blocks in fs - public readonly long fs_dsize; - /// blk addr of cyl grp summary area - public readonly long fs_csaddr; - /// (u) blocks being freed - public readonly long fs_pendingblocks; - /// (u) inodes being freed - public readonly uint fs_pendinginodes; - /// list of snapshot inode numbers - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly uint[] fs_snapinum; - /// expected average file size - public readonly uint fs_avgfilesize; - /// expected # of files per directory - public readonly uint fs_avgfpdir; - /// save real cg size to use fs_bsize - public readonly int fs_save_cgsize; - /// Last mount or fsck time. - public readonly long fs_mtime; - /// SUJ free list - public readonly int fs_sujfree; - /// reserved for future constants - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 23)] - public readonly int[] fs_sparecon32; - /// see FS_ flags below - public readonly int fs_flags; - /// size of cluster summary array - public readonly int fs_contigsumsize; - /// max length of an internal symlink - public readonly int fs_maxsymlinklen; - /// format of on-disk inodes - public readonly int fs_old_inodefmt; - /// maximum representable file size - public readonly ulong fs_maxfilesize; - /// ~fs_bmask for use with 64-bit size - public readonly long fs_qbmask; - /// ~fs_fmask for use with 64-bit size - public readonly long fs_qfmask; - /// validate fs_clean field - public readonly int fs_state; - /// format of positional layout tables - public readonly int fs_old_postblformat; - /// number of rotational positions - public readonly int fs_old_nrpos; - /// (short) rotation block list head - public readonly int fs_old_postbloff; - /// (uchar_t) blocks for each rotation - public readonly int fs_old_rotbloff; - /// magic number - public readonly uint fs_magic; - /// list of blocks for each rotation - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] - public readonly byte[] fs_rotbl; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/FFS/Structs.cs b/Aaru.Filesystems/FFS/Structs.cs new file mode 100644 index 000000000..c7b90e103 --- /dev/null +++ b/Aaru.Filesystems/FFS/Structs.cs @@ -0,0 +1,292 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : BSD Fast File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; +using time_t = System.Int32; +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + +// Using information from Linux kernel headers +/// +/// Implements detection of BSD Fast File System (FFS, aka UNIX File System) +[SuppressMessage("ReSharper", "InconsistentNaming")] +public sealed partial class FFSPlugin +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct csum + { + /// number of directories + public int cs_ndir; + /// number of free blocks + public int cs_nbfree; + /// number of free inodes + public int cs_nifree; + /// number of free frags + public int cs_nffree; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct csum_total + { + /// number of directories + public long cs_ndir; + /// number of free blocks + public long cs_nbfree; + /// number of free inodes + public long cs_nifree; + /// number of free frags + public long cs_nffree; + /// number of free clusters + public long cs_numclusters; + /// future expansion + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly long[] cs_spare; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct SuperBlock + { + /// linked list of file systems + public readonly uint fs_link; + /// used for incore super blocks on Sun: uint fs_rolled; // logging only: fs fully rolled + public readonly uint fs_rlink; + /// addr of super-block in filesys + public readonly int fs_sblkno; + /// offset of cyl-block in filesys + public readonly int fs_cblkno; + /// offset of inode-blocks in filesys + public readonly int fs_iblkno; + /// offset of first data after cg + public readonly int fs_dblkno; + /// cylinder group offset in cylinder + public readonly int fs_old_cgoffset; + /// used to calc mod fs_ntrak + public readonly int fs_old_cgmask; + /// last time written + public readonly int fs_old_time; + /// number of blocks in fs + public readonly int fs_old_size; + /// number of data blocks in fs + public readonly int fs_old_dsize; + /// number of cylinder groups + public readonly int fs_ncg; + /// size of basic blocks in fs + public readonly int fs_bsize; + /// size of frag blocks in fs + public readonly int fs_fsize; + /// number of frags in a block in fs + public readonly int fs_frag; + /* these are configuration parameters */ + /// minimum percentage of free blocks + public readonly int fs_minfree; + /// num of ms for optimal next block + public readonly int fs_old_rotdelay; + /// disk revolutions per second + public readonly int fs_old_rps; + /* these fields can be computed from the others */ + /// ``blkoff'' calc of blk offsets + public readonly int fs_bmask; + /// ``fragoff'' calc of frag offsets + public readonly int fs_fmask; + /// ``lblkno'' calc of logical blkno + public readonly int fs_bshift; + /// ``numfrags'' calc number of frags + public readonly int fs_fshift; + /* these are configuration parameters */ + /// max number of contiguous blks + public readonly int fs_maxcontig; + /// max number of blks per cyl group + public readonly int fs_maxbpg; + /* these fields can be computed from the others */ + /// block to frag shift + public readonly int fs_fragshift; + /// fsbtodb and dbtofsb shift constant + public readonly int fs_fsbtodb; + /// actual size of super block + public readonly int fs_sbsize; + /// csum block offset + public readonly int fs_csmask; + /// csum block number + public readonly int fs_csshift; + /// value of NINDIR + public readonly int fs_nindir; + /// value of INOPB + public readonly uint fs_inopb; + /// value of NSPF + public readonly int fs_old_nspf; + /* yet another configuration parameter */ + /// optimization preference, see below On SVR: int fs_state; // file system state + public readonly int fs_optim; + /// # sectors/track including spares + public readonly int fs_old_npsect; + /// hardware sector interleave + public readonly int fs_old_interleave; + /// sector 0 skew, per track On A/UX: int fs_state; // file system state + public readonly int fs_old_trackskew; + /// unique filesystem id On old: int fs_headswitch; // head switch time, usec + public readonly int fs_id_1; + /// unique filesystem id On old: int fs_trkseek; // track-to-track seek, usec + public readonly int fs_id_2; + /* sizes determined by number of cylinder groups and their sizes */ + /// blk addr of cyl grp summary area + public readonly int fs_old_csaddr; + /// size of cyl grp summary area + public readonly int fs_cssize; + /// cylinder group size + public readonly int fs_cgsize; + /* these fields are derived from the hardware */ + /// tracks per cylinder + public readonly int fs_old_ntrak; + /// sectors per track + public readonly int fs_old_nsect; + /// sectors per cylinder + public readonly int fs_old_spc; + /* this comes from the disk driver partitioning */ + /// cylinders in filesystem + public readonly int fs_old_ncyl; + /* these fields can be computed from the others */ + /// cylinders per group + public readonly int fs_old_cpg; + /// inodes per group + public readonly int fs_ipg; + /// blocks per group * fs_frag + public readonly int fs_fpg; + /* this data must be re-computed after crashes */ + /// cylinder summary information + public csum fs_old_cstotal; + /* these fields are cleared at mount time */ + /// super block modified flag + public readonly sbyte fs_fmod; + /// filesystem is clean flag + public readonly sbyte fs_clean; + /// mounted read-only flag + public readonly sbyte fs_ronly; + /// old FS_ flags + public readonly sbyte fs_old_flags; + /// name mounted on + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 468)] + public readonly byte[] fs_fsmnt; + /// volume name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] fs_volname; + /// system-wide uid + public readonly ulong fs_swuid; + /// due to alignment of fs_swuid + public readonly int fs_pad; + /* these fields retain the current block allocation info */ + /// last cg searched + public readonly int fs_cgrotor; + /// padding; was list of fs_cs buffers + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] + public readonly uint[] fs_ocsp; + /// (u) # of contig. allocated dirs + public readonly uint fs_contigdirs; + /// (u) cg summary info buffer + public readonly uint fs_csp; + /// (u) max cluster in each cyl group + public readonly uint fs_maxcluster; + /// (u) used by snapshots to track fs + public readonly uint fs_active; + /// cyl per cycle in postbl + public readonly int fs_old_cpc; + /// maximum blocking factor permitted + public readonly int fs_maxbsize; + /// number of unreferenced inodes + public readonly long fs_unrefs; + /// size of underlying GEOM provider + public readonly long fs_providersize; + /// size of area reserved for metadata + public readonly long fs_metaspace; + /// old rotation block list head + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + public readonly long[] fs_sparecon64; + /// byte offset of standard superblock + public readonly long fs_sblockloc; + /// (u) cylinder summary information + public csum_total fs_cstotal; + /// last time written + public readonly long fs_time; + /// number of blocks in fs + public readonly long fs_size; + /// number of data blocks in fs + public readonly long fs_dsize; + /// blk addr of cyl grp summary area + public readonly long fs_csaddr; + /// (u) blocks being freed + public readonly long fs_pendingblocks; + /// (u) inodes being freed + public readonly uint fs_pendinginodes; + /// list of snapshot inode numbers + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly uint[] fs_snapinum; + /// expected average file size + public readonly uint fs_avgfilesize; + /// expected # of files per directory + public readonly uint fs_avgfpdir; + /// save real cg size to use fs_bsize + public readonly int fs_save_cgsize; + /// Last mount or fsck time. + public readonly long fs_mtime; + /// SUJ free list + public readonly int fs_sujfree; + /// reserved for future constants + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 23)] + public readonly int[] fs_sparecon32; + /// see FS_ flags below + public readonly int fs_flags; + /// size of cluster summary array + public readonly int fs_contigsumsize; + /// max length of an internal symlink + public readonly int fs_maxsymlinklen; + /// format of on-disk inodes + public readonly int fs_old_inodefmt; + /// maximum representable file size + public readonly ulong fs_maxfilesize; + /// ~fs_bmask for use with 64-bit size + public readonly long fs_qbmask; + /// ~fs_fmask for use with 64-bit size + public readonly long fs_qfmask; + /// validate fs_clean field + public readonly int fs_state; + /// format of positional layout tables + public readonly int fs_old_postblformat; + /// number of rotational positions + public readonly int fs_old_nrpos; + /// (short) rotation block list head + public readonly int fs_old_postbloff; + /// (uchar_t) blocks for each rotation + public readonly int fs_old_rotbloff; + /// magic number + public readonly uint fs_magic; + /// list of blocks for each rotation + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] + public readonly byte[] fs_rotbl; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Fossil/Consts.cs b/Aaru.Filesystems/Fossil/Consts.cs new file mode 100644 index 000000000..44ee341aa --- /dev/null +++ b/Aaru.Filesystems/Fossil/Consts.cs @@ -0,0 +1,42 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Fossil filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the Plan-9 Fossil on-disk filesystem +public sealed partial class Fossil +{ + const uint FOSSIL_HDR_MAGIC = 0x3776AE89; + const uint FOSSIL_SB_MAGIC = 0x2340A3B1; + + // Fossil header starts at 128KiB + const ulong HEADER_POS = 128 * 1024; + + const string FS_TYPE = "fossil"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Fossil/Fossil.cs b/Aaru.Filesystems/Fossil/Fossil.cs new file mode 100644 index 000000000..8093ee6eb --- /dev/null +++ b/Aaru.Filesystems/Fossil/Fossil.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Fossil.cs +// Author(s) : Natalia Portillo +// +// Component : Fossil filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the Plan-9 Fossil on-disk filesystem +public sealed partial class Fossil : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.Fossil_Name; + /// + public Guid Id => new("932BF104-43F6-494F-973C-45EF58A51DA9"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Fossil.cs b/Aaru.Filesystems/Fossil/Info.cs similarity index 64% rename from Aaru.Filesystems/Fossil.cs rename to Aaru.Filesystems/Fossil/Info.cs index 6408ba504..d7fc1cde4 100644 --- a/Aaru.Filesystems/Fossil.cs +++ b/Aaru.Filesystems/Fossil/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Fossil.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Fossil filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Fossil filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,8 +26,6 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -39,33 +33,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection for the Plan-9 Fossil on-disk filesystem -public sealed class Fossil : IFilesystem +public sealed partial class Fossil { - const uint FOSSIL_HDR_MAGIC = 0x3776AE89; - const uint FOSSIL_SB_MAGIC = 0x2340A3B1; - - // Fossil header starts at 128KiB - const ulong HEADER_POS = 128 * 1024; - - const string FS_TYPE = "fossil"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.Fossil_Name; - /// - public Guid Id => new("932BF104-43F6-494F-973C-45EF58A51DA9"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -148,50 +122,4 @@ public sealed class Fossil : IFilesystem information = sb.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Header - { - /// Magic number - public readonly uint magic; - /// Header version - public readonly ushort version; - /// Block size - public readonly ushort blockSize; - /// Block containing superblock - public readonly uint super; - /// Block containing labels - public readonly uint label; - /// Where do data blocks start - public readonly uint data; - /// How many data blocks does it have - public readonly uint end; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - /// Magic number - public readonly uint magic; - /// Header version - public readonly ushort version; - /// file system low epoch - public readonly uint epochLow; - /// file system high(active) epoch - public readonly uint epochHigh; - /// next qid to allocate - public readonly ulong qid; - /// data block number: root of active file system - public readonly int active; - /// data block number: root of next file system to archive - public readonly int next; - /// data block number: root of file system currently being archived - public readonly int current; - /// Venti score of last successful archive - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly byte[] last; - /// name of file system(just a comment) - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public readonly byte[] name; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Fossil/Structs.cs b/Aaru.Filesystems/Fossil/Structs.cs new file mode 100644 index 000000000..4e225eb63 --- /dev/null +++ b/Aaru.Filesystems/Fossil/Structs.cs @@ -0,0 +1,82 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Fossil filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the Plan-9 Fossil on-disk filesystem +public sealed partial class Fossil +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Header + { + /// Magic number + public readonly uint magic; + /// Header version + public readonly ushort version; + /// Block size + public readonly ushort blockSize; + /// Block containing superblock + public readonly uint super; + /// Block containing labels + public readonly uint label; + /// Where do data blocks start + public readonly uint data; + /// How many data blocks does it have + public readonly uint end; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + /// Magic number + public readonly uint magic; + /// Header version + public readonly ushort version; + /// file system low epoch + public readonly uint epochLow; + /// file system high(active) epoch + public readonly uint epochHigh; + /// next qid to allocate + public readonly ulong qid; + /// data block number: root of active file system + public readonly int active; + /// data block number: root of next file system to archive + public readonly int next; + /// data block number: root of file system currently being archived + public readonly int current; + /// Venti score of last successful archive + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly byte[] last; + /// name of file system(just a comment) + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] + public readonly byte[] name; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/HAMMER/Consts.cs b/Aaru.Filesystems/HAMMER/Consts.cs new file mode 100644 index 000000000..de2d732b8 --- /dev/null +++ b/Aaru.Filesystems/HAMMER/Consts.cs @@ -0,0 +1,47 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : HAMMER filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using hammer_crc_t = System.UInt32; +using hammer_off_t = System.UInt64; +using hammer_tid_t = System.UInt64; + +#pragma warning disable 169 + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the HAMMER filesystem +public sealed partial class HAMMER +{ + const ulong HAMMER_FSBUF_VOLUME = 0xC8414D4DC5523031; + const ulong HAMMER_FSBUF_VOLUME_REV = 0x313052C54D4D41C8; + const uint HAMMER_VOLHDR_SIZE = 1928; + const int HAMMER_BIGBLOCK_SIZE = 8192 * 1024; + + const string FS_TYPE = "hammer"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/HAMMER/HAMMER.cs b/Aaru.Filesystems/HAMMER/HAMMER.cs new file mode 100644 index 000000000..ae2cd4f8b --- /dev/null +++ b/Aaru.Filesystems/HAMMER/HAMMER.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : HAMMER.cs +// Author(s) : Natalia Portillo +// +// Component : HAMMER filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; +using hammer_crc_t = System.UInt32; +using hammer_off_t = System.UInt64; +using hammer_tid_t = System.UInt64; + +#pragma warning disable 169 + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the HAMMER filesystem +public sealed partial class HAMMER : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.HAMMER_Name; + /// + public Guid Id => new("91A188BF-5FD7-4677-BBD3-F59EBA9C864D"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/HAMMER.cs b/Aaru.Filesystems/HAMMER/Info.cs similarity index 53% rename from Aaru.Filesystems/HAMMER.cs rename to Aaru.Filesystems/HAMMER/Info.cs index 4605563ca..1f76828dc 100644 --- a/Aaru.Filesystems/HAMMER.cs +++ b/Aaru.Filesystems/HAMMER/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : HAMMER.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : HAMMER filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the HAMMER filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,8 +27,6 @@ // ****************************************************************************/ using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -42,7 +36,6 @@ using Schemas; using hammer_crc_t = System.UInt32; using hammer_off_t = System.UInt64; using hammer_tid_t = System.UInt64; -using Marshal = Aaru.Helpers.Marshal; #pragma warning disable 169 @@ -50,26 +43,8 @@ namespace Aaru.Filesystems; /// /// Implements detection for the HAMMER filesystem -public sealed class HAMMER : IFilesystem +public sealed partial class HAMMER { - const ulong HAMMER_FSBUF_VOLUME = 0xC8414D4DC5523031; - const ulong HAMMER_FSBUF_VOLUME_REV = 0x313052C54D4D41C8; - const uint HAMMER_VOLHDR_SIZE = 1928; - const int HAMMER_BIGBLOCK_SIZE = 8192 * 1024; - - const string FS_TYPE = "hammer"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.HAMMER_Name; - /// - public Guid Id => new("91A188BF-5FD7-4677-BBD3-F59EBA9C864D"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -164,95 +139,4 @@ public sealed class HAMMER : IFilesystem information = sb.ToString(); } - - /// Hammer superblock - [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] - readonly struct SuperBlock - { - /// for a valid header - public readonly ulong vol_signature; - - /* These are relative to block device offset, not zone offsets. */ - /// offset of boot area - public readonly long vol_bot_beg; - /// offset of memory log - public readonly long vol_mem_beg; - /// offset of the first buffer in volume - public readonly long vol_buf_beg; - /// offset of volume EOF (on buffer boundary) - public readonly long vol_buf_end; - public readonly long vol_reserved01; - - /// identify filesystem - public readonly Guid vol_fsid; - /// identify filesystem type - public readonly Guid vol_fstype; - /// filesystem label - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] vol_label; - - /// volume number within filesystem - public readonly int vol_no; - /// number of volumes making up filesystem - public readonly int vol_count; - - /// version control information - public readonly uint vol_version; - /// header crc - public readonly hammer_crc_t vol_crc; - /// volume flags - public readonly uint vol_flags; - /// the root volume number (must be 0) - public readonly uint vol_rootvol; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly uint[] vol_reserved; - - /* - * These fields are initialized and space is reserved in every - * volume making up a HAMMER filesystem, but only the root volume - * contains valid data. Note that vol0_stat_bigblocks does not - * include big-blocks for freemap and undomap initially allocated - * by newfs_hammer(8). - */ - /// total big-blocks when fs is empty - public readonly long vol0_stat_bigblocks; - /// number of free big-blocks - public readonly long vol0_stat_freebigblocks; - public readonly long vol0_reserved01; - /// for statfs only - public readonly long vol0_stat_inodes; - public readonly long vol0_reserved02; - /// B-Tree root offset in zone-8 - public readonly hammer_off_t vol0_btree_root; - /// highest partially synchronized TID - public readonly hammer_tid_t vol0_next_tid; - public readonly hammer_off_t vol0_reserved03; - - /// - /// Blockmaps for zones. Not all zones use a blockmap. Note that the entire root blockmap is cached in the - /// hammer_mount structure. - /// - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly HammerBlockMap[] vol0_blockmap; - - /// Array of zone-2 addresses for undo FIFO. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public readonly hammer_off_t[] vol0_undo_array; - } - - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] - struct HammerBlockMap - { - /// zone-2 offset only used by zone-4 - public hammer_off_t phys_offset; - /// zone-X offset only used by zone-3 - public hammer_off_t first_offset; - /// zone-X offset for allocation - public hammer_off_t next_offset; - /// zone-X offset only used by zone-3 - public hammer_off_t alloc_offset; - public uint reserved01; - public hammer_crc_t entry_crc; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/HAMMER/Structs.cs b/Aaru.Filesystems/HAMMER/Structs.cs new file mode 100644 index 000000000..2ceb95654 --- /dev/null +++ b/Aaru.Filesystems/HAMMER/Structs.cs @@ -0,0 +1,134 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : HAMMER filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; +using hammer_crc_t = System.UInt32; +using hammer_off_t = System.UInt64; +using hammer_tid_t = System.UInt64; + +#pragma warning disable 169 + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the HAMMER filesystem +public sealed partial class HAMMER +{ + /// Hammer superblock + [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] + readonly struct SuperBlock + { + /// for a valid header + public readonly ulong vol_signature; + + /* These are relative to block device offset, not zone offsets. */ + /// offset of boot area + public readonly long vol_bot_beg; + /// offset of memory log + public readonly long vol_mem_beg; + /// offset of the first buffer in volume + public readonly long vol_buf_beg; + /// offset of volume EOF (on buffer boundary) + public readonly long vol_buf_end; + public readonly long vol_reserved01; + + /// identify filesystem + public readonly Guid vol_fsid; + /// identify filesystem type + public readonly Guid vol_fstype; + /// filesystem label + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] vol_label; + + /// volume number within filesystem + public readonly int vol_no; + /// number of volumes making up filesystem + public readonly int vol_count; + + /// version control information + public readonly uint vol_version; + /// header crc + public readonly hammer_crc_t vol_crc; + /// volume flags + public readonly uint vol_flags; + /// the root volume number (must be 0) + public readonly uint vol_rootvol; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly uint[] vol_reserved; + + /* + * These fields are initialized and space is reserved in every + * volume making up a HAMMER filesystem, but only the root volume + * contains valid data. Note that vol0_stat_bigblocks does not + * include big-blocks for freemap and undomap initially allocated + * by newfs_hammer(8). + */ + /// total big-blocks when fs is empty + public readonly long vol0_stat_bigblocks; + /// number of free big-blocks + public readonly long vol0_stat_freebigblocks; + public readonly long vol0_reserved01; + /// for statfs only + public readonly long vol0_stat_inodes; + public readonly long vol0_reserved02; + /// B-Tree root offset in zone-8 + public readonly hammer_off_t vol0_btree_root; + /// highest partially synchronized TID + public readonly hammer_tid_t vol0_next_tid; + public readonly hammer_off_t vol0_reserved03; + + /// + /// Blockmaps for zones. Not all zones use a blockmap. Note that the entire root blockmap is cached in the + /// hammer_mount structure. + /// + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly HammerBlockMap[] vol0_blockmap; + + /// Array of zone-2 addresses for undo FIFO. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] + public readonly hammer_off_t[] vol0_undo_array; + } + + [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] + struct HammerBlockMap + { + /// zone-2 offset only used by zone-4 + public hammer_off_t phys_offset; + /// zone-X offset only used by zone-3 + public hammer_off_t first_offset; + /// zone-X offset for allocation + public hammer_off_t next_offset; + /// zone-X offset only used by zone-3 + public hammer_off_t alloc_offset; + public uint reserved01; + public hammer_crc_t entry_crc; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/HPFS/Consts.cs b/Aaru.Filesystems/HPFS/Consts.cs new file mode 100644 index 000000000..3fff50049 --- /dev/null +++ b/Aaru.Filesystems/HPFS/Consts.cs @@ -0,0 +1,41 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : OS/2 High Performance File System plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the OS/2 High Performance 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from an old unnamed document +/// +/// Implements detection of IBM's High Performance File System (HPFS) +public sealed partial class HPFS +{ + const string FS_TYPE = "hpfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/HPFS/HPFS.cs b/Aaru.Filesystems/HPFS/HPFS.cs new file mode 100644 index 000000000..6da3660a2 --- /dev/null +++ b/Aaru.Filesystems/HPFS/HPFS.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : HPFS.cs +// Author(s) : Natalia Portillo +// +// Component : OS/2 High Performance File System plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the OS/2 High Performance 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from an old unnamed document +/// +/// Implements detection of IBM's High Performance File System (HPFS) +public sealed partial class HPFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.HPFS_Name; + /// + public Guid Id => new("33513B2C-f590-4acb-8bf2-0b1d5e19dec5"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/HPFS.cs b/Aaru.Filesystems/HPFS/Info.cs similarity index 62% rename from Aaru.Filesystems/HPFS.cs rename to Aaru.Filesystems/HPFS/Info.cs index d2ea3dc5f..27b76080b 100644 --- a/Aaru.Filesystems/HPFS.cs +++ b/Aaru.Filesystems/HPFS/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : HPFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : OS/2 High Performance File System plugin. @@ -31,7 +31,6 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.Checksums; using Aaru.CommonTypes; @@ -39,27 +38,14 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; // Information from an old unnamed document /// /// Implements detection of IBM's High Performance File System (HPFS) -public sealed class HPFS : IFilesystem +public sealed partial class HPFS { - const string FS_TYPE = "hpfs"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.HPFS_Name; - /// - public Guid Id => new("33513B2C-f590-4acb-8bf2-0b1d5e19dec5"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -261,145 +247,4 @@ public sealed class HPFS : IFilesystem information = sb.ToString(); } - - /// BIOS Parameter Block, at sector 0 - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct BiosParameterBlock - { - /// 0x000, Jump to boot code - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// 0x003, OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// 0x00B, Bytes per sector - public readonly ushort bps; - /// 0x00D, Sectors per cluster - public readonly byte spc; - /// 0x00E, Reserved sectors between BPB and... does it have sense in HPFS? - public readonly ushort rsectors; - /// 0x010, Number of FATs... seriously? - public readonly byte fats_no; - /// 0x011, Number of entries on root directory... ok - public readonly ushort root_ent; - /// 0x013, Sectors in volume... doubt it - public readonly ushort sectors; - /// 0x015, Media descriptor - public readonly byte media; - /// 0x016, Sectors per FAT... again - public readonly ushort spfat; - /// 0x018, Sectors per track... you're kidding - public readonly ushort sptrk; - /// 0x01A, Heads... stop! - public readonly ushort heads; - /// 0x01C, Hidden sectors before BPB - public readonly uint hsectors; - /// 0x024, Sectors in volume if > 65535... - public readonly uint big_sectors; - /// 0x028, Drive number - public readonly byte drive_no; - /// 0x029, Volume flags? - public readonly byte nt_flags; - /// 0x02A, EPB signature, 0x29 - public readonly byte signature; - /// 0x02B, Volume serial number - public readonly uint serial_no; - /// 0x02F, Volume label, 11 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] volume_label; - /// 0x03A, Filesystem type, 8 bytes, space-padded ("HPFS ") - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] fs_type; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 448)] - public readonly byte[] boot_code; - /// 0x1FE, 0xAA55 - public readonly ushort signature2; - } - - /// HPFS superblock at sector 16 - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - /// 0x000, 0xF995E849 - public readonly uint magic1; - /// 0x004, 0xFA53E9C5 - public readonly uint magic2; - /// 0x008, HPFS version - public readonly byte version; - /// 0x009, 2 if <= 4 GiB, 3 if > 4 GiB - public readonly byte func_version; - /// 0x00A, Alignment - public readonly ushort dummy; - /// 0x00C, LSN pointer to root fnode - public readonly uint root_fnode; - /// 0x010, Sectors on volume - public readonly uint sectors; - /// 0x014, Bad blocks on volume - public readonly uint badblocks; - /// 0x018, LSN pointer to volume bitmap - public readonly uint bitmap_lsn; - /// 0x01C, 0 - public readonly uint zero1; - /// 0x020, LSN pointer to badblock directory - public readonly uint badblock_lsn; - /// 0x024, 0 - public readonly uint zero2; - /// 0x028, Time of last CHKDSK - public readonly int last_chkdsk; - /// 0x02C, Time of last optimization - public readonly int last_optim; - /// 0x030, Sectors of dir band - public readonly uint dband_sectors; - /// 0x034, Start sector of dir band - public readonly uint dband_start; - /// 0x038, Last sector of dir band - public readonly uint dband_last; - /// 0x03C, LSN of free space bitmap - public readonly uint dband_bitmap; - /// 0x040, Can be used for volume name (32 bytes) - public readonly ulong zero3; - /// 0x048, ... - public readonly ulong zero4; - /// 0x04C, ... - public readonly ulong zero5; - /// 0x050, ...; - public readonly ulong zero6; - /// 0x058, LSN pointer to ACLs (only HPFS386) - public readonly uint acl_start; - } - - /// HPFS spareblock at sector 17 - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SpareBlock - { - /// 0x000, 0xF9911849 - public readonly uint magic1; - /// 0x004, 0xFA5229C5 - public readonly uint magic2; - /// 0x008, HPFS flags - public readonly byte flags1; - /// 0x009, HPFS386 flags - public readonly byte flags2; - /// 0x00A, Alignment - public readonly ushort dummy; - /// 0x00C, LSN of hotfix directory - public readonly uint hotfix_start; - /// 0x010, Used hotfixes - public readonly uint hotfix_used; - /// 0x014, Total hotfixes available - public readonly uint hotfix_entries; - /// 0x018, Unused spare dnodes - public readonly uint spare_dnodes_free; - /// 0x01C, Length of spare dnodes list - public readonly uint spare_dnodes; - /// 0x020, LSN of codepage directory - public readonly uint codepage_lsn; - /// 0x024, Number of codepages used - public readonly uint codepages; - /// 0x028, SuperBlock CRC32 (only HPFS386) - public readonly uint sb_crc32; - /// 0x02C, SpareBlock CRC32 (only HPFS386) - public readonly uint sp_crc32; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/HPFS/Structs.cs b/Aaru.Filesystems/HPFS/Structs.cs new file mode 100644 index 000000000..619be1f80 --- /dev/null +++ b/Aaru.Filesystems/HPFS/Structs.cs @@ -0,0 +1,182 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : OS/2 High Performance File System plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the OS/2 High Performance 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from an old unnamed document +/// +/// Implements detection of IBM's High Performance File System (HPFS) +public sealed partial class HPFS +{ + /// BIOS Parameter Block, at sector 0 + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct BiosParameterBlock + { + /// 0x000, Jump to boot code + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// 0x003, OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// 0x00B, Bytes per sector + public readonly ushort bps; + /// 0x00D, Sectors per cluster + public readonly byte spc; + /// 0x00E, Reserved sectors between BPB and... does it have sense in HPFS? + public readonly ushort rsectors; + /// 0x010, Number of FATs... seriously? + public readonly byte fats_no; + /// 0x011, Number of entries on root directory... ok + public readonly ushort root_ent; + /// 0x013, Sectors in volume... doubt it + public readonly ushort sectors; + /// 0x015, Media descriptor + public readonly byte media; + /// 0x016, Sectors per FAT... again + public readonly ushort spfat; + /// 0x018, Sectors per track... you're kidding + public readonly ushort sptrk; + /// 0x01A, Heads... stop! + public readonly ushort heads; + /// 0x01C, Hidden sectors before BPB + public readonly uint hsectors; + /// 0x024, Sectors in volume if > 65535... + public readonly uint big_sectors; + /// 0x028, Drive number + public readonly byte drive_no; + /// 0x029, Volume flags? + public readonly byte nt_flags; + /// 0x02A, EPB signature, 0x29 + public readonly byte signature; + /// 0x02B, Volume serial number + public readonly uint serial_no; + /// 0x02F, Volume label, 11 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] volume_label; + /// 0x03A, Filesystem type, 8 bytes, space-padded ("HPFS ") + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] fs_type; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 448)] + public readonly byte[] boot_code; + /// 0x1FE, 0xAA55 + public readonly ushort signature2; + } + + /// HPFS superblock at sector 16 + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + /// 0x000, 0xF995E849 + public readonly uint magic1; + /// 0x004, 0xFA53E9C5 + public readonly uint magic2; + /// 0x008, HPFS version + public readonly byte version; + /// 0x009, 2 if <= 4 GiB, 3 if > 4 GiB + public readonly byte func_version; + /// 0x00A, Alignment + public readonly ushort dummy; + /// 0x00C, LSN pointer to root fnode + public readonly uint root_fnode; + /// 0x010, Sectors on volume + public readonly uint sectors; + /// 0x014, Bad blocks on volume + public readonly uint badblocks; + /// 0x018, LSN pointer to volume bitmap + public readonly uint bitmap_lsn; + /// 0x01C, 0 + public readonly uint zero1; + /// 0x020, LSN pointer to badblock directory + public readonly uint badblock_lsn; + /// 0x024, 0 + public readonly uint zero2; + /// 0x028, Time of last CHKDSK + public readonly int last_chkdsk; + /// 0x02C, Time of last optimization + public readonly int last_optim; + /// 0x030, Sectors of dir band + public readonly uint dband_sectors; + /// 0x034, Start sector of dir band + public readonly uint dband_start; + /// 0x038, Last sector of dir band + public readonly uint dband_last; + /// 0x03C, LSN of free space bitmap + public readonly uint dband_bitmap; + /// 0x040, Can be used for volume name (32 bytes) + public readonly ulong zero3; + /// 0x048, ... + public readonly ulong zero4; + /// 0x04C, ... + public readonly ulong zero5; + /// 0x050, ...; + public readonly ulong zero6; + /// 0x058, LSN pointer to ACLs (only HPFS386) + public readonly uint acl_start; + } + + /// HPFS spareblock at sector 17 + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SpareBlock + { + /// 0x000, 0xF9911849 + public readonly uint magic1; + /// 0x004, 0xFA5229C5 + public readonly uint magic2; + /// 0x008, HPFS flags + public readonly byte flags1; + /// 0x009, HPFS386 flags + public readonly byte flags2; + /// 0x00A, Alignment + public readonly ushort dummy; + /// 0x00C, LSN of hotfix directory + public readonly uint hotfix_start; + /// 0x010, Used hotfixes + public readonly uint hotfix_used; + /// 0x014, Total hotfixes available + public readonly uint hotfix_entries; + /// 0x018, Unused spare dnodes + public readonly uint spare_dnodes_free; + /// 0x01C, Length of spare dnodes list + public readonly uint spare_dnodes; + /// 0x020, LSN of codepage directory + public readonly uint codepage_lsn; + /// 0x024, Number of codepages used + public readonly uint codepages; + /// 0x028, SuperBlock CRC32 (only HPFS386) + public readonly uint sb_crc32; + /// 0x02C, SpareBlock CRC32 (only HPFS386) + public readonly uint sp_crc32; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/HPOFS/Consts.cs b/Aaru.Filesystems/HPOFS/Consts.cs index 301c3781b..a06c74acf 100644 --- a/Aaru.Filesystems/HPOFS/Consts.cs +++ b/Aaru.Filesystems/HPOFS/Consts.cs @@ -7,10 +7,6 @@ // // Component : High Performance Optical File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// High Performance Optical File System constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/HPOFS/HPOFS.cs b/Aaru.Filesystems/HPOFS/HPOFS.cs index 5a21ae140..240aa0b71 100644 --- a/Aaru.Filesystems/HPOFS/HPOFS.cs +++ b/Aaru.Filesystems/HPOFS/HPOFS.cs @@ -7,10 +7,6 @@ // // Component : High Performance Optical File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// High Performance Optical File System. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/HPOFS/Structs.cs b/Aaru.Filesystems/HPOFS/Structs.cs index df9ffb02e..e5348f6a9 100644 --- a/Aaru.Filesystems/HPOFS/Structs.cs +++ b/Aaru.Filesystems/HPOFS/Structs.cs @@ -7,10 +7,6 @@ // // Component : High Performance Optical File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// High Performance Optical File System structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/AAIP.cs b/Aaru.Filesystems/ISO9660/Consts/AAIP.cs index d83d581d1..a40405e9c 100644 --- a/Aaru.Filesystems/ISO9660/Consts/AAIP.cs +++ b/Aaru.Filesystems/ISO9660/Consts/AAIP.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// AAIP extensions constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/Amiga.cs b/Aaru.Filesystems/ISO9660/Consts/Amiga.cs index 486b3ee41..4dfac99fd 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Amiga.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Amiga.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Amiga extensions constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/Apple.cs b/Aaru.Filesystems/ISO9660/Consts/Apple.cs index 266ae3de5..05335122c 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Apple.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Apple.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple extensions constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs b/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs index db895f3bd..7738d6c60 100644 --- a/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs +++ b/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// El Torito extensions constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs b/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs index 15d33eb58..0fc1d5367 100644 --- a/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs +++ b/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// High Sierra Format constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/ISO.cs b/Aaru.Filesystems/ISO9660/Consts/ISO.cs index 18a38b6a9..4dd527e5c 100644 --- a/Aaru.Filesystems/ISO9660/Consts/ISO.cs +++ b/Aaru.Filesystems/ISO9660/Consts/ISO.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// ISO9660 filesystem constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/Internal.cs b/Aaru.Filesystems/ISO9660/Consts/Internal.cs index fc6edd170..404f7465e 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Internal.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Internal.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Internal constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/RRIP.cs b/Aaru.Filesystems/ISO9660/Consts/RRIP.cs index 798a7ed86..09b9d7b32 100644 --- a/Aaru.Filesystems/ISO9660/Consts/RRIP.cs +++ b/Aaru.Filesystems/ISO9660/Consts/RRIP.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// RRIP extensions constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/SUSP.cs b/Aaru.Filesystems/ISO9660/Consts/SUSP.cs index 319afd9f2..8268dab63 100644 --- a/Aaru.Filesystems/ISO9660/Consts/SUSP.cs +++ b/Aaru.Filesystems/ISO9660/Consts/SUSP.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// SUSP extensions constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Consts/Ziso.cs b/Aaru.Filesystems/ISO9660/Consts/Ziso.cs index 01bc84d6d..db4720726 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Ziso.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Ziso.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// zisofs extensions constants and enumerations. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Date.cs b/Aaru.Filesystems/ISO9660/Date.cs index cbbbc27aa..90d9cba73 100644 --- a/Aaru.Filesystems/ISO9660/Date.cs +++ b/Aaru.Filesystems/ISO9660/Date.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Decodes timestamps. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Dir.cs b/Aaru.Filesystems/ISO9660/Dir.cs index 5a15735b1..bcc603f6b 100644 --- a/Aaru.Filesystems/ISO9660/Dir.cs +++ b/Aaru.Filesystems/ISO9660/Dir.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles directory traversal and listing. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs index 0991a0a98..39d73e677 100644 --- a/Aaru.Filesystems/ISO9660/File.cs +++ b/Aaru.Filesystems/ISO9660/File.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles file and extents. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/ISO9660.cs b/Aaru.Filesystems/ISO9660/ISO9660.cs index 1b38ddf17..c2286f023 100644 --- a/Aaru.Filesystems/ISO9660/ISO9660.cs +++ b/Aaru.Filesystems/ISO9660/ISO9660.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Constructors and common variables for the ISO9660 filesystem plugin. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index d3ecfbf6a..550ace161 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the ISO9660 filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/PathTable.cs b/Aaru.Filesystems/ISO9660/PathTable.cs index 4de13e47d..9cb463349 100644 --- a/Aaru.Filesystems/ISO9660/PathTable.cs +++ b/Aaru.Filesystems/ISO9660/PathTable.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Decodes path tables. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/Amiga.cs b/Aaru.Filesystems/ISO9660/Structs/Amiga.cs index ea72e208e..17dbce77d 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Amiga.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Amiga.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Amiga extensions structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/Apple.cs b/Aaru.Filesystems/ISO9660/Structs/Apple.cs index 040ac5498..425f9da11 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Apple.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Apple.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple extensions structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs b/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs index 2b0b9891a..98106a93b 100644 --- a/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs +++ b/Aaru.Filesystems/ISO9660/Structs/ElTorito.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// El Torito extensions structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs index f440c9129..c13190801 100644 --- a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs +++ b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// High Sierra Format structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/ISO.cs b/Aaru.Filesystems/ISO9660/Structs/ISO.cs index 44f13d00a..e811b5073 100644 --- a/Aaru.Filesystems/ISO9660/Structs/ISO.cs +++ b/Aaru.Filesystems/ISO9660/Structs/ISO.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// ISO9660 filesystem structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/Internal.cs b/Aaru.Filesystems/ISO9660/Structs/Internal.cs index 553a1161c..87378ab00 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Internal.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Internal.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Internal structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs index dfe0091bf..ae5544e69 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Joliet extensions structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/RRIP.cs b/Aaru.Filesystems/ISO9660/Structs/RRIP.cs index 62758ba1f..ff2824e7c 100644 --- a/Aaru.Filesystems/ISO9660/Structs/RRIP.cs +++ b/Aaru.Filesystems/ISO9660/Structs/RRIP.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// RRIP extensions structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/SUSP.cs b/Aaru.Filesystems/ISO9660/Structs/SUSP.cs index 3ec5eab33..d6ec5bc40 100644 --- a/Aaru.Filesystems/ISO9660/Structs/SUSP.cs +++ b/Aaru.Filesystems/ISO9660/Structs/SUSP.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// SUSP extensions structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/ISO9660/Structs/Ziso.cs b/Aaru.Filesystems/ISO9660/Structs/Ziso.cs index f85ba5838..063dedf5c 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Ziso.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Ziso.cs @@ -7,10 +7,6 @@ // // Component : ISO9660 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// zisofs extensions structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/JFS/Consts.cs b/Aaru.Filesystems/JFS/Consts.cs new file mode 100644 index 000000000..455ff0670 --- /dev/null +++ b/Aaru.Filesystems/JFS/Consts.cs @@ -0,0 +1,41 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : IBM JFS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of IBM's Journaled File System +public sealed partial class JFS +{ + const uint JFS_BOOT_BLOCKS_SIZE = 0x8000; + const uint JFS_MAGIC = 0x3153464A; + + const string FS_TYPE = "jfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/JFS/Enums.cs b/Aaru.Filesystems/JFS/Enums.cs new file mode 100644 index 000000000..bd6b9d07d --- /dev/null +++ b/Aaru.Filesystems/JFS/Enums.cs @@ -0,0 +1,59 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : IBM JFS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of IBM's Journaled File System +public sealed partial class JFS +{ + [Flags, SuppressMessage("ReSharper", "InconsistentNaming")] + enum Flags : uint + { + Unicode = 0x00000001, RemountRO = 0x00000002, Continue = 0x00000004, + Panic = 0x00000008, UserQuota = 0x00000010, GroupQuota = 0x00000020, + NoJournal = 0x00000040, Discard = 0x00000080, GroupCommit = 0x00000100, + LazyCommit = 0x00000200, Temporary = 0x00000400, InlineLog = 0x00000800, + InlineMoving = 0x00001000, BadSAIT = 0x00010000, Sparse = 0x00020000, + DASDEnabled = 0x00040000, DASDPrime = 0x00080000, SwapBytes = 0x00100000, + DirIndex = 0x00200000, Linux = 0x10000000, DFS = 0x20000000, + OS2 = 0x40000000, AIX = 0x80000000 + } + + [Flags] + enum State : uint + { + Clean = 0, Mounted = 1, Dirty = 2, + Logredo = 4, Extendfs = 8 + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/JFS.cs b/Aaru.Filesystems/JFS/Info.cs similarity index 66% rename from Aaru.Filesystems/JFS.cs rename to Aaru.Filesystems/JFS/Info.cs index d50e7aff6..571c496e3 100644 --- a/Aaru.Filesystems/JFS.cs +++ b/Aaru.Filesystems/JFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : JFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : IBM JFS filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the IBM JFS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,39 +28,19 @@ // ReSharper disable UnusedMember.Local -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of IBM's Journaled File System -public sealed class JFS : IFilesystem +public sealed partial class JFS { - const uint JFS_BOOT_BLOCKS_SIZE = 0x8000; - const uint JFS_MAGIC = 0x3153464A; - - const string FS_TYPE = "jfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.JFS_Name; - /// - public Guid Id => new("D3BE2A41-8F28-4055-94DC-BB6C72A0E9C4"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -207,75 +183,4 @@ public sealed class JFS : IFilesystem information = sb.ToString(); } - - [Flags, SuppressMessage("ReSharper", "InconsistentNaming")] - enum Flags : uint - { - Unicode = 0x00000001, RemountRO = 0x00000002, Continue = 0x00000004, - Panic = 0x00000008, UserQuota = 0x00000010, GroupQuota = 0x00000020, - NoJournal = 0x00000040, Discard = 0x00000080, GroupCommit = 0x00000100, - LazyCommit = 0x00000200, Temporary = 0x00000400, InlineLog = 0x00000800, - InlineMoving = 0x00001000, BadSAIT = 0x00010000, Sparse = 0x00020000, - DASDEnabled = 0x00040000, DASDPrime = 0x00080000, SwapBytes = 0x00100000, - DirIndex = 0x00200000, Linux = 0x10000000, DFS = 0x20000000, - OS2 = 0x40000000, AIX = 0x80000000 - } - - [Flags] - enum State : uint - { - Clean = 0, Mounted = 1, Dirty = 2, - Logredo = 4, Extendfs = 8 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Extent - { - /// Leftmost 24 bits are extent length, rest 8 bits are most significant for - public readonly uint len_addr; - public readonly uint addr2; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct TimeStruct - { - public readonly uint tv_sec; - public readonly uint tv_nsec; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - public readonly uint s_magic; - public readonly uint s_version; - public readonly ulong s_size; - public readonly uint s_bsize; - public readonly ushort s_l2bsize; - public readonly ushort s_l2bfactor; - public readonly uint s_pbsize; - public readonly ushort s_l1pbsize; - public readonly ushort pad; - public readonly uint s_agsize; - public readonly Flags s_flags; - public readonly State s_state; - public readonly uint s_compress; - public readonly Extent s_ait2; - public readonly Extent s_aim2; - public readonly uint s_logdev; - public readonly uint s_logserial; - public readonly Extent s_logpxd; - public readonly Extent s_fsckpxd; - public readonly TimeStruct s_time; - public readonly uint s_fsckloglen; - public readonly sbyte s_fscklog; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] s_fpack; - public readonly ulong s_xsize; - public readonly Extent s_xfsckpxd; - public readonly Extent s_xlogpxd; - public readonly Guid s_uuid; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] s_label; - public readonly Guid s_loguuid; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/JFS/JFS.cs b/Aaru.Filesystems/JFS/JFS.cs new file mode 100644 index 000000000..83d5f0bae --- /dev/null +++ b/Aaru.Filesystems/JFS/JFS.cs @@ -0,0 +1,52 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : JFS.cs +// Author(s) : Natalia Portillo +// +// Component : IBM JFS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of IBM's Journaled File System +public sealed partial class JFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.JFS_Name; + /// + public Guid Id => new("D3BE2A41-8F28-4055-94DC-BB6C72A0E9C4"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/JFS/Structs.cs b/Aaru.Filesystems/JFS/Structs.cs new file mode 100644 index 000000000..4e7500aec --- /dev/null +++ b/Aaru.Filesystems/JFS/Structs.cs @@ -0,0 +1,90 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : IBM JFS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of IBM's Journaled File System +public sealed partial class JFS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Extent + { + /// Leftmost 24 bits are extent length, rest 8 bits are most significant for + public readonly uint len_addr; + public readonly uint addr2; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct TimeStruct + { + public readonly uint tv_sec; + public readonly uint tv_nsec; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + public readonly uint s_magic; + public readonly uint s_version; + public readonly ulong s_size; + public readonly uint s_bsize; + public readonly ushort s_l2bsize; + public readonly ushort s_l2bfactor; + public readonly uint s_pbsize; + public readonly ushort s_l1pbsize; + public readonly ushort pad; + public readonly uint s_agsize; + public readonly Flags s_flags; + public readonly State s_state; + public readonly uint s_compress; + public readonly Extent s_ait2; + public readonly Extent s_aim2; + public readonly uint s_logdev; + public readonly uint s_logserial; + public readonly Extent s_logpxd; + public readonly Extent s_fsckpxd; + public readonly TimeStruct s_time; + public readonly uint s_fsckloglen; + public readonly sbyte s_fscklog; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] s_fpack; + public readonly ulong s_xsize; + public readonly Extent s_xfsckpxd; + public readonly Extent s_xlogpxd; + public readonly Guid s_uuid; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] s_label; + public readonly Guid s_loguuid; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/LIF/Consts.cs b/Aaru.Filesystems/LIF/Consts.cs new file mode 100644 index 000000000..d085cfd9d --- /dev/null +++ b/Aaru.Filesystems/LIF/Consts.cs @@ -0,0 +1,39 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : HP Logical Interchange Format plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from http://www.hp9845.net/9845/projects/hpdir/#lif_filesystem +/// +/// Implements detection of the LIF filesystem +public sealed partial class LIF +{ + const uint LIF_MAGIC = 0x8000; + + const string FS_TYPE = "hplif"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/LIF.cs b/Aaru.Filesystems/LIF/Info.cs similarity index 74% rename from Aaru.Filesystems/LIF.cs rename to Aaru.Filesystems/LIF/Info.cs index 656ba0676..fa7d91a1b 100644 --- a/Aaru.Filesystems/LIF.cs +++ b/Aaru.Filesystems/LIF/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : LIF.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : HP Logical Interchange Format plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the HP Logical Interchange Format and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,8 +26,6 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -39,30 +33,14 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; // Information from http://www.hp9845.net/9845/projects/hpdir/#lif_filesystem /// /// Implements detection of the LIF filesystem -public sealed class LIF : IFilesystem +public sealed partial class LIF { - const uint LIF_MAGIC = 0x8000; - - const string FS_TYPE = "hplif"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.LIF_Name; - /// - public Guid Id => new("41535647-77A5-477B-9206-DA727ACDC704"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -126,23 +104,4 @@ public sealed class LIF : IFilesystem VolumeName = StringHandlers.CToString(lifSb.volumeLabel, Encoding) }; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SystemBlock - { - public readonly ushort magic; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] volumeLabel; - public readonly uint directoryStart; - public readonly ushort lifId; - public readonly ushort unused; - public readonly uint directorySize; - public readonly ushort lifVersion; - public readonly ushort unused2; - public readonly uint tracks; - public readonly uint heads; - public readonly uint sectors; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] creationDate; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/LIF/LIF.cs b/Aaru.Filesystems/LIF/LIF.cs new file mode 100644 index 000000000..6cd096182 --- /dev/null +++ b/Aaru.Filesystems/LIF/LIF.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : LIF.cs +// Author(s) : Natalia Portillo +// +// Component : HP Logical Interchange Format plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from http://www.hp9845.net/9845/projects/hpdir/#lif_filesystem +/// +/// Implements detection of the LIF filesystem +public sealed partial class LIF : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.LIF_Name; + /// + public Guid Id => new("41535647-77A5-477B-9206-DA727ACDC704"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/LIF/Structs.cs b/Aaru.Filesystems/LIF/Structs.cs new file mode 100644 index 000000000..833c7d146 --- /dev/null +++ b/Aaru.Filesystems/LIF/Structs.cs @@ -0,0 +1,56 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : HP Logical Interchange Format plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from http://www.hp9845.net/9845/projects/hpdir/#lif_filesystem +/// +/// Implements detection of the LIF filesystem +public sealed partial class LIF +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SystemBlock + { + public readonly ushort magic; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] volumeLabel; + public readonly uint directoryStart; + public readonly ushort lifId; + public readonly ushort unused; + public readonly uint directorySize; + public readonly ushort lifVersion; + public readonly ushort unused2; + public readonly uint tracks; + public readonly uint heads; + public readonly uint sectors; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] creationDate; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/LisaFS/Consts.cs b/Aaru.Filesystems/LisaFS/Consts.cs index c46d61985..7eace9881 100644 --- a/Aaru.Filesystems/LisaFS/Consts.cs +++ b/Aaru.Filesystems/LisaFS/Consts.cs @@ -7,10 +7,6 @@ // // Component : Apple Lisa filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Lisa filesystem constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs index b9764f469..e4d807c04 100644 --- a/Aaru.Filesystems/LisaFS/Extent.cs +++ b/Aaru.Filesystems/LisaFS/Extent.cs @@ -7,10 +7,6 @@ // // Component : Apple Lisa filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle Apple Lisa filesystem extents. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index dc7e9b2c7..0c1b4f759 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -7,10 +7,6 @@ // // Component : Apple Lisa filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/LisaFS/Info.cs b/Aaru.Filesystems/LisaFS/Info.cs index b37eee345..60117bbd5 100644 --- a/Aaru.Filesystems/LisaFS/Info.cs +++ b/Aaru.Filesystems/LisaFS/Info.cs @@ -7,10 +7,6 @@ // // Component : Apple Lisa filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Apple Lisa filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/LisaFS/LisaFS.cs b/Aaru.Filesystems/LisaFS/LisaFS.cs index 4d4ef24d9..5ff795cdb 100644 --- a/Aaru.Filesystems/LisaFS/LisaFS.cs +++ b/Aaru.Filesystems/LisaFS/LisaFS.cs @@ -7,10 +7,6 @@ // // Component : Apple Lisa filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Constructors and common variables for the Apple Lisa filesystem plugin. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/LisaFS/Structs.cs b/Aaru.Filesystems/LisaFS/Structs.cs index e24085930..e620c9e88 100644 --- a/Aaru.Filesystems/LisaFS/Structs.cs +++ b/Aaru.Filesystems/LisaFS/Structs.cs @@ -7,10 +7,6 @@ // // Component : Apple Lisa filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Apple Lisa filesystem structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs index 9072c9df0..84071382b 100644 --- a/Aaru.Filesystems/LisaFS/Super.cs +++ b/Aaru.Filesystems/LisaFS/Super.cs @@ -7,10 +7,6 @@ // // Component : Apple Lisa filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles mounting and umounting the Apple Lisa filesystem. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Locus/Consts.cs b/Aaru.Filesystems/Locus/Consts.cs new file mode 100644 index 000000000..e3bc631fa --- /dev/null +++ b/Aaru.Filesystems/Locus/Consts.cs @@ -0,0 +1,71 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Locus filesystem plugin +// +// --[ 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 aint with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2023 Natalia Portillo +// ****************************************************************************/ + +// Commit count + +using commitcnt_t = System.Int32; + +// Disk address +using daddr_t = System.Int32; + +// Fstore +using fstore_t = System.Int32; + +// Global File System number +using gfs_t = System.Int32; + +// Inode number +using ino_t = System.Int32; + +// Filesystem pack number +using pckno_t = System.Int16; + +// Timestamp +using time_t = System.Int32; + +// ReSharper disable UnusedMember.Local +// ReSharper disable UnusedType.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class Locus +{ + const int NICINOD = 325; + const int NICFREE = 600; + const int OLDNICINOD = 700; + const int OLDNICFREE = 500; + + const uint LOCUS_MAGIC = 0xFFEEDDCD; + const uint LOCUS_CIGAM = 0xCDDDEEFF; + const uint LOCUS_MAGIC_OLD = 0xFFEEDDCC; + const uint LOCUS_CIGAM_OLD = 0xCCDDEEFF; + + const string FS_TYPE = "locus"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Locus/Enums.cs b/Aaru.Filesystems/Locus/Enums.cs new file mode 100644 index 000000000..1f4659113 --- /dev/null +++ b/Aaru.Filesystems/Locus/Enums.cs @@ -0,0 +1,84 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : Locus filesystem plugin +// +// --[ 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 aint with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2023 Natalia Portillo +// ****************************************************************************/ + +// Commit count + +using System; +using System.Diagnostics.CodeAnalysis; +using commitcnt_t = System.Int32; + +// Disk address +using daddr_t = System.Int32; + +// Fstore +using fstore_t = System.Int32; + +// Global File System number +using gfs_t = System.Int32; + +// Inode number +using ino_t = System.Int32; + +// Filesystem pack number +using pckno_t = System.Int16; + +// Timestamp +using time_t = System.Int32; + +// ReSharper disable UnusedMember.Local +// ReSharper disable UnusedType.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class Locus +{ + [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), + Flags] + enum Flags : ushort + { + SB_RDONLY = 0x1, /* no writes on filesystem */ SB_CLEAN = 0x2, /* fs unmounted cleanly (or checks run) */ + SB_DIRTY = 0x4, /* fs mounted without CLEAN bit set */ SB_RMV = 0x8, /* fs is a removable file system */ + SB_PRIMPACK = 0x10, /* This is the primary pack of the filesystem */ + SB_REPLTYPE = 0x20, /* This is a replicated type filesystem. */ + SB_USER = 0x40, /* This is a "user" replicated filesystem. */ + SB_BACKBONE = 0x80, /* backbone pack ; complete copy of primary pack but not modifiable */ + SB_NFS = 0x100, /* This is a NFS type filesystem */ + SB_BYHAND = 0x200, /* Inhibits automatic fscks on a mangled file system */ + SB_NOSUID = 0x400, /* Set-uid/Set-gid is disabled */ SB_SYNCW = 0x800 /* Synchronous Write */ + } + + [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), + Flags] + enum Version : byte + { + SB_SB4096 = 1, /* smallblock filesys with 4096 byte blocks */ SB_B1024 = 2, /* 1024 byte block filesystem */ + NUMSCANDEV = 5 /* Used by scangfs(), refed in space.h */ + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Locus.cs b/Aaru.Filesystems/Locus/Info.cs similarity index 55% rename from Aaru.Filesystems/Locus.cs rename to Aaru.Filesystems/Locus/Info.cs index 41d7ca941..b9c312f4b 100644 --- a/Aaru.Filesystems/Locus.cs +++ b/Aaru.Filesystems/Locus/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Locus.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Locus filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Locus filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,9 +28,6 @@ // Commit count -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -55,7 +48,6 @@ using gfs_t = System.Int32; // Inode number using ino_t = System.Int32; -using Marshal = Aaru.Helpers.Marshal; // Filesystem pack number using pckno_t = System.Int16; @@ -70,31 +62,8 @@ namespace Aaru.Filesystems; /// /// Implements detection of the Locus filesystem -public sealed class Locus : IFilesystem +public sealed partial class Locus { - const int NICINOD = 325; - const int NICFREE = 600; - const int OLDNICINOD = 700; - const int OLDNICFREE = 500; - - const uint LOCUS_MAGIC = 0xFFEEDDCD; - const uint LOCUS_CIGAM = 0xCDDDEEFF; - const uint LOCUS_MAGIC_OLD = 0xFFEEDDCC; - const uint LOCUS_CIGAM_OLD = 0xCCDDEEFF; - - const string FS_TYPE = "locus"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.Locus_Name; - /// - public Guid Id => new("1A70B30A-437D-479A-88E1-D0C9C1797FF4"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -284,137 +253,4 @@ public sealed class Locus : IFilesystem FreeClustersSpecified = true }; } - - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), - StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Superblock - { - public readonly uint s_magic; /* identifies this as a locus filesystem */ - /* defined as a constant below */ - public readonly gfs_t s_gfs; /* global filesystem number */ - public readonly daddr_t s_fsize; /* size in blocks of entire volume */ - /* several ints for replicated filesystems */ - public readonly commitcnt_t s_lwm; /* all prior commits propagated */ - public readonly commitcnt_t s_hwm; /* highest commit propagated */ - /* oldest committed version in the list. - * llst mod NCMTLST is the offset of commit #llst in the list, - * which wraps around from there. - */ - public readonly commitcnt_t s_llst; - public readonly fstore_t s_fstore; /* filesystem storage bit mask; if the - filsys is replicated and this is not a - primary or backbone copy, this bit mask - determines which files are stored */ - - public readonly time_t s_time; /* last super block update */ - public readonly daddr_t s_tfree; /* total free blocks*/ - - public readonly ino_t s_isize; /* size in blocks of i-list */ - public readonly short s_nfree; /* number of addresses in s_free */ - public Flags s_flags; /* filsys flags, defined below */ - public readonly ino_t s_tinode; /* total free inodes */ - public readonly ino_t s_lasti; /* start place for circular search */ - public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ - public readonly pckno_t s_gfspack; /* global filesystem pack number */ - public readonly short s_ninode; /* number of i-nodes in s_inode */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - public readonly short[] s_dinfo; /* interleave stuff */ - - //#define s_m s_dinfo[0] - //#define s_skip s_dinfo[0] /* AIX defines */ - //#define s_n s_dinfo[1] - //#define s_cyl s_dinfo[1] /* AIX defines */ - public readonly byte s_flock; /* lock during free list manipulation */ - public readonly byte s_ilock; /* lock during i-list manipulation */ - public readonly byte s_fmod; /* super block modified flag */ - public readonly Version s_version; /* version of the data format in fs. */ - /* defined below. */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] s_fsmnt; /* name of this file system */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] s_fpack; /* name of this physical volume */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NICINOD)] - public readonly ino_t[] s_inode; /* free i-node list */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NICFREE)] - public readonly daddr_t[] su_free; /* free block list for non-replicated filsys */ - public readonly byte s_byteorder; /* byte order of integers */ - } - - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), - StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct OldSuperblock - { - public readonly uint s_magic; /* identifies this as a locus filesystem */ - /* defined as a constant below */ - public readonly gfs_t s_gfs; /* global filesystem number */ - public readonly daddr_t s_fsize; /* size in blocks of entire volume */ - /* several ints for replicated filsystems */ - public readonly commitcnt_t s_lwm; /* all prior commits propagated */ - public readonly commitcnt_t s_hwm; /* highest commit propagated */ - /* oldest committed version in the list. - * llst mod NCMTLST is the offset of commit #llst in the list, - * which wraps around from there. - */ - public readonly commitcnt_t s_llst; - public readonly fstore_t s_fstore; /* filesystem storage bit mask; if the - filsys is replicated and this is not a - primary or backbone copy, this bit mask - determines which files are stored */ - - public readonly time_t s_time; /* last super block update */ - public readonly daddr_t s_tfree; /* total free blocks*/ - - public readonly ino_t s_isize; /* size in blocks of i-list */ - public readonly short s_nfree; /* number of addresses in s_free */ - public readonly Flags s_flags; /* filsys flags, defined below */ - public readonly ino_t s_tinode; /* total free inodes */ - public readonly ino_t s_lasti; /* start place for circular search */ - public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ - public readonly pckno_t s_gfspack; /* global filesystem pack number */ - public readonly short s_ninode; /* number of i-nodes in s_inode */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - public readonly short[] s_dinfo; /* interleave stuff */ - - //#define s_m s_dinfo[0] - //#define s_skip s_dinfo[0] /* AIX defines */ - //#define s_n s_dinfo[1] - //#define s_cyl s_dinfo[1] /* AIX defines */ - public readonly byte s_flock; /* lock during free list manipulation */ - public readonly byte s_ilock; /* lock during i-list manipulation */ - public readonly byte s_fmod; /* super block modified flag */ - public readonly Version s_version; /* version of the data format in fs. */ - /* defined below. */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] s_fsmnt; /* name of this file system */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] s_fpack; /* name of this physical volume */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICINOD)] - public readonly ino_t[] s_inode; /* free i-node list */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICFREE)] - public readonly daddr_t[] su_free; /* free block list for non-replicated filsys */ - public readonly byte s_byteorder; /* byte order of integers */ - } - - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), - Flags] - enum Flags : ushort - { - SB_RDONLY = 0x1, /* no writes on filesystem */ SB_CLEAN = 0x2, /* fs unmounted cleanly (or checks run) */ - SB_DIRTY = 0x4, /* fs mounted without CLEAN bit set */ SB_RMV = 0x8, /* fs is a removable file system */ - SB_PRIMPACK = 0x10, /* This is the primary pack of the filesystem */ - SB_REPLTYPE = 0x20, /* This is a replicated type filesystem. */ - SB_USER = 0x40, /* This is a "user" replicated filesystem. */ - SB_BACKBONE = 0x80, /* backbone pack ; complete copy of primary pack but not modifiable */ - SB_NFS = 0x100, /* This is a NFS type filesystem */ - SB_BYHAND = 0x200, /* Inhibits automatic fscks on a mangled file system */ - SB_NOSUID = 0x400, /* Set-uid/Set-gid is disabled */ SB_SYNCW = 0x800 /* Synchronous Write */ - } - - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), - Flags] - enum Version : byte - { - SB_SB4096 = 1, /* smallblock filesys with 4096 byte blocks */ SB_B1024 = 2, /* 1024 byte block filesystem */ - NUMSCANDEV = 5 /* Used by scangfs(), refed in space.h */ - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Locus/Locus.cs b/Aaru.Filesystems/Locus/Locus.cs new file mode 100644 index 000000000..d5d7542ee --- /dev/null +++ b/Aaru.Filesystems/Locus/Locus.cs @@ -0,0 +1,74 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Locus.cs +// Author(s) : Natalia Portillo +// +// Component : Locus filesystem plugin +// +// --[ 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 aint with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2023 Natalia Portillo +// ****************************************************************************/ + +// Commit count + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; +using commitcnt_t = System.Int32; + +// Disk address +using daddr_t = System.Int32; + +// Fstore +using fstore_t = System.Int32; + +// Global File System number +using gfs_t = System.Int32; + +// Inode number +using ino_t = System.Int32; + +// Filesystem pack number +using pckno_t = System.Int16; + +// Timestamp +using time_t = System.Int32; + +// ReSharper disable UnusedMember.Local +// ReSharper disable UnusedType.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class Locus : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.Locus_Name; + /// + public Guid Id => new("1A70B30A-437D-479A-88E1-D0C9C1797FF4"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Locus/Structs.cs b/Aaru.Filesystems/Locus/Structs.cs new file mode 100644 index 000000000..98daac0a0 --- /dev/null +++ b/Aaru.Filesystems/Locus/Structs.cs @@ -0,0 +1,171 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Locus filesystem plugin +// +// --[ 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 aint with this library; if not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2023 Natalia Portillo +// ****************************************************************************/ + +// Commit count + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; +using commitcnt_t = System.Int32; + +// Disk address +using daddr_t = System.Int32; + +// Fstore +using fstore_t = System.Int32; + +// Global File System number +using gfs_t = System.Int32; + +// Inode number +using ino_t = System.Int32; + +// Filesystem pack number +using pckno_t = System.Int16; + +// Timestamp +using time_t = System.Int32; + +// ReSharper disable UnusedMember.Local +// ReSharper disable UnusedType.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class Locus +{ + [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), + StructLayout(LayoutKind.Sequential, Pack = 1)] + struct Superblock + { + public readonly uint s_magic; /* identifies this as a locus filesystem */ + /* defined as a constant below */ + public readonly gfs_t s_gfs; /* global filesystem number */ + public readonly daddr_t s_fsize; /* size in blocks of entire volume */ + /* several ints for replicated filesystems */ + public readonly commitcnt_t s_lwm; /* all prior commits propagated */ + public readonly commitcnt_t s_hwm; /* highest commit propagated */ + /* oldest committed version in the list. + * llst mod NCMTLST is the offset of commit #llst in the list, + * which wraps around from there. + */ + public readonly commitcnt_t s_llst; + public readonly fstore_t s_fstore; /* filesystem storage bit mask; if the + filsys is replicated and this is not a + primary or backbone copy, this bit mask + determines which files are stored */ + + public readonly time_t s_time; /* last super block update */ + public readonly daddr_t s_tfree; /* total free blocks*/ + + public readonly ino_t s_isize; /* size in blocks of i-list */ + public readonly short s_nfree; /* number of addresses in s_free */ + public Flags s_flags; /* filsys flags, defined below */ + public readonly ino_t s_tinode; /* total free inodes */ + public readonly ino_t s_lasti; /* start place for circular search */ + public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ + public readonly pckno_t s_gfspack; /* global filesystem pack number */ + public readonly short s_ninode; /* number of i-nodes in s_inode */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public readonly short[] s_dinfo; /* interleave stuff */ + + //#define s_m s_dinfo[0] + //#define s_skip s_dinfo[0] /* AIX defines */ + //#define s_n s_dinfo[1] + //#define s_cyl s_dinfo[1] /* AIX defines */ + public readonly byte s_flock; /* lock during free list manipulation */ + public readonly byte s_ilock; /* lock during i-list manipulation */ + public readonly byte s_fmod; /* super block modified flag */ + public readonly Version s_version; /* version of the data format in fs. */ + /* defined below. */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] s_fsmnt; /* name of this file system */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] s_fpack; /* name of this physical volume */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NICINOD)] + public readonly ino_t[] s_inode; /* free i-node list */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NICFREE)] + public readonly daddr_t[] su_free; /* free block list for non-replicated filsys */ + public readonly byte s_byteorder; /* byte order of integers */ + } + + [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), + StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct OldSuperblock + { + public readonly uint s_magic; /* identifies this as a locus filesystem */ + /* defined as a constant below */ + public readonly gfs_t s_gfs; /* global filesystem number */ + public readonly daddr_t s_fsize; /* size in blocks of entire volume */ + /* several ints for replicated filsystems */ + public readonly commitcnt_t s_lwm; /* all prior commits propagated */ + public readonly commitcnt_t s_hwm; /* highest commit propagated */ + /* oldest committed version in the list. + * llst mod NCMTLST is the offset of commit #llst in the list, + * which wraps around from there. + */ + public readonly commitcnt_t s_llst; + public readonly fstore_t s_fstore; /* filesystem storage bit mask; if the + filsys is replicated and this is not a + primary or backbone copy, this bit mask + determines which files are stored */ + + public readonly time_t s_time; /* last super block update */ + public readonly daddr_t s_tfree; /* total free blocks*/ + + public readonly ino_t s_isize; /* size in blocks of i-list */ + public readonly short s_nfree; /* number of addresses in s_free */ + public readonly Flags s_flags; /* filsys flags, defined below */ + public readonly ino_t s_tinode; /* total free inodes */ + public readonly ino_t s_lasti; /* start place for circular search */ + public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ + public readonly pckno_t s_gfspack; /* global filesystem pack number */ + public readonly short s_ninode; /* number of i-nodes in s_inode */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public readonly short[] s_dinfo; /* interleave stuff */ + + //#define s_m s_dinfo[0] + //#define s_skip s_dinfo[0] /* AIX defines */ + //#define s_n s_dinfo[1] + //#define s_cyl s_dinfo[1] /* AIX defines */ + public readonly byte s_flock; /* lock during free list manipulation */ + public readonly byte s_ilock; /* lock during i-list manipulation */ + public readonly byte s_fmod; /* super block modified flag */ + public readonly Version s_version; /* version of the data format in fs. */ + /* defined below. */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] s_fsmnt; /* name of this file system */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] s_fpack; /* name of this physical volume */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICINOD)] + public readonly ino_t[] s_inode; /* free i-node list */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICFREE)] + public readonly daddr_t[] su_free; /* free block list for non-replicated filsys */ + public readonly byte s_byteorder; /* byte order of integers */ + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/MicroDOS/Consts.cs b/Aaru.Filesystems/MicroDOS/Consts.cs new file mode 100644 index 000000000..558b545e9 --- /dev/null +++ b/Aaru.Filesystems/MicroDOS/Consts.cs @@ -0,0 +1,45 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : MicroDOS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedType.Local +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + +/// +/// +/// Implements detection for the MicroDOS filesystem. Information from http://www.owg.ru/mkt/BK/MKDOS.TXT Thanks +/// to tarlabnor for translating it +/// +public sealed partial class MicroDOS +{ + const ushort MAGIC = 0xA72E; + const ushort MAGIC2 = 0x530C; + + const string FS_TYPE = "microdos"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/MicroDOS/Enums.cs b/Aaru.Filesystems/MicroDOS/Enums.cs new file mode 100644 index 000000000..19ea2646d --- /dev/null +++ b/Aaru.Filesystems/MicroDOS/Enums.cs @@ -0,0 +1,46 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : MicroDOS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedType.Local +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + +/// +/// +/// Implements detection for the MicroDOS filesystem. Information from http://www.owg.ru/mkt/BK/MKDOS.TXT Thanks +/// to tarlabnor for translating it +/// +public sealed partial class MicroDOS +{ + enum FileStatus : byte + { + CommonFile = 0, Protected = 1, LogicalDisk = 2, + BadFile = 0x80, Deleted = 0xFF + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/MicroDOS/Info.cs b/Aaru.Filesystems/MicroDOS/Info.cs new file mode 100644 index 000000000..4318c7f37 --- /dev/null +++ b/Aaru.Filesystems/MicroDOS/Info.cs @@ -0,0 +1,104 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Info.cs +// Author(s) : Natalia Portillo +// +// Component : MicroDOS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedType.Local +// ReSharper disable UnusedMember.Local + +using System.Text; +using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.Helpers; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// +/// Implements detection for the MicroDOS filesystem. Information from http://www.owg.ru/mkt/BK/MKDOS.TXT Thanks +/// to tarlabnor for translating it +/// +public sealed partial class MicroDOS +{ + /// + public bool Identify(IMediaImage imagePlugin, Partition partition) + { + if(1 + partition.Start >= partition.End) + return false; + + if(imagePlugin.Info.SectorSize < 512) + return false; + + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0); + + if(errno != ErrorNumber.NoError) + return false; + + Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); + + return block0 is { label: MAGIC, mklabel: MAGIC2 }; + } + + /// + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) + { + Encoding = encoding ?? Encoding.GetEncoding("koi8-r"); + information = ""; + + var sb = new StringBuilder(); + + ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0); + + if(errno != ErrorNumber.NoError) + return; + + Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); + + sb.AppendLine(Localization.MicroDOS_filesystem); + sb.AppendFormat(Localization.Volume_has_0_blocks_1_bytes, block0.blocks, block0.blocks * 512).AppendLine(); + + sb.AppendFormat(Localization.Volume_has_0_blocks_used_1_bytes, block0.usedBlocks, block0.usedBlocks * 512). + AppendLine(); + + sb.AppendFormat(Localization.Volume_contains_0_files, block0.files).AppendLine(); + sb.AppendFormat(Localization.First_used_block_is_0, block0.firstUsedBlock).AppendLine(); + + XmlFsType = new FileSystemType + { + Type = FS_TYPE, + ClusterSize = 512, + Clusters = block0.blocks, + Files = block0.files, + FilesSpecified = true, + FreeClusters = (ulong)(block0.blocks - block0.usedBlocks), + FreeClustersSpecified = true + }; + + information = sb.ToString(); + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/MicroDOS/MicroDOS.cs b/Aaru.Filesystems/MicroDOS/MicroDOS.cs new file mode 100644 index 000000000..8a5b92574 --- /dev/null +++ b/Aaru.Filesystems/MicroDOS/MicroDOS.cs @@ -0,0 +1,56 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : MicroDOS.cs +// Author(s) : Natalia Portillo +// +// Component : MicroDOS filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedType.Local +// ReSharper disable UnusedMember.Local + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// +/// Implements detection for the MicroDOS filesystem. Information from http://www.owg.ru/mkt/BK/MKDOS.TXT Thanks +/// to tarlabnor for translating it +/// +public sealed partial class MicroDOS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.MicroDOS_Name; + /// + public Guid Id => new("9F9A364A-1A27-48A3-B730-7A7122000324"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/MicroDOS.cs b/Aaru.Filesystems/MicroDOS/Structs.cs similarity index 57% rename from Aaru.Filesystems/MicroDOS.cs rename to Aaru.Filesystems/MicroDOS/Structs.cs index 8c3325328..1d7e77515 100644 --- a/Aaru.Filesystems/MicroDOS.cs +++ b/Aaru.Filesystems/MicroDOS/Structs.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : MicroDOS.cs +// Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : MicroDOS filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the MicroDOS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -33,14 +29,7 @@ // ReSharper disable UnusedType.Local // ReSharper disable UnusedMember.Local -using System; using System.Runtime.InteropServices; -using System.Text; -using Aaru.CommonTypes; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; -using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -49,81 +38,8 @@ namespace Aaru.Filesystems; /// Implements detection for the MicroDOS filesystem. Information from http://www.owg.ru/mkt/BK/MKDOS.TXT Thanks /// to tarlabnor for translating it /// -public sealed class MicroDOS : IFilesystem +public sealed partial class MicroDOS { - const ushort MAGIC = 0xA72E; - const ushort MAGIC2 = 0x530C; - - const string FS_TYPE = "microdos"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.MicroDOS_Name; - /// - public Guid Id => new("9F9A364A-1A27-48A3-B730-7A7122000324"); - /// - public string Author => Authors.NataliaPortillo; - - /// - public bool Identify(IMediaImage imagePlugin, Partition partition) - { - if(1 + partition.Start >= partition.End) - return false; - - if(imagePlugin.Info.SectorSize < 512) - return false; - - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0); - - if(errno != ErrorNumber.NoError) - return false; - - Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); - - return block0 is { label: MAGIC, mklabel: MAGIC2 }; - } - - /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) - { - Encoding = encoding ?? Encoding.GetEncoding("koi8-r"); - information = ""; - - var sb = new StringBuilder(); - - ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bk0); - - if(errno != ErrorNumber.NoError) - return; - - Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); - - sb.AppendLine(Localization.MicroDOS_filesystem); - sb.AppendFormat(Localization.Volume_has_0_blocks_1_bytes, block0.blocks, block0.blocks * 512).AppendLine(); - - sb.AppendFormat(Localization.Volume_has_0_blocks_used_1_bytes, block0.usedBlocks, block0.usedBlocks * 512). - AppendLine(); - - sb.AppendFormat(Localization.Volume_contains_0_files, block0.files).AppendLine(); - sb.AppendFormat(Localization.First_used_block_is_0, block0.firstUsedBlock).AppendLine(); - - XmlFsType = new FileSystemType - { - Type = FS_TYPE, - ClusterSize = 512, - Clusters = block0.blocks, - Files = block0.files, - FilesSpecified = true, - FreeClusters = (ulong)(block0.blocks - block0.usedBlocks), - FreeClustersSpecified = true - }; - - information = sb.ToString(); - } - // Followed by directory entries [StructLayout(LayoutKind.Sequential, Pack = 1)] readonly struct Block0 @@ -176,10 +92,4 @@ public sealed class MicroDOS : IFilesystem /// Length public readonly ushort length; } - - enum FileStatus : byte - { - CommonFile = 0, Protected = 1, LogicalDisk = 2, - BadFile = 0x80, Deleted = 0xFF - } } \ No newline at end of file diff --git a/Aaru.Filesystems/MinixFS/Consts.cs b/Aaru.Filesystems/MinixFS/Consts.cs new file mode 100644 index 000000000..991b90414 --- /dev/null +++ b/Aaru.Filesystems/MinixFS/Consts.cs @@ -0,0 +1,62 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : MINIX filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the MINIX filesystem +public sealed partial class MinixFS +{ + /// Minix v1, 14 char filenames + const ushort MINIX_MAGIC = 0x137F; + /// Minix v1, 30 char filenames + const ushort MINIX_MAGIC2 = 0x138F; + /// Minix v2, 14 char filenames + const ushort MINIX2_MAGIC = 0x2468; + /// Minix v2, 30 char filenames + const ushort MINIX2_MAGIC2 = 0x2478; + /// Minix v3, 60 char filenames + const ushort MINIX3_MAGIC = 0x4D5A; + + // Byteswapped + /// Minix v1, 14 char filenames + const ushort MINIX_CIGAM = 0x7F13; + /// Minix v1, 30 char filenames + const ushort MINIX_CIGAM2 = 0x8F13; + /// Minix v2, 14 char filenames + const ushort MINIX2_CIGAM = 0x6824; + /// Minix v2, 30 char filenames + const ushort MINIX2_CIGAM2 = 0x7824; + /// Minix v3, 60 char filenames + const ushort MINIX3_CIGAM = 0x5A4D; + + const string FS_TYPE_V1 = "minix"; + const string FS_TYPE_V2 = "minix2"; + const string FS_TYPE_V3 = "minix3"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/MinixFS.cs b/Aaru.Filesystems/MinixFS/Info.cs similarity index 71% rename from Aaru.Filesystems/MinixFS.cs rename to Aaru.Filesystems/MinixFS/Info.cs index 05c7ffed4..e8920f830 100644 --- a/Aaru.Filesystems/MinixFS.cs +++ b/Aaru.Filesystems/MinixFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : MinixFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : MINIX filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the MINIX filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,58 +27,20 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; +using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; // Information from the Linux kernel /// /// Implements detection of the MINIX filesystem -public sealed class MinixFS : IFilesystem +public sealed partial class MinixFS { - /// Minix v1, 14 char filenames - const ushort MINIX_MAGIC = 0x137F; - /// Minix v1, 30 char filenames - const ushort MINIX_MAGIC2 = 0x138F; - /// Minix v2, 14 char filenames - const ushort MINIX2_MAGIC = 0x2468; - /// Minix v2, 30 char filenames - const ushort MINIX2_MAGIC2 = 0x2478; - /// Minix v3, 60 char filenames - const ushort MINIX3_MAGIC = 0x4D5A; - - // Byteswapped - /// Minix v1, 14 char filenames - const ushort MINIX_CIGAM = 0x7F13; - /// Minix v1, 30 char filenames - const ushort MINIX_CIGAM2 = 0x8F13; - /// Minix v2, 14 char filenames - const ushort MINIX2_CIGAM = 0x6824; - /// Minix v2, 30 char filenames - const ushort MINIX2_CIGAM2 = 0x7824; - /// Minix v3, 60 char filenames - const ushort MINIX3_CIGAM = 0x5A4D; - const string FS_TYPE_V1 = "minix"; - const string FS_TYPE_V2 = "minix2"; - const string FS_TYPE_V3 = "minix3"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.MinixFS_Name; - /// - public Guid Id => new("FE248C3B-B727-4AE5-A39F-79EA9A07D4B3"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -326,62 +284,4 @@ public sealed class MinixFS : IFilesystem information = sb.ToString(); } - - /// Superblock for Minix v1 and V2 filesystems - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - /// 0x00, inodes on volume - public readonly ushort s_ninodes; - /// 0x02, zones on volume - public readonly ushort s_nzones; - /// 0x04, blocks on inode map - public readonly short s_imap_blocks; - /// 0x06, blocks on zone map - public readonly short s_zmap_blocks; - /// 0x08, first data zone - public readonly ushort s_firstdatazone; - /// 0x0A, log2 of blocks/zone - public readonly short s_log_zone_size; - /// 0x0C, max file size - public readonly uint s_max_size; - /// 0x10, magic - public readonly ushort s_magic; - /// 0x12, filesystem state - public readonly ushort s_state; - /// 0x14, number of zones - public readonly uint s_zones; - } - - /// Superblock for Minix v3 filesystems - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock3 - { - /// 0x00, inodes on volume - public readonly uint s_ninodes; - /// 0x02, old zones on volume - public readonly ushort s_nzones; - /// 0x06, blocks on inode map - public readonly ushort s_imap_blocks; - /// 0x08, blocks on zone map - public readonly ushort s_zmap_blocks; - /// 0x0A, first data zone - public readonly ushort s_firstdatazone; - /// 0x0C, log2 of blocks/zone - public readonly ushort s_log_zone_size; - /// 0x0E, padding - public readonly ushort s_pad1; - /// 0x10, max file size - public readonly uint s_max_size; - /// 0x14, number of zones - public readonly uint s_zones; - /// 0x18, magic - public readonly ushort s_magic; - /// 0x1A, padding - public readonly ushort s_pad2; - /// 0x1C, bytes in a block - public ushort s_blocksize; - /// 0x1E, on-disk structures version - public readonly byte s_disk_version; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/MinixFS/MinixFS.cs b/Aaru.Filesystems/MinixFS/MinixFS.cs new file mode 100644 index 000000000..b374e0dd8 --- /dev/null +++ b/Aaru.Filesystems/MinixFS/MinixFS.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : MinixFS.cs +// Author(s) : Natalia Portillo +// +// Component : MINIX filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the MINIX filesystem +public sealed partial class MinixFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.MinixFS_Name; + /// + public Guid Id => new("FE248C3B-B727-4AE5-A39F-79EA9A07D4B3"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/MinixFS/Structs.cs b/Aaru.Filesystems/MinixFS/Structs.cs new file mode 100644 index 000000000..03b9d757e --- /dev/null +++ b/Aaru.Filesystems/MinixFS/Structs.cs @@ -0,0 +1,95 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : MINIX filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the MINIX filesystem +public sealed partial class MinixFS +{ + /// Superblock for Minix v1 and V2 filesystems + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + /// 0x00, inodes on volume + public readonly ushort s_ninodes; + /// 0x02, zones on volume + public readonly ushort s_nzones; + /// 0x04, blocks on inode map + public readonly short s_imap_blocks; + /// 0x06, blocks on zone map + public readonly short s_zmap_blocks; + /// 0x08, first data zone + public readonly ushort s_firstdatazone; + /// 0x0A, log2 of blocks/zone + public readonly short s_log_zone_size; + /// 0x0C, max file size + public readonly uint s_max_size; + /// 0x10, magic + public readonly ushort s_magic; + /// 0x12, filesystem state + public readonly ushort s_state; + /// 0x14, number of zones + public readonly uint s_zones; + } + + /// Superblock for Minix v3 filesystems + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct SuperBlock3 + { + /// 0x00, inodes on volume + public readonly uint s_ninodes; + /// 0x02, old zones on volume + public readonly ushort s_nzones; + /// 0x06, blocks on inode map + public readonly ushort s_imap_blocks; + /// 0x08, blocks on zone map + public readonly ushort s_zmap_blocks; + /// 0x0A, first data zone + public readonly ushort s_firstdatazone; + /// 0x0C, log2 of blocks/zone + public readonly ushort s_log_zone_size; + /// 0x0E, padding + public readonly ushort s_pad1; + /// 0x10, max file size + public readonly uint s_max_size; + /// 0x14, number of zones + public readonly uint s_zones; + /// 0x18, magic + public readonly ushort s_magic; + /// 0x1A, padding + public readonly ushort s_pad2; + /// 0x1C, bytes in a block + public ushort s_blocksize; + /// 0x1E, on-disk structures version + public readonly byte s_disk_version; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/NILFS2/Consts.cs b/Aaru.Filesystems/NILFS2/Consts.cs new file mode 100644 index 000000000..7c8f0cfd2 --- /dev/null +++ b/Aaru.Filesystems/NILFS2/Consts.cs @@ -0,0 +1,41 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : NILFS2 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the New Implementation of a Log-structured File System v2 +public sealed partial class NILFS2 +{ + const ushort NILFS2_MAGIC = 0x3434; + const uint NILFS2_SUPER_OFFSET = 1024; + + const string FS_TYPE = "nilfs2"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/NILFS2/Enums.cs b/Aaru.Filesystems/NILFS2/Enums.cs new file mode 100644 index 000000000..07e252336 --- /dev/null +++ b/Aaru.Filesystems/NILFS2/Enums.cs @@ -0,0 +1,41 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : NILFS2 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the New Implementation of a Log-structured File System v2 +public sealed partial class NILFS2 +{ + enum State : ushort + { + Valid = 0x0001, Error = 0x0002, Resize = 0x0004 + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/NILFS2.cs b/Aaru.Filesystems/NILFS2/Info.cs similarity index 67% rename from Aaru.Filesystems/NILFS2.cs rename to Aaru.Filesystems/NILFS2/Info.cs index 4ba0280e5..de0650763 100644 --- a/Aaru.Filesystems/NILFS2.cs +++ b/Aaru.Filesystems/NILFS2/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : NILFS2.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : NILFS2 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the NILFS2 filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,38 +28,19 @@ // ReSharper disable UnusedMember.Local -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the New Implementation of a Log-structured File System v2 -public sealed class NILFS2 : IFilesystem +public sealed partial class NILFS2 { - const ushort NILFS2_MAGIC = 0x3434; - const uint NILFS2_SUPER_OFFSET = 1024; - - const string FS_TYPE = "nilfs2"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.NILFS2_Name; - /// - public Guid Id => new("35224226-C5CC-48B5-8FFD-3781E91E86B6"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -176,56 +153,4 @@ public sealed class NILFS2 : IFilesystem XmlFsType.Clusters = nilfsSb.dev_size / XmlFsType.ClusterSize; } - - enum State : ushort - { - Valid = 0x0001, Error = 0x0002, Resize = 0x0004 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Superblock - { - public readonly uint rev_level; - public readonly ushort minor_rev_level; - public readonly ushort magic; - public readonly ushort bytes; - public readonly ushort flags; - public readonly uint crc_seed; - public readonly uint sum; - public readonly uint log_block_size; - public readonly ulong nsegments; - public readonly ulong dev_size; - public readonly ulong first_data_block; - public readonly uint blocks_per_segment; - public readonly uint r_segments_percentage; - public readonly ulong last_cno; - public readonly ulong last_pseg; - public readonly ulong last_seq; - public readonly ulong free_blocks_count; - public readonly ulong ctime; - public readonly ulong mtime; - public readonly ulong wtime; - public readonly ushort mnt_count; - public readonly ushort max_mnt_count; - public readonly State state; - public readonly ushort errors; - public readonly ulong lastcheck; - public readonly uint checkinterval; - public readonly uint creator_os; - public readonly ushort def_resuid; - public readonly ushort def_resgid; - public readonly uint first_ino; - public readonly ushort inode_size; - public readonly ushort dat_entry_size; - public readonly ushort checkpoint_size; - public readonly ushort segment_usage_size; - public readonly Guid uuid; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] - public readonly byte[] volume_name; - public readonly uint c_interval; - public readonly uint c_block_max; - public readonly ulong feature_compat; - public readonly ulong feature_compat_ro; - public readonly ulong feature_incompat; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/NILFS2/NILFS2.cs b/Aaru.Filesystems/NILFS2/NILFS2.cs new file mode 100644 index 000000000..4d5b2835d --- /dev/null +++ b/Aaru.Filesystems/NILFS2/NILFS2.cs @@ -0,0 +1,52 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : NILFS2.cs +// Author(s) : Natalia Portillo +// +// Component : NILFS2 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the New Implementation of a Log-structured File System v2 +public sealed partial class NILFS2 : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.NILFS2_Name; + /// + public Guid Id => new("35224226-C5CC-48B5-8FFD-3781E91E86B6"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/NILFS2/Structs.cs b/Aaru.Filesystems/NILFS2/Structs.cs new file mode 100644 index 000000000..ed14685e9 --- /dev/null +++ b/Aaru.Filesystems/NILFS2/Structs.cs @@ -0,0 +1,86 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : NILFS2 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedMember.Local + +using System; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the New Implementation of a Log-structured File System v2 +public sealed partial class NILFS2 +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Superblock + { + public readonly uint rev_level; + public readonly ushort minor_rev_level; + public readonly ushort magic; + public readonly ushort bytes; + public readonly ushort flags; + public readonly uint crc_seed; + public readonly uint sum; + public readonly uint log_block_size; + public readonly ulong nsegments; + public readonly ulong dev_size; + public readonly ulong first_data_block; + public readonly uint blocks_per_segment; + public readonly uint r_segments_percentage; + public readonly ulong last_cno; + public readonly ulong last_pseg; + public readonly ulong last_seq; + public readonly ulong free_blocks_count; + public readonly ulong ctime; + public readonly ulong mtime; + public readonly ulong wtime; + public readonly ushort mnt_count; + public readonly ushort max_mnt_count; + public readonly State state; + public readonly ushort errors; + public readonly ulong lastcheck; + public readonly uint checkinterval; + public readonly uint creator_os; + public readonly ushort def_resuid; + public readonly ushort def_resgid; + public readonly uint first_ino; + public readonly ushort inode_size; + public readonly ushort dat_entry_size; + public readonly ushort checkpoint_size; + public readonly ushort segment_usage_size; + public readonly Guid uuid; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] + public readonly byte[] volume_name; + public readonly uint c_interval; + public readonly uint c_block_max; + public readonly ulong feature_compat; + public readonly ulong feature_compat_ro; + public readonly ulong feature_incompat; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/NTFS/Consts.cs b/Aaru.Filesystems/NTFS/Consts.cs new file mode 100644 index 000000000..0950228d9 --- /dev/null +++ b/Aaru.Filesystems/NTFS/Consts.cs @@ -0,0 +1,37 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft NT File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from Inside Windows NT +/// +/// Implements detection of the New Technology File System (NTFS) +public sealed partial class NTFS +{ + const string FS_TYPE = "ntfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/NTFS.cs b/Aaru.Filesystems/NTFS/Info.cs similarity index 61% rename from Aaru.Filesystems/NTFS.cs rename to Aaru.Filesystems/NTFS/Info.cs index c579a2be6..44f5caec1 100644 --- a/Aaru.Filesystems/NTFS.cs +++ b/Aaru.Filesystems/NTFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : NTFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Microsoft NT File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Microsoft NT File System and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.Checksums; using Aaru.CommonTypes; @@ -39,27 +34,14 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; // Information from Inside Windows NT /// /// Implements detection of the New Technology File System (NTFS) -public sealed class NTFS : IFilesystem +public sealed partial class NTFS { - const string FS_TYPE = "ntfs"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.NTFS_Name; - /// - public Guid Id => new("33513B2C-1e6d-4d21-a660-0bbc789c3871"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -168,78 +150,4 @@ public sealed class NTFS : IFilesystem information = sb.ToString(); } - - /// NTFS $BOOT - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct BiosParameterBlock - { - // Start of BIOS Parameter Block - /// 0x000, Jump to boot code - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// 0x003, OEM Name, 8 bytes, space-padded, must be "NTFS " - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// 0x00B, Bytes per sector - public readonly ushort bps; - /// 0x00D, Sectors per cluster - public readonly byte spc; - /// 0x00E, Reserved sectors, seems 0 - public readonly ushort rsectors; - /// 0x010, Number of FATs... obviously, 0 - public readonly byte fats_no; - /// 0x011, Number of entries on root directory... 0 - public readonly ushort root_ent; - /// 0x013, Sectors in volume... 0 - public readonly ushort sml_sectors; - /// 0x015, Media descriptor - public readonly byte media; - /// 0x016, Sectors per FAT... 0 - public readonly ushort spfat; - /// 0x018, Sectors per track, required to boot - public readonly ushort sptrk; - /// 0x01A, Heads... required to boot - public readonly ushort heads; - /// 0x01C, Hidden sectors before BPB - public readonly uint hsectors; - /// 0x020, Sectors in volume if > 65535... 0 - public readonly uint big_sectors; - /// 0x024, Drive number - public readonly byte drive_no; - /// 0x025, 0 - public readonly byte nt_flags; - /// 0x026, EPB signature, 0x80 - public readonly byte signature1; - /// 0x027, Alignment - public readonly byte dummy; - - // End of BIOS Parameter Block - - // Start of NTFS real superblock - /// 0x028, Sectors on volume - public readonly long sectors; - /// 0x030, LSN of $MFT - public readonly long mft_lsn; - /// 0x038, LSN of $MFTMirror - public readonly long mftmirror_lsn; - /// 0x040, Clusters per MFT record - public readonly sbyte mft_rc_clusters; - /// 0x041, Alignment - public readonly byte dummy2; - /// 0x042, Alignment - public readonly ushort dummy3; - /// 0x044, Clusters per index block - public readonly sbyte index_blk_cts; - /// 0x045, Alignment - public readonly byte dummy4; - /// 0x046, Alignment - public readonly ushort dummy5; - /// 0x048, Volume serial number - public readonly ulong serial_no; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 430)] - public readonly byte[] boot_code; - /// 0x1FE, 0xAA55 - public readonly ushort signature2; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/NTFS/NTFS.cs b/Aaru.Filesystems/NTFS/NTFS.cs new file mode 100644 index 000000000..80d33720f --- /dev/null +++ b/Aaru.Filesystems/NTFS/NTFS.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : NTFS.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft NT File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from Inside Windows NT +/// +/// Implements detection of the New Technology File System (NTFS) +public sealed partial class NTFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.NTFS_Name; + /// + public Guid Id => new("33513B2C-1e6d-4d21-a660-0bbc789c3871"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/NTFS/Structs.cs b/Aaru.Filesystems/NTFS/Structs.cs new file mode 100644 index 000000000..0d16f8dfd --- /dev/null +++ b/Aaru.Filesystems/NTFS/Structs.cs @@ -0,0 +1,111 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft NT File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from Inside Windows NT +/// +/// Implements detection of the New Technology File System (NTFS) +public sealed partial class NTFS +{ + /// NTFS $BOOT + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct BiosParameterBlock + { + // Start of BIOS Parameter Block + /// 0x000, Jump to boot code + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// 0x003, OEM Name, 8 bytes, space-padded, must be "NTFS " + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// 0x00B, Bytes per sector + public readonly ushort bps; + /// 0x00D, Sectors per cluster + public readonly byte spc; + /// 0x00E, Reserved sectors, seems 0 + public readonly ushort rsectors; + /// 0x010, Number of FATs... obviously, 0 + public readonly byte fats_no; + /// 0x011, Number of entries on root directory... 0 + public readonly ushort root_ent; + /// 0x013, Sectors in volume... 0 + public readonly ushort sml_sectors; + /// 0x015, Media descriptor + public readonly byte media; + /// 0x016, Sectors per FAT... 0 + public readonly ushort spfat; + /// 0x018, Sectors per track, required to boot + public readonly ushort sptrk; + /// 0x01A, Heads... required to boot + public readonly ushort heads; + /// 0x01C, Hidden sectors before BPB + public readonly uint hsectors; + /// 0x020, Sectors in volume if > 65535... 0 + public readonly uint big_sectors; + /// 0x024, Drive number + public readonly byte drive_no; + /// 0x025, 0 + public readonly byte nt_flags; + /// 0x026, EPB signature, 0x80 + public readonly byte signature1; + /// 0x027, Alignment + public readonly byte dummy; + + // End of BIOS Parameter Block + + // Start of NTFS real superblock + /// 0x028, Sectors on volume + public readonly long sectors; + /// 0x030, LSN of $MFT + public readonly long mft_lsn; + /// 0x038, LSN of $MFTMirror + public readonly long mftmirror_lsn; + /// 0x040, Clusters per MFT record + public readonly sbyte mft_rc_clusters; + /// 0x041, Alignment + public readonly byte dummy2; + /// 0x042, Alignment + public readonly ushort dummy3; + /// 0x044, Clusters per index block + public readonly sbyte index_blk_cts; + /// 0x045, Alignment + public readonly byte dummy4; + /// 0x046, Alignment + public readonly ushort dummy5; + /// 0x048, Volume serial number + public readonly ulong serial_no; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 430)] + public readonly byte[] boot_code; + /// 0x1FE, 0xAA55 + public readonly ushort signature2; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Nintendo/Consts.cs b/Aaru.Filesystems/Nintendo/Consts.cs new file mode 100644 index 000000000..c300b7ef3 --- /dev/null +++ b/Aaru.Filesystems/Nintendo/Consts.cs @@ -0,0 +1,37 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Nintendo optical filesystems plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem used by Nintendo Gamecube and Wii discs +public sealed partial class NintendoPlugin +{ + const string FS_TYPE_NGC = "ngcfs"; + const string FS_TYPE_WII = "wiifs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Nintendo/Helpers.cs b/Aaru.Filesystems/Nintendo/Helpers.cs new file mode 100644 index 000000000..2e260efde --- /dev/null +++ b/Aaru.Filesystems/Nintendo/Helpers.cs @@ -0,0 +1,118 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Helpers.cs +// Author(s) : Natalia Portillo +// +// Component : Nintendo optical filesystems plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem used by Nintendo Gamecube and Wii discs +public sealed partial class NintendoPlugin +{ + static string DiscTypeToString(string discType) => discType switch + { + "C" => Localization.Commodore_64_Virtual_Console, + "D" => Localization.Demo, + "E" => Localization.Neo_Geo_Virtual_Console, + "F" => Localization.NES_Virtual_Console, + "G" => Localization.Gamecube, + "H" => Localization.Wii_channel, + "J" => Localization.Super_Nintendo_Virtual_Console, + "L" => Localization.Master_System_Virtual_Console, + "M" => Localization.Megadrive_Virtual_Console, + "N" => Localization.Nintendo_64_Virtual_Console, + "P" => Localization.Promotional_or_TurboGrafx_Virtual_Console, + "Q" => Localization.TurboGrafx_CD_Virtual_Console, + "R" => Localization.Wii, + "S" => Localization.Wii, + "U" => Localization.Utility, + "W" => Localization.WiiWare, + "X" => Localization.MSX_Virtual_Console_or_WiiWare_demo, + "0" => Localization.Diagnostic, + "1" => Localization.Diagnostic, + "4" => Localization.Wii_Backup, + "_" => Localization.WiiFit, + _ => string.Format(Localization.unknown_type_0, discType) + }; + + static string RegionCodeToString(string regionCode) => regionCode switch + { + "A" => Localization.NintendoPlugin_RegionCodeToString_any_region, + "D" => Localization.NintendoPlugin_RegionCodeToString_Germany, + "N" => Localization.NintendoPlugin_RegionCodeToString_USA, + "E" => Localization.NintendoPlugin_RegionCodeToString_USA, + "F" => Localization.NintendoPlugin_RegionCodeToString_France, + "I" => Localization.NintendoPlugin_RegionCodeToString_Italy, + "J" => Localization.NintendoPlugin_RegionCodeToString_Japan, + "K" => Localization.NintendoPlugin_RegionCodeToString_Korea, + "Q" => Localization.NintendoPlugin_RegionCodeToString_Korea, + "L" => Localization.NintendoPlugin_RegionCodeToString_PAL, + "M" => Localization.NintendoPlugin_RegionCodeToString_PAL, + "P" => Localization.NintendoPlugin_RegionCodeToString_PAL, + "R" => Localization.NintendoPlugin_RegionCodeToString_Russia, + "S" => Localization.NintendoPlugin_RegionCodeToString_Spain, + "T" => Localization.NintendoPlugin_RegionCodeToString_Taiwan, + "U" => Localization.NintendoPlugin_RegionCodeToString_Australia, + _ => string.Format(Localization.NintendoPlugin_RegionCodeToString_unknown_region_code_0, regionCode) + }; + + [SuppressMessage("ReSharper", "StringLiteralTypo")] + static string PublisherCodeToString(string publisherCode) => publisherCode switch + { + "01" => "Nintendo", + "08" => "CAPCOM", + "41" => "Ubisoft", + "4F" => "Eidos", + "51" => "Acclaim", + "52" => "Activision", + "5D" => "Midway", + "5G" => "Hudson", + "64" => "LucasArts", + "69" => "Electronic Arts", + "6S" => "TDK Mediactive", + "8P" => "SEGA", + "A4" => "Mirage Studios", + "AF" => "Namco", + "B2" => "Bandai", + "DA" => "Tomy", + "EM" => "Konami", + "70" => "Atari", + "4Q" => "Disney Interactive", + "GD" => "Square Enix", + "7D" => "Sierra", + _ => string.Format(Localization.Unknown_publisher_0, publisherCode) + }; + + static string PartitionTypeToString(uint type) => type switch + { + 0 => Localization.data, + 1 => Localization.update, + 2 => Localization.channel, + _ => string.Format(Localization.unknown_partition_type_0, type) + }; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Nintendo.cs b/Aaru.Filesystems/Nintendo/Info.cs similarity index 74% rename from Aaru.Filesystems/Nintendo.cs rename to Aaru.Filesystems/Nintendo/Info.cs index 304e5dbfd..23086d3a4 100644 --- a/Aaru.Filesystems/Nintendo.cs +++ b/Aaru.Filesystems/Nintendo/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Nintendo.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Nintendo optical filesystems plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Nintendo optical filesystems and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -44,21 +39,8 @@ namespace Aaru.Filesystems; /// /// Implements detection of the filesystem used by Nintendo Gamecube and Wii discs -public sealed class NintendoPlugin : IFilesystem +public sealed partial class NintendoPlugin { - const string FS_TYPE_NGC = "ngcfs"; - const string FS_TYPE_WII = "wiifs"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.NintendoPlugin_Name; - /// - public Guid Id => new("4675fcb4-4418-4288-9e4a-33d6a4ac1126"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -349,126 +331,4 @@ public sealed class NintendoPlugin : IFilesystem XmlFsType.VolumeName = fields.Title; XmlFsType.VolumeSerial = fields.DiscId; } - - static string DiscTypeToString(string discType) => discType switch - { - "C" => Localization.Commodore_64_Virtual_Console, - "D" => Localization.Demo, - "E" => Localization.Neo_Geo_Virtual_Console, - "F" => Localization.NES_Virtual_Console, - "G" => Localization.Gamecube, - "H" => Localization.Wii_channel, - "J" => Localization.Super_Nintendo_Virtual_Console, - "L" => Localization.Master_System_Virtual_Console, - "M" => Localization.Megadrive_Virtual_Console, - "N" => Localization.Nintendo_64_Virtual_Console, - "P" => Localization.Promotional_or_TurboGrafx_Virtual_Console, - "Q" => Localization.TurboGrafx_CD_Virtual_Console, - "R" => Localization.Wii, - "S" => Localization.Wii, - "U" => Localization.Utility, - "W" => Localization.WiiWare, - "X" => Localization.MSX_Virtual_Console_or_WiiWare_demo, - "0" => Localization.Diagnostic, - "1" => Localization.Diagnostic, - "4" => Localization.Wii_Backup, - "_" => Localization.WiiFit, - _ => string.Format(Localization.unknown_type_0, discType) - }; - - static string RegionCodeToString(string regionCode) => regionCode switch - { - "A" => Localization.NintendoPlugin_RegionCodeToString_any_region, - "D" => Localization.NintendoPlugin_RegionCodeToString_Germany, - "N" => Localization.NintendoPlugin_RegionCodeToString_USA, - "E" => Localization.NintendoPlugin_RegionCodeToString_USA, - "F" => Localization.NintendoPlugin_RegionCodeToString_France, - "I" => Localization.NintendoPlugin_RegionCodeToString_Italy, - "J" => Localization.NintendoPlugin_RegionCodeToString_Japan, - "K" => Localization.NintendoPlugin_RegionCodeToString_Korea, - "Q" => Localization.NintendoPlugin_RegionCodeToString_Korea, - "L" => Localization.NintendoPlugin_RegionCodeToString_PAL, - "M" => Localization.NintendoPlugin_RegionCodeToString_PAL, - "P" => Localization.NintendoPlugin_RegionCodeToString_PAL, - "R" => Localization.NintendoPlugin_RegionCodeToString_Russia, - "S" => Localization.NintendoPlugin_RegionCodeToString_Spain, - "T" => Localization.NintendoPlugin_RegionCodeToString_Taiwan, - "U" => Localization.NintendoPlugin_RegionCodeToString_Australia, - _ => string.Format(Localization.NintendoPlugin_RegionCodeToString_unknown_region_code_0, regionCode) - }; - - [SuppressMessage("ReSharper", "StringLiteralTypo")] - static string PublisherCodeToString(string publisherCode) => publisherCode switch - { - "01" => "Nintendo", - "08" => "CAPCOM", - "41" => "Ubisoft", - "4F" => "Eidos", - "51" => "Acclaim", - "52" => "Activision", - "5D" => "Midway", - "5G" => "Hudson", - "64" => "LucasArts", - "69" => "Electronic Arts", - "6S" => "TDK Mediactive", - "8P" => "SEGA", - "A4" => "Mirage Studios", - "AF" => "Namco", - "B2" => "Bandai", - "DA" => "Tomy", - "EM" => "Konami", - "70" => "Atari", - "4Q" => "Disney Interactive", - "GD" => "Square Enix", - "7D" => "Sierra", - _ => string.Format(Localization.Unknown_publisher_0, publisherCode) - }; - - static string PartitionTypeToString(uint type) => type switch - { - 0 => Localization.data, - 1 => Localization.update, - 2 => Localization.channel, - _ => string.Format(Localization.unknown_partition_type_0, type) - }; - - struct NintendoFields - { - public string DiscType; - public string GameCode; - public string RegionCode; - public string PublisherCode; - public string DiscId; - public byte DiscNumber; - public byte DiscVersion; - public bool Streaming; - public byte StreamBufferSize; - public string Title; - public uint DebugOff; - public uint DebugAddr; - public uint DolOff; - public uint FstOff; - public uint FstSize; - public uint FstMax; - public NintendoPartition[] FirstPartitions; - public NintendoPartition[] SecondPartitions; - public NintendoPartition[] ThirdPartitions; - public NintendoPartition[] FourthPartitions; - public byte Region; - public byte JapanAge; - public byte UsaAge; - public byte GermanAge; - public byte PegiAge; - public byte FinlandAge; - public byte PortugalAge; - public byte UkAge; - public byte AustraliaAge; - public byte KoreaAge; - } - - struct NintendoPartition - { - public uint Offset; - public uint Type; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Nintendo/Nintendo.cs b/Aaru.Filesystems/Nintendo/Nintendo.cs new file mode 100644 index 000000000..db34210d4 --- /dev/null +++ b/Aaru.Filesystems/Nintendo/Nintendo.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Nintendo.cs +// Author(s) : Natalia Portillo +// +// Component : Nintendo optical filesystems plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem used by Nintendo Gamecube and Wii discs +public sealed partial class NintendoPlugin : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.NintendoPlugin_Name; + /// + public Guid Id => new("4675fcb4-4418-4288-9e4a-33d6a4ac1126"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Nintendo/Structs.cs b/Aaru.Filesystems/Nintendo/Structs.cs new file mode 100644 index 000000000..1a4f832b3 --- /dev/null +++ b/Aaru.Filesystems/Nintendo/Structs.cs @@ -0,0 +1,74 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Nintendo optical filesystems plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the filesystem used by Nintendo Gamecube and Wii discs +public sealed partial class NintendoPlugin +{ + struct NintendoFields + { + public string DiscType; + public string GameCode; + public string RegionCode; + public string PublisherCode; + public string DiscId; + public byte DiscNumber; + public byte DiscVersion; + public bool Streaming; + public byte StreamBufferSize; + public string Title; + public uint DebugOff; + public uint DebugAddr; + public uint DolOff; + public uint FstOff; + public uint FstSize; + public uint FstMax; + public NintendoPartition[] FirstPartitions; + public NintendoPartition[] SecondPartitions; + public NintendoPartition[] ThirdPartitions; + public NintendoPartition[] FourthPartitions; + public byte Region; + public byte JapanAge; + public byte UsaAge; + public byte GermanAge; + public byte PegiAge; + public byte FinlandAge; + public byte PortugalAge; + public byte UkAge; + public byte AustraliaAge; + public byte KoreaAge; + } + + struct NintendoPartition + { + public uint Offset; + public uint Type; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ODS/Consts.cs b/Aaru.Filesystems/ODS/Consts.cs new file mode 100644 index 000000000..cfffbcd84 --- /dev/null +++ b/Aaru.Filesystems/ODS/Consts.cs @@ -0,0 +1,49 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Files-11 On-Disk Structure plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Files-11 On-Disk Structure 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from VMS File System Internals by Kirby McCoy +// ISBN: 1-55558-056-4 +// With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h +// Expects the home block to be always in sector #1 (does not check deltas) +// Assumes a sector size of 512 bytes (VMS does on HDDs and optical drives, dunno about M.O.) +// Book only describes ODS-2. Need to test ODS-1 and ODS-5 +// There is an ODS with signature "DECFILES11A", yet to be seen +// Time is a 64 bit unsigned integer, tenths of microseconds since 1858/11/17 00:00:00. +// TODO: Implement checksum +/// +/// Implements detection of DEC's On-Disk Structure, aka the ODS filesystem +public sealed partial class ODS +{ + const string FS_TYPE = "files11"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ODS.cs b/Aaru.Filesystems/ODS/Info.cs similarity index 66% rename from Aaru.Filesystems/ODS.cs rename to Aaru.Filesystems/ODS/Info.cs index ab1d0f384..b16e56d56 100644 --- a/Aaru.Filesystems/ODS.cs +++ b/Aaru.Filesystems/ODS/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : ODS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Files-11 On-Disk Structure plugin. @@ -31,7 +31,6 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -39,7 +38,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -54,20 +52,8 @@ namespace Aaru.Filesystems; // TODO: Implement checksum /// /// Implements detection of DEC's On-Disk Structure, aka the ODS filesystem -public sealed class ODS : IFilesystem +public sealed partial class ODS { - const string FS_TYPE = "files11"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.ODS_Name; - /// - public Guid Id => new("de20633c-8021-4384-aeb0-83b0df14491f"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -294,108 +280,4 @@ public sealed class ODS : IFilesystem information = sb.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct HomeBlock - { - /// 0x000, LBN of THIS home block - public readonly uint homelbn; - /// 0x004, LBN of the secondary home block - public readonly uint alhomelbn; - /// 0x008, LBN of backup INDEXF.SYS;1 - public readonly uint altidxlbn; - /// 0x00C, High byte contains filesystem version (1, 2 or 5), low byte contains revision (1) - public readonly ushort struclev; - /// 0x00E, Number of blocks each bit of the volume bitmap represents - public readonly ushort cluster; - /// 0x010, VBN of THIS home block - public readonly ushort homevbn; - /// 0x012, VBN of the secondary home block - public readonly ushort alhomevbn; - /// 0x014, VBN of backup INDEXF.SYS;1 - public readonly ushort altidxvbn; - /// 0x016, VBN of the bitmap - public readonly ushort ibmapvbn; - /// 0x018, LBN of the bitmap - public readonly uint ibmaplbn; - /// 0x01C, Max files on volume - public readonly uint maxfiles; - /// 0x020, Bitmap size in sectors - public readonly ushort ibmapsize; - /// 0x022, Reserved files, 5 at minimum - public readonly ushort resfiles; - /// 0x024, Device type, ODS-2 defines it as always 0 - public readonly ushort devtype; - /// 0x026, Relative volume number (number of the volume in a set) - public readonly ushort rvn; - /// 0x028, Total number of volumes in the set this volume is - public readonly ushort setcount; - /// 0x02A, Flags - public readonly ushort volchar; - /// 0x02C, User ID of the volume owner - public readonly uint volowner; - /// 0x030, Security mask (??) - public readonly uint sec_mask; - /// 0x034, Volume permissions (system, owner, group and other) - public readonly ushort protect; - /// 0x036, Default file protection, unsupported in ODS-2 - public readonly ushort fileprot; - /// 0x038, Default file record protection - public readonly ushort recprot; - /// 0x03A, Checksum of all preceding entries - public readonly ushort checksum1; - /// 0x03C, Creation date - public readonly ulong credate; - /// 0x044, Window size (pointers for the window) - public readonly byte window; - /// 0x045, Directories to be stored in cache - public readonly byte lru_lim; - /// 0x046, Default allocation size in blocks - public readonly ushort extend; - /// 0x048, Minimum file retention period - public readonly ulong retainmin; - /// 0x050, Maximum file retention period - public readonly ulong retainmax; - /// 0x058, Last modification date - public readonly ulong revdate; - /// 0x060, Minimum security class, 20 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly byte[] min_class; - /// 0x074, Maximum security class, 20 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly byte[] max_class; - /// 0x088, File lookup table FID - public readonly ushort filetab_fid1; - /// 0x08A, File lookup table FID - public readonly ushort filetab_fid2; - /// 0x08C, File lookup table FID - public readonly ushort filetab_fid3; - /// 0x08E, Lowest structure level on the volume - public readonly ushort lowstruclev; - /// 0x090, Highest structure level on the volume - public readonly ushort highstruclev; - /// 0x092, Volume copy date (??) - public readonly ulong copydate; - /// 0x09A, 302 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 302)] - public readonly byte[] reserved1; - /// 0x1C8, Physical drive serial number - public readonly uint serialnum; - /// 0x1CC, Name of the volume set, 12 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] strucname; - /// 0x1D8, Volume label, 12 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] volname; - /// 0x1E4, Name of the volume owner, 12 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] ownername; - /// 0x1F0, ODS-2 defines it as "DECFILE11B", 12 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] format; - /// 0x1FC, Reserved - public readonly ushort reserved2; - /// 0x1FE, Checksum of preceding 255 words (16 bit units) - public readonly ushort checksum2; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/ODS/ODS.cs b/Aaru.Filesystems/ODS/ODS.cs new file mode 100644 index 000000000..df3165543 --- /dev/null +++ b/Aaru.Filesystems/ODS/ODS.cs @@ -0,0 +1,63 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : ODS.cs +// Author(s) : Natalia Portillo +// +// Component : Files-11 On-Disk Structure plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Files-11 On-Disk Structure 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from VMS File System Internals by Kirby McCoy +// ISBN: 1-55558-056-4 +// With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h +// Expects the home block to be always in sector #1 (does not check deltas) +// Assumes a sector size of 512 bytes (VMS does on HDDs and optical drives, dunno about M.O.) +// Book only describes ODS-2. Need to test ODS-1 and ODS-5 +// There is an ODS with signature "DECFILES11A", yet to be seen +// Time is a 64 bit unsigned integer, tenths of microseconds since 1858/11/17 00:00:00. +// TODO: Implement checksum +/// +/// Implements detection of DEC's On-Disk Structure, aka the ODS filesystem +public sealed partial class ODS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.ODS_Name; + /// + public Guid Id => new("de20633c-8021-4384-aeb0-83b0df14491f"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ODS/Structs.cs b/Aaru.Filesystems/ODS/Structs.cs new file mode 100644 index 000000000..1a8741321 --- /dev/null +++ b/Aaru.Filesystems/ODS/Structs.cs @@ -0,0 +1,153 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Files-11 On-Disk Structure plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Files-11 On-Disk Structure 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from VMS File System Internals by Kirby McCoy +// ISBN: 1-55558-056-4 +// With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h +// Expects the home block to be always in sector #1 (does not check deltas) +// Assumes a sector size of 512 bytes (VMS does on HDDs and optical drives, dunno about M.O.) +// Book only describes ODS-2. Need to test ODS-1 and ODS-5 +// There is an ODS with signature "DECFILES11A", yet to be seen +// Time is a 64 bit unsigned integer, tenths of microseconds since 1858/11/17 00:00:00. +// TODO: Implement checksum +/// +/// Implements detection of DEC's On-Disk Structure, aka the ODS filesystem +public sealed partial class ODS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct HomeBlock + { + /// 0x000, LBN of THIS home block + public readonly uint homelbn; + /// 0x004, LBN of the secondary home block + public readonly uint alhomelbn; + /// 0x008, LBN of backup INDEXF.SYS;1 + public readonly uint altidxlbn; + /// 0x00C, High byte contains filesystem version (1, 2 or 5), low byte contains revision (1) + public readonly ushort struclev; + /// 0x00E, Number of blocks each bit of the volume bitmap represents + public readonly ushort cluster; + /// 0x010, VBN of THIS home block + public readonly ushort homevbn; + /// 0x012, VBN of the secondary home block + public readonly ushort alhomevbn; + /// 0x014, VBN of backup INDEXF.SYS;1 + public readonly ushort altidxvbn; + /// 0x016, VBN of the bitmap + public readonly ushort ibmapvbn; + /// 0x018, LBN of the bitmap + public readonly uint ibmaplbn; + /// 0x01C, Max files on volume + public readonly uint maxfiles; + /// 0x020, Bitmap size in sectors + public readonly ushort ibmapsize; + /// 0x022, Reserved files, 5 at minimum + public readonly ushort resfiles; + /// 0x024, Device type, ODS-2 defines it as always 0 + public readonly ushort devtype; + /// 0x026, Relative volume number (number of the volume in a set) + public readonly ushort rvn; + /// 0x028, Total number of volumes in the set this volume is + public readonly ushort setcount; + /// 0x02A, Flags + public readonly ushort volchar; + /// 0x02C, User ID of the volume owner + public readonly uint volowner; + /// 0x030, Security mask (??) + public readonly uint sec_mask; + /// 0x034, Volume permissions (system, owner, group and other) + public readonly ushort protect; + /// 0x036, Default file protection, unsupported in ODS-2 + public readonly ushort fileprot; + /// 0x038, Default file record protection + public readonly ushort recprot; + /// 0x03A, Checksum of all preceding entries + public readonly ushort checksum1; + /// 0x03C, Creation date + public readonly ulong credate; + /// 0x044, Window size (pointers for the window) + public readonly byte window; + /// 0x045, Directories to be stored in cache + public readonly byte lru_lim; + /// 0x046, Default allocation size in blocks + public readonly ushort extend; + /// 0x048, Minimum file retention period + public readonly ulong retainmin; + /// 0x050, Maximum file retention period + public readonly ulong retainmax; + /// 0x058, Last modification date + public readonly ulong revdate; + /// 0x060, Minimum security class, 20 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly byte[] min_class; + /// 0x074, Maximum security class, 20 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] + public readonly byte[] max_class; + /// 0x088, File lookup table FID + public readonly ushort filetab_fid1; + /// 0x08A, File lookup table FID + public readonly ushort filetab_fid2; + /// 0x08C, File lookup table FID + public readonly ushort filetab_fid3; + /// 0x08E, Lowest structure level on the volume + public readonly ushort lowstruclev; + /// 0x090, Highest structure level on the volume + public readonly ushort highstruclev; + /// 0x092, Volume copy date (??) + public readonly ulong copydate; + /// 0x09A, 302 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 302)] + public readonly byte[] reserved1; + /// 0x1C8, Physical drive serial number + public readonly uint serialnum; + /// 0x1CC, Name of the volume set, 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] strucname; + /// 0x1D8, Volume label, 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] volname; + /// 0x1E4, Name of the volume owner, 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] ownername; + /// 0x1F0, ODS-2 defines it as "DECFILE11B", 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] format; + /// 0x1FC, Reserved + public readonly ushort reserved2; + /// 0x1FE, Checksum of preceding 255 words (16 bit units) + public readonly ushort checksum2; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Opera/Consts.cs b/Aaru.Filesystems/Opera/Consts.cs index b17d92778..a736e0a67 100644 --- a/Aaru.Filesystems/Opera/Consts.cs +++ b/Aaru.Filesystems/Opera/Consts.cs @@ -7,10 +7,6 @@ // // Component : Opera filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Opera filesystem constants. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index ea1b2ef56..b51e1c34a 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -7,10 +7,6 @@ // // Component : Opera filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle Opera filesystem directories. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Opera/File.cs b/Aaru.Filesystems/Opera/File.cs index 4a7676dd8..4210e6bb8 100644 --- a/Aaru.Filesystems/Opera/File.cs +++ b/Aaru.Filesystems/Opera/File.cs @@ -7,10 +7,6 @@ // // Component : Opera filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Opera/Info.cs b/Aaru.Filesystems/Opera/Info.cs index a77234513..4a5bf77cc 100644 --- a/Aaru.Filesystems/Opera/Info.cs +++ b/Aaru.Filesystems/Opera/Info.cs @@ -7,10 +7,6 @@ // // Component : Opera filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Opera filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Opera/Opera.cs b/Aaru.Filesystems/Opera/Opera.cs index 235287b31..decd76ec6 100644 --- a/Aaru.Filesystems/Opera/Opera.cs +++ b/Aaru.Filesystems/Opera/Opera.cs @@ -7,10 +7,6 @@ // // Component : Opera filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Opera filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Opera/Structs.cs b/Aaru.Filesystems/Opera/Structs.cs index 77ca80648..58c4d53f6 100644 --- a/Aaru.Filesystems/Opera/Structs.cs +++ b/Aaru.Filesystems/Opera/Structs.cs @@ -7,10 +7,6 @@ // // Component : Opera filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Opera filesystem structures. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index bccec6daa..8eb0ef98d 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -7,10 +7,6 @@ // // Component : Opera filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Handles mounting and umounting the Opera filesystem. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/PCEngine/Consts.cs b/Aaru.Filesystems/PCEngine/Consts.cs new file mode 100644 index 000000000..ca7db8224 --- /dev/null +++ b/Aaru.Filesystems/PCEngine/Consts.cs @@ -0,0 +1,40 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : NEC PC-Engine CD filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the NEC PC-Engine CD filesystem 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the PC-Engine CD file headers +public sealed partial class PCEnginePlugin +{ + const string FS_TYPE = "pcengine"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/PCEngine.cs b/Aaru.Filesystems/PCEngine/Info.cs similarity index 84% rename from Aaru.Filesystems/PCEngine.cs rename to Aaru.Filesystems/PCEngine/Info.cs index f521b43d7..20ea20ba9 100644 --- a/Aaru.Filesystems/PCEngine.cs +++ b/Aaru.Filesystems/PCEngine/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : PCEngine.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : NEC PC-Engine CD filesystem plugin. @@ -41,20 +41,8 @@ namespace Aaru.Filesystems; /// /// Implements detection of the PC-Engine CD file headers -public sealed class PCEnginePlugin : IFilesystem +public sealed partial class PCEnginePlugin { - const string FS_TYPE = "pcengine"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.PCEnginePlugin_Name; - /// - public Guid Id => new("e5ee6d7c-90fa-49bd-ac89-14ef750b8af3"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { diff --git a/Aaru.Filesystems/PCEngine/PCEngine.cs b/Aaru.Filesystems/PCEngine/PCEngine.cs new file mode 100644 index 000000000..ab638287c --- /dev/null +++ b/Aaru.Filesystems/PCEngine/PCEngine.cs @@ -0,0 +1,54 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : PCEngine.cs +// Author(s) : Natalia Portillo +// +// Component : NEC PC-Engine CD filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the NEC PC-Engine CD filesystem 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the PC-Engine CD file headers +public sealed partial class PCEnginePlugin : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.PCEnginePlugin_Name; + /// + public Guid Id => new("e5ee6d7c-90fa-49bd-ac89-14ef750b8af3"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/PCFX/Consts.cs b/Aaru.Filesystems/PCFX/Consts.cs new file mode 100644 index 000000000..6f50b60fe --- /dev/null +++ b/Aaru.Filesystems/PCFX/Consts.cs @@ -0,0 +1,45 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : NEC PC-FX plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the NEC PC-FX track header 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-2023 Natalia Portillo +// ****************************************************************************/ + +using Aaru.CommonTypes.Interfaces; + +namespace Aaru.Filesystems; + +// Not a filesystem, more like an executable header +/// +/// Implements detection of NEC PC-FX headers +public sealed partial class PCFX : IFilesystem +{ + const string IDENTIFIER = "PC-FX:Hu_CD-ROM "; + + const string FS_TYPE = "pcfx"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/PCFX.cs b/Aaru.Filesystems/PCFX/Info.cs similarity index 74% rename from Aaru.Filesystems/PCFX.cs rename to Aaru.Filesystems/PCFX/Info.cs index 832f903f9..a8036a1cd 100644 --- a/Aaru.Filesystems/PCFX.cs +++ b/Aaru.Filesystems/PCFX/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : PCEngine.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : NEC PC-FX plugin. @@ -31,36 +31,20 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; // Not a filesystem, more like an executable header /// /// Implements detection of NEC PC-FX headers -public sealed class PCFX : IFilesystem +public sealed partial class PCFX { - const string IDENTIFIER = "PC-FX:Hu_CD-ROM "; - - const string FS_TYPE = "pcfx"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.PCFX_Name; - /// - public Guid Id => new("8BC27CCE-D9E9-48F8-BA93-C66A86EB565A"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -141,31 +125,4 @@ public sealed class PCFX : IFilesystem SystemIdentifier = "PC-FX" }; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Header - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] signature; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0xE0)] - public readonly byte[] copyright; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x710)] - public readonly byte[] unknown; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] title; - public readonly uint loadOffset; - public readonly uint loadCount; - public readonly uint loadAddress; - public readonly uint entryPoint; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - public readonly byte[] makerId; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 60)] - public readonly byte[] makerName; - public readonly uint volumeNumber; - public readonly byte majorVersion; - public readonly byte minorVersion; - public readonly ushort country; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] date; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/PCFX/PCFX.cs b/Aaru.Filesystems/PCFX/PCFX.cs new file mode 100644 index 000000000..1fbba949c --- /dev/null +++ b/Aaru.Filesystems/PCFX/PCFX.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : PCEngine.cs +// Author(s) : Natalia Portillo +// +// Component : NEC PC-FX plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the NEC PC-FX track header 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Not a filesystem, more like an executable header +/// +/// Implements detection of NEC PC-FX headers +public sealed partial class PCFX : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.PCFX_Name; + /// + public Guid Id => new("8BC27CCE-D9E9-48F8-BA93-C66A86EB565A"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/PCFX/Structs.cs b/Aaru.Filesystems/PCFX/Structs.cs new file mode 100644 index 000000000..a5c566463 --- /dev/null +++ b/Aaru.Filesystems/PCFX/Structs.cs @@ -0,0 +1,68 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : NEC PC-FX plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the NEC PC-FX track header 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Not a filesystem, more like an executable header +/// +/// Implements detection of NEC PC-FX headers +public sealed partial class PCFX +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Header + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] signature; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0xE0)] + public readonly byte[] copyright; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x710)] + public readonly byte[] unknown; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] title; + public readonly uint loadOffset; + public readonly uint loadCount; + public readonly uint loadAddress; + public readonly uint entryPoint; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public readonly byte[] makerId; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 60)] + public readonly byte[] makerName; + public readonly uint volumeNumber; + public readonly byte majorVersion; + public readonly byte minorVersion; + public readonly ushort country; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] date; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/PFS/Consts.cs b/Aaru.Filesystems/PFS/Consts.cs new file mode 100644 index 000000000..30a26c8dd --- /dev/null +++ b/Aaru.Filesystems/PFS/Consts.cs @@ -0,0 +1,49 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Professional File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedType.Local + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Professional File System +public sealed partial class PFS +{ + /// Identifier for AFS (PFS v1) + const uint AFS_DISK = 0x41465301; + /// Identifier for PFS v2 + const uint PFS2_DISK = 0x50465302; + /// Identifier for PFS v3 + const uint PFS_DISK = 0x50465301; + /// Identifier for multi-user AFS + const uint MUAF_DISK = 0x6D754146; + /// Identifier for multi-user PFS + const uint MUPFS_DISK = 0x6D755046; + + const string FS_TYPE = "pfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/PFS.cs b/Aaru.Filesystems/PFS/Info.cs similarity index 57% rename from Aaru.Filesystems/PFS.cs rename to Aaru.Filesystems/PFS/Info.cs index 17184d424..43f407daa 100644 --- a/Aaru.Filesystems/PFS.cs +++ b/Aaru.Filesystems/PFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : PFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Professional File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Professional File System and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,46 +28,19 @@ // ReSharper disable UnusedType.Local -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Professional File System -public sealed class PFS : IFilesystem +public sealed partial class PFS { - /// Identifier for AFS (PFS v1) - const uint AFS_DISK = 0x41465301; - /// Identifier for PFS v2 - const uint PFS2_DISK = 0x50465302; - /// Identifier for PFS v3 - const uint PFS_DISK = 0x50465301; - /// Identifier for multi-user AFS - const uint MUAF_DISK = 0x6D754146; - /// Identifier for multi-user PFS - const uint MUPFS_DISK = 0x6D755046; - - const string FS_TYPE = "pfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.PFS_Name; - /// - public Guid Id => new("68DE769E-D957-406A-8AE4-3781CA8CDA77"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -157,60 +126,4 @@ public sealed class PFS : IFilesystem XmlFsType.ClusterSize = imagePlugin.Info.SectorSize; XmlFsType.VolumeName = StringHandlers.PascalToString(rootBlock.diskname, Encoding); } - - /// Boot block, first 2 sectors - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct BootBlock - { - /// "PFS\1" disk type - public readonly uint diskType; - /// Boot code, til completion - public readonly byte[] bootCode; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct RootBlock - { - /// Disk type - public readonly uint diskType; - /// Options - public readonly uint options; - /// Current datestamp - public readonly uint datestamp; - /// Volume creation day - public readonly ushort creationday; - /// Volume creation minute - public readonly ushort creationminute; - /// Volume creation tick - public readonly ushort creationtick; - /// AmigaDOS protection bits - public readonly ushort protection; - /// Volume label (Pascal string) - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] diskname; - /// Last reserved block - public readonly uint lastreserved; - /// First reserved block - public readonly uint firstreserved; - /// Free reserved blocks - public readonly uint reservedfree; - /// Size of reserved blocks in bytes - public readonly ushort reservedblocksize; - /// Blocks in rootblock, including bitmap - public readonly ushort rootblockclusters; - /// Free blocks - public readonly uint blocksfree; - /// Blocks that must be always free - public readonly uint alwaysfree; - /// Current bitmapfield number for allocation - public readonly uint rovingPointer; - /// Pointer to deldir - public readonly uint delDirPtr; - /// Disk size in sectors - public readonly uint diskSize; - /// Rootblock extension - public readonly uint extension; - /// Unused - public readonly uint unused; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/PFS/PFS.cs b/Aaru.Filesystems/PFS/PFS.cs new file mode 100644 index 000000000..a4049eed6 --- /dev/null +++ b/Aaru.Filesystems/PFS/PFS.cs @@ -0,0 +1,52 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : PFS.cs +// Author(s) : Natalia Portillo +// +// Component : Professional File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedType.Local + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Professional File System +public sealed partial class PFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.PFS_Name; + /// + public Guid Id => new("68DE769E-D957-406A-8AE4-3781CA8CDA77"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/PFS/Structs.cs b/Aaru.Filesystems/PFS/Structs.cs new file mode 100644 index 000000000..51da1ecc0 --- /dev/null +++ b/Aaru.Filesystems/PFS/Structs.cs @@ -0,0 +1,94 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Professional File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable UnusedType.Local + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Professional File System +public sealed partial class PFS +{ + /// Boot block, first 2 sectors + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct BootBlock + { + /// "PFS\1" disk type + public readonly uint diskType; + /// Boot code, til completion + public readonly byte[] bootCode; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct RootBlock + { + /// Disk type + public readonly uint diskType; + /// Options + public readonly uint options; + /// Current datestamp + public readonly uint datestamp; + /// Volume creation day + public readonly ushort creationday; + /// Volume creation minute + public readonly ushort creationminute; + /// Volume creation tick + public readonly ushort creationtick; + /// AmigaDOS protection bits + public readonly ushort protection; + /// Volume label (Pascal string) + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] diskname; + /// Last reserved block + public readonly uint lastreserved; + /// First reserved block + public readonly uint firstreserved; + /// Free reserved blocks + public readonly uint reservedfree; + /// Size of reserved blocks in bytes + public readonly ushort reservedblocksize; + /// Blocks in rootblock, including bitmap + public readonly ushort rootblockclusters; + /// Free blocks + public readonly uint blocksfree; + /// Blocks that must be always free + public readonly uint alwaysfree; + /// Current bitmapfield number for allocation + public readonly uint rovingPointer; + /// Pointer to deldir + public readonly uint delDirPtr; + /// Disk size in sectors + public readonly uint diskSize; + /// Rootblock extension + public readonly uint extension; + /// Unused + public readonly uint unused; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ProDOS/Consts.cs b/Aaru.Filesystems/ProDOS/Consts.cs new file mode 100644 index 000000000..b35b7d00c --- /dev/null +++ b/Aaru.Filesystems/ProDOS/Consts.cs @@ -0,0 +1,74 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Apple ProDOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable NotAccessedField.Local + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from Apple ProDOS 8 Technical Reference +/// +/// Implements detection of Apple ProDOS filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class ProDOSPlugin +{ + const byte EMPTY_STORAGE_TYPE = 0x00; + /// A file that occupies one block or less + const byte SEEDLING_FILE_TYPE = 0x01; + /// A file that occupies between 2 and 256 blocks + const byte SAPLING_FILE_TYPE = 0x02; + /// A file that occupies between 257 and 32768 blocks + const byte TREE_FILE_TYPE = 0x03; + const byte PASCAL_AREA_TYPE = 0x04; + const byte SUBDIRECTORY_TYPE = 0x0D; + const byte SUBDIRECTORY_HEADER_TYPE = 0x0E; + const byte ROOT_DIRECTORY_TYPE = 0x0F; + + const byte VERSION1 = 0x00; + + const uint YEAR_MASK = 0xFE000000; + const uint MONTH_MASK = 0x1E00000; + const uint DAY_MASK = 0x1F0000; + const uint HOUR_MASK = 0x1F00; + const uint MINUTE_MASK = 0x3F; + + const byte DESTROY_ATTRIBUTE = 0x80; + const byte RENAME_ATTRIBUTE = 0x40; + const byte BACKUP_ATTRIBUTE = 0x20; + const byte WRITE_ATTRIBUTE = 0x02; + const byte READ_ATTRIBUTE = 0x01; + const byte RESERVED_ATTRIBUTE_MASK = 0x1C; + + const byte STORAGE_TYPE_MASK = 0xF0; + const byte NAME_LENGTH_MASK = 0x0F; + const byte ENTRY_LENGTH = 0x27; + const byte ENTRIES_PER_BLOCK = 0x0D; + + const string FS_TYPE = "prodos"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ProDOS.cs b/Aaru.Filesystems/ProDOS/Info.cs similarity index 59% rename from Aaru.Filesystems/ProDOS.cs rename to Aaru.Filesystems/ProDOS/Info.cs index 5dd5cded2..fca60323e 100644 --- a/Aaru.Filesystems/ProDOS.cs +++ b/Aaru.Filesystems/ProDOS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : ProDOS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Apple ProDOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Apple ProDOS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -50,51 +46,8 @@ namespace Aaru.Filesystems; /// /// Implements detection of Apple ProDOS filesystem [SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] -public sealed class ProDOSPlugin : IFilesystem +public sealed partial class ProDOSPlugin { - const byte EMPTY_STORAGE_TYPE = 0x00; - /// A file that occupies one block or less - const byte SEEDLING_FILE_TYPE = 0x01; - /// A file that occupies between 2 and 256 blocks - const byte SAPLING_FILE_TYPE = 0x02; - /// A file that occupies between 257 and 32768 blocks - const byte TREE_FILE_TYPE = 0x03; - const byte PASCAL_AREA_TYPE = 0x04; - const byte SUBDIRECTORY_TYPE = 0x0D; - const byte SUBDIRECTORY_HEADER_TYPE = 0x0E; - const byte ROOT_DIRECTORY_TYPE = 0x0F; - - const byte VERSION1 = 0x00; - - const uint YEAR_MASK = 0xFE000000; - const uint MONTH_MASK = 0x1E00000; - const uint DAY_MASK = 0x1F0000; - const uint HOUR_MASK = 0x1F00; - const uint MINUTE_MASK = 0x3F; - - const byte DESTROY_ATTRIBUTE = 0x80; - const byte RENAME_ATTRIBUTE = 0x40; - const byte BACKUP_ATTRIBUTE = 0x20; - const byte WRITE_ATTRIBUTE = 0x02; - const byte READ_ATTRIBUTE = 0x01; - const byte RESERVED_ATTRIBUTE_MASK = 0x1C; - - const byte STORAGE_TYPE_MASK = 0xF0; - const byte NAME_LENGTH_MASK = 0x0F; - const byte ENTRY_LENGTH = 0x27; - const byte ENTRIES_PER_BLOCK = 0x0D; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.ProDOSPlugin_Name; - /// - public Guid Id => new("43874265-7B8A-4739-BCF7-07F80D5932BF"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -359,161 +312,4 @@ public sealed class ProDOSPlugin : IFilesystem XmlFsType.CreationDate = rootDirectoryKeyBlock.header.creation_time; XmlFsType.CreationDateSpecified = true; } - - const string FS_TYPE = "prodos"; - - /// ProDOS directory entry, decoded structure - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct Entry - { - /// Type of file pointed by this entry Offset 0x00, mask 0xF0 - public byte storage_type; - /// Length of name_length pascal string Offset 0x00, mask 0x0F - public byte name_length; - /// Pascal string of file name Offset 0x01, 15 bytes - public string file_name; - /// Descriptor of internal structure of the file Offset 0x10, 1 byte - public byte file_type; - /// - /// Block address of master index block for tree files. Block address of index block for sapling files. Block - /// address of block for seedling files. Offset 0x11, 2 bytes - /// - public ushort key_pointer; - /// Blocks used by file or directory, including index blocks. Offset 0x13, 2 bytes - public ushort blocks_used; - /// Size of file in bytes Offset 0x15, 3 bytes - public uint EOF; - /// File creation datetime Offset 0x18, 4 bytes - public DateTime creation_time; - /// Version of ProDOS that created this file Offset 0x1C, 1 byte - public byte version; - /// Minimum version of ProDOS needed to access this file Offset 0x1D, 1 byte - public byte min_version; - /// File permissions Offset 0x1E, 1 byte - public byte access; - /// General purpose field to store additional information about file format Offset 0x1F, 2 bytes - public ushort aux_type; - /// File last modification date time Offset 0x21, 4 bytes - public DateTime last_mod; - /// Block address pointer to key block of the directory containing this entry Offset 0x25, 2 bytes - public ushort header_pointer; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct RootDirectoryHeader - { - /// Constant 0x0F Offset 0x04, mask 0xF0 - public byte storage_type; - /// Length of volume_name pascal string Offset 0x04, mask 0x0F - public byte name_length; - /// The name of the volume. Offset 0x05, 15 bytes - public string volume_name; - /// Reserved for future expansion Offset 0x14, 8 bytes - public ulong reserved; - /// Creation time of the volume Offset 0x1C, 4 bytes - public DateTime creation_time; - /// Version number of the volume format Offset 0x20, 1 byte - public byte version; - /// Reserved for future use Offset 0x21, 1 byte - public byte min_version; - /// Permissions for the volume Offset 0x22, 1 byte - public byte access; - /// Length of an entry in this directory Const 0x27 Offset 0x23, 1 byte - public byte entry_length; - /// Number of entries per block Const 0x0D Offset 0x24, 1 byte - public byte entries_per_block; - /// Number of active files in this directory Offset 0x25, 2 bytes - public ushort file_count; - /// - /// Block address of the first block of the volume's bitmap, one for every 4096 blocks or fraction Offset 0x27, 2 - /// bytes - /// - public ushort bit_map_pointer; - /// Total number of blocks in the volume Offset 0x29, 2 bytes - public ushort total_blocks; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct DirectoryHeader - { - /// Constant 0x0E Offset 0x04, mask 0xF0 - public byte storage_type; - /// Length of volume_name pascal string Offset 0x04, mask 0x0F - public byte name_length; - /// The name of the directory. Offset 0x05, 15 bytes - public string directory_name; - /// Reserved for future expansion Offset 0x14, 8 bytes - public ulong reserved; - /// Creation time of the volume Offset 0x1C, 4 bytes - public DateTime creation_time; - /// Version number of the volume format Offset 0x20, 1 byte - public byte version; - /// Reserved for future use Offset 0x21, 1 byte - public byte min_version; - /// Permissions for the volume Offset 0x22, 1 byte - public byte access; - /// Length of an entry in this directory Const 0x27 Offset 0x23, 1 byte - public byte entry_length; - /// Number of entries per block Const 0x0D Offset 0x24, 1 byte - public byte entries_per_block; - /// Number of active files in this directory Offset 0x25, 2 bytes - public ushort file_count; - /// Block address of parent directory block that contains this entry Offset 0x27, 2 bytes - public ushort parent_pointer; - /// Entry number within the block indicated in parent_pointer Offset 0x29, 1 byte - public byte parent_entry_number; - /// Length of the entry that holds this directory, in the parent entry Const 0x27 Offset 0x2A, 1 byte - public byte parent_entry_length; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct DirectoryKeyBlock - { - /// Always 0 Offset 0x00, 2 bytes - public ushort zero; - /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes - public ushort next_pointer; - /// Directory header Offset 0x04, 39 bytes - public DirectoryHeader header; - /// Directory entries Offset 0x2F, 39 bytes each, 12 entries - public Entry[] entries; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct RootDirectoryKeyBlock - { - /// Always 0 Offset 0x00, 2 bytes - public ushort zero; - /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes - public ushort next_pointer; - /// Directory header Offset 0x04, 39 bytes - public RootDirectoryHeader header; - /// Directory entries Offset 0x2F, 39 bytes each, 12 entries - public Entry[] entries; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct DirectoryBlock - { - /// Pointer to previous directory block Offset 0x00, 2 bytes - public ushort zero; - /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes - public ushort next_pointer; - /// Directory entries Offset 0x2F, 39 bytes each, 13 entries - public Entry[] entries; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct IndexBlock - { - /// Up to 256 pointers to blocks, 0 to indicate the block is sparsed (non-allocated) - public ushort[] block_pointer; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct MasterIndexBlock - { - /// Up to 128 pointers to index blocks - public ushort[] index_block_pointer; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/ProDOS/ProDOS.cs b/Aaru.Filesystems/ProDOS/ProDOS.cs new file mode 100644 index 000000000..7fb6eebb3 --- /dev/null +++ b/Aaru.Filesystems/ProDOS/ProDOS.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : ProDOS.cs +// Author(s) : Natalia Portillo +// +// Component : Apple ProDOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable NotAccessedField.Local + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from Apple ProDOS 8 Technical Reference +/// +/// Implements detection of Apple ProDOS filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class ProDOSPlugin : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.ProDOSPlugin_Name; + /// + public Guid Id => new("43874265-7B8A-4739-BCF7-07F80D5932BF"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ProDOS/Structs.cs b/Aaru.Filesystems/ProDOS/Structs.cs new file mode 100644 index 000000000..e4fa8ff3d --- /dev/null +++ b/Aaru.Filesystems/ProDOS/Structs.cs @@ -0,0 +1,196 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Apple ProDOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable NotAccessedField.Local + +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from Apple ProDOS 8 Technical Reference +/// +/// Implements detection of Apple ProDOS filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class ProDOSPlugin +{ + /// ProDOS directory entry, decoded structure + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct Entry + { + /// Type of file pointed by this entry Offset 0x00, mask 0xF0 + public byte storage_type; + /// Length of name_length pascal string Offset 0x00, mask 0x0F + public byte name_length; + /// Pascal string of file name Offset 0x01, 15 bytes + public string file_name; + /// Descriptor of internal structure of the file Offset 0x10, 1 byte + public byte file_type; + /// + /// Block address of master index block for tree files. Block address of index block for sapling files. Block + /// address of block for seedling files. Offset 0x11, 2 bytes + /// + public ushort key_pointer; + /// Blocks used by file or directory, including index blocks. Offset 0x13, 2 bytes + public ushort blocks_used; + /// Size of file in bytes Offset 0x15, 3 bytes + public uint EOF; + /// File creation datetime Offset 0x18, 4 bytes + public DateTime creation_time; + /// Version of ProDOS that created this file Offset 0x1C, 1 byte + public byte version; + /// Minimum version of ProDOS needed to access this file Offset 0x1D, 1 byte + public byte min_version; + /// File permissions Offset 0x1E, 1 byte + public byte access; + /// General purpose field to store additional information about file format Offset 0x1F, 2 bytes + public ushort aux_type; + /// File last modification date time Offset 0x21, 4 bytes + public DateTime last_mod; + /// Block address pointer to key block of the directory containing this entry Offset 0x25, 2 bytes + public ushort header_pointer; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct RootDirectoryHeader + { + /// Constant 0x0F Offset 0x04, mask 0xF0 + public byte storage_type; + /// Length of volume_name pascal string Offset 0x04, mask 0x0F + public byte name_length; + /// The name of the volume. Offset 0x05, 15 bytes + public string volume_name; + /// Reserved for future expansion Offset 0x14, 8 bytes + public ulong reserved; + /// Creation time of the volume Offset 0x1C, 4 bytes + public DateTime creation_time; + /// Version number of the volume format Offset 0x20, 1 byte + public byte version; + /// Reserved for future use Offset 0x21, 1 byte + public byte min_version; + /// Permissions for the volume Offset 0x22, 1 byte + public byte access; + /// Length of an entry in this directory Const 0x27 Offset 0x23, 1 byte + public byte entry_length; + /// Number of entries per block Const 0x0D Offset 0x24, 1 byte + public byte entries_per_block; + /// Number of active files in this directory Offset 0x25, 2 bytes + public ushort file_count; + /// + /// Block address of the first block of the volume's bitmap, one for every 4096 blocks or fraction Offset 0x27, 2 + /// bytes + /// + public ushort bit_map_pointer; + /// Total number of blocks in the volume Offset 0x29, 2 bytes + public ushort total_blocks; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct DirectoryHeader + { + /// Constant 0x0E Offset 0x04, mask 0xF0 + public byte storage_type; + /// Length of volume_name pascal string Offset 0x04, mask 0x0F + public byte name_length; + /// The name of the directory. Offset 0x05, 15 bytes + public string directory_name; + /// Reserved for future expansion Offset 0x14, 8 bytes + public ulong reserved; + /// Creation time of the volume Offset 0x1C, 4 bytes + public DateTime creation_time; + /// Version number of the volume format Offset 0x20, 1 byte + public byte version; + /// Reserved for future use Offset 0x21, 1 byte + public byte min_version; + /// Permissions for the volume Offset 0x22, 1 byte + public byte access; + /// Length of an entry in this directory Const 0x27 Offset 0x23, 1 byte + public byte entry_length; + /// Number of entries per block Const 0x0D Offset 0x24, 1 byte + public byte entries_per_block; + /// Number of active files in this directory Offset 0x25, 2 bytes + public ushort file_count; + /// Block address of parent directory block that contains this entry Offset 0x27, 2 bytes + public ushort parent_pointer; + /// Entry number within the block indicated in parent_pointer Offset 0x29, 1 byte + public byte parent_entry_number; + /// Length of the entry that holds this directory, in the parent entry Const 0x27 Offset 0x2A, 1 byte + public byte parent_entry_length; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct DirectoryKeyBlock + { + /// Always 0 Offset 0x00, 2 bytes + public ushort zero; + /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes + public ushort next_pointer; + /// Directory header Offset 0x04, 39 bytes + public DirectoryHeader header; + /// Directory entries Offset 0x2F, 39 bytes each, 12 entries + public Entry[] entries; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct RootDirectoryKeyBlock + { + /// Always 0 Offset 0x00, 2 bytes + public ushort zero; + /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes + public ushort next_pointer; + /// Directory header Offset 0x04, 39 bytes + public RootDirectoryHeader header; + /// Directory entries Offset 0x2F, 39 bytes each, 12 entries + public Entry[] entries; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct DirectoryBlock + { + /// Pointer to previous directory block Offset 0x00, 2 bytes + public ushort zero; + /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes + public ushort next_pointer; + /// Directory entries Offset 0x2F, 39 bytes each, 13 entries + public Entry[] entries; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct IndexBlock + { + /// Up to 256 pointers to blocks, 0 to indicate the block is sparsed (non-allocated) + public ushort[] block_pointer; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct MasterIndexBlock + { + /// Up to 128 pointers to index blocks + public ushort[] index_block_pointer; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/QNX4/Consts.cs b/Aaru.Filesystems/QNX4/Consts.cs new file mode 100644 index 000000000..1c5c78ab8 --- /dev/null +++ b/Aaru.Filesystems/QNX4/Consts.cs @@ -0,0 +1,44 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : QNX4 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of QNX 4 filesystem +[SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class QNX4 +{ + readonly byte[] _rootDirFname = + { + 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + const string FS_TYPE = "qnx4"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/QNX4.cs b/Aaru.Filesystems/QNX4/Info.cs similarity index 80% rename from Aaru.Filesystems/QNX4.cs rename to Aaru.Filesystems/QNX4/Info.cs index 447d4eb24..2492db9e1 100644 --- a/Aaru.Filesystems/QNX4.cs +++ b/Aaru.Filesystems/QNX4/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : QNX4.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : QNX4 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the QNX4 filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,41 +26,22 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of QNX 4 filesystem [SuppressMessage("ReSharper", "UnusedType.Local")] -public sealed class QNX4 : IFilesystem +public sealed partial class QNX4 { - readonly byte[] _rootDirFname = - { - 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.QNX4_Name; - /// - public Guid Id => new("E73A63FA-B5B0-48BF-BF82-DA5F0A8170D2"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -213,71 +190,4 @@ public sealed class QNX4 : IFilesystem XmlFsType.Bootable |= qnxSb.boot.di_size != 0 || qnxSb.altBoot.di_size != 0; } - - const string FS_TYPE = "qnx4"; - - struct Extent - { - public uint Block; - public uint Length; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Inode - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] di_fname; - public readonly uint di_size; - public readonly Extent di_first_xtnt; - public readonly uint di_xblk; - public readonly uint di_ftime; - public readonly uint di_mtime; - public readonly uint di_atime; - public readonly uint di_ctime; - public readonly ushort di_num_xtnts; - public readonly ushort di_mode; - public readonly ushort di_uid; - public readonly ushort di_gid; - public readonly ushort di_nlink; - public readonly uint di_zero; - public readonly byte di_type; - public readonly byte di_status; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct LinkInfo - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)] - public readonly byte[] dl_fname; - public readonly uint dl_inode_blk; - public readonly byte dl_inode_ndx; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - public readonly byte[] dl_spare; - public readonly byte dl_status; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct ExtentBlock - { - public readonly uint next_xblk; - public readonly uint prev_xblk; - public readonly byte num_xtnts; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] spare; - public readonly uint num_blocks; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 60)] - public readonly Extent[] xtnts; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] signature; - public readonly Extent first_xtnt; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Superblock - { - public readonly Inode rootDir; - public readonly Inode inode; - public readonly Inode boot; - public readonly Inode altBoot; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/QNX4/QNX4.cs b/Aaru.Filesystems/QNX4/QNX4.cs new file mode 100644 index 000000000..f3df0c5d0 --- /dev/null +++ b/Aaru.Filesystems/QNX4/QNX4.cs @@ -0,0 +1,52 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : QNX4.cs +// Author(s) : Natalia Portillo +// +// Component : QNX4 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of QNX 4 filesystem +[SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class QNX4 : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.QNX4_Name; + /// + public Guid Id => new("E73A63FA-B5B0-48BF-BF82-DA5F0A8170D2"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/QNX4/Structs.cs b/Aaru.Filesystems/QNX4/Structs.cs new file mode 100644 index 000000000..7b8d02274 --- /dev/null +++ b/Aaru.Filesystems/QNX4/Structs.cs @@ -0,0 +1,103 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : QNX4 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of QNX 4 filesystem +[SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class QNX4 +{ + struct Extent + { + public uint Block; + public uint Length; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Inode + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] di_fname; + public readonly uint di_size; + public readonly Extent di_first_xtnt; + public readonly uint di_xblk; + public readonly uint di_ftime; + public readonly uint di_mtime; + public readonly uint di_atime; + public readonly uint di_ctime; + public readonly ushort di_num_xtnts; + public readonly ushort di_mode; + public readonly ushort di_uid; + public readonly ushort di_gid; + public readonly ushort di_nlink; + public readonly uint di_zero; + public readonly byte di_type; + public readonly byte di_status; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct LinkInfo + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)] + public readonly byte[] dl_fname; + public readonly uint dl_inode_blk; + public readonly byte dl_inode_ndx; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] + public readonly byte[] dl_spare; + public readonly byte dl_status; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct ExtentBlock + { + public readonly uint next_xblk; + public readonly uint prev_xblk; + public readonly byte num_xtnts; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] spare; + public readonly uint num_blocks; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 60)] + public readonly Extent[] xtnts; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] signature; + public readonly Extent first_xtnt; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Superblock + { + public readonly Inode rootDir; + public readonly Inode inode; + public readonly Inode boot; + public readonly Inode altBoot; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/QNX6/Consts.cs b/Aaru.Filesystems/QNX6/Consts.cs new file mode 100644 index 000000000..35b151bfd --- /dev/null +++ b/Aaru.Filesystems/QNX6/Consts.cs @@ -0,0 +1,40 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : QNX6 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of QNX 6 filesystem +public sealed partial class QNX6 +{ + const uint QNX6_SUPER_BLOCK_SIZE = 0x1000; + const uint QNX6_BOOT_BLOCKS_SIZE = 0x2000; + const uint QNX6_MAGIC = 0x68191122; + + const string FS_TYPE = "qnx6"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/QNX6.cs b/Aaru.Filesystems/QNX6/Info.cs similarity index 70% rename from Aaru.Filesystems/QNX6.cs rename to Aaru.Filesystems/QNX6/Info.cs index 2fb68a758..20bec07bd 100644 --- a/Aaru.Filesystems/QNX6.cs +++ b/Aaru.Filesystems/QNX6/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : QNX6.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : QNX6 filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the QNX6 filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,39 +26,19 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of QNX 6 filesystem -public sealed class QNX6 : IFilesystem +public sealed partial class QNX6 { - const uint QNX6_SUPER_BLOCK_SIZE = 0x1000; - const uint QNX6_BOOT_BLOCKS_SIZE = 0x2000; - const uint QNX6_MAGIC = 0x68191122; - - const string FS_TYPE = "qnx6"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.QNX6_Name; - /// - public Guid Id => new("3E610EA2-4D08-4D70-8947-830CD4C74FC0"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -190,63 +166,4 @@ public sealed class QNX6 : IFilesystem information = sb.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct RootNode - { - public readonly ulong size; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly uint[] pointers; - public readonly byte levels; - public readonly byte mode; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] spare; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - public readonly uint magic; - public readonly uint checksum; - public readonly ulong serial; - public readonly uint ctime; - public readonly uint atime; - public readonly uint flags; - public readonly ushort version1; - public readonly ushort version2; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] volumeid; - public readonly uint blockSize; - public readonly uint numInodes; - public readonly uint freeInodes; - public readonly uint numBlocks; - public readonly uint freeBlocks; - public readonly uint allocationGroup; - public readonly RootNode inode; - public readonly RootNode bitmap; - public readonly RootNode longfile; - public readonly RootNode unknown; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct AudiSuperBlock - { - public readonly uint magic; - public readonly uint checksum; - public readonly ulong serial; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] spare1; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] id; - public readonly uint blockSize; - public readonly uint numInodes; - public readonly uint freeInodes; - public readonly uint numBlocks; - public readonly uint freeBlocks; - public readonly uint spare2; - public readonly RootNode inode; - public readonly RootNode bitmap; - public readonly RootNode longfile; - public readonly RootNode unknown; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/QNX6/QNX6.cs b/Aaru.Filesystems/QNX6/QNX6.cs new file mode 100644 index 000000000..6d046c832 --- /dev/null +++ b/Aaru.Filesystems/QNX6/QNX6.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : QNX6.cs +// Author(s) : Natalia Portillo +// +// Component : QNX6 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of QNX 6 filesystem +public sealed partial class QNX6 : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.QNX6_Name; + /// + public Guid Id => new("3E610EA2-4D08-4D70-8947-830CD4C74FC0"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/QNX6/Structs.cs b/Aaru.Filesystems/QNX6/Structs.cs new file mode 100644 index 000000000..4609148f9 --- /dev/null +++ b/Aaru.Filesystems/QNX6/Structs.cs @@ -0,0 +1,95 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : QNX6 filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of QNX 6 filesystem +public sealed partial class QNX6 +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct RootNode + { + public readonly ulong size; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly uint[] pointers; + public readonly byte levels; + public readonly byte mode; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] spare; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + public readonly uint magic; + public readonly uint checksum; + public readonly ulong serial; + public readonly uint ctime; + public readonly uint atime; + public readonly uint flags; + public readonly ushort version1; + public readonly ushort version2; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] volumeid; + public readonly uint blockSize; + public readonly uint numInodes; + public readonly uint freeInodes; + public readonly uint numBlocks; + public readonly uint freeBlocks; + public readonly uint allocationGroup; + public readonly RootNode inode; + public readonly RootNode bitmap; + public readonly RootNode longfile; + public readonly RootNode unknown; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct AudiSuperBlock + { + public readonly uint magic; + public readonly uint checksum; + public readonly ulong serial; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] spare1; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] id; + public readonly uint blockSize; + public readonly uint numInodes; + public readonly uint freeInodes; + public readonly uint numBlocks; + public readonly uint freeBlocks; + public readonly uint spare2; + public readonly RootNode inode; + public readonly RootNode bitmap; + public readonly RootNode longfile; + public readonly RootNode unknown; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/RBF/Consts.cs b/Aaru.Filesystems/RBF/Consts.cs new file mode 100644 index 000000000..39f8a0323 --- /dev/null +++ b/Aaru.Filesystems/RBF/Consts.cs @@ -0,0 +1,40 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Random Block File filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class RBF +{ + /// Magic number for OS-9. Same for OS-9000? + const uint RBF_SYNC = 0x4372757A; + const uint RBF_CNYS = 0x7A757243; + + const string FS_TYPE = "rbf"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/RBF/Helpers.cs b/Aaru.Filesystems/RBF/Helpers.cs new file mode 100644 index 000000000..55117f690 --- /dev/null +++ b/Aaru.Filesystems/RBF/Helpers.cs @@ -0,0 +1,42 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Helpers.cs +// Author(s) : Natalia Portillo +// +// Component : Random Block File filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class RBF +{ + static uint LSNToUInt32(byte[] lsn) + { + if(lsn is not { Length: 3 }) + return 0; + + return (uint)((lsn[0] << 16) + (lsn[1] << 8) + lsn[2]); + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/RBF.cs b/Aaru.Filesystems/RBF/Info.cs similarity index 67% rename from Aaru.Filesystems/RBF.cs rename to Aaru.Filesystems/RBF/Info.cs index 970066270..97462b254 100644 --- a/Aaru.Filesystems/RBF.cs +++ b/Aaru.Filesystems/RBF/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : RBF.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Random Block File filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Random Block File filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,8 +26,6 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -39,31 +33,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Locus filesystem -public sealed class RBF : IFilesystem +public sealed partial class RBF : IFilesystem { - /// Magic number for OS-9. Same for OS-9000? - const uint RBF_SYNC = 0x4372757A; - const uint RBF_CNYS = 0x7A757243; - - const string FS_TYPE = "rbf"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.RBF_Name; - /// - public Guid Id => new("E864E45B-0B52-4D29-A858-7BDFA9199FB2"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -296,123 +272,4 @@ public sealed class RBF : IFilesystem information = sb.ToString(); } - - static uint LSNToUInt32(byte[] lsn) - { - if(lsn is not { Length: 3 }) - return 0; - - return (uint)((lsn[0] << 16) + (lsn[1] << 8) + lsn[2]); - } - - /// Identification sector. Wherever the sector this resides on, becomes LSN 0. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct IdSector - { - /// Sectors on disk - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] dd_tot; - /// Tracks - public readonly byte dd_tks; - /// Bytes in allocation map - public readonly ushort dd_map; - /// Sectors per cluster - public readonly ushort dd_bit; - /// LSN of root directory - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] dd_dir; - /// Owner ID - public readonly ushort dd_own; - /// Attributes - public readonly byte dd_att; - /// Disk ID - public readonly ushort dd_dsk; - /// Format byte - public readonly byte dd_fmt; - /// Sectors per track - public readonly ushort dd_spt; - /// Reserved - public readonly ushort dd_res; - /// LSN of boot file - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] dd_bt; - /// Size of boot file - public readonly ushort dd_bsz; - /// Creation date - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] - public readonly byte[] dd_dat; - /// Volume name - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] dd_nam; - /// Path options - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] dd_opt; - /// Reserved - public readonly byte reserved; - /// Magic number - public readonly uint dd_sync; - /// LSN of allocation map - public readonly uint dd_maplsn; - /// Size of an LSN - public readonly ushort dd_lsnsize; - /// Version ID - public readonly ushort dd_versid; - } - - /// - /// Identification sector. Wherever the sector this resides on, becomes LSN 0. Introduced on OS-9000, this can be - /// big or little endian. - /// - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct NewIdSector - { - /// Magic number - public readonly uint rid_sync; - /// Disk ID - public readonly uint rid_diskid; - /// Sectors on disk - public readonly uint rid_totblocks; - /// Cylinders - public readonly ushort rid_cylinders; - /// Sectors in cylinder 0 - public readonly ushort rid_cyl0size; - /// Sectors per cylinder - public readonly ushort rid_cylsize; - /// Heads - public readonly ushort rid_heads; - /// Bytes per sector - public readonly ushort rid_blocksize; - /// Disk format - public readonly ushort rid_format; - /// Flags - public readonly ushort rid_flags; - /// Padding - public readonly ushort rid_unused1; - /// Sector of allocation bitmap - public readonly uint rid_bitmap; - /// Sector of debugger FD - public readonly uint rid_firstboot; - /// Sector of bootfile FD - public readonly uint rid_bootfile; - /// Sector of root directory FD - public readonly uint rid_rootdir; - /// Group owner of media - public readonly ushort rid_group; - /// Owner of media - public readonly ushort rid_owner; - /// Creation time - public readonly uint rid_ctime; - /// Last write time for this structure - public readonly uint rid_mtime; - /// Volume name - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] rid_name; - /// Endian flag - public readonly byte rid_endflag; - /// Padding - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] rid_unused2; - /// Parity - public readonly uint rid_parity; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/RBF/RBF.cs b/Aaru.Filesystems/RBF/RBF.cs new file mode 100644 index 000000000..d1f2b3927 --- /dev/null +++ b/Aaru.Filesystems/RBF/RBF.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : RBF.cs +// Author(s) : Natalia Portillo +// +// Component : Random Block File filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class RBF : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.RBF_Name; + /// + public Guid Id => new("E864E45B-0B52-4D29-A858-7BDFA9199FB2"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/RBF/Structs.cs b/Aaru.Filesystems/RBF/Structs.cs new file mode 100644 index 000000000..9cf6ce9f0 --- /dev/null +++ b/Aaru.Filesystems/RBF/Structs.cs @@ -0,0 +1,147 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Random Block File filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Locus filesystem +public sealed partial class RBF +{ + /// Identification sector. Wherever the sector this resides on, becomes LSN 0. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct IdSector + { + /// Sectors on disk + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] dd_tot; + /// Tracks + public readonly byte dd_tks; + /// Bytes in allocation map + public readonly ushort dd_map; + /// Sectors per cluster + public readonly ushort dd_bit; + /// LSN of root directory + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] dd_dir; + /// Owner ID + public readonly ushort dd_own; + /// Attributes + public readonly byte dd_att; + /// Disk ID + public readonly ushort dd_dsk; + /// Format byte + public readonly byte dd_fmt; + /// Sectors per track + public readonly ushort dd_spt; + /// Reserved + public readonly ushort dd_res; + /// LSN of boot file + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] dd_bt; + /// Size of boot file + public readonly ushort dd_bsz; + /// Creation date + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] + public readonly byte[] dd_dat; + /// Volume name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] dd_nam; + /// Path options + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] dd_opt; + /// Reserved + public readonly byte reserved; + /// Magic number + public readonly uint dd_sync; + /// LSN of allocation map + public readonly uint dd_maplsn; + /// Size of an LSN + public readonly ushort dd_lsnsize; + /// Version ID + public readonly ushort dd_versid; + } + + /// + /// Identification sector. Wherever the sector this resides on, becomes LSN 0. Introduced on OS-9000, this can be + /// big or little endian. + /// + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct NewIdSector + { + /// Magic number + public readonly uint rid_sync; + /// Disk ID + public readonly uint rid_diskid; + /// Sectors on disk + public readonly uint rid_totblocks; + /// Cylinders + public readonly ushort rid_cylinders; + /// Sectors in cylinder 0 + public readonly ushort rid_cyl0size; + /// Sectors per cylinder + public readonly ushort rid_cylsize; + /// Heads + public readonly ushort rid_heads; + /// Bytes per sector + public readonly ushort rid_blocksize; + /// Disk format + public readonly ushort rid_format; + /// Flags + public readonly ushort rid_flags; + /// Padding + public readonly ushort rid_unused1; + /// Sector of allocation bitmap + public readonly uint rid_bitmap; + /// Sector of debugger FD + public readonly uint rid_firstboot; + /// Sector of bootfile FD + public readonly uint rid_bootfile; + /// Sector of root directory FD + public readonly uint rid_rootdir; + /// Group owner of media + public readonly ushort rid_group; + /// Owner of media + public readonly ushort rid_owner; + /// Creation time + public readonly uint rid_ctime; + /// Last write time for this structure + public readonly uint rid_mtime; + /// Volume name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] rid_name; + /// Endian flag + public readonly byte rid_endflag; + /// Padding + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] rid_unused2; + /// Parity + public readonly uint rid_parity; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/RT11/Consts.cs b/Aaru.Filesystems/RT11/Consts.cs new file mode 100644 index 000000000..fc91a7741 --- /dev/null +++ b/Aaru.Filesystems/RT11/Consts.cs @@ -0,0 +1,43 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : RT-11 file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the RT-11 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-2023 Natalia Portillo +// ****************************************************************************/ + +using Aaru.CommonTypes.Interfaces; + +namespace Aaru.Filesystems; + +// Information from http://www.trailing-edge.com/~shoppa/rt11fs/ +/// +/// Implements detection of the DEC RT-11 filesystem +public sealed partial class RT11 : IFilesystem +{ + const string FS_TYPE = "rt11"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/RT11.cs b/Aaru.Filesystems/RT11/Info.cs similarity index 61% rename from Aaru.Filesystems/RT11.cs rename to Aaru.Filesystems/RT11/Info.cs index 32a687448..e5cdb8b2e 100644 --- a/Aaru.Filesystems/RT11.cs +++ b/Aaru.Filesystems/RT11/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : RT11.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : RT-11 file system plugin. @@ -31,7 +31,6 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -40,27 +39,14 @@ using Aaru.Helpers; using Claunia.Encoding; using Schemas; using Encoding = System.Text.Encoding; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; // Information from http://www.trailing-edge.com/~shoppa/rt11fs/ /// /// Implements detection of the DEC RT-11 filesystem -public sealed class RT11 : IFilesystem +public sealed partial class RT11 { - const string FS_TYPE = "rt11"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.RT11_Name; - /// - public Guid Id => new("DB3E2F98-8F98-463C-8126-E937843DA024"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -135,52 +121,4 @@ public sealed class RT11 : IFilesystem information = sb.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct HomeBlock - { - /// Bad block replacement table - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 130)] - public readonly byte[] badBlockTable; - /// Unused - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] unused; - /// INITIALIZE/RESTORE data area - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)] - public readonly byte[] initArea; - /// BUP information area - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)] - public readonly byte[] bupInformation; - /// Empty - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] - public readonly byte[] empty; - /// Reserved - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] reserved1; - /// Reserved - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] reserved2; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] - public readonly byte[] empty2; - /// Cluster size - public readonly ushort cluster; - /// Block of the first directory segment - public readonly ushort rootBlock; - /// "V3A" in Radix-50 - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] systemVersion; - /// Name of the volume, 12 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] volname; - /// Name of the volume owner, 12 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] ownername; - /// RT11 defines it as "DECRT11A ", 12 bytes - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] format; - /// Unused - public readonly ushort unused2; - /// Checksum of preceding 255 words (16 bit units) - public readonly ushort checksum; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/RT11/RT11.cs b/Aaru.Filesystems/RT11/RT11.cs new file mode 100644 index 000000000..82021f0b5 --- /dev/null +++ b/Aaru.Filesystems/RT11/RT11.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : RT11.cs +// Author(s) : Natalia Portillo +// +// Component : RT-11 file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the RT-11 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from http://www.trailing-edge.com/~shoppa/rt11fs/ +/// +/// Implements detection of the DEC RT-11 filesystem +public sealed partial class RT11 : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.RT11_Name; + /// + public Guid Id => new("DB3E2F98-8F98-463C-8126-E937843DA024"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/RT11/Structs.cs b/Aaru.Filesystems/RT11/Structs.cs new file mode 100644 index 000000000..742e69c54 --- /dev/null +++ b/Aaru.Filesystems/RT11/Structs.cs @@ -0,0 +1,90 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : RT-11 file system plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the RT-11 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; +using Aaru.CommonTypes.Interfaces; + +namespace Aaru.Filesystems; + +// Information from http://www.trailing-edge.com/~shoppa/rt11fs/ +/// +/// Implements detection of the DEC RT-11 filesystem +public sealed partial class RT11 : IFilesystem +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct HomeBlock + { + /// Bad block replacement table + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 130)] + public readonly byte[] badBlockTable; + /// Unused + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly byte[] unused; + /// INITIALIZE/RESTORE data area + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)] + public readonly byte[] initArea; + /// BUP information area + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)] + public readonly byte[] bupInformation; + /// Empty + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] + public readonly byte[] empty; + /// Reserved + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly byte[] reserved1; + /// Reserved + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly byte[] reserved2; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + public readonly byte[] empty2; + /// Cluster size + public readonly ushort cluster; + /// Block of the first directory segment + public readonly ushort rootBlock; + /// "V3A" in Radix-50 + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly byte[] systemVersion; + /// Name of the volume, 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] volname; + /// Name of the volume owner, 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] ownername; + /// RT11 defines it as "DECRT11A ", 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] format; + /// Unused + public readonly ushort unused2; + /// Checksum of preceding 255 words (16 bit units) + public readonly ushort checksum; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ReFS/Consts.cs b/Aaru.Filesystems/ReFS/Consts.cs new file mode 100644 index 000000000..93d775c6b --- /dev/null +++ b/Aaru.Filesystems/ReFS/Consts.cs @@ -0,0 +1,42 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Resilient File System plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Microsoft's Resilient filesystem (ReFS) +public sealed partial class ReFS +{ + const uint FSRS = 0x53525346; + + const string FS_TYPE = "refs"; + readonly byte[] _signature = + { + 0x52, 0x65, 0x46, 0x53, 0x00, 0x00, 0x00, 0x00 + }; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ReFS.cs b/Aaru.Filesystems/ReFS/Info.cs similarity index 77% rename from Aaru.Filesystems/ReFS.cs rename to Aaru.Filesystems/ReFS/Info.cs index 4245efc95..dbb8e5000 100644 --- a/Aaru.Filesystems/ReFS.cs +++ b/Aaru.Filesystems/ReFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : ReFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Resilient File System plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Resilient File System and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,7 +28,6 @@ using System; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -40,32 +35,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of Microsoft's Resilient filesystem (ReFS) -public sealed class ReFS : IFilesystem +public sealed partial class ReFS : IFilesystem { - const uint FSRS = 0x53525346; - - const string FS_TYPE = "refs"; - readonly byte[] _signature = - { - 0x52, 0x65, 0x46, 0x53, 0x00, 0x00, 0x00, 0x00 - }; - /// - public string Name => Localization.ReFS_Name; - /// - public Guid Id => new("37766C4E-EBF5-4113-A712-B758B756ABD6"); - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -167,27 +143,4 @@ public sealed class ReFS : IFilesystem Clusters = vhdr.sectors / vhdr.sectorsPerCluster }; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct VolumeHeader - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] signature; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] - public readonly byte[] mustBeZero; - public readonly uint identifier; - public readonly ushort length; - public readonly ushort checksum; - public readonly ulong sectors; - public readonly uint bytesPerSector; - public readonly uint sectorsPerCluster; - public readonly uint unknown1; - public readonly uint unknown2; - public readonly ulong unknown3; - public readonly ulong unknown4; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15872)] - public readonly byte[] unknown5; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/ReFS/ReFS.cs b/Aaru.Filesystems/ReFS/ReFS.cs new file mode 100644 index 000000000..94d7cec7f --- /dev/null +++ b/Aaru.Filesystems/ReFS/ReFS.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : ReFS.cs +// Author(s) : Natalia Portillo +// +// Component : Resilient File System plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Microsoft's Resilient filesystem (ReFS) +public sealed partial class ReFS : IFilesystem +{ + /// + public string Name => Localization.ReFS_Name; + /// + public Guid Id => new("37766C4E-EBF5-4113-A712-B758B756ABD6"); + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ReFS/Structs.cs b/Aaru.Filesystems/ReFS/Structs.cs new file mode 100644 index 000000000..c0690bcb1 --- /dev/null +++ b/Aaru.Filesystems/ReFS/Structs.cs @@ -0,0 +1,59 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Resilient File System plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of Microsoft's Resilient filesystem (ReFS) +public sealed partial class ReFS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct VolumeHeader + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] signature; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] + public readonly byte[] mustBeZero; + public readonly uint identifier; + public readonly ushort length; + public readonly ushort checksum; + public readonly ulong sectors; + public readonly uint bytesPerSector; + public readonly uint sectorsPerCluster; + public readonly uint unknown1; + public readonly uint unknown2; + public readonly ulong unknown3; + public readonly ulong unknown4; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15872)] + public readonly byte[] unknown5; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Register.cs b/Aaru.Filesystems/Register.cs index 1fe79e9f5..000cf8638 100644 --- a/Aaru.Filesystems/Register.cs +++ b/Aaru.Filesystems/Register.cs @@ -7,10 +7,6 @@ // // Component : Core algorithms. // -// --[ Description ] ---------------------------------------------------------- -// -// Registers all plugins in this assembly. -// // --[ License ] -------------------------------------------------------------- // // Permission is hereby granted, free of charge, to any person obtaining a diff --git a/Aaru.Filesystems/Reiser/Consts.cs b/Aaru.Filesystems/Reiser/Consts.cs new file mode 100644 index 000000000..8609e02d8 --- /dev/null +++ b/Aaru.Filesystems/Reiser/Consts.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Reiser filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Reiser v3 filesystem +public sealed partial class Reiser +{ + const uint REISER_SUPER_OFFSET = 0x10000; + + const string FS_TYPE = "reiserfs"; + + readonly byte[] _magic35 = + { + 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x46, 0x73, 0x00, 0x00 + }; + readonly byte[] _magic36 = + { + 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x32, 0x46, 0x73, 0x00 + }; + readonly byte[] _magicJr = + { + 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x33, 0x46, 0x73, 0x00 + }; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser.cs b/Aaru.Filesystems/Reiser/Info.cs similarity index 65% rename from Aaru.Filesystems/Reiser.cs rename to Aaru.Filesystems/Reiser/Info.cs index 5060707cf..b775a3d56 100644 --- a/Aaru.Filesystems/Reiser.cs +++ b/Aaru.Filesystems/Reiser/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Reiser.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Reiser filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Reiser filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,51 +26,20 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Reiser v3 filesystem -public sealed class Reiser : IFilesystem +public sealed partial class Reiser : IFilesystem { - const uint REISER_SUPER_OFFSET = 0x10000; - - const string FS_TYPE = "reiserfs"; - - readonly byte[] _magic35 = - { - 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x46, 0x73, 0x00, 0x00 - }; - readonly byte[] _magic36 = - { - 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x32, 0x46, 0x73, 0x00 - }; - readonly byte[] _magicJr = - { - 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x33, 0x46, 0x73, 0x00 - }; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.Reiser_Name; - /// - public Guid Id => new("1D8CD8B8-27E6-410F-9973-D16409225FBA"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -187,49 +152,4 @@ public sealed class Reiser : IFilesystem XmlFsType.VolumeName = StringHandlers.CToString(reiserSb.label, Encoding); XmlFsType.VolumeSerial = reiserSb.uuid.ToString(); } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct JournalParameters - { - public readonly uint journal_1stblock; - public readonly uint journal_dev; - public readonly uint journal_size; - public readonly uint journal_trans_max; - public readonly uint journal_magic; - public readonly uint journal_max_batch; - public readonly uint journal_max_commit_age; - public readonly uint journal_max_trans_age; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Superblock - { - public readonly uint block_count; - public readonly uint free_blocks; - public readonly uint root_block; - public readonly JournalParameters journal; - public readonly ushort blocksize; - public readonly ushort oid_maxsize; - public readonly ushort oid_cursize; - public readonly ushort umount_state; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - public readonly byte[] magic; - public readonly ushort fs_state; - public readonly uint hash_function_code; - public readonly ushort tree_height; - public readonly ushort bmap_nr; - public readonly ushort version; - public readonly ushort reserved_for_journal; - public readonly uint inode_generation; - public readonly uint flags; - public readonly Guid uuid; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] label; - public readonly ushort mnt_count; - public readonly ushort max_mnt_count; - public readonly uint last_check; - public readonly uint check_interval; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 76)] - public readonly byte[] unused; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser/Reiser.cs b/Aaru.Filesystems/Reiser/Reiser.cs new file mode 100644 index 000000000..9010d96d9 --- /dev/null +++ b/Aaru.Filesystems/Reiser/Reiser.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Reiser.cs +// Author(s) : Natalia Portillo +// +// Component : Reiser filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Reiser v3 filesystem +public sealed partial class Reiser : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.Reiser_Name; + /// + public Guid Id => new("1D8CD8B8-27E6-410F-9973-D16409225FBA"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser/Structs.cs b/Aaru.Filesystems/Reiser/Structs.cs new file mode 100644 index 000000000..4406fa82e --- /dev/null +++ b/Aaru.Filesystems/Reiser/Structs.cs @@ -0,0 +1,82 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Reiser filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Reiser v3 filesystem +public sealed partial class Reiser +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct JournalParameters + { + public readonly uint journal_1stblock; + public readonly uint journal_dev; + public readonly uint journal_size; + public readonly uint journal_trans_max; + public readonly uint journal_magic; + public readonly uint journal_max_batch; + public readonly uint journal_max_commit_age; + public readonly uint journal_max_trans_age; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct Superblock + { + public readonly uint block_count; + public readonly uint free_blocks; + public readonly uint root_block; + public readonly JournalParameters journal; + public readonly ushort blocksize; + public readonly ushort oid_maxsize; + public readonly ushort oid_cursize; + public readonly ushort umount_state; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] + public readonly byte[] magic; + public readonly ushort fs_state; + public readonly uint hash_function_code; + public readonly ushort tree_height; + public readonly ushort bmap_nr; + public readonly ushort version; + public readonly ushort reserved_for_journal; + public readonly uint inode_generation; + public readonly uint flags; + public readonly Guid uuid; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] label; + public readonly ushort mnt_count; + public readonly ushort max_mnt_count; + public readonly uint last_check; + public readonly uint check_interval; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 76)] + public readonly byte[] unused; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser4/Consts.cs b/Aaru.Filesystems/Reiser4/Consts.cs new file mode 100644 index 000000000..748b7d778 --- /dev/null +++ b/Aaru.Filesystems/Reiser4/Consts.cs @@ -0,0 +1,43 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Reiser4 filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Reiser v4 filesystem +public sealed partial class Reiser4 +{ + const uint REISER4_SUPER_OFFSET = 0x10000; + + const string FS_TYPE = "reiser4"; + + readonly byte[] _magic = + { + 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser4.cs b/Aaru.Filesystems/Reiser4/Info.cs similarity index 76% rename from Aaru.Filesystems/Reiser4.cs rename to Aaru.Filesystems/Reiser4/Info.cs index 587fa772d..c2d058080 100644 --- a/Aaru.Filesystems/Reiser4.cs +++ b/Aaru.Filesystems/Reiser4/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Reiser4.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Reiser4 filesystem plugin // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Reiser4 filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,43 +26,20 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Reiser v4 filesystem -public sealed class Reiser4 : IFilesystem +public sealed partial class Reiser4 { - const uint REISER4_SUPER_OFFSET = 0x10000; - - const string FS_TYPE = "reiser4"; - - readonly byte[] _magic = - { - 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.Reiser4_Name; - /// - public Guid Id => new("301F2D00-E8D5-4F04-934E-81DFB21D15BA"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -150,16 +123,4 @@ public sealed class Reiser4 : IFilesystem VolumeSerial = reiserSb.uuid.ToString() }; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Superblock - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] magic; - public readonly ushort diskformat; - public readonly ushort blocksize; - public readonly Guid uuid; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] label; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser4/Reiser4.cs b/Aaru.Filesystems/Reiser4/Reiser4.cs new file mode 100644 index 000000000..c44bbd51d --- /dev/null +++ b/Aaru.Filesystems/Reiser4/Reiser4.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Reiser4.cs +// Author(s) : Natalia Portillo +// +// Component : Reiser4 filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Reiser v4 filesystem +public sealed partial class Reiser4 : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.Reiser4_Name; + /// + public Guid Id => new("301F2D00-E8D5-4F04-934E-81DFB21D15BA"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Reiser4/Structs.cs b/Aaru.Filesystems/Reiser4/Structs.cs new file mode 100644 index 000000000..e65fcdd46 --- /dev/null +++ b/Aaru.Filesystems/Reiser4/Structs.cs @@ -0,0 +1,49 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Reiser4 filesystem plugin +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Reiser v4 filesystem +public sealed partial class Reiser4 +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Superblock + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] magic; + public readonly ushort diskformat; + public readonly ushort blocksize; + public readonly Guid uuid; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] label; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/SFS/Consts.cs b/Aaru.Filesystems/SFS/Consts.cs new file mode 100644 index 000000000..aff5f54e7 --- /dev/null +++ b/Aaru.Filesystems/SFS/Consts.cs @@ -0,0 +1,41 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : SmartFileSystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Smart File System +public sealed partial class SFS +{ + /// Identifier for SFS v1 + const uint SFS_MAGIC = 0x53465300; + /// Identifier for SFS v2 + const uint SFS2_MAGIC = 0x53465302; + + const string FS_TYPE = "sfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/SFS/Enums.cs b/Aaru.Filesystems/SFS/Enums.cs new file mode 100644 index 000000000..d618ab88e --- /dev/null +++ b/Aaru.Filesystems/SFS/Enums.cs @@ -0,0 +1,42 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : SmartFileSystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Smart File System +public sealed partial class SFS +{ + [Flags] + enum Flags : byte + { + RecycledFolder = 64, CaseSensitive = 128 + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/SFS.cs b/Aaru.Filesystems/SFS/Info.cs similarity index 67% rename from Aaru.Filesystems/SFS.cs rename to Aaru.Filesystems/SFS/Info.cs index 71c6eb116..92bd51cb9 100644 --- a/Aaru.Filesystems/SFS.cs +++ b/Aaru.Filesystems/SFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : SFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : SmartFileSystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the SmartFileSystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,40 +26,19 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Smart File System -public sealed class SFS : IFilesystem +public sealed partial class SFS { - /// Identifier for SFS v1 - const uint SFS_MAGIC = 0x53465300; - /// Identifier for SFS v2 - const uint SFS2_MAGIC = 0x53465302; - - const string FS_TYPE = "sfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.SFS_Name; - /// - public Guid Id => new("26550C19-3671-4A2D-BC2F-F20CEB7F48DC"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -140,41 +115,4 @@ public sealed class SFS : IFilesystem Type = FS_TYPE }; } - - [Flags] - enum Flags : byte - { - RecycledFolder = 64, CaseSensitive = 128 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct RootBlock - { - public readonly uint blockId; - public readonly uint blockChecksum; - public readonly uint blockSelfPointer; - public readonly ushort version; - public readonly ushort sequence; - public readonly uint datecreated; - public readonly Flags bits; - public readonly byte padding1; - public readonly ushort padding2; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly uint[] reserved1; - public readonly ulong firstbyte; - public readonly ulong lastbyte; - public readonly uint totalblocks; - public readonly uint blocksize; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly uint[] reserved2; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly uint[] reserved3; - public readonly uint bitmapbase; - public readonly uint adminspacecontainer; - public readonly uint rootobjectcontainer; - public readonly uint extentbnoderoot; - public readonly uint objectnoderoot; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly uint[] reserved4; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/SFS/SFS.cs b/Aaru.Filesystems/SFS/SFS.cs new file mode 100644 index 000000000..3501e5b8a --- /dev/null +++ b/Aaru.Filesystems/SFS/SFS.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : SFS.cs +// Author(s) : Natalia Portillo +// +// Component : SmartFileSystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Smart File System +public sealed partial class SFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.SFS_Name; + /// + public Guid Id => new("26550C19-3671-4A2D-BC2F-F20CEB7F48DC"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/SFS/Structs.cs b/Aaru.Filesystems/SFS/Structs.cs new file mode 100644 index 000000000..b0d9bf904 --- /dev/null +++ b/Aaru.Filesystems/SFS/Structs.cs @@ -0,0 +1,68 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : SmartFileSystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; +using Aaru.CommonTypes.Interfaces; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Smart File System +public sealed partial class SFS : IFilesystem +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct RootBlock + { + public readonly uint blockId; + public readonly uint blockChecksum; + public readonly uint blockSelfPointer; + public readonly ushort version; + public readonly ushort sequence; + public readonly uint datecreated; + public readonly Flags bits; + public readonly byte padding1; + public readonly ushort padding2; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly uint[] reserved1; + public readonly ulong firstbyte; + public readonly ulong lastbyte; + public readonly uint totalblocks; + public readonly uint blocksize; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly uint[] reserved2; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly uint[] reserved3; + public readonly uint bitmapbase; + public readonly uint adminspacecontainer; + public readonly uint rootobjectcontainer; + public readonly uint extentbnoderoot; + public readonly uint objectnoderoot; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly uint[] reserved4; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/SolarFS/Consts.cs b/Aaru.Filesystems/SolarFS/Consts.cs new file mode 100644 index 000000000..ee2f0751f --- /dev/null +++ b/Aaru.Filesystems/SolarFS/Consts.cs @@ -0,0 +1,37 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : SolarOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Based on FAT's BPB, cannot find a FAT or directory +/// +/// Implements detection of the Solar OS filesystem +public sealed partial class SolarFS +{ + const string FS_TYPE = "solarfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/SolarFS.cs b/Aaru.Filesystems/SolarFS/Info.cs similarity index 77% rename from Aaru.Filesystems/SolarFS.cs rename to Aaru.Filesystems/SolarFS/Info.cs index 56b5d84db..8228ac551 100644 --- a/Aaru.Filesystems/SolarFS.cs +++ b/Aaru.Filesystems/SolarFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : SolarFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : SolarOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the SolarOS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -45,20 +40,8 @@ namespace Aaru.Filesystems; // Based on FAT's BPB, cannot find a FAT or directory /// /// Implements detection of the Solar OS filesystem -public sealed class SolarFS : IFilesystem +public sealed partial class SolarFS { - const string FS_TYPE = "solarfs"; - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.SolarFS_Name; - /// - public Guid Id => new("EA3101C1-E777-4B4F-B5A3-8C57F50F6E65"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -181,41 +164,4 @@ public sealed class SolarFS : IFilesystem information = sb.ToString(); } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct BiosParameterBlock - { - /// 0x00, x86 jump (3 bytes), jumps to 0x60 - public byte[] x86_jump; - /// 0x03, 8 bytes, "SOLAR_OS" - public string OEMName; - /// 0x0B, Bytes per sector - public ushort bps; - /// 0x0D, unknown, 0x01 - public byte unk1; - /// 0x0E, unknown, 0x0201 - public ushort unk2; - /// 0x10, Number of entries on root directory ? (no root directory found) - public ushort root_ent; - /// 0x12, Sectors in volume - public ushort sectors; - /// 0x14, Media descriptor - public byte media; - /// 0x15, Sectors per FAT ? (no FAT found) - public ushort spfat; - /// 0x17, Sectors per track - public ushort sptrk; - /// 0x19, Heads - public ushort heads; - /// 0x1B, unknown, 10 bytes, zero-filled - public byte[] unk3; - /// 0x25, 0x29 - public byte signature; - /// 0x26, unknown, zero-filled - public uint unk4; - /// 0x2A, 11 bytes, volume name, space-padded - public string vol_name; - /// 0x35, 8 bytes, "SOL_FS " - public string fs_type; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/SolarFS/SolarFS.cs b/Aaru.Filesystems/SolarFS/SolarFS.cs new file mode 100644 index 000000000..e212fb1b3 --- /dev/null +++ b/Aaru.Filesystems/SolarFS/SolarFS.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : SolarFS.cs +// Author(s) : Natalia Portillo +// +// Component : SolarOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Based on FAT's BPB, cannot find a FAT or directory +/// +/// Implements detection of the Solar OS filesystem +public sealed partial class SolarFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.SolarFS_Name; + /// + public Guid Id => new("EA3101C1-E777-4B4F-B5A3-8C57F50F6E65"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/SolarFS/Structs.cs b/Aaru.Filesystems/SolarFS/Structs.cs new file mode 100644 index 000000000..20ceae513 --- /dev/null +++ b/Aaru.Filesystems/SolarFS/Structs.cs @@ -0,0 +1,74 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : SolarOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Based on FAT's BPB, cannot find a FAT or directory +/// +/// Implements detection of the Solar OS filesystem +public sealed partial class SolarFS +{ + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct BiosParameterBlock + { + /// 0x00, x86 jump (3 bytes), jumps to 0x60 + public byte[] x86_jump; + /// 0x03, 8 bytes, "SOLAR_OS" + public string OEMName; + /// 0x0B, Bytes per sector + public ushort bps; + /// 0x0D, unknown, 0x01 + public byte unk1; + /// 0x0E, unknown, 0x0201 + public ushort unk2; + /// 0x10, Number of entries on root directory ? (no root directory found) + public ushort root_ent; + /// 0x12, Sectors in volume + public ushort sectors; + /// 0x14, Media descriptor + public byte media; + /// 0x15, Sectors per FAT ? (no FAT found) + public ushort spfat; + /// 0x17, Sectors per track + public ushort sptrk; + /// 0x19, Heads + public ushort heads; + /// 0x1B, unknown, 10 bytes, zero-filled + public byte[] unk3; + /// 0x25, 0x29 + public byte signature; + /// 0x26, unknown, zero-filled + public uint unk4; + /// 0x2A, 11 bytes, volume name, space-padded + public string vol_name; + /// 0x35, 8 bytes, "SOL_FS " + public string fs_type; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Squash/Consts.cs b/Aaru.Filesystems/Squash/Consts.cs new file mode 100644 index 000000000..070eafa37 --- /dev/null +++ b/Aaru.Filesystems/Squash/Consts.cs @@ -0,0 +1,40 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Squash file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the squash filesystem +public sealed partial class Squash +{ + /// Identifier for Squash + const uint SQUASH_MAGIC = 0x73717368; + const uint SQUASH_CIGAM = 0x68737173; + + const string FS_TYPE = "squashfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Squash/Enums.cs b/Aaru.Filesystems/Squash/Enums.cs new file mode 100644 index 000000000..9def15b15 --- /dev/null +++ b/Aaru.Filesystems/Squash/Enums.cs @@ -0,0 +1,40 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : Squash file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the squash filesystem +public sealed partial class Squash +{ + enum SquashCompression : ushort + { + Zlib = 1, Lzma = 2, Lzo = 3, + Xz = 4, Lz4 = 5, Zstd = 6 + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Squash.cs b/Aaru.Filesystems/Squash/Info.cs similarity index 74% rename from Aaru.Filesystems/Squash.cs rename to Aaru.Filesystems/Squash/Info.cs index e86354313..0a6036c20 100644 --- a/Aaru.Filesystems/Squash.cs +++ b/Aaru.Filesystems/Squash/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Squash.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Squash file system plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Squash file system and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,38 +27,19 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the squash filesystem -public sealed class Squash : IFilesystem +public sealed partial class Squash { - /// Identifier for Squash - const uint SQUASH_MAGIC = 0x73717368; - const uint SQUASH_CIGAM = 0x68737173; - - const string FS_TYPE = "squashfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.Squash_Name; - /// - public Guid Id => new("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -170,34 +147,4 @@ public sealed class Squash : IFilesystem FreeClustersSpecified = true }; } - - enum SquashCompression : ushort - { - Zlib = 1, Lzma = 2, Lzo = 3, - Xz = 4, Lz4 = 5, Zstd = 6 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - public readonly uint magic; - public readonly uint inodes; - public readonly uint mkfs_time; - public readonly uint block_size; - public readonly uint fragments; - public readonly ushort compression; - public readonly ushort block_log; - public readonly ushort flags; - public readonly ushort no_ids; - public readonly ushort s_major; - public readonly ushort s_minor; - public readonly ulong root_inode; - public readonly ulong bytes_used; - public readonly ulong id_table_start; - public readonly ulong xattr_id_table_start; - public readonly ulong inode_table_start; - public readonly ulong directory_table_start; - public readonly ulong fragment_table_start; - public readonly ulong lookup_table_start; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Squash/Squash.cs b/Aaru.Filesystems/Squash/Squash.cs new file mode 100644 index 000000000..2443acdcd --- /dev/null +++ b/Aaru.Filesystems/Squash/Squash.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Squash.cs +// Author(s) : Natalia Portillo +// +// Component : Squash file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the squash filesystem +public sealed partial class Squash : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.Squash_Name; + /// + public Guid Id => new("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Squash/Structs.cs b/Aaru.Filesystems/Squash/Structs.cs new file mode 100644 index 000000000..b66df6da1 --- /dev/null +++ b/Aaru.Filesystems/Squash/Structs.cs @@ -0,0 +1,60 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Squash file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the squash filesystem +public sealed partial class Squash +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + public readonly uint magic; + public readonly uint inodes; + public readonly uint mkfs_time; + public readonly uint block_size; + public readonly uint fragments; + public readonly ushort compression; + public readonly ushort block_log; + public readonly ushort flags; + public readonly ushort no_ids; + public readonly ushort s_major; + public readonly ushort s_minor; + public readonly ulong root_inode; + public readonly ulong bytes_used; + public readonly ulong id_table_start; + public readonly ulong xattr_id_table_start; + public readonly ulong inode_table_start; + public readonly ulong directory_table_start; + public readonly ulong fragment_table_start; + public readonly ulong lookup_table_start; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/SysV/Consts.cs b/Aaru.Filesystems/SysV/Consts.cs new file mode 100644 index 000000000..b88ec929b --- /dev/null +++ b/Aaru.Filesystems/SysV/Consts.cs @@ -0,0 +1,68 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : UNIX System V filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable NotAccessedField.Local + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the UNIX System V filesystem +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local"), + SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class SysVfs +{ + const uint XENIX_MAGIC = 0x002B5544; + const uint XENIX_CIGAM = 0x44552B00; + const uint SYSV_MAGIC = 0xFD187E20; + const uint SYSV_CIGAM = 0x207E18FD; + + // Rest have no magic. + // Per a Linux kernel, Coherent fs has following: + const string COH_FNAME = "noname"; + const string COH_FPACK = "nopack"; + const string COH_XXXXX = "xxxxx"; + const string COH_XXXXS = "xxxxx "; + const string COH_XXXXN = "xxxxx\n"; + + // SCO AFS + const ushort SCO_NFREE = 0xFFFF; + + // UNIX 7th Edition has nothing to detect it, so check for a valid filesystem is a must :( + const ushort V7_NICINOD = 100; + const ushort V7_NICFREE = 100; + const uint V7_MAXSIZE = 0x00FFFFFF; + + const string FS_TYPE_XENIX = "xenixfs"; + const string FS_TYPE_SVR4 = "sysv_r4"; + const string FS_TYPE_SVR2 = "sysv_r2"; + const string FS_TYPE_COHERENT = "coherent"; + const string FS_TYPE_UNIX7 = "unix7fs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/SysV.cs b/Aaru.Filesystems/SysV/Info.cs similarity index 73% rename from Aaru.Filesystems/SysV.cs rename to Aaru.Filesystems/SysV/Info.cs index 0ad3182ed..26e8c6ad1 100644 --- a/Aaru.Filesystems/SysV.cs +++ b/Aaru.Filesystems/SysV/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : SysV.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : UNIX System V filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the UNIX System V filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -49,40 +45,8 @@ namespace Aaru.Filesystems; /// Implements detection of the UNIX System V filesystem [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] -public sealed class SysVfs : IFilesystem +public sealed partial class SysVfs { - const uint XENIX_MAGIC = 0x002B5544; - const uint XENIX_CIGAM = 0x44552B00; - const uint SYSV_MAGIC = 0xFD187E20; - const uint SYSV_CIGAM = 0x207E18FD; - - // Rest have no magic. - // Per a Linux kernel, Coherent fs has following: - const string COH_FNAME = "noname"; - const string COH_FPACK = "nopack"; - const string COH_XXXXX = "xxxxx"; - const string COH_XXXXS = "xxxxx "; - const string COH_XXXXN = "xxxxx\n"; - - // SCO AFS - const ushort SCO_NFREE = 0xFFFF; - - // UNIX 7th Edition has nothing to detect it, so check for a valid filesystem is a must :( - const ushort V7_NICINOD = 100; - const ushort V7_NICFREE = 100; - const uint V7_MAXSIZE = 0x00FFFFFF; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.SysVfs_Name; - /// - public Guid Id => new("9B8D016A-8561-400E-A12A-A198283C211D"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -190,12 +154,6 @@ public sealed class SysVfs : IFilesystem return false; } - const string FS_TYPE_XENIX = "xenixfs"; - const string FS_TYPE_SVR4 = "sysv_r4"; - const string FS_TYPE_SVR2 = "sysv_r2"; - const string FS_TYPE_COHERENT = "coherent"; - const string FS_TYPE_UNIX7 = "unix7fs"; - /// public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { @@ -883,271 +841,4 @@ public sealed class SysVfs : IFilesystem information = sb.ToString(); } - - // Old XENIX use different offsets - #pragma warning disable CS0649 - struct XenixSuperBlock - { - /// 0x000, index of first data zone - public ushort s_isize; - /// 0x002, total number of zones of this volume - public uint s_fsize; - - // the start of the free block list: - /// 0x006, blocks in s_free, <=100 - public ushort s_nfree; - /// 0x008, 100 entries, 50 entries for Xenix 3, first free block list chunk - public uint[] s_free; - - // the cache of free inodes: - /// 0x198 (0xD0), number of inodes in s_inode, <= 100 - public ushort s_ninode; - /// 0x19A (0xD2), 100 entries, some free inodes - public ushort[] s_inode; - /// 0x262 (0x19A), free block list manipulation lock - public byte s_flock; - /// 0x263 (0x19B), inode cache manipulation lock - public byte s_ilock; - /// 0x264 (0x19C), superblock modification flag - public byte s_fmod; - /// 0x265 (0x19D), read-only mounted flag - public byte s_ronly; - /// 0x266 (0x19E), time of last superblock update - public int s_time; - /// 0x26A (0x1A2), total number of free zones - public uint s_tfree; - /// 0x26E (0x1A6), total number of free inodes - public ushort s_tinode; - /// 0x270 (0x1A8), blocks per cylinder - public ushort s_cylblks; - /// 0x272 (0x1AA), blocks per gap - public ushort s_gapblks; - /// 0x274 (0x1AC), device information ?? - public ushort s_dinfo0; - /// 0x276 (0x1AE), device information ?? - public ushort s_dinfo1; - /// 0x278 (0x1B0), 6 bytes, volume name - public string s_fname; - /// 0x27E (0x1B6), 6 bytes, pack name - public string s_fpack; - /// 0x284 (0x1BC), 0x46 if volume is clean - public byte s_clean; - /// 0x285 (0x1BD), 371 bytes, 51 bytes for Xenix 3 - public byte[] s_fill; - /// 0x3F8 (0x1F0), magic - public uint s_magic; - /// 0x3FC (0x1F4), filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk, 3 = 2048 bytes/blk) - public uint s_type; - } - #pragma warning restore CS0649 - - #pragma warning disable CS0649 - struct SystemVRelease4SuperBlock - { - /// 0x000, index of first data zone - public ushort s_isize; - /// 0x002, padding - public ushort s_pad0; - /// 0x004, total number of zones of this volume - public uint s_fsize; - - // the start of the free block list: - /// 0x008, blocks in s_free, <=100 - public ushort s_nfree; - /// 0x00A, padding - public ushort s_pad1; - /// 0x00C, 50 entries, first free block list chunk - public uint[] s_free; - - // the cache of free inodes: - /// 0x0D4, number of inodes in s_inode, <= 100 - public ushort s_ninode; - /// 0x0D6, padding - public ushort s_pad2; - /// 0x0D8, 100 entries, some free inodes - public ushort[] s_inode; - /// 0x1A0, free block list manipulation lock - public byte s_flock; - /// 0x1A1, inode cache manipulation lock - public byte s_ilock; - /// 0x1A2, superblock modification flag - public byte s_fmod; - /// 0x1A3, read-only mounted flag - public byte s_ronly; - /// 0x1A4, time of last superblock update - public uint s_time; - /// 0x1A8, blocks per cylinder - public ushort s_cylblks; - /// 0x1AA, blocks per gap - public ushort s_gapblks; - /// 0x1AC, device information ?? - public ushort s_dinfo0; - /// 0x1AE, device information ?? - public ushort s_dinfo1; - /// 0x1B0, total number of free zones - public uint s_tfree; - /// 0x1B4, total number of free inodes - public ushort s_tinode; - /// 0x1B6, padding - public ushort s_pad3; - /// 0x1B8, 6 bytes, volume name - public string s_fname; - /// 0x1BE, 6 bytes, pack name - public string s_fpack; - /// 0x1C4, 48 bytes - public byte[] s_fill; - /// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean - public uint s_state; - /// 0x1F8, magic - public uint s_magic; - /// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) - public uint s_type; - } - #pragma warning restore CS0649 - - #pragma warning disable CS0649 - struct SystemVRelease2SuperBlock - { - /// 0x000, index of first data zone - public ushort s_isize; - /// 0x002, total number of zones of this volume - public uint s_fsize; - - // the start of the free block list: - /// 0x006, blocks in s_free, <=100 - public ushort s_nfree; - /// 0x008, 50 entries, first free block list chunk - public uint[] s_free; - - // the cache of free inodes: - /// 0x0D0, number of inodes in s_inode, <= 100 - public ushort s_ninode; - /// 0x0D2, 100 entries, some free inodes - public ushort[] s_inode; - /// 0x19A, free block list manipulation lock - public byte s_flock; - /// 0x19B, inode cache manipulation lock - public byte s_ilock; - /// 0x19C, superblock modification flag - public byte s_fmod; - /// 0x19D, read-only mounted flag - public byte s_ronly; - /// 0x19E, time of last superblock update - public uint s_time; - /// 0x1A2, blocks per cylinder - public ushort s_cylblks; - /// 0x1A4, blocks per gap - public ushort s_gapblks; - /// 0x1A6, device information ?? - public ushort s_dinfo0; - /// 0x1A8, device information ?? - public ushort s_dinfo1; - /// 0x1AA, total number of free zones - public uint s_tfree; - /// 0x1AE, total number of free inodes - public ushort s_tinode; - /// 0x1B0, 6 bytes, volume name - public string s_fname; - /// 0x1B6, 6 bytes, pack name - public string s_fpack; - /// 0x1BC, 56 bytes - public byte[] s_fill; - /// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean - public uint s_state; - /// 0x1F8, magic - public uint s_magic; - /// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) - public uint s_type; - } - #pragma warning restore CS0649 - - #pragma warning disable CS0649 - struct UNIX7thEditionSuperBlock - { - /// 0x000, index of first data zone - public ushort s_isize; - /// 0x002, total number of zones of this volume - public uint s_fsize; - - // the start of the free block list: - /// 0x006, blocks in s_free, <=100 - public ushort s_nfree; - /// 0x008, 50 entries, first free block list chunk - public uint[] s_free; - - // the cache of free inodes: - /// 0x0D0, number of inodes in s_inode, <= 100 - public ushort s_ninode; - /// 0x0D2, 100 entries, some free inodes - public ushort[] s_inode; - /// 0x19A, free block list manipulation lock - public byte s_flock; - /// 0x19B, inode cache manipulation lock - public byte s_ilock; - /// 0x19C, superblock modification flag - public byte s_fmod; - /// 0x19D, read-only mounted flag - public byte s_ronly; - /// 0x19E, time of last superblock update - public uint s_time; - /// 0x1A2, total number of free zones - public uint s_tfree; - /// 0x1A6, total number of free inodes - public ushort s_tinode; - /// 0x1A8, interleave factor - public ushort s_int_m; - /// 0x1AA, interleave factor - public ushort s_int_n; - /// 0x1AC, 6 bytes, volume name - public string s_fname; - /// 0x1B2, 6 bytes, pack name - public string s_fpack; - } - #pragma warning restore CS0649 - - #pragma warning disable CS0649 - struct CoherentSuperBlock - { - /// 0x000, index of first data zone - public ushort s_isize; - /// 0x002, total number of zones of this volume - public uint s_fsize; - - // the start of the free block list: - /// 0x006, blocks in s_free, <=100 - public ushort s_nfree; - /// 0x008, 64 entries, first free block list chunk - public uint[] s_free; - - // the cache of free inodes: - /// 0x108, number of inodes in s_inode, <= 100 - public ushort s_ninode; - /// 0x10A, 100 entries, some free inodes - public ushort[] s_inode; - /// 0x1D2, free block list manipulation lock - public byte s_flock; - /// 0x1D3, inode cache manipulation lock - public byte s_ilock; - /// 0x1D4, superblock modification flag - public byte s_fmod; - /// 0x1D5, read-only mounted flag - public byte s_ronly; - /// 0x1D6, time of last superblock update - public uint s_time; - /// 0x1DE, total number of free zones - public uint s_tfree; - /// 0x1E2, total number of free inodes - public ushort s_tinode; - /// 0x1E4, interleave factor - public ushort s_int_m; - /// 0x1E6, interleave factor - public ushort s_int_n; - /// 0x1E8, 6 bytes, volume name - public string s_fname; - /// 0x1EE, 6 bytes, pack name - public string s_fpack; - /// 0x1F4, zero-filled - public uint s_unique; - } - #pragma warning restore CS0649 } \ No newline at end of file diff --git a/Aaru.Filesystems/SysV/Structs.cs b/Aaru.Filesystems/SysV/Structs.cs new file mode 100644 index 000000000..bf3cd90f1 --- /dev/null +++ b/Aaru.Filesystems/SysV/Structs.cs @@ -0,0 +1,308 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : UNIX System V filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable NotAccessedField.Local + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the UNIX System V filesystem +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local"), + SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class SysVfs +{ + // Old XENIX use different offsets + #pragma warning disable CS0649 + struct XenixSuperBlock + { + /// 0x000, index of first data zone + public ushort s_isize; + /// 0x002, total number of zones of this volume + public uint s_fsize; + + // the start of the free block list: + /// 0x006, blocks in s_free, <=100 + public ushort s_nfree; + /// 0x008, 100 entries, 50 entries for Xenix 3, first free block list chunk + public uint[] s_free; + + // the cache of free inodes: + /// 0x198 (0xD0), number of inodes in s_inode, <= 100 + public ushort s_ninode; + /// 0x19A (0xD2), 100 entries, some free inodes + public ushort[] s_inode; + /// 0x262 (0x19A), free block list manipulation lock + public byte s_flock; + /// 0x263 (0x19B), inode cache manipulation lock + public byte s_ilock; + /// 0x264 (0x19C), superblock modification flag + public byte s_fmod; + /// 0x265 (0x19D), read-only mounted flag + public byte s_ronly; + /// 0x266 (0x19E), time of last superblock update + public int s_time; + /// 0x26A (0x1A2), total number of free zones + public uint s_tfree; + /// 0x26E (0x1A6), total number of free inodes + public ushort s_tinode; + /// 0x270 (0x1A8), blocks per cylinder + public ushort s_cylblks; + /// 0x272 (0x1AA), blocks per gap + public ushort s_gapblks; + /// 0x274 (0x1AC), device information ?? + public ushort s_dinfo0; + /// 0x276 (0x1AE), device information ?? + public ushort s_dinfo1; + /// 0x278 (0x1B0), 6 bytes, volume name + public string s_fname; + /// 0x27E (0x1B6), 6 bytes, pack name + public string s_fpack; + /// 0x284 (0x1BC), 0x46 if volume is clean + public byte s_clean; + /// 0x285 (0x1BD), 371 bytes, 51 bytes for Xenix 3 + public byte[] s_fill; + /// 0x3F8 (0x1F0), magic + public uint s_magic; + /// 0x3FC (0x1F4), filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk, 3 = 2048 bytes/blk) + public uint s_type; + } + #pragma warning restore CS0649 + + #pragma warning disable CS0649 + struct SystemVRelease4SuperBlock + { + /// 0x000, index of first data zone + public ushort s_isize; + /// 0x002, padding + public ushort s_pad0; + /// 0x004, total number of zones of this volume + public uint s_fsize; + + // the start of the free block list: + /// 0x008, blocks in s_free, <=100 + public ushort s_nfree; + /// 0x00A, padding + public ushort s_pad1; + /// 0x00C, 50 entries, first free block list chunk + public uint[] s_free; + + // the cache of free inodes: + /// 0x0D4, number of inodes in s_inode, <= 100 + public ushort s_ninode; + /// 0x0D6, padding + public ushort s_pad2; + /// 0x0D8, 100 entries, some free inodes + public ushort[] s_inode; + /// 0x1A0, free block list manipulation lock + public byte s_flock; + /// 0x1A1, inode cache manipulation lock + public byte s_ilock; + /// 0x1A2, superblock modification flag + public byte s_fmod; + /// 0x1A3, read-only mounted flag + public byte s_ronly; + /// 0x1A4, time of last superblock update + public uint s_time; + /// 0x1A8, blocks per cylinder + public ushort s_cylblks; + /// 0x1AA, blocks per gap + public ushort s_gapblks; + /// 0x1AC, device information ?? + public ushort s_dinfo0; + /// 0x1AE, device information ?? + public ushort s_dinfo1; + /// 0x1B0, total number of free zones + public uint s_tfree; + /// 0x1B4, total number of free inodes + public ushort s_tinode; + /// 0x1B6, padding + public ushort s_pad3; + /// 0x1B8, 6 bytes, volume name + public string s_fname; + /// 0x1BE, 6 bytes, pack name + public string s_fpack; + /// 0x1C4, 48 bytes + public byte[] s_fill; + /// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean + public uint s_state; + /// 0x1F8, magic + public uint s_magic; + /// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) + public uint s_type; + } + #pragma warning restore CS0649 + + #pragma warning disable CS0649 + struct SystemVRelease2SuperBlock + { + /// 0x000, index of first data zone + public ushort s_isize; + /// 0x002, total number of zones of this volume + public uint s_fsize; + + // the start of the free block list: + /// 0x006, blocks in s_free, <=100 + public ushort s_nfree; + /// 0x008, 50 entries, first free block list chunk + public uint[] s_free; + + // the cache of free inodes: + /// 0x0D0, number of inodes in s_inode, <= 100 + public ushort s_ninode; + /// 0x0D2, 100 entries, some free inodes + public ushort[] s_inode; + /// 0x19A, free block list manipulation lock + public byte s_flock; + /// 0x19B, inode cache manipulation lock + public byte s_ilock; + /// 0x19C, superblock modification flag + public byte s_fmod; + /// 0x19D, read-only mounted flag + public byte s_ronly; + /// 0x19E, time of last superblock update + public uint s_time; + /// 0x1A2, blocks per cylinder + public ushort s_cylblks; + /// 0x1A4, blocks per gap + public ushort s_gapblks; + /// 0x1A6, device information ?? + public ushort s_dinfo0; + /// 0x1A8, device information ?? + public ushort s_dinfo1; + /// 0x1AA, total number of free zones + public uint s_tfree; + /// 0x1AE, total number of free inodes + public ushort s_tinode; + /// 0x1B0, 6 bytes, volume name + public string s_fname; + /// 0x1B6, 6 bytes, pack name + public string s_fpack; + /// 0x1BC, 56 bytes + public byte[] s_fill; + /// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean + public uint s_state; + /// 0x1F8, magic + public uint s_magic; + /// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) + public uint s_type; + } + #pragma warning restore CS0649 + + #pragma warning disable CS0649 + struct UNIX7thEditionSuperBlock + { + /// 0x000, index of first data zone + public ushort s_isize; + /// 0x002, total number of zones of this volume + public uint s_fsize; + + // the start of the free block list: + /// 0x006, blocks in s_free, <=100 + public ushort s_nfree; + /// 0x008, 50 entries, first free block list chunk + public uint[] s_free; + + // the cache of free inodes: + /// 0x0D0, number of inodes in s_inode, <= 100 + public ushort s_ninode; + /// 0x0D2, 100 entries, some free inodes + public ushort[] s_inode; + /// 0x19A, free block list manipulation lock + public byte s_flock; + /// 0x19B, inode cache manipulation lock + public byte s_ilock; + /// 0x19C, superblock modification flag + public byte s_fmod; + /// 0x19D, read-only mounted flag + public byte s_ronly; + /// 0x19E, time of last superblock update + public uint s_time; + /// 0x1A2, total number of free zones + public uint s_tfree; + /// 0x1A6, total number of free inodes + public ushort s_tinode; + /// 0x1A8, interleave factor + public ushort s_int_m; + /// 0x1AA, interleave factor + public ushort s_int_n; + /// 0x1AC, 6 bytes, volume name + public string s_fname; + /// 0x1B2, 6 bytes, pack name + public string s_fpack; + } + #pragma warning restore CS0649 + + #pragma warning disable CS0649 + struct CoherentSuperBlock + { + /// 0x000, index of first data zone + public ushort s_isize; + /// 0x002, total number of zones of this volume + public uint s_fsize; + + // the start of the free block list: + /// 0x006, blocks in s_free, <=100 + public ushort s_nfree; + /// 0x008, 64 entries, first free block list chunk + public uint[] s_free; + + // the cache of free inodes: + /// 0x108, number of inodes in s_inode, <= 100 + public ushort s_ninode; + /// 0x10A, 100 entries, some free inodes + public ushort[] s_inode; + /// 0x1D2, free block list manipulation lock + public byte s_flock; + /// 0x1D3, inode cache manipulation lock + public byte s_ilock; + /// 0x1D4, superblock modification flag + public byte s_fmod; + /// 0x1D5, read-only mounted flag + public byte s_ronly; + /// 0x1D6, time of last superblock update + public uint s_time; + /// 0x1DE, total number of free zones + public uint s_tfree; + /// 0x1E2, total number of free inodes + public ushort s_tinode; + /// 0x1E4, interleave factor + public ushort s_int_m; + /// 0x1E6, interleave factor + public ushort s_int_n; + /// 0x1E8, 6 bytes, volume name + public string s_fname; + /// 0x1EE, 6 bytes, pack name + public string s_fpack; + /// 0x1F4, zero-filled + public uint s_unique; + } + #pragma warning restore CS0649 +} \ No newline at end of file diff --git a/Aaru.Filesystems/SysV/SysV.cs b/Aaru.Filesystems/SysV/SysV.cs new file mode 100644 index 000000000..5bd48d1cf --- /dev/null +++ b/Aaru.Filesystems/SysV/SysV.cs @@ -0,0 +1,56 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : SysV.cs +// Author(s) : Natalia Portillo +// +// Component : UNIX System V filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// ReSharper disable NotAccessedField.Local + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the UNIX System V filesystem +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local"), + SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class SysVfs : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.SysVfs_Name; + /// + public Guid Id => new("9B8D016A-8561-400E-A12A-A198283C211D"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs index 08daaed8d..057b857c4 100644 --- a/Aaru.Filesystems/UCSDPascal/File.cs +++ b/Aaru.Filesystems/UCSDPascal/File.cs @@ -7,10 +7,6 @@ // // Component : U.C.S.D. Pascal filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Methods to handle files. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify diff --git a/Aaru.Filesystems/UDF/Consts.cs b/Aaru.Filesystems/UDF/Consts.cs new file mode 100644 index 000000000..dd12e5b2a --- /dev/null +++ b/Aaru.Filesystems/UDF/Consts.cs @@ -0,0 +1,46 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Universal Disk Format plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// TODO: Detect bootable +/// +/// Implements detection of the Universal Disk Format filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class UDF +{ + readonly byte[] _magic = + { + 0x2A, 0x4F, 0x53, 0x54, 0x41, 0x20, 0x55, 0x44, 0x46, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x6C, 0x69, 0x61, 0x6E, + 0x74, 0x00, 0x00, 0x00, 0x00 + }; + + const string FS_TYPE = "udf"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/UDF/Enums.cs b/Aaru.Filesystems/UDF/Enums.cs new file mode 100644 index 000000000..8f53056ef --- /dev/null +++ b/Aaru.Filesystems/UDF/Enums.cs @@ -0,0 +1,45 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : Universal Disk Format plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// TODO: Detect bootable +/// +/// Implements detection of the Universal Disk Format filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class UDF +{ + [Flags] + enum EntityFlags : byte + { + Dirty = 0x01, Protected = 0x02 + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/UDF/Helpers.cs b/Aaru.Filesystems/UDF/Helpers.cs new file mode 100644 index 000000000..6bc9a9dc7 --- /dev/null +++ b/Aaru.Filesystems/UDF/Helpers.cs @@ -0,0 +1,44 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Helpers.cs +// Author(s) : Natalia Portillo +// +// Component : Universal Disk Format plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using Aaru.Helpers; + +namespace Aaru.Filesystems; + +// TODO: Detect bootable +/// +/// Implements detection of the Universal Disk Format filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class UDF +{ + static DateTime EcmaToDateTime(Timestamp timestamp) => DateHandlers.EcmaToDateTime(timestamp.typeAndZone, + timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second, + timestamp.centiseconds, timestamp.hundredsMicroseconds, timestamp.microseconds); +} \ No newline at end of file diff --git a/Aaru.Filesystems/UDF.cs b/Aaru.Filesystems/UDF/Info.cs similarity index 65% rename from Aaru.Filesystems/UDF.cs rename to Aaru.Filesystems/UDF/Info.cs index ee72d6726..43ce1be1b 100644 --- a/Aaru.Filesystems/UDF.cs +++ b/Aaru.Filesystems/UDF/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : UDF.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Universal Disk Format plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Universal Disk Format and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -33,7 +29,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -41,7 +36,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -49,25 +43,8 @@ namespace Aaru.Filesystems; /// /// Implements detection of the Universal Disk Format filesystem [SuppressMessage("ReSharper", "UnusedMember.Local")] -public sealed class UDF : IFilesystem +public sealed partial class UDF { - readonly byte[] _magic = - { - 0x2A, 0x4F, 0x53, 0x54, 0x41, 0x20, 0x55, 0x44, 0x46, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x6C, 0x69, 0x61, 0x6E, - 0x74, 0x00, 0x00, 0x00, 0x00 - }; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.UDF_Name; - /// - public Guid Id => new("83976FEC-A91B-464B-9293-56C719461BAB"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -409,168 +386,4 @@ public sealed class UDF : IFilesystem information = sbInformation.ToString(); } - - const string FS_TYPE = "udf"; - - static DateTime EcmaToDateTime(Timestamp timestamp) => DateHandlers.EcmaToDateTime(timestamp.typeAndZone, - timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second, - timestamp.centiseconds, timestamp.hundredsMicroseconds, timestamp.microseconds); - - [Flags] - enum EntityFlags : byte - { - Dirty = 0x01, Protected = 0x02 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct EntityIdentifier - { - /// Entity flags - public readonly EntityFlags flags; - /// Structure identifier - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 23)] - public readonly byte[] identifier; - /// Structure data - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] identifierSuffix; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Timestamp - { - public readonly ushort typeAndZone; - public readonly short year; - public readonly byte month; - public readonly byte day; - public readonly byte hour; - public readonly byte minute; - public readonly byte second; - public readonly byte centiseconds; - public readonly byte hundredsMicroseconds; - public readonly byte microseconds; - } - - enum TagIdentifier : ushort - { - PrimaryVolumeDescriptor = 1, AnchorVolumeDescriptorPointer = 2, VolumeDescriptorPointer = 3, - ImplementationUseVolumeDescriptor = 4, PartitionDescriptor = 5, LogicalVolumeDescriptor = 6, - UnallocatedSpaceDescriptor = 7, TerminatingDescriptor = 8, LogicalVolumeIntegrityDescriptor = 9 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DescriptorTag - { - public readonly TagIdentifier tagIdentifier; - public readonly ushort descriptorVersion; - public readonly byte tagChecksum; - public readonly byte reserved; - public readonly ushort tagSerialNumber; - public readonly ushort descriptorCrc; - public readonly ushort descriptorCrcLength; - public readonly uint tagLocation; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct ExtentDescriptor - { - public readonly uint length; - public readonly uint location; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct CharacterSpecification - { - public readonly byte type; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 63)] - public readonly byte[] information; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct AnchorVolumeDescriptorPointer - { - public readonly DescriptorTag tag; - public readonly ExtentDescriptor mainVolumeDescriptorSequenceExtent; - public readonly ExtentDescriptor reserveVolumeDescriptorSequenceExtent; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 480)] - public readonly byte[] reserved; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct PrimaryVolumeDescriptor - { - public readonly DescriptorTag tag; - public readonly uint volumeDescriptorSequenceNumber; - public readonly uint primaryVolumeDescriptorNumber; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] volumeIdentifier; - public readonly ushort volumeSequenceNumber; - public readonly ushort maximumVolumeSequenceNumber; - public readonly ushort interchangeLevel; - public readonly ushort maximumInterchangeLevel; - public readonly uint characterSetList; - public readonly uint maximumCharacterSetList; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public readonly byte[] volumeSetIdentifier; - public readonly CharacterSpecification descriptorCharacterSet; - public readonly CharacterSpecification explanatoryCharacterSet; - public readonly ExtentDescriptor volumeAbstract; - public readonly ExtentDescriptor volumeCopyright; - public readonly EntityIdentifier applicationIdentifier; - public readonly Timestamp recordingDateTime; - public readonly EntityIdentifier implementationIdentifier; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] implementationUse; - public readonly uint predecessorVolumeDescriptorSequenceLocation; - public readonly ushort flags; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)] - public readonly byte[] reserved; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct LogicalVolumeDescriptor - { - public readonly DescriptorTag tag; - public readonly uint volumeDescriptorSequenceNumber; - public readonly CharacterSpecification descriptorCharacterSet; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public readonly byte[] logicalVolumeIdentifier; - public readonly uint logicalBlockSize; - public readonly EntityIdentifier domainIdentifier; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] logicalVolumeContentsUse; - public readonly uint mapTableLength; - public readonly uint numberOfPartitionMaps; - public readonly EntityIdentifier implementationIdentifier; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public readonly byte[] implementationUse; - public readonly ExtentDescriptor integritySequenceExtent; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct LogicalVolumeIntegrityDescriptor - { - public readonly DescriptorTag tag; - public readonly Timestamp recordingDateTime; - public readonly uint integrityType; - public readonly ExtentDescriptor nextIntegrityExtent; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] logicalVolumeContentsUse; - public readonly uint numberOfPartitions; - public readonly uint lengthOfImplementationUse; - - // Follows uint[numberOfPartitions] freeSpaceTable; - // Follows uint[numberOfPartitions] sizeTable; - // Follows byte[lengthOfImplementationUse] implementationUse; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct LogicalVolumeIntegrityDescriptorImplementationUse - { - public readonly EntityIdentifier implementationId; - public readonly uint files; - public readonly uint directories; - public readonly ushort minimumReadUDF; - public readonly ushort minimumWriteUDF; - public readonly ushort maximumWriteUDF; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/UDF/Structs.cs b/Aaru.Filesystems/UDF/Structs.cs new file mode 100644 index 000000000..4b417956b --- /dev/null +++ b/Aaru.Filesystems/UDF/Structs.cs @@ -0,0 +1,191 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Universal Disk Format plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// TODO: Detect bootable +/// +/// Implements detection of the Universal Disk Format filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class UDF +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct EntityIdentifier + { + /// Entity flags + public readonly EntityFlags flags; + /// Structure identifier + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 23)] + public readonly byte[] identifier; + /// Structure data + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] identifierSuffix; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Timestamp + { + public readonly ushort typeAndZone; + public readonly short year; + public readonly byte month; + public readonly byte day; + public readonly byte hour; + public readonly byte minute; + public readonly byte second; + public readonly byte centiseconds; + public readonly byte hundredsMicroseconds; + public readonly byte microseconds; + } + + enum TagIdentifier : ushort + { + PrimaryVolumeDescriptor = 1, AnchorVolumeDescriptorPointer = 2, VolumeDescriptorPointer = 3, + ImplementationUseVolumeDescriptor = 4, PartitionDescriptor = 5, LogicalVolumeDescriptor = 6, + UnallocatedSpaceDescriptor = 7, TerminatingDescriptor = 8, LogicalVolumeIntegrityDescriptor = 9 + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct DescriptorTag + { + public readonly TagIdentifier tagIdentifier; + public readonly ushort descriptorVersion; + public readonly byte tagChecksum; + public readonly byte reserved; + public readonly ushort tagSerialNumber; + public readonly ushort descriptorCrc; + public readonly ushort descriptorCrcLength; + public readonly uint tagLocation; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct ExtentDescriptor + { + public readonly uint length; + public readonly uint location; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct CharacterSpecification + { + public readonly byte type; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 63)] + public readonly byte[] information; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct AnchorVolumeDescriptorPointer + { + public readonly DescriptorTag tag; + public readonly ExtentDescriptor mainVolumeDescriptorSequenceExtent; + public readonly ExtentDescriptor reserveVolumeDescriptorSequenceExtent; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 480)] + public readonly byte[] reserved; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct PrimaryVolumeDescriptor + { + public readonly DescriptorTag tag; + public readonly uint volumeDescriptorSequenceNumber; + public readonly uint primaryVolumeDescriptorNumber; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] volumeIdentifier; + public readonly ushort volumeSequenceNumber; + public readonly ushort maximumVolumeSequenceNumber; + public readonly ushort interchangeLevel; + public readonly ushort maximumInterchangeLevel; + public readonly uint characterSetList; + public readonly uint maximumCharacterSetList; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] + public readonly byte[] volumeSetIdentifier; + public readonly CharacterSpecification descriptorCharacterSet; + public readonly CharacterSpecification explanatoryCharacterSet; + public readonly ExtentDescriptor volumeAbstract; + public readonly ExtentDescriptor volumeCopyright; + public readonly EntityIdentifier applicationIdentifier; + public readonly Timestamp recordingDateTime; + public readonly EntityIdentifier implementationIdentifier; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] implementationUse; + public readonly uint predecessorVolumeDescriptorSequenceLocation; + public readonly ushort flags; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)] + public readonly byte[] reserved; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct LogicalVolumeDescriptor + { + public readonly DescriptorTag tag; + public readonly uint volumeDescriptorSequenceNumber; + public readonly CharacterSpecification descriptorCharacterSet; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] + public readonly byte[] logicalVolumeIdentifier; + public readonly uint logicalBlockSize; + public readonly EntityIdentifier domainIdentifier; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] logicalVolumeContentsUse; + public readonly uint mapTableLength; + public readonly uint numberOfPartitionMaps; + public readonly EntityIdentifier implementationIdentifier; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] + public readonly byte[] implementationUse; + public readonly ExtentDescriptor integritySequenceExtent; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct LogicalVolumeIntegrityDescriptor + { + public readonly DescriptorTag tag; + public readonly Timestamp recordingDateTime; + public readonly uint integrityType; + public readonly ExtentDescriptor nextIntegrityExtent; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] logicalVolumeContentsUse; + public readonly uint numberOfPartitions; + public readonly uint lengthOfImplementationUse; + + // Follows uint[numberOfPartitions] freeSpaceTable; + // Follows uint[numberOfPartitions] sizeTable; + // Follows byte[lengthOfImplementationUse] implementationUse; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct LogicalVolumeIntegrityDescriptorImplementationUse + { + public readonly EntityIdentifier implementationId; + public readonly uint files; + public readonly uint directories; + public readonly ushort minimumReadUDF; + public readonly ushort minimumWriteUDF; + public readonly ushort maximumWriteUDF; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/UDF/UDF.cs b/Aaru.Filesystems/UDF/UDF.cs new file mode 100644 index 000000000..8e9c487fd --- /dev/null +++ b/Aaru.Filesystems/UDF/UDF.cs @@ -0,0 +1,53 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : UDF.cs +// Author(s) : Natalia Portillo +// +// Component : Universal Disk Format plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// TODO: Detect bootable +/// +/// Implements detection of the Universal Disk Format filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class UDF : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.UDF_Name; + /// + public Guid Id => new("83976FEC-A91B-464B-9293-56C719461BAB"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/UNICOS/Consts.cs b/Aaru.Filesystems/UNICOS/Consts.cs new file mode 100644 index 000000000..dfa66b668 --- /dev/null +++ b/Aaru.Filesystems/UNICOS/Consts.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : UNICOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// UNICOS is ILP64 so let's think everything is 64-bit + +using blkno_t = System.Int64; +using daddr_t = System.Int64; +using dev_t = System.Int64; +using extent_t = System.Int64; +using ino_t = System.Int64; +using time_t = System.Int64; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the Cray UNICOS filesystem +public sealed partial class UNICOS +{ + const int NC1_MAXPART = 64; + const int NC1_MAXIREG = 4; + + const ulong UNICOS_MAGIC = 0x6e6331667331636e; + const ulong UNICOS_SECURE = 0xcd076d1771d670cd; + + const string FS_TYPE = "unicos"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/UNICOS/Info.cs b/Aaru.Filesystems/UNICOS/Info.cs new file mode 100644 index 000000000..bb9b2a52c --- /dev/null +++ b/Aaru.Filesystems/UNICOS/Info.cs @@ -0,0 +1,144 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Info.cs +// Author(s) : Natalia Portillo +// +// Component : UNICOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// UNICOS is ILP64 so let's think everything is 64-bit + +using System.Text; +using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.Console; +using Aaru.Helpers; +using Schemas; +using blkno_t = System.Int64; +using daddr_t = System.Int64; +using dev_t = System.Int64; +using extent_t = System.Int64; +using ino_t = System.Int64; +using time_t = System.Int64; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the Cray UNICOS filesystem +public sealed partial class UNICOS +{ + /// + public bool Identify(IMediaImage imagePlugin, Partition partition) + { + if(imagePlugin.Info.SectorSize < 512) + return false; + + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + sbSize++; + + if(partition.Start + sbSize >= partition.End) + return false; + + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return false; + + if(sector.Length < Marshal.SizeOf()) + return false; + + Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); + + AaruConsole.DebugWriteLine("UNICOS plugin", Localization.magic_equals_0_expected_1, unicosSb.s_magic, + UNICOS_MAGIC); + + return unicosSb.s_magic == UNICOS_MAGIC; + } + + /// + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) + { + Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); + information = ""; + + if(imagePlugin.Info.SectorSize < 512) + return; + + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + sbSize++; + + ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return; + + if(sector.Length < Marshal.SizeOf()) + return; + + Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); + + if(unicosSb.s_magic != UNICOS_MAGIC) + return; + + var sb = new StringBuilder(); + + sb.AppendLine(Localization.UNICOS_filesystem); + + if(unicosSb.s_secure == UNICOS_SECURE) + sb.AppendLine(Localization.Volume_is_secure); + + sb.AppendFormat(Localization.Volume_contains_0_partitions, unicosSb.s_npart).AppendLine(); + sb.AppendFormat(Localization._0_bytes_per_sector, unicosSb.s_iounit).AppendLine(); + sb.AppendLine(Localization._4096_bytes_per_block); + sb.AppendFormat(Localization._0_data_blocks_in_volume, unicosSb.s_fsize).AppendLine(); + sb.AppendFormat(Localization.Root_resides_on_inode_0, unicosSb.s_root).AppendLine(); + sb.AppendFormat(Localization._0_inodes_in_volume, unicosSb.s_isize).AppendLine(); + + sb.AppendFormat(Localization.Volume_last_updated_on_0, DateHandlers.UnixToDateTime(unicosSb.s_time)). + AppendLine(); + + if(unicosSb.s_error > 0) + sb.AppendFormat(Localization.Volume_is_dirty_error_code_equals_0, unicosSb.s_error).AppendLine(); + + sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(unicosSb.s_fname, Encoding)).AppendLine(); + + information = sb.ToString(); + + XmlFsType = new FileSystemType + { + Type = FS_TYPE, + ClusterSize = 4096, + Clusters = (ulong)unicosSb.s_fsize, + VolumeName = StringHandlers.CToString(unicosSb.s_fname, Encoding), + ModificationDate = DateHandlers.UnixToDateTime(unicosSb.s_time), + ModificationDateSpecified = true + }; + + XmlFsType.Dirty |= unicosSb.s_error > 0; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/UNICOS.cs b/Aaru.Filesystems/UNICOS/Structs.cs similarity index 59% rename from Aaru.Filesystems/UNICOS.cs rename to Aaru.Filesystems/UNICOS/Structs.cs index cbf215c72..252e59c5e 100644 --- a/Aaru.Filesystems/UNICOS.cs +++ b/Aaru.Filesystems/UNICOS/Structs.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : UNICOS.cs +// Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : UNICOS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the UNICOS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,143 +28,21 @@ // UNICOS is ILP64 so let's think everything is 64-bit -using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -using System.Text; -using Aaru.CommonTypes; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; -using Aaru.Console; -using Aaru.Helpers; -using Schemas; using blkno_t = System.Int64; using daddr_t = System.Int64; using dev_t = System.Int64; using extent_t = System.Int64; using ino_t = System.Int64; -using Marshal = Aaru.Helpers.Marshal; using time_t = System.Int64; namespace Aaru.Filesystems; /// /// Implements detection for the Cray UNICOS filesystem -public sealed class UNICOS : IFilesystem +public sealed partial class UNICOS { - const int NC1_MAXPART = 64; - const int NC1_MAXIREG = 4; - - const ulong UNICOS_MAGIC = 0x6e6331667331636e; - const ulong UNICOS_SECURE = 0xcd076d1771d670cd; - - const string FS_TYPE = "unicos"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.UNICOS_Name; - /// - public Guid Id => new("61712F04-066C-44D5-A2A0-1E44C66B33F0"); - /// - public string Author => Authors.NataliaPortillo; - - /// - public bool Identify(IMediaImage imagePlugin, Partition partition) - { - if(imagePlugin.Info.SectorSize < 512) - return false; - - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; - - if(partition.Start + sbSize >= partition.End) - return false; - - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - - if(errno != ErrorNumber.NoError) - return false; - - if(sector.Length < Marshal.SizeOf()) - return false; - - Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); - - AaruConsole.DebugWriteLine("UNICOS plugin", Localization.magic_equals_0_expected_1, unicosSb.s_magic, - UNICOS_MAGIC); - - return unicosSb.s_magic == UNICOS_MAGIC; - } - - /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) - { - Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15"); - information = ""; - - if(imagePlugin.Info.SectorSize < 512) - return; - - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) - sbSize++; - - ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, sbSize, out byte[] sector); - - if(errno != ErrorNumber.NoError) - return; - - if(sector.Length < Marshal.SizeOf()) - return; - - Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); - - if(unicosSb.s_magic != UNICOS_MAGIC) - return; - - var sb = new StringBuilder(); - - sb.AppendLine(Localization.UNICOS_filesystem); - - if(unicosSb.s_secure == UNICOS_SECURE) - sb.AppendLine(Localization.Volume_is_secure); - - sb.AppendFormat(Localization.Volume_contains_0_partitions, unicosSb.s_npart).AppendLine(); - sb.AppendFormat(Localization._0_bytes_per_sector, unicosSb.s_iounit).AppendLine(); - sb.AppendLine(Localization._4096_bytes_per_block); - sb.AppendFormat(Localization._0_data_blocks_in_volume, unicosSb.s_fsize).AppendLine(); - sb.AppendFormat(Localization.Root_resides_on_inode_0, unicosSb.s_root).AppendLine(); - sb.AppendFormat(Localization._0_inodes_in_volume, unicosSb.s_isize).AppendLine(); - - sb.AppendFormat(Localization.Volume_last_updated_on_0, DateHandlers.UnixToDateTime(unicosSb.s_time)). - AppendLine(); - - if(unicosSb.s_error > 0) - sb.AppendFormat(Localization.Volume_is_dirty_error_code_equals_0, unicosSb.s_error).AppendLine(); - - sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(unicosSb.s_fname, Encoding)).AppendLine(); - - information = sb.ToString(); - - XmlFsType = new FileSystemType - { - Type = FS_TYPE, - ClusterSize = 4096, - Clusters = (ulong)unicosSb.s_fsize, - VolumeName = StringHandlers.CToString(unicosSb.s_fname, Encoding), - ModificationDate = DateHandlers.UnixToDateTime(unicosSb.s_time), - ModificationDateSpecified = true - }; - - XmlFsType.Dirty |= unicosSb.s_error > 0; - } - [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] readonly struct nc1ireg_sb { diff --git a/Aaru.Filesystems/UNICOS/UNICOS.cs b/Aaru.Filesystems/UNICOS/UNICOS.cs new file mode 100644 index 000000000..509bfd0fa --- /dev/null +++ b/Aaru.Filesystems/UNICOS/UNICOS.cs @@ -0,0 +1,58 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : UNICOS.cs +// Author(s) : Natalia Portillo +// +// Component : UNICOS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +// UNICOS is ILP64 so let's think everything is 64-bit + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; +using blkno_t = System.Int64; +using daddr_t = System.Int64; +using dev_t = System.Int64; +using extent_t = System.Int64; +using ino_t = System.Int64; +using time_t = System.Int64; + +namespace Aaru.Filesystems; + +/// +/// Implements detection for the Cray UNICOS filesystem +public sealed partial class UNICOS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.UNICOS_Name; + /// + public Guid Id => new("61712F04-066C-44D5-A2A0-1E44C66B33F0"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/UNIXBFS/Consts.cs b/Aaru.Filesystems/UNIXBFS/Consts.cs new file mode 100644 index 000000000..f4a94ccdc --- /dev/null +++ b/Aaru.Filesystems/UNIXBFS/Consts.cs @@ -0,0 +1,39 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : UnixWare boot filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the UNIX boot filesystem +public sealed partial class BFS +{ + const uint BFS_MAGIC = 0x1BADFACE; + + const string FS_TYPE = "bfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/UNIXBFS.cs b/Aaru.Filesystems/UNIXBFS/Info.cs similarity index 75% rename from Aaru.Filesystems/UNIXBFS.cs rename to Aaru.Filesystems/UNIXBFS/Info.cs index 4a014f48d..125d983d6 100644 --- a/Aaru.Filesystems/UNIXBFS.cs +++ b/Aaru.Filesystems/UNIXBFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : UNIXBFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : UnixWare boot filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the UnixWare boot filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -45,23 +40,8 @@ namespace Aaru.Filesystems; // Information from the Linux kernel /// /// Implements detection of the UNIX boot filesystem -public sealed class BFS : IFilesystem +public sealed partial class BFS { - const uint BFS_MAGIC = 0x1BADFACE; - - const string FS_TYPE = "bfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.BFS_Name; - /// - public Guid Id => new("1E6E0DA6-F7E4-494C-80C6-CB5929E96155"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -136,27 +116,4 @@ public sealed class BFS : IFilesystem information = sb.ToString(); } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct SuperBlock - { - /// 0x00, 0x1BADFACE - public uint s_magic; - /// 0x04, start in bytes of volume - public uint s_start; - /// 0x08, end in bytes of volume - public uint s_end; - /// 0x0C, unknown :p - public uint s_from; - /// 0x10, unknown :p - public uint s_to; - /// 0x14, unknown :p - public int s_bfrom; - /// 0x18, unknown :p - public int s_bto; - /// 0x1C, 6 bytes, filesystem name - public string s_fsname; - /// 0x22, 6 bytes, volume name - public string s_volume; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/UNIXBFS/Structs.cs b/Aaru.Filesystems/UNIXBFS/Structs.cs new file mode 100644 index 000000000..846b7c35f --- /dev/null +++ b/Aaru.Filesystems/UNIXBFS/Structs.cs @@ -0,0 +1,60 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : UnixWare boot filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the UNIX boot filesystem +public sealed partial class BFS +{ + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct SuperBlock + { + /// 0x00, 0x1BADFACE + public uint s_magic; + /// 0x04, start in bytes of volume + public uint s_start; + /// 0x08, end in bytes of volume + public uint s_end; + /// 0x0C, unknown :p + public uint s_from; + /// 0x10, unknown :p + public uint s_to; + /// 0x14, unknown :p + public int s_bfrom; + /// 0x18, unknown :p + public int s_bto; + /// 0x1C, 6 bytes, filesystem name + public string s_fsname; + /// 0x22, 6 bytes, volume name + public string s_volume; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/UNIXBFS/UNIXBFS.cs b/Aaru.Filesystems/UNIXBFS/UNIXBFS.cs new file mode 100644 index 000000000..5d00b3937 --- /dev/null +++ b/Aaru.Filesystems/UNIXBFS/UNIXBFS.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : UNIXBFS.cs +// Author(s) : Natalia Portillo +// +// Component : UnixWare boot filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the UNIX boot filesystem +public sealed partial class BFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.BFS_Name; + /// + public Guid Id => new("1E6E0DA6-F7E4-494C-80C6-CB5929E96155"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/VMfs/Consts.cs b/Aaru.Filesystems/VMfs/Consts.cs new file mode 100644 index 000000000..ffe9379f9 --- /dev/null +++ b/Aaru.Filesystems/VMfs/Consts.cs @@ -0,0 +1,42 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : VMware file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the VMware filesystem +[SuppressMessage("ReSharper", "UnusedType.Local"), SuppressMessage("ReSharper", "IdentifierTypo"), + SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class VMfs +{ + /// Identifier for VMfs + const uint VMFS_MAGIC = 0xC001D00D; + const uint VMFS_BASE = 0x00100000; +} \ No newline at end of file diff --git a/Aaru.Filesystems/VMfs.cs b/Aaru.Filesystems/VMfs/Info.cs similarity index 73% rename from Aaru.Filesystems/VMfs.cs rename to Aaru.Filesystems/VMfs/Info.cs index 6efec7c94..fe3572998 100644 --- a/Aaru.Filesystems/VMfs.cs +++ b/Aaru.Filesystems/VMfs/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : VMfs.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : VMware file system plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the VMware file system and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -32,14 +28,12 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -47,23 +41,8 @@ namespace Aaru.Filesystems; /// Implements detection of the VMware filesystem [SuppressMessage("ReSharper", "UnusedType.Local"), SuppressMessage("ReSharper", "IdentifierTypo"), SuppressMessage("ReSharper", "UnusedMember.Local")] -public sealed class VMfs : IFilesystem +public sealed partial class VMfs { - /// Identifier for VMfs - const uint VMFS_MAGIC = 0xC001D00D; - const uint VMFS_BASE = 0x00100000; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.VMfs_Name; - /// - public Guid Id => new("EE52BDB8-B49C-4122-A3DA-AD21CBE79843"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -137,32 +116,4 @@ public sealed class VMfs : IFilesystem VolumeSerial = volInfo.uuid.ToString() }; } - - [Flags] - enum Flags : byte - { - RecyledFolder = 64, CaseSensitive = 128 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct VolumeInfo - { - public readonly uint magic; - public readonly uint version; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] unknown1; - public readonly byte lun; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] unknown2; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] - public readonly byte[] name; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 49)] - public readonly byte[] unknown3; - public readonly uint size; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)] - public readonly byte[] unknown4; - public readonly Guid uuid; - public readonly ulong ctime; - public readonly ulong mtime; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/VMfs/Structs.cs b/Aaru.Filesystems/VMfs/Structs.cs new file mode 100644 index 000000000..b12fe3750 --- /dev/null +++ b/Aaru.Filesystems/VMfs/Structs.cs @@ -0,0 +1,62 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : VMware file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the VMware filesystem +[SuppressMessage("ReSharper", "UnusedType.Local"), SuppressMessage("ReSharper", "IdentifierTypo"), + SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class VMfs +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct VolumeInfo + { + public readonly uint magic; + public readonly uint version; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] unknown1; + public readonly byte lun; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] unknown2; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] + public readonly byte[] name; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 49)] + public readonly byte[] unknown3; + public readonly uint size; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 31)] + public readonly byte[] unknown4; + public readonly Guid uuid; + public readonly ulong ctime; + public readonly ulong mtime; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/VMfs/VMfs.cs b/Aaru.Filesystems/VMfs/VMfs.cs new file mode 100644 index 000000000..f7dc3fe09 --- /dev/null +++ b/Aaru.Filesystems/VMfs/VMfs.cs @@ -0,0 +1,53 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : VMfs.cs +// Author(s) : Natalia Portillo +// +// Component : VMware file system plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the VMware filesystem +[SuppressMessage("ReSharper", "UnusedType.Local"), SuppressMessage("ReSharper", "IdentifierTypo"), + SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class VMfs : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.VMfs_Name; + /// + public Guid Id => new("EE52BDB8-B49C-4122-A3DA-AD21CBE79843"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/VxFS/Consts.cs b/Aaru.Filesystems/VxFS/Consts.cs new file mode 100644 index 000000000..30d5ad365 --- /dev/null +++ b/Aaru.Filesystems/VxFS/Consts.cs @@ -0,0 +1,40 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Veritas File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Veritas filesystem +public sealed partial class VxFS +{ + /// Identifier for VxFS + const uint VXFS_MAGIC = 0xA501FCF5; + const uint VXFS_BASE = 0x400; + + const string FS_TYPE = "vxfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/VxFS/Info.cs b/Aaru.Filesystems/VxFS/Info.cs new file mode 100644 index 000000000..82c8ae05b --- /dev/null +++ b/Aaru.Filesystems/VxFS/Info.cs @@ -0,0 +1,115 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Info.cs +// Author(s) : Natalia Portillo +// +// Component : Veritas File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Aaru.Helpers; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Veritas filesystem +public sealed partial class VxFS +{ + /// + public bool Identify(IMediaImage imagePlugin, Partition partition) + { + ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; + + if(partition.Start + vmfsSuperOff >= partition.End) + return false; + + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return false; + + uint magic = BitConverter.ToUInt32(sector, 0x00); + + return magic == VXFS_MAGIC; + } + + /// + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) + { + Encoding = encoding ?? Encoding.UTF8; + information = ""; + ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; + ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); + + if(errno != ErrorNumber.NoError) + return; + + SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + + var sbInformation = new StringBuilder(); + + sbInformation.AppendLine(Localization.Veritas_file_system); + + sbInformation.AppendFormat(Localization.Volume_version_0, vxSb.vs_version).AppendLine(); + + sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(vxSb.vs_fname, Encoding)). + AppendLine(); + + sbInformation.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, vxSb.vs_bsize, vxSb.vs_size). + AppendLine(); + + sbInformation.AppendFormat(Localization.Volume_has_0_inodes_per_block, vxSb.vs_inopb).AppendLine(); + sbInformation.AppendFormat(Localization.Volume_has_0_free_inodes, vxSb.vs_ifree).AppendLine(); + sbInformation.AppendFormat(Localization.Volume_has_0_free_blocks, vxSb.vs_free).AppendLine(); + + sbInformation.AppendFormat(Localization.Volume_created_on_0, + DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)).AppendLine(); + + sbInformation.AppendFormat(Localization.Volume_last_modified_on_0, + DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)).AppendLine(); + + if(vxSb.vs_clean != 0) + sbInformation.AppendLine(Localization.Volume_is_dirty); + + information = sbInformation.ToString(); + + XmlFsType = new FileSystemType + { + Type = FS_TYPE, + CreationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime), + CreationDateSpecified = true, + ModificationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime), + ModificationDateSpecified = true, + Clusters = (ulong)vxSb.vs_size, + ClusterSize = (uint)vxSb.vs_bsize, + Dirty = vxSb.vs_clean != 0, + FreeClusters = (ulong)vxSb.vs_free, + FreeClustersSpecified = true + }; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/VxFS.cs b/Aaru.Filesystems/VxFS/Structs.cs similarity index 65% rename from Aaru.Filesystems/VxFS.cs rename to Aaru.Filesystems/VxFS/Structs.cs index 13d48d0be..49beed50e 100644 --- a/Aaru.Filesystems/VxFS.cs +++ b/Aaru.Filesystems/VxFS/Structs.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : VxFS.cs +// Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : Veritas File System plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Veritas file system and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,112 +26,14 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; -using System.Text; -using Aaru.CommonTypes; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; -using Aaru.Helpers; -using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of the Veritas filesystem -public sealed class VxFS : IFilesystem +public sealed partial class VxFS { - /// Identifier for VxFS - const uint VXFS_MAGIC = 0xA501FCF5; - const uint VXFS_BASE = 0x400; - - const string FS_TYPE = "vxfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.VxFS_Name; - /// - public Guid Id => new("EC372605-7687-453C-8BEA-7E0DFF79CB03"); - /// - public string Author => Authors.NataliaPortillo; - - /// - public bool Identify(IMediaImage imagePlugin, Partition partition) - { - ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; - - if(partition.Start + vmfsSuperOff >= partition.End) - return false; - - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); - - if(errno != ErrorNumber.NoError) - return false; - - uint magic = BitConverter.ToUInt32(sector, 0x00); - - return magic == VXFS_MAGIC; - } - - /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) - { - Encoding = encoding ?? Encoding.UTF8; - information = ""; - ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; - ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector); - - if(errno != ErrorNumber.NoError) - return; - - SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian(sector); - - var sbInformation = new StringBuilder(); - - sbInformation.AppendLine(Localization.Veritas_file_system); - - sbInformation.AppendFormat(Localization.Volume_version_0, vxSb.vs_version).AppendLine(); - - sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(vxSb.vs_fname, Encoding)). - AppendLine(); - - sbInformation.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, vxSb.vs_bsize, vxSb.vs_size). - AppendLine(); - - sbInformation.AppendFormat(Localization.Volume_has_0_inodes_per_block, vxSb.vs_inopb).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_has_0_free_inodes, vxSb.vs_ifree).AppendLine(); - sbInformation.AppendFormat(Localization.Volume_has_0_free_blocks, vxSb.vs_free).AppendLine(); - - sbInformation.AppendFormat(Localization.Volume_created_on_0, - DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)).AppendLine(); - - sbInformation.AppendFormat(Localization.Volume_last_modified_on_0, - DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)).AppendLine(); - - if(vxSb.vs_clean != 0) - sbInformation.AppendLine(Localization.Volume_is_dirty); - - information = sbInformation.ToString(); - - XmlFsType = new FileSystemType - { - Type = FS_TYPE, - CreationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime), - CreationDateSpecified = true, - ModificationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime), - ModificationDateSpecified = true, - Clusters = (ulong)vxSb.vs_size, - ClusterSize = (uint)vxSb.vs_bsize, - Dirty = vxSb.vs_clean != 0, - FreeClusters = (ulong)vxSb.vs_free, - FreeClustersSpecified = true - }; - } - [StructLayout(LayoutKind.Sequential, Pack = 1)] readonly struct SuperBlock { diff --git a/Aaru.Filesystems/VxFS/VxFS.cs b/Aaru.Filesystems/VxFS/VxFS.cs new file mode 100644 index 000000000..0192f1525 --- /dev/null +++ b/Aaru.Filesystems/VxFS/VxFS.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : VxFS.cs +// Author(s) : Natalia Portillo +// +// Component : Veritas File System plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of the Veritas filesystem +public sealed partial class VxFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.VxFS_Name; + /// + public Guid Id => new("EC372605-7687-453C-8BEA-7E0DFF79CB03"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/XFS/Consts.cs b/Aaru.Filesystems/XFS/Consts.cs new file mode 100644 index 000000000..8025cfcca --- /dev/null +++ b/Aaru.Filesystems/XFS/Consts.cs @@ -0,0 +1,38 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : XFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +/// +/// Implements detection of SGI's XFS +public sealed partial class XFS +{ + const uint XFS_MAGIC = 0x58465342; + + const string FS_TYPE = "xfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/XFS.cs b/Aaru.Filesystems/XFS/Info.cs similarity index 72% rename from Aaru.Filesystems/XFS.cs rename to Aaru.Filesystems/XFS/Info.cs index 22b29e571..99014763b 100644 --- a/Aaru.Filesystems/XFS.cs +++ b/Aaru.Filesystems/XFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : XFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : XFS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the XFS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -39,29 +34,13 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; /// /// Implements detection of SGI's XFS -public sealed class XFS : IFilesystem +public sealed partial class XFS { - const uint XFS_MAGIC = 0x58465342; - - const string FS_TYPE = "xfs"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.XFS_Name; - /// - public Guid Id => new("1D8CD8B8-27E6-410F-9973-D16409225FBA"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -242,67 +221,4 @@ public sealed class XFS : IFilesystem VolumeSerial = xfsSb.uuid.ToString() }; } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Superblock - { - public readonly uint magicnum; - public readonly uint blocksize; - public readonly ulong dblocks; - public readonly ulong rblocks; - public readonly ulong rextents; - public readonly Guid uuid; - public readonly ulong logstat; - public readonly ulong rootino; - public readonly ulong rbmino; - public readonly ulong rsumino; - public readonly uint rextsize; - public readonly uint agblocks; - public readonly uint agcount; - public readonly uint rbmblocks; - public readonly uint logblocks; - public readonly ushort version; - public readonly ushort sectsize; - public readonly ushort inodesize; - public readonly ushort inopblock; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] fname; - public readonly byte blocklog; - public readonly byte sectlog; - public readonly byte inodelog; - public readonly byte inopblog; - public readonly byte agblklog; - public readonly byte rextslog; - public readonly byte inprogress; - public readonly byte imax_pct; - public readonly ulong icount; - public readonly ulong ifree; - public readonly ulong fdblocks; - public readonly ulong frextents; - public readonly ulong uquotino; - public readonly ulong gquotino; - public readonly ushort qflags; - public readonly byte flags; - public readonly byte shared_vn; - public readonly ulong inoalignmt; - public readonly ulong unit; - public readonly ulong width; - public readonly byte dirblklog; - public readonly byte logsectlog; - public readonly ushort logsectsize; - public readonly uint logsunit; - public readonly uint features2; - public readonly uint bad_features2; - public readonly uint features_compat; - public readonly uint features_ro_compat; - public readonly uint features_incompat; - public readonly uint features_log_incompat; - - // This field is little-endian while rest of superblock is big-endian - public readonly uint crc; - public readonly uint spino_align; - public readonly ulong pquotino; - public readonly ulong lsn; - public readonly Guid meta_uuid; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/XFS/Structs.cs b/Aaru.Filesystems/XFS/Structs.cs new file mode 100644 index 000000000..57365b137 --- /dev/null +++ b/Aaru.Filesystems/XFS/Structs.cs @@ -0,0 +1,100 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : XFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of SGI's XFS +public sealed partial class XFS +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Superblock + { + public readonly uint magicnum; + public readonly uint blocksize; + public readonly ulong dblocks; + public readonly ulong rblocks; + public readonly ulong rextents; + public readonly Guid uuid; + public readonly ulong logstat; + public readonly ulong rootino; + public readonly ulong rbmino; + public readonly ulong rsumino; + public readonly uint rextsize; + public readonly uint agblocks; + public readonly uint agcount; + public readonly uint rbmblocks; + public readonly uint logblocks; + public readonly ushort version; + public readonly ushort sectsize; + public readonly ushort inodesize; + public readonly ushort inopblock; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] fname; + public readonly byte blocklog; + public readonly byte sectlog; + public readonly byte inodelog; + public readonly byte inopblog; + public readonly byte agblklog; + public readonly byte rextslog; + public readonly byte inprogress; + public readonly byte imax_pct; + public readonly ulong icount; + public readonly ulong ifree; + public readonly ulong fdblocks; + public readonly ulong frextents; + public readonly ulong uquotino; + public readonly ulong gquotino; + public readonly ushort qflags; + public readonly byte flags; + public readonly byte shared_vn; + public readonly ulong inoalignmt; + public readonly ulong unit; + public readonly ulong width; + public readonly byte dirblklog; + public readonly byte logsectlog; + public readonly ushort logsectsize; + public readonly uint logsunit; + public readonly uint features2; + public readonly uint bad_features2; + public readonly uint features_compat; + public readonly uint features_ro_compat; + public readonly uint features_incompat; + public readonly uint features_log_incompat; + + // This field is little-endian while rest of superblock is big-endian + public readonly uint crc; + public readonly uint spino_align; + public readonly ulong pquotino; + public readonly ulong lsn; + public readonly Guid meta_uuid; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/XFS/XFS.cs b/Aaru.Filesystems/XFS/XFS.cs new file mode 100644 index 000000000..bcbe9cd06 --- /dev/null +++ b/Aaru.Filesystems/XFS/XFS.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : XFS.cs +// Author(s) : Natalia Portillo +// +// Component : XFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/// +/// Implements detection of SGI's XFS +public sealed partial class XFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.XFS_Name; + /// + public Guid Id => new("1D8CD8B8-27E6-410F-9973-D16409225FBA"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Xia/Consts.cs b/Aaru.Filesystems/Xia/Consts.cs new file mode 100644 index 000000000..fc6c73d11 --- /dev/null +++ b/Aaru.Filesystems/Xia/Consts.cs @@ -0,0 +1,46 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Xia filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection for the Xia filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class Xia +{ + const uint XIAFS_SUPER_MAGIC = 0x012FD16D; + const uint XIAFS_ROOT_INO = 1; + const uint XIAFS_BAD_INO = 2; + const int XIAFS_MAX_LINK = 64000; + const int XIAFS_DIR_SIZE = 12; + const int XIAFS_NUM_BLOCK_POINTERS = 10; + const int XIAFS_NAME_LEN = 248; +} \ No newline at end of file diff --git a/Aaru.Filesystems/Xia.cs b/Aaru.Filesystems/Xia/Info.cs similarity index 57% rename from Aaru.Filesystems/Xia.cs rename to Aaru.Filesystems/Xia/Info.cs index 5cb9eeba8..e9f82a0c9 100644 --- a/Aaru.Filesystems/Xia.cs +++ b/Aaru.Filesystems/Xia/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : Xia.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Xia filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Xia filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -30,16 +26,13 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -47,27 +40,8 @@ namespace Aaru.Filesystems; /// /// Implements detection for the Xia filesystem [SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] -public sealed class Xia : IFilesystem +public sealed partial class Xia { - const uint XIAFS_SUPER_MAGIC = 0x012FD16D; - const uint XIAFS_ROOT_INO = 1; - const uint XIAFS_BAD_INO = 2; - const int XIAFS_MAX_LINK = 64000; - const int XIAFS_DIR_SIZE = 12; - const int XIAFS_NUM_BLOCK_POINTERS = 10; - const int XIAFS_NAME_LEN = 248; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.Xia_Name; - /// - public Guid Id => new("169E1DE5-24F2-4EF6-A04D-A4B2CA66DE9D"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -149,72 +123,4 @@ public sealed class Xia : IFilesystem information = sb.ToString(); } - - /// Xia superblock - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct SuperBlock - { - /// 1st sector reserved for boot - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] - public readonly byte[] s_boot_segment; - /// the name says it - public readonly uint s_zone_size; - /// volume size, zone aligned - public readonly uint s_nzones; - /// # of inodes - public readonly uint s_ninodes; - /// # of data zones - public readonly uint s_ndatazones; - /// # of imap zones - public readonly uint s_imap_zones; - /// # of zmap zones - public readonly uint s_zmap_zones; - /// first data zone - public readonly uint s_firstdatazone; - /// z size = 1KB << z shift - public readonly uint s_zone_shift; - /// max size of a single file - public readonly uint s_max_size; - /// reserved - public readonly uint s_reserved0; - /// reserved - public readonly uint s_reserved1; - /// reserved - public readonly uint s_reserved2; - /// reserved - public readonly uint s_reserved3; - /// first kernel zone - public readonly uint s_firstkernzone; - /// kernel size in zones - public readonly uint s_kernzones; - /// magic number for xiafs - public readonly uint s_magic; - } - - /// Xia directory entry - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct DirectoryEntry - { - public readonly uint d_ino; - public readonly ushort d_rec_len; - public readonly byte d_name_len; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = XIAFS_NAME_LEN + 1)] - public readonly byte[] d_name; - } - - /// Xia inode - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct Inode - { - public readonly ushort i_mode; - public readonly ushort i_nlinks; - public readonly ushort i_uid; - public readonly ushort i_gid; - public readonly uint i_size; - public readonly uint i_ctime; - public readonly uint i_atime; - public readonly uint i_mtime; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = XIAFS_NUM_BLOCK_POINTERS)] - public readonly uint[] i_zone; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/Xia/Structs.cs b/Aaru.Filesystems/Xia/Structs.cs new file mode 100644 index 000000000..75d53912c --- /dev/null +++ b/Aaru.Filesystems/Xia/Structs.cs @@ -0,0 +1,107 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Xia filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection for the Xia filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class Xia +{ + /// Xia superblock + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct SuperBlock + { + /// 1st sector reserved for boot + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] + public readonly byte[] s_boot_segment; + /// the name says it + public readonly uint s_zone_size; + /// volume size, zone aligned + public readonly uint s_nzones; + /// # of inodes + public readonly uint s_ninodes; + /// # of data zones + public readonly uint s_ndatazones; + /// # of imap zones + public readonly uint s_imap_zones; + /// # of zmap zones + public readonly uint s_zmap_zones; + /// first data zone + public readonly uint s_firstdatazone; + /// z size = 1KB << z shift + public readonly uint s_zone_shift; + /// max size of a single file + public readonly uint s_max_size; + /// reserved + public readonly uint s_reserved0; + /// reserved + public readonly uint s_reserved1; + /// reserved + public readonly uint s_reserved2; + /// reserved + public readonly uint s_reserved3; + /// first kernel zone + public readonly uint s_firstkernzone; + /// kernel size in zones + public readonly uint s_kernzones; + /// magic number for xiafs + public readonly uint s_magic; + } + + /// Xia directory entry + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct DirectoryEntry + { + public readonly uint d_ino; + public readonly ushort d_rec_len; + public readonly byte d_name_len; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = XIAFS_NAME_LEN + 1)] + public readonly byte[] d_name; + } + + /// Xia inode + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct Inode + { + public readonly ushort i_mode; + public readonly ushort i_nlinks; + public readonly ushort i_uid; + public readonly ushort i_gid; + public readonly uint i_size; + public readonly uint i_ctime; + public readonly uint i_atime; + public readonly uint i_mtime; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = XIAFS_NUM_BLOCK_POINTERS)] + public readonly uint[] i_zone; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/Xia/Xia.cs b/Aaru.Filesystems/Xia/Xia.cs new file mode 100644 index 000000000..c393f7637 --- /dev/null +++ b/Aaru.Filesystems/Xia/Xia.cs @@ -0,0 +1,53 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Xia.cs +// Author(s) : Natalia Portillo +// +// Component : Xia filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection for the Xia filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")] +public sealed partial class Xia : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.Xia_Name; + /// + public Guid Id => new("169E1DE5-24F2-4EF6-A04D-A4B2CA66DE9D"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ZFS/Consts.cs b/Aaru.Filesystems/ZFS/Consts.cs new file mode 100644 index 000000000..852a5c96f --- /dev/null +++ b/Aaru.Filesystems/ZFS/Consts.cs @@ -0,0 +1,72 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : ZFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/* + * The ZFS on-disk structure is quite undocumented, so this has been checked using several test images and reading the comments and headers (but not the code) + * of ZFS-On-Linux. + * + * The most basic structure, the vdev label, is as follows: + * 8KiB of blank space + * 8KiB reserved for boot code, stored as a ZIO block with magic and checksum + * 112KiB of nvlist, usually encoded using XDR + * 128KiB of copies of the 1KiB uberblock + * + * Two vdev labels, L0 and L1 are stored at the start of the vdev. + * Another two, L2 and L3 are stored at the end. + * + * The nvlist is nothing more than a double linked list of name/value pairs where name is a string and value is an arbitrary type (and can be an array of it). + * On-disk they are stored sequentially (no pointers) and can be encoded in XDR (an old Sun serialization method that stores everything as 4 bytes chunks) or + * natively (that is as the host natively stores that values, for example on Intel an extended float would be 10 bytes (80 bit). + * It can also be encoded little or big endian. + * Because of this variations, ZFS stored a header indicating the used encoding and endianess before the encoded nvlist. + */ +/// +/// Implements detection for the Zettabyte File System (ZFS) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"), + SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")] +public sealed partial class ZFS +{ + const ulong ZEC_MAGIC = 0x0210DA7AB10C7A11; + const ulong ZEC_CIGAM = 0x117A0CB17ADA1002; + + // These parameters define how the nvlist is stored + const byte NVS_LITTLE_ENDIAN = 1; + const byte NVS_BIG_ENDIAN = 0; + const byte NVS_NATIVE = 0; + const byte NVS_XDR = 1; + + const ulong UBERBLOCK_MAGIC = 0x00BAB10C; + + const uint ZFS_MAGIC = 0x58465342; + + const string FS_TYPE = "zfs"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ZFS/Enums.cs b/Aaru.Filesystems/ZFS/Enums.cs new file mode 100644 index 000000000..ee5afdb5c --- /dev/null +++ b/Aaru.Filesystems/ZFS/Enums.cs @@ -0,0 +1,71 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : ZFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +/* + * The ZFS on-disk structure is quite undocumented, so this has been checked using several test images and reading the comments and headers (but not the code) + * of ZFS-On-Linux. + * + * The most basic structure, the vdev label, is as follows: + * 8KiB of blank space + * 8KiB reserved for boot code, stored as a ZIO block with magic and checksum + * 112KiB of nvlist, usually encoded using XDR + * 128KiB of copies of the 1KiB uberblock + * + * Two vdev labels, L0 and L1 are stored at the start of the vdev. + * Another two, L2 and L3 are stored at the end. + * + * The nvlist is nothing more than a double linked list of name/value pairs where name is a string and value is an arbitrary type (and can be an array of it). + * On-disk they are stored sequentially (no pointers) and can be encoded in XDR (an old Sun serialization method that stores everything as 4 bytes chunks) or + * natively (that is as the host natively stores that values, for example on Intel an extended float would be 10 bytes (80 bit). + * It can also be encoded little or big endian. + * Because of this variations, ZFS stored a header indicating the used encoding and endianess before the encoded nvlist. + */ +/// +/// Implements detection for the Zettabyte File System (ZFS) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"), + SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")] +public sealed partial class ZFS +{ + enum NVS_DataTypes : uint + { + DATA_TYPE_UNKNOWN = 0, DATA_TYPE_BOOLEAN, DATA_TYPE_BYTE, + DATA_TYPE_INT16, DATA_TYPE_UINT16, DATA_TYPE_INT32, + DATA_TYPE_UINT32, DATA_TYPE_INT64, DATA_TYPE_UINT64, + DATA_TYPE_STRING, DATA_TYPE_BYTE_ARRAY, DATA_TYPE_INT16_ARRAY, + DATA_TYPE_UINT16_ARRAY, DATA_TYPE_INT32_ARRAY, DATA_TYPE_UINT32_ARRAY, + DATA_TYPE_INT64_ARRAY, DATA_TYPE_UINT64_ARRAY, DATA_TYPE_STRING_ARRAY, + DATA_TYPE_HRTIME, DATA_TYPE_NVLIST, DATA_TYPE_NVLIST_ARRAY, + DATA_TYPE_BOOLEAN_VALUE, DATA_TYPE_INT8, DATA_TYPE_UINT8, + DATA_TYPE_BOOLEAN_ARRAY, DATA_TYPE_INT8_ARRAY, DATA_TYPE_UINT8_ARRAY, + DATA_TYPE_DOUBLE + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ZFS.cs b/Aaru.Filesystems/ZFS/Helpers.cs similarity index 74% rename from Aaru.Filesystems/ZFS.cs rename to Aaru.Filesystems/ZFS/Helpers.cs index 1f6905af9..63f0525c7 100644 --- a/Aaru.Filesystems/ZFS.cs +++ b/Aaru.Filesystems/ZFS/Helpers.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : ZFS.cs +// Filename : Helpers.cs // Author(s) : Natalia Portillo // // Component : ZFS filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the ZFS filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -33,13 +29,8 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; -using Aaru.CommonTypes; -using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; -using Schemas; namespace Aaru.Filesystems; @@ -66,141 +57,8 @@ namespace Aaru.Filesystems; /// Implements detection for the Zettabyte File System (ZFS) [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"), SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")] -public sealed class ZFS : IFilesystem +public sealed partial class ZFS { - const ulong ZEC_MAGIC = 0x0210DA7AB10C7A11; - const ulong ZEC_CIGAM = 0x117A0CB17ADA1002; - - // These parameters define how the nvlist is stored - const byte NVS_LITTLE_ENDIAN = 1; - const byte NVS_BIG_ENDIAN = 0; - const byte NVS_NATIVE = 0; - const byte NVS_XDR = 1; - - const ulong UBERBLOCK_MAGIC = 0x00BAB10C; - - const uint ZFS_MAGIC = 0x58465342; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.ZFS_Name; - /// - public Guid Id => new("0750014F-A714-4692-A369-E23F6EC3659C"); - /// - public string Author => Authors.NataliaPortillo; - - /// - public bool Identify(IMediaImage imagePlugin, Partition partition) - { - if(imagePlugin.Info.SectorSize < 512) - return false; - - byte[] sector; - ulong magic; - ErrorNumber errno; - - if(partition.Start + 31 < partition.End) - { - errno = imagePlugin.ReadSector(partition.Start + 31, out sector); - - if(errno != ErrorNumber.NoError) - return false; - - magic = BitConverter.ToUInt64(sector, 0x1D8); - - if(magic is ZEC_MAGIC or ZEC_CIGAM) - return true; - } - - if(partition.Start + 16 >= partition.End) - return false; - - errno = imagePlugin.ReadSector(partition.Start + 16, out sector); - - if(errno != ErrorNumber.NoError) - return false; - - magic = BitConverter.ToUInt64(sector, 0x1D8); - - return magic is ZEC_MAGIC or ZEC_CIGAM; - } - - const string FS_TYPE = "zfs"; - - /// - public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) - { - // ZFS is always UTF-8 - Encoding = Encoding.UTF8; - information = ""; - ErrorNumber errno; - - if(imagePlugin.Info.SectorSize < 512) - return; - - byte[] sector; - ulong magic; - - ulong nvlistOff = 32; - uint nvlistLen = 114688 / imagePlugin.Info.SectorSize; - - if(partition.Start + 31 < partition.End) - { - errno = imagePlugin.ReadSector(partition.Start + 31, out sector); - - if(errno != ErrorNumber.NoError) - return; - - magic = BitConverter.ToUInt64(sector, 0x1D8); - - if(magic is ZEC_MAGIC or ZEC_CIGAM) - nvlistOff = 32; - } - - if(partition.Start + 16 < partition.End) - { - errno = imagePlugin.ReadSector(partition.Start + 16, out sector); - - if(errno != ErrorNumber.NoError) - return; - - magic = BitConverter.ToUInt64(sector, 0x1D8); - - if(magic is ZEC_MAGIC or ZEC_CIGAM) - nvlistOff = 17; - } - - var sb = new StringBuilder(); - sb.AppendLine(Localization.ZFS_filesystem); - - errno = imagePlugin.ReadSectors(partition.Start + nvlistOff, nvlistLen, out byte[] nvlist); - - if(errno != ErrorNumber.NoError) - return; - - sb.AppendLine(!DecodeNvList(nvlist, out Dictionary decodedNvList) ? "Could not decode nvlist" - : PrintNvList(decodedNvList)); - - information = sb.ToString(); - - XmlFsType = new FileSystemType - { - Type = FS_TYPE - }; - - if(decodedNvList.TryGetValue("name", out NVS_Item tmpObj)) - XmlFsType.VolumeName = (string)tmpObj.value; - - if(decodedNvList.TryGetValue("guid", out tmpObj)) - XmlFsType.VolumeSerial = $"{(ulong)tmpObj.value}"; - - if(decodedNvList.TryGetValue("pool_guid", out tmpObj)) - XmlFsType.VolumeSetIdentifier = $"{(ulong)tmpObj.value}"; - } - static bool DecodeNvList(byte[] nvlist, out Dictionary decodedNvList) { byte[] tmp = new byte[nvlist.Length - 4]; @@ -724,111 +582,4 @@ public sealed class ZFS : IFilesystem return sb.ToString(); } - - struct ZIO_Checksum - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - public ulong[] word; - } - - /// - /// There is an empty ZIO at sector 16 or sector 31, with magic and checksum, to detect it is really ZFS I - /// suppose. - /// - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ZIO_Empty - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 472)] - public readonly byte[] empty; - public readonly ulong magic; - public readonly ZIO_Checksum checksum; - } - - /// This structure indicates which encoding method and endianness is used to encode the nvlist - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NVS_Method - { - public readonly byte encoding; - public readonly byte endian; - public readonly byte reserved1; - public readonly byte reserved2; - } - - /// This structure gives information about the encoded nvlist - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NVS_XDR_Header - { - public readonly NVS_Method encodingAndEndian; - public readonly uint version; - public readonly uint flags; - } - - enum NVS_DataTypes : uint - { - DATA_TYPE_UNKNOWN = 0, DATA_TYPE_BOOLEAN, DATA_TYPE_BYTE, - DATA_TYPE_INT16, DATA_TYPE_UINT16, DATA_TYPE_INT32, - DATA_TYPE_UINT32, DATA_TYPE_INT64, DATA_TYPE_UINT64, - DATA_TYPE_STRING, DATA_TYPE_BYTE_ARRAY, DATA_TYPE_INT16_ARRAY, - DATA_TYPE_UINT16_ARRAY, DATA_TYPE_INT32_ARRAY, DATA_TYPE_UINT32_ARRAY, - DATA_TYPE_INT64_ARRAY, DATA_TYPE_UINT64_ARRAY, DATA_TYPE_STRING_ARRAY, - DATA_TYPE_HRTIME, DATA_TYPE_NVLIST, DATA_TYPE_NVLIST_ARRAY, - DATA_TYPE_BOOLEAN_VALUE, DATA_TYPE_INT8, DATA_TYPE_UINT8, - DATA_TYPE_BOOLEAN_ARRAY, DATA_TYPE_INT8_ARRAY, DATA_TYPE_UINT8_ARRAY, - DATA_TYPE_DOUBLE - } - - /// This represent an encoded nvpair (an item of an nvlist) - struct NVS_Item - { - /// Size in bytes when encoded in XDR - public uint encodedSize; - /// Size in bytes when decoded - public uint decodedSize; - /// On disk, it is null-padded for alignment to 4 bytes and prepended by a 4 byte length indicator - public string name; - /// Data type - public NVS_DataTypes dataType; - /// How many elements are here - public uint elements; - /// On disk size is relative to and always aligned to 4 bytes - public object value; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DVA - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly ulong[] word; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SPA_BlockPointer - { - /// Data virtual address - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly DVA[] dataVirtualAddress; - /// Block properties - public readonly ulong properties; - /// Reserved for future expansion - public readonly ulong[] padding; - /// TXG when block was allocated - public readonly ulong birthTxg; - /// Transaction group at birth - public readonly ulong birth; - /// Fill count - public readonly ulong fill; - public readonly ZIO_Checksum checksum; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ZFS_Uberblock - { - public readonly ulong magic; - public readonly ulong spaVersion; - public readonly ulong lastTxg; - public readonly ulong guidSum; - public readonly ulong timestamp; - public readonly SPA_BlockPointer mosPtr; - public readonly ulong softwareVersion; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/ZFS/Info.cs b/Aaru.Filesystems/ZFS/Info.cs new file mode 100644 index 000000000..85640fa80 --- /dev/null +++ b/Aaru.Filesystems/ZFS/Info.cs @@ -0,0 +1,171 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Info.cs +// Author(s) : Natalia Portillo +// +// Component : ZFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/* + * The ZFS on-disk structure is quite undocumented, so this has been checked using several test images and reading the comments and headers (but not the code) + * of ZFS-On-Linux. + * + * The most basic structure, the vdev label, is as follows: + * 8KiB of blank space + * 8KiB reserved for boot code, stored as a ZIO block with magic and checksum + * 112KiB of nvlist, usually encoded using XDR + * 128KiB of copies of the 1KiB uberblock + * + * Two vdev labels, L0 and L1 are stored at the start of the vdev. + * Another two, L2 and L3 are stored at the end. + * + * The nvlist is nothing more than a double linked list of name/value pairs where name is a string and value is an arbitrary type (and can be an array of it). + * On-disk they are stored sequentially (no pointers) and can be encoded in XDR (an old Sun serialization method that stores everything as 4 bytes chunks) or + * natively (that is as the host natively stores that values, for example on Intel an extended float would be 10 bytes (80 bit). + * It can also be encoded little or big endian. + * Because of this variations, ZFS stored a header indicating the used encoding and endianess before the encoded nvlist. + */ +/// +/// Implements detection for the Zettabyte File System (ZFS) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"), + SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")] +public sealed partial class ZFS +{ + /// + public bool Identify(IMediaImage imagePlugin, Partition partition) + { + if(imagePlugin.Info.SectorSize < 512) + return false; + + byte[] sector; + ulong magic; + ErrorNumber errno; + + if(partition.Start + 31 < partition.End) + { + errno = imagePlugin.ReadSector(partition.Start + 31, out sector); + + if(errno != ErrorNumber.NoError) + return false; + + magic = BitConverter.ToUInt64(sector, 0x1D8); + + if(magic is ZEC_MAGIC or ZEC_CIGAM) + return true; + } + + if(partition.Start + 16 >= partition.End) + return false; + + errno = imagePlugin.ReadSector(partition.Start + 16, out sector); + + if(errno != ErrorNumber.NoError) + return false; + + magic = BitConverter.ToUInt64(sector, 0x1D8); + + return magic is ZEC_MAGIC or ZEC_CIGAM; + } + + /// + public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) + { + // ZFS is always UTF-8 + Encoding = Encoding.UTF8; + information = ""; + ErrorNumber errno; + + if(imagePlugin.Info.SectorSize < 512) + return; + + byte[] sector; + ulong magic; + + ulong nvlistOff = 32; + uint nvlistLen = 114688 / imagePlugin.Info.SectorSize; + + if(partition.Start + 31 < partition.End) + { + errno = imagePlugin.ReadSector(partition.Start + 31, out sector); + + if(errno != ErrorNumber.NoError) + return; + + magic = BitConverter.ToUInt64(sector, 0x1D8); + + if(magic is ZEC_MAGIC or ZEC_CIGAM) + nvlistOff = 32; + } + + if(partition.Start + 16 < partition.End) + { + errno = imagePlugin.ReadSector(partition.Start + 16, out sector); + + if(errno != ErrorNumber.NoError) + return; + + magic = BitConverter.ToUInt64(sector, 0x1D8); + + if(magic is ZEC_MAGIC or ZEC_CIGAM) + nvlistOff = 17; + } + + var sb = new StringBuilder(); + sb.AppendLine(Localization.ZFS_filesystem); + + errno = imagePlugin.ReadSectors(partition.Start + nvlistOff, nvlistLen, out byte[] nvlist); + + if(errno != ErrorNumber.NoError) + return; + + sb.AppendLine(!DecodeNvList(nvlist, out Dictionary decodedNvList) ? "Could not decode nvlist" + : PrintNvList(decodedNvList)); + + information = sb.ToString(); + + XmlFsType = new FileSystemType + { + Type = FS_TYPE + }; + + if(decodedNvList.TryGetValue("name", out NVS_Item tmpObj)) + XmlFsType.VolumeName = (string)tmpObj.value; + + if(decodedNvList.TryGetValue("guid", out tmpObj)) + XmlFsType.VolumeSerial = $"{(ulong)tmpObj.value}"; + + if(decodedNvList.TryGetValue("pool_guid", out tmpObj)) + XmlFsType.VolumeSetIdentifier = $"{(ulong)tmpObj.value}"; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ZFS/Structs.cs b/Aaru.Filesystems/ZFS/Structs.cs new file mode 100644 index 000000000..80bbb2d8b --- /dev/null +++ b/Aaru.Filesystems/ZFS/Structs.cs @@ -0,0 +1,151 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : ZFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +/* + * The ZFS on-disk structure is quite undocumented, so this has been checked using several test images and reading the comments and headers (but not the code) + * of ZFS-On-Linux. + * + * The most basic structure, the vdev label, is as follows: + * 8KiB of blank space + * 8KiB reserved for boot code, stored as a ZIO block with magic and checksum + * 112KiB of nvlist, usually encoded using XDR + * 128KiB of copies of the 1KiB uberblock + * + * Two vdev labels, L0 and L1 are stored at the start of the vdev. + * Another two, L2 and L3 are stored at the end. + * + * The nvlist is nothing more than a double linked list of name/value pairs where name is a string and value is an arbitrary type (and can be an array of it). + * On-disk they are stored sequentially (no pointers) and can be encoded in XDR (an old Sun serialization method that stores everything as 4 bytes chunks) or + * natively (that is as the host natively stores that values, for example on Intel an extended float would be 10 bytes (80 bit). + * It can also be encoded little or big endian. + * Because of this variations, ZFS stored a header indicating the used encoding and endianess before the encoded nvlist. + */ +/// +/// Implements detection for the Zettabyte File System (ZFS) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"), + SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")] +public sealed partial class ZFS +{ + struct ZIO_Checksum + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public ulong[] word; + } + + /// + /// There is an empty ZIO at sector 16 or sector 31, with magic and checksum, to detect it is really ZFS I + /// suppose. + /// + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct ZIO_Empty + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 472)] + public readonly byte[] empty; + public readonly ulong magic; + public readonly ZIO_Checksum checksum; + } + + /// This structure indicates which encoding method and endianness is used to encode the nvlist + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct NVS_Method + { + public readonly byte encoding; + public readonly byte endian; + public readonly byte reserved1; + public readonly byte reserved2; + } + + /// This structure gives information about the encoded nvlist + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct NVS_XDR_Header + { + public readonly NVS_Method encodingAndEndian; + public readonly uint version; + public readonly uint flags; + } + + /// This represent an encoded nvpair (an item of an nvlist) + struct NVS_Item + { + /// Size in bytes when encoded in XDR + public uint encodedSize; + /// Size in bytes when decoded + public uint decodedSize; + /// On disk, it is null-padded for alignment to 4 bytes and prepended by a 4 byte length indicator + public string name; + /// Data type + public NVS_DataTypes dataType; + /// How many elements are here + public uint elements; + /// On disk size is relative to and always aligned to 4 bytes + public object value; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct DVA + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly ulong[] word; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct SPA_BlockPointer + { + /// Data virtual address + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly DVA[] dataVirtualAddress; + /// Block properties + public readonly ulong properties; + /// Reserved for future expansion + public readonly ulong[] padding; + /// TXG when block was allocated + public readonly ulong birthTxg; + /// Transaction group at birth + public readonly ulong birth; + /// Fill count + public readonly ulong fill; + public readonly ZIO_Checksum checksum; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct ZFS_Uberblock + { + public readonly ulong magic; + public readonly ulong spaVersion; + public readonly ulong lastTxg; + public readonly ulong guidSum; + public readonly ulong timestamp; + public readonly SPA_BlockPointer mosPtr; + public readonly ulong softwareVersion; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ZFS/ZFS.cs b/Aaru.Filesystems/ZFS/ZFS.cs new file mode 100644 index 000000000..1c7c13801 --- /dev/null +++ b/Aaru.Filesystems/ZFS/ZFS.cs @@ -0,0 +1,72 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : ZFS.cs +// Author(s) : Natalia Portillo +// +// Component : ZFS filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +/* + * The ZFS on-disk structure is quite undocumented, so this has been checked using several test images and reading the comments and headers (but not the code) + * of ZFS-On-Linux. + * + * The most basic structure, the vdev label, is as follows: + * 8KiB of blank space + * 8KiB reserved for boot code, stored as a ZIO block with magic and checksum + * 112KiB of nvlist, usually encoded using XDR + * 128KiB of copies of the 1KiB uberblock + * + * Two vdev labels, L0 and L1 are stored at the start of the vdev. + * Another two, L2 and L3 are stored at the end. + * + * The nvlist is nothing more than a double linked list of name/value pairs where name is a string and value is an arbitrary type (and can be an array of it). + * On-disk they are stored sequentially (no pointers) and can be encoded in XDR (an old Sun serialization method that stores everything as 4 bytes chunks) or + * natively (that is as the host natively stores that values, for example on Intel an extended float would be 10 bytes (80 bit). + * It can also be encoded little or big endian. + * Because of this variations, ZFS stored a header indicating the used encoding and endianess before the encoded nvlist. + */ +/// +/// Implements detection for the Zettabyte File System (ZFS) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedType.Local"), + SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "NotAccessedField.Local")] +public sealed partial class ZFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.ZFS_Name; + /// + public Guid Id => new("0750014F-A714-4692-A369-E23F6EC3659C"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/dump/Consts.cs b/Aaru.Filesystems/dump/Consts.cs new file mode 100644 index 000000000..9daf42192 --- /dev/null +++ b/Aaru.Filesystems/dump/Consts.cs @@ -0,0 +1,85 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : dump(8) file system plugin +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies backups created with dump(8) 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + +/// +/// Implements identification of a dump(8) image (virtual filesystem on a file) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class dump +{ + /// Magic number for old dump + const ushort OFS_MAGIC = 60011; + /// Magic number for new dump + const uint NFS_MAGIC = 60012; + /// Magic number for AIX dump + const uint XIX_MAGIC = 60013; + /// Magic number for UFS2 dump + const uint UFS2_MAGIC = 0x19540119; + /// Magic number for old dump + const uint OFS_CIGAM = 0x6BEA0000; + /// Magic number for new dump + const uint NFS_CIGAM = 0x6CEA0000; + /// Magic number for AIX dump + const uint XIX_CIGAM = 0x6DEA0000; + /// Magic number for UFS2 dump + const uint UFS2_CIGAM = 0x19015419; + + const int TP_BSIZE = 1024; + + /// Dump tape header + const short TS_TAPE = 1; + /// Beginning of file record + const short TS_INODE = 2; + /// Map of inodes on tape + const short TS_BITS = 3; + /// Continuation of file record + const short TS_ADDR = 4; + /// Map of inodes deleted since last dump + const short TS_END = 5; + /// Inode bitmap + const short TS_CLRI = 6; + const short TS_ACL = 7; + const short TS_PCL = 8; + + const int TP_NINDIR = TP_BSIZE / 2; + const int LBLSIZE = 16; + const int NAMELEN = 64; + + const int NDADDR = 12; + const int NIADDR = 3; + + const string FS_TYPE = "dump"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/dump.cs b/Aaru.Filesystems/dump/Info.cs similarity index 57% rename from Aaru.Filesystems/dump.cs rename to Aaru.Filesystems/dump/Info.cs index e7b16c570..f966624ca 100644 --- a/Aaru.Filesystems/dump.cs +++ b/Aaru.Filesystems/dump/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : dump.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : dump(8) file system plugin @@ -30,9 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ -using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -40,7 +38,6 @@ using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; using ufs_daddr_t = System.Int32; namespace Aaru.Filesystems; @@ -48,60 +45,8 @@ namespace Aaru.Filesystems; /// /// Implements identification of a dump(8) image (virtual filesystem on a file) [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local")] -public sealed class dump : IFilesystem +public sealed partial class dump { - /// Magic number for old dump - const ushort OFS_MAGIC = 60011; - /// Magic number for new dump - const uint NFS_MAGIC = 60012; - /// Magic number for AIX dump - const uint XIX_MAGIC = 60013; - /// Magic number for UFS2 dump - const uint UFS2_MAGIC = 0x19540119; - /// Magic number for old dump - const uint OFS_CIGAM = 0x6BEA0000; - /// Magic number for new dump - const uint NFS_CIGAM = 0x6CEA0000; - /// Magic number for AIX dump - const uint XIX_CIGAM = 0x6DEA0000; - /// Magic number for UFS2 dump - const uint UFS2_CIGAM = 0x19015419; - - const int TP_BSIZE = 1024; - - /// Dump tape header - const short TS_TAPE = 1; - /// Beginning of file record - const short TS_INODE = 2; - /// Map of inodes on tape - const short TS_BITS = 3; - /// Continuation of file record - const short TS_ADDR = 4; - /// Map of inodes deleted since last dump - const short TS_END = 5; - /// Inode bitmap - const short TS_CLRI = 6; - const short TS_ACL = 7; - const short TS_PCL = 8; - - const int TP_NINDIR = TP_BSIZE / 2; - const int LBLSIZE = 16; - const int NAMELEN = 64; - - const int NDADDR = 12; - const int NIADDR = 3; - - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.dump_Name; - /// - public Guid Id => new("E53B4D28-C858-4800-B092-DDAE80D361B9"); - /// - public FileSystemType XmlFsType { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -313,123 +258,4 @@ public sealed class dump : IFilesystem information = sb.ToString(); } - - const string FS_TYPE = "dump"; - - // Old 16-bit format record - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct spcl16 - { - /// Record type - public readonly short c_type; - /// Dump date - public int c_date; - /// Previous dump date - public int c_ddate; - /// Dump volume number - public readonly short c_volume; - /// Logical block of this record - public readonly int c_tapea; - /// Inode number - public readonly ushort c_inumber; - /// Magic number - public readonly ushort c_magic; - /// Record checksum - public readonly int c_checksum; - - // Unneeded for now - /* - struct dinode c_dinode; - int c_count; - char c_addr[BSIZE]; - */ - } - - // 32-bit AIX format record - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct spcl_aix - { - /// Record type - public readonly int c_type; - /// Dump date - public readonly int c_date; - /// Previous dump date - public readonly int c_ddate; - /// Dump volume number - public readonly int c_volume; - /// Logical block of this record - public readonly int c_tapea; - public readonly uint c_inumber; - public readonly uint c_magic; - public readonly int c_checksum; - - // Unneeded for now - /* - public bsd_dinode bsd_c_dinode; - public int c_count; - public char c_addr[TP_NINDIR]; - public int xix_flag; - public dinode xix_dinode; - */ - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct s_spcl - { - public readonly int c_type; /* record type (see below) */ - public readonly int c_date; /* date of this dump */ - public readonly int c_ddate; /* date of previous dump */ - public readonly int c_volume; /* dump volume number */ - public readonly int c_tapea; /* logical block of this record */ - public readonly uint c_inumber; /* number of inode */ - public readonly int c_magic; /* magic number (see above) */ - public readonly int c_checksum; /* record checksum */ - public readonly dinode c_dinode; /* ownership and mode of inode */ - public readonly int c_count; /* number of valid c_addr entries */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = TP_NINDIR)] - public readonly byte[] c_addr; /* 1 => data; 0 => hole in inode */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = LBLSIZE)] - public readonly byte[] c_label; /* dump label */ - public readonly int c_level; /* level of this dump */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] - public readonly byte[] c_filesys; /* name of dumpped file system */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] - public readonly byte[] c_dev; /* name of dumpped device */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] - public readonly byte[] c_host; /* name of dumpped host */ - public readonly int c_flags; /* additional information */ - public readonly int c_firstrec; /* first record on volume */ - public readonly long c_ndate; /* date of this dump */ - public readonly long c_nddate; /* date of previous dump */ - public readonly long c_ntapea; /* logical block of this record */ - public readonly long c_nfirstrec; /* first record on volume */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly int[] c_spare; /* reserved for future uses */ - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct dinode - { - public readonly ushort di_mode; /* 0: IFMT, permissions; see below. */ - public readonly short di_nlink; /* 2: File link count. */ - public readonly int inumber; /* 4: Lfs: inode number. */ - public readonly ulong di_size; /* 8: File byte count. */ - public readonly int di_atime; /* 16: Last access time. */ - public readonly int di_atimensec; /* 20: Last access time. */ - public readonly int di_mtime; /* 24: Last modified time. */ - public readonly int di_mtimensec; /* 28: Last modified time. */ - public readonly int di_ctime; /* 32: Last inode change time. */ - public readonly int di_ctimensec; /* 36: Last inode change time. */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NDADDR)] - public readonly int[] di_db; /* 40: Direct disk blocks. */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NIADDR)] - public readonly int[] di_ib; /* 88: Indirect disk blocks. */ - public readonly uint di_flags; /* 100: Status flags (chflags). */ - public readonly uint di_blocks; /* 104: Blocks actually held. */ - public readonly int di_gen; /* 108: Generation number. */ - public readonly uint di_uid; /* 112: File owner. */ - public readonly uint di_gid; /* 116: File group. */ - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly int[] di_spare; /* 120: Reserved; currently unused */ - } } \ No newline at end of file diff --git a/Aaru.Filesystems/dump/Structs.cs b/Aaru.Filesystems/dump/Structs.cs new file mode 100644 index 000000000..687708502 --- /dev/null +++ b/Aaru.Filesystems/dump/Structs.cs @@ -0,0 +1,160 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : dump(8) file system plugin +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies backups created with dump(8) 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + +/// +/// Implements identification of a dump(8) image (virtual filesystem on a file) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class dump +{ + // Old 16-bit format record + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct spcl16 + { + /// Record type + public readonly short c_type; + /// Dump date + public int c_date; + /// Previous dump date + public int c_ddate; + /// Dump volume number + public readonly short c_volume; + /// Logical block of this record + public readonly int c_tapea; + /// Inode number + public readonly ushort c_inumber; + /// Magic number + public readonly ushort c_magic; + /// Record checksum + public readonly int c_checksum; + + // Unneeded for now + /* + struct dinode c_dinode; + int c_count; + char c_addr[BSIZE]; + */ + } + + // 32-bit AIX format record + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct spcl_aix + { + /// Record type + public readonly int c_type; + /// Dump date + public readonly int c_date; + /// Previous dump date + public readonly int c_ddate; + /// Dump volume number + public readonly int c_volume; + /// Logical block of this record + public readonly int c_tapea; + public readonly uint c_inumber; + public readonly uint c_magic; + public readonly int c_checksum; + + // Unneeded for now + /* + public bsd_dinode bsd_c_dinode; + public int c_count; + public char c_addr[TP_NINDIR]; + public int xix_flag; + public dinode xix_dinode; + */ + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct s_spcl + { + public readonly int c_type; /* record type (see below) */ + public readonly int c_date; /* date of this dump */ + public readonly int c_ddate; /* date of previous dump */ + public readonly int c_volume; /* dump volume number */ + public readonly int c_tapea; /* logical block of this record */ + public readonly uint c_inumber; /* number of inode */ + public readonly int c_magic; /* magic number (see above) */ + public readonly int c_checksum; /* record checksum */ + public readonly dinode c_dinode; /* ownership and mode of inode */ + public readonly int c_count; /* number of valid c_addr entries */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = TP_NINDIR)] + public readonly byte[] c_addr; /* 1 => data; 0 => hole in inode */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = LBLSIZE)] + public readonly byte[] c_label; /* dump label */ + public readonly int c_level; /* level of this dump */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] + public readonly byte[] c_filesys; /* name of dumpped file system */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] + public readonly byte[] c_dev; /* name of dumpped device */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] + public readonly byte[] c_host; /* name of dumpped host */ + public readonly int c_flags; /* additional information */ + public readonly int c_firstrec; /* first record on volume */ + public readonly long c_ndate; /* date of this dump */ + public readonly long c_nddate; /* date of previous dump */ + public readonly long c_ntapea; /* logical block of this record */ + public readonly long c_nfirstrec; /* first record on volume */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly int[] c_spare; /* reserved for future uses */ + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct dinode + { + public readonly ushort di_mode; /* 0: IFMT, permissions; see below. */ + public readonly short di_nlink; /* 2: File link count. */ + public readonly int inumber; /* 4: Lfs: inode number. */ + public readonly ulong di_size; /* 8: File byte count. */ + public readonly int di_atime; /* 16: Last access time. */ + public readonly int di_atimensec; /* 20: Last access time. */ + public readonly int di_mtime; /* 24: Last modified time. */ + public readonly int di_mtimensec; /* 28: Last modified time. */ + public readonly int di_ctime; /* 32: Last inode change time. */ + public readonly int di_ctimensec; /* 36: Last inode change time. */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NDADDR)] + public readonly int[] di_db; /* 40: Direct disk blocks. */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = NIADDR)] + public readonly int[] di_ib; /* 88: Indirect disk blocks. */ + public readonly uint di_flags; /* 100: Status flags (chflags). */ + public readonly uint di_blocks; /* 104: Blocks actually held. */ + public readonly int di_gen; /* 108: Generation number. */ + public readonly uint di_uid; /* 112: File owner. */ + public readonly uint di_gid; /* 116: File group. */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly int[] di_spare; /* 120: Reserved; currently unused */ + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/dump/dump.cs b/Aaru.Filesystems/dump/dump.cs new file mode 100644 index 000000000..4092a78c4 --- /dev/null +++ b/Aaru.Filesystems/dump/dump.cs @@ -0,0 +1,57 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : dump.cs +// Author(s) : Natalia Portillo +// +// Component : dump(8) file system plugin +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies backups created with dump(8) 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; +using ufs_daddr_t = System.Int32; + +namespace Aaru.Filesystems; + +/// +/// Implements identification of a dump(8) image (virtual filesystem on a file) +[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "UnusedMember.Local")] +public sealed partial class dump : IFilesystem +{ + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.dump_Name; + /// + public Guid Id => new("E53B4D28-C858-4800-B092-DDAE80D361B9"); + /// + public FileSystemType XmlFsType { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/exFAT/Consts.cs b/Aaru.Filesystems/exFAT/Consts.cs new file mode 100644 index 000000000..ca986958e --- /dev/null +++ b/Aaru.Filesystems/exFAT/Consts.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft exFAT filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from https://www.sans.org/reading-room/whitepapers/forensics/reverse-engineering-microsoft-exfat-file-system-33274 +/// +/// Implements detection of the exFAT filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] + +// ReSharper disable once InconsistentNaming +public sealed partial class exFAT +{ + readonly Guid _oemFlashParameterGuid = new("0A0C7E46-3399-4021-90C8-FA6D389C4BA2"); + + readonly byte[] _signature = + { + 0x45, 0x58, 0x46, 0x41, 0x54, 0x20, 0x20, 0x20 + }; + + const string FS_TYPE = "exfat"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/exFAT/Enums.cs b/Aaru.Filesystems/exFAT/Enums.cs new file mode 100644 index 000000000..fb6debcef --- /dev/null +++ b/Aaru.Filesystems/exFAT/Enums.cs @@ -0,0 +1,48 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Enums.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft exFAT filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from https://www.sans.org/reading-room/whitepapers/forensics/reverse-engineering-microsoft-exfat-file-system-33274 +/// +/// Implements detection of the exFAT filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] + +// ReSharper disable once InconsistentNaming +public sealed partial class exFAT +{ + [Flags] + enum VolumeFlags : ushort + { + SecondFatActive = 1, VolumeDirty = 2, MediaFailure = 4, + ClearToZero = 8 + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/exFAT.cs b/Aaru.Filesystems/exFAT/Info.cs similarity index 67% rename from Aaru.Filesystems/exFAT.cs rename to Aaru.Filesystems/exFAT/Info.cs index 5d42146b2..cf64b42c8 100644 --- a/Aaru.Filesystems/exFAT.cs +++ b/Aaru.Filesystems/exFAT/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : exFAT.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Microsoft exFAT filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Microsoft exFAT filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -33,13 +29,12 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; +using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -49,26 +44,8 @@ namespace Aaru.Filesystems; [SuppressMessage("ReSharper", "UnusedMember.Local")] // ReSharper disable once InconsistentNaming -public sealed class exFAT : IFilesystem +public sealed partial class exFAT { - readonly Guid _oemFlashParameterGuid = new("0A0C7E46-3399-4021-90C8-FA6D389C4BA2"); - - readonly byte[] _signature = - { - 0x45, 0x58, 0x46, 0x41, 0x54, 0x20, 0x20, 0x20 - }; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.exFAT_Name; - /// - public Guid Id => new("8271D088-1533-4CB3-AC28-D802B68BB95C"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -191,75 +168,4 @@ public sealed class exFAT : IFilesystem information = sb.ToString(); } - - const string FS_TYPE = "exfat"; - - [Flags] - enum VolumeFlags : ushort - { - SecondFatActive = 1, VolumeDirty = 2, MediaFailure = 4, - ClearToZero = 8 - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct VolumeBootRecord - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] signature; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 53)] - public readonly byte[] zero; - public readonly ulong offset; - public readonly ulong sectors; - public readonly uint fatOffset; - public readonly uint fatLength; - public readonly uint clusterHeapOffset; - public readonly uint clusterHeapLength; - public readonly uint rootDirectoryCluster; - public readonly uint volumeSerial; - public readonly ushort revision; - public readonly VolumeFlags flags; - public readonly byte sectorShift; - public readonly byte clusterShift; - public readonly byte fats; - public readonly byte drive; - public readonly byte heapUsage; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 53)] - public readonly byte[] reserved; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 53)] - public readonly byte[] bootCode; - public readonly ushort bootSignature; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct OemParameter - { - public readonly Guid OemParameterType; - public readonly uint eraseBlockSize; - public readonly uint pageSize; - public readonly uint spareBlocks; - public readonly uint randomAccessTime; - public readonly uint programTime; - public readonly uint readCycleTime; - public readonly uint writeCycleTime; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - public readonly byte[] reserved; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct OemParameterTable - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - public readonly OemParameter[] parameters; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] padding; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - readonly struct ChecksumSector - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public readonly uint[] checksum; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/exFAT/Structs.cs b/Aaru.Filesystems/exFAT/Structs.cs new file mode 100644 index 000000000..76f967917 --- /dev/null +++ b/Aaru.Filesystems/exFAT/Structs.cs @@ -0,0 +1,104 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft exFAT filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from https://www.sans.org/reading-room/whitepapers/forensics/reverse-engineering-microsoft-exfat-file-system-33274 +/// +/// Implements detection of the exFAT filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] + +// ReSharper disable once InconsistentNaming +public sealed partial class exFAT +{ + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct VolumeBootRecord + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] signature; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 53)] + public readonly byte[] zero; + public readonly ulong offset; + public readonly ulong sectors; + public readonly uint fatOffset; + public readonly uint fatLength; + public readonly uint clusterHeapOffset; + public readonly uint clusterHeapLength; + public readonly uint rootDirectoryCluster; + public readonly uint volumeSerial; + public readonly ushort revision; + public readonly VolumeFlags flags; + public readonly byte sectorShift; + public readonly byte clusterShift; + public readonly byte fats; + public readonly byte drive; + public readonly byte heapUsage; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 53)] + public readonly byte[] reserved; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 53)] + public readonly byte[] bootCode; + public readonly ushort bootSignature; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct OemParameter + { + public readonly Guid OemParameterType; + public readonly uint eraseBlockSize; + public readonly uint pageSize; + public readonly uint spareBlocks; + public readonly uint randomAccessTime; + public readonly uint programTime; + public readonly uint readCycleTime; + public readonly uint writeCycleTime; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public readonly byte[] reserved; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct OemParameterTable + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] + public readonly OemParameter[] parameters; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] padding; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + readonly struct ChecksumSector + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] + public readonly uint[] checksum; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/exFAT/exFAT.cs b/Aaru.Filesystems/exFAT/exFAT.cs new file mode 100644 index 000000000..1aafebe3e --- /dev/null +++ b/Aaru.Filesystems/exFAT/exFAT.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : exFAT.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft exFAT filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from https://www.sans.org/reading-room/whitepapers/forensics/reverse-engineering-microsoft-exfat-file-system-33274 +/// +/// Implements detection of the exFAT filesystem +[SuppressMessage("ReSharper", "UnusedMember.Local")] + +// ReSharper disable once InconsistentNaming +public sealed partial class exFAT : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.exFAT_Name; + /// + public Guid Id => new("8271D088-1533-4CB3-AC28-D802B68BB95C"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ext2FS/Consts.cs b/Aaru.Filesystems/ext2FS/Consts.cs new file mode 100644 index 000000000..3a0f7cbe7 --- /dev/null +++ b/Aaru.Filesystems/ext2FS/Consts.cs @@ -0,0 +1,166 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Linux extended filesystem 2, 3 and 4 plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Linux extended filesystem 2, 3 and 4 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the Linux extended filesystem v2, v3 and v4 +[SuppressMessage("ReSharper", "UnusedMember.Local")] + +// ReSharper disable once InconsistentNaming +public sealed partial class ext2FS +{ + const int SB_POS = 0x400; + + /// Same magic for ext2, ext3 and ext4 + const ushort EXT2_MAGIC = 0xEF53; + + const ushort EXT2_MAGIC_OLD = 0xEF51; + + // ext? filesystem states + /// Cleanly-unmounted volume + const ushort EXT2_VALID_FS = 0x0001; + /// Dirty volume + const ushort EXT2_ERROR_FS = 0x0002; + /// Recovering orphan files + const ushort EXT3_ORPHAN_FS = 0x0004; + + // ext? default mount flags + /// Enable debugging messages + const uint EXT2_DEFM_DEBUG = 0x000001; + /// Emulates BSD behaviour on new file creation + const uint EXT2_DEFM_BSDGROUPS = 0x000002; + /// Enable user xattrs + const uint EXT2_DEFM_XATTR_USER = 0x000004; + /// Enable POSIX ACLs + const uint EXT2_DEFM_ACL = 0x000008; + /// Use 16bit UIDs + const uint EXT2_DEFM_UID16 = 0x000010; + /// Journal data mode + const uint EXT3_DEFM_JMODE_DATA = 0x000040; + /// Journal ordered mode + const uint EXT3_DEFM_JMODE_ORDERED = 0x000080; + /// Journal writeback mode + const uint EXT3_DEFM_JMODE_WBACK = 0x000100; + + // Behaviour on errors + /// Continue execution + const ushort EXT2_ERRORS_CONTINUE = 1; + /// Remount fs read-only + const ushort EXT2_ERRORS_RO = 2; + /// Panic + const ushort EXT2_ERRORS_PANIC = 3; + + // OS codes + const uint EXT2_OS_LINUX = 0; + const uint EXT2_OS_HURD = 1; + const uint EXT2_OS_MASIX = 2; + const uint EXT2_OS_FREEBSD = 3; + const uint EXT2_OS_LITES = 4; + + // Revision levels + /// The good old (original) format + const uint EXT2_GOOD_OLD_REV = 0; + /// V2 format w/ dynamic inode sizes + const uint EXT2_DYNAMIC_REV = 1; + + // Compatible features + /// Pre-allocate directories + const uint EXT2_FEATURE_COMPAT_DIR_PREALLOC = 0x00000001; + /// imagic inodes ? + const uint EXT2_FEATURE_COMPAT_IMAGIC_INODES = 0x00000002; + /// Has journal (it's ext3) + const uint EXT3_FEATURE_COMPAT_HAS_JOURNAL = 0x00000004; + /// EA blocks + const uint EXT2_FEATURE_COMPAT_EXT_ATTR = 0x00000008; + /// Online filesystem resize reservations + const uint EXT2_FEATURE_COMPAT_RESIZE_INO = 0x00000010; + /// Can use hashed indexes on directories + const uint EXT2_FEATURE_COMPAT_DIR_INDEX = 0x00000020; + + // Read-only compatible features + /// Reduced number of superblocks + const uint EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x00000001; + /// Can have files bigger than 2GiB + const uint EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x00000002; + /// Use B-Tree for directories + const uint EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x00000004; + /// Can have files bigger than 2TiB *ext4* + const uint EXT4_FEATURE_RO_COMPAT_HUGE_FILE = 0x00000008; + /// Group descriptor checksums and sparse inode table *ext4* + const uint EXT4_FEATURE_RO_COMPAT_GDT_CSUM = 0x00000010; + /// More than 32000 directory entries *ext4* + const uint EXT4_FEATURE_RO_COMPAT_DIR_NLINK = 0x00000020; + /// Nanosecond timestamps and creation time *ext4* + const uint EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x00000040; + + // Incompatible features + /// Uses compression + const uint EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x00000001; + /// Filetype in directory entries + const uint EXT2_FEATURE_INCOMPAT_FILETYPE = 0x00000002; + /// Journal needs recovery *ext3* + const uint EXT3_FEATURE_INCOMPAT_RECOVER = 0x00000004; + /// Has journal on another device *ext3* + const uint EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x00000008; + /// Reduced block group backups + const uint EXT2_FEATURE_INCOMPAT_META_BG = 0x00000010; + /// Volume use extents *ext4* + const uint EXT4_FEATURE_INCOMPAT_EXTENTS = 0x00000040; + /// Supports volumes bigger than 2^32 blocks *ext4* + + // ReSharper disable once InconsistentNaming + const uint EXT4_FEATURE_INCOMPAT_64BIT = 0x00000080; + /// Multi-mount protection *ext4* + const uint EXT4_FEATURE_INCOMPAT_MMP = 0x00000100; + /// Flexible block group metadata location *ext4* + const uint EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x00000200; + /// EA in inode *ext4* + const uint EXT4_FEATURE_INCOMPAT_EA_INODE = 0x00000400; + /// Data can reside in directory entry *ext4* + const uint EXT4_FEATURE_INCOMPAT_DIRDATA = 0x00001000; + + // Miscellaneous filesystem flags + /// Signed dirhash in use + const uint EXT2_FLAGS_SIGNED_HASH = 0x00000001; + /// Unsigned dirhash in use + const uint EXT2_FLAGS_UNSIGNED_HASH = 0x00000002; + /// Testing development code + const uint EXT2_FLAGS_TEST_FILESYS = 0x00000004; + + const string FS_TYPE_EXT2 = "ext2"; + const string FS_TYPE_EXT3 = "ext3"; + const string FS_TYPE_EXT4 = "ext4"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/ext2FS.cs b/Aaru.Filesystems/ext2FS/Info.cs similarity index 61% rename from Aaru.Filesystems/ext2FS.cs rename to Aaru.Filesystems/ext2FS/Info.cs index ebecab41f..20bb1d99f 100644 --- a/Aaru.Filesystems/ext2FS.cs +++ b/Aaru.Filesystems/ext2FS/Info.cs @@ -2,7 +2,7 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : ext2FS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Linux extended filesystem 2, 3 and 4 plugin. @@ -32,14 +32,12 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Schemas; -using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Filesystems; @@ -49,137 +47,8 @@ namespace Aaru.Filesystems; [SuppressMessage("ReSharper", "UnusedMember.Local")] // ReSharper disable once InconsistentNaming -public sealed class ext2FS : IFilesystem +public sealed partial class ext2FS { - const int SB_POS = 0x400; - - /// Same magic for ext2, ext3 and ext4 - const ushort EXT2_MAGIC = 0xEF53; - - const ushort EXT2_MAGIC_OLD = 0xEF51; - - // ext? filesystem states - /// Cleanly-unmounted volume - const ushort EXT2_VALID_FS = 0x0001; - /// Dirty volume - const ushort EXT2_ERROR_FS = 0x0002; - /// Recovering orphan files - const ushort EXT3_ORPHAN_FS = 0x0004; - - // ext? default mount flags - /// Enable debugging messages - const uint EXT2_DEFM_DEBUG = 0x000001; - /// Emulates BSD behaviour on new file creation - const uint EXT2_DEFM_BSDGROUPS = 0x000002; - /// Enable user xattrs - const uint EXT2_DEFM_XATTR_USER = 0x000004; - /// Enable POSIX ACLs - const uint EXT2_DEFM_ACL = 0x000008; - /// Use 16bit UIDs - const uint EXT2_DEFM_UID16 = 0x000010; - /// Journal data mode - const uint EXT3_DEFM_JMODE_DATA = 0x000040; - /// Journal ordered mode - const uint EXT3_DEFM_JMODE_ORDERED = 0x000080; - /// Journal writeback mode - const uint EXT3_DEFM_JMODE_WBACK = 0x000100; - - // Behaviour on errors - /// Continue execution - const ushort EXT2_ERRORS_CONTINUE = 1; - /// Remount fs read-only - const ushort EXT2_ERRORS_RO = 2; - /// Panic - const ushort EXT2_ERRORS_PANIC = 3; - - // OS codes - const uint EXT2_OS_LINUX = 0; - const uint EXT2_OS_HURD = 1; - const uint EXT2_OS_MASIX = 2; - const uint EXT2_OS_FREEBSD = 3; - const uint EXT2_OS_LITES = 4; - - // Revision levels - /// The good old (original) format - const uint EXT2_GOOD_OLD_REV = 0; - /// V2 format w/ dynamic inode sizes - const uint EXT2_DYNAMIC_REV = 1; - - // Compatible features - /// Pre-allocate directories - const uint EXT2_FEATURE_COMPAT_DIR_PREALLOC = 0x00000001; - /// imagic inodes ? - const uint EXT2_FEATURE_COMPAT_IMAGIC_INODES = 0x00000002; - /// Has journal (it's ext3) - const uint EXT3_FEATURE_COMPAT_HAS_JOURNAL = 0x00000004; - /// EA blocks - const uint EXT2_FEATURE_COMPAT_EXT_ATTR = 0x00000008; - /// Online filesystem resize reservations - const uint EXT2_FEATURE_COMPAT_RESIZE_INO = 0x00000010; - /// Can use hashed indexes on directories - const uint EXT2_FEATURE_COMPAT_DIR_INDEX = 0x00000020; - - // Read-only compatible features - /// Reduced number of superblocks - const uint EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x00000001; - /// Can have files bigger than 2GiB - const uint EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x00000002; - /// Use B-Tree for directories - const uint EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x00000004; - /// Can have files bigger than 2TiB *ext4* - const uint EXT4_FEATURE_RO_COMPAT_HUGE_FILE = 0x00000008; - /// Group descriptor checksums and sparse inode table *ext4* - const uint EXT4_FEATURE_RO_COMPAT_GDT_CSUM = 0x00000010; - /// More than 32000 directory entries *ext4* - const uint EXT4_FEATURE_RO_COMPAT_DIR_NLINK = 0x00000020; - /// Nanosecond timestamps and creation time *ext4* - const uint EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x00000040; - - // Incompatible features - /// Uses compression - const uint EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x00000001; - /// Filetype in directory entries - const uint EXT2_FEATURE_INCOMPAT_FILETYPE = 0x00000002; - /// Journal needs recovery *ext3* - const uint EXT3_FEATURE_INCOMPAT_RECOVER = 0x00000004; - /// Has journal on another device *ext3* - const uint EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x00000008; - /// Reduced block group backups - const uint EXT2_FEATURE_INCOMPAT_META_BG = 0x00000010; - /// Volume use extents *ext4* - const uint EXT4_FEATURE_INCOMPAT_EXTENTS = 0x00000040; - /// Supports volumes bigger than 2^32 blocks *ext4* - - // ReSharper disable once InconsistentNaming - const uint EXT4_FEATURE_INCOMPAT_64BIT = 0x00000080; - /// Multi-mount protection *ext4* - const uint EXT4_FEATURE_INCOMPAT_MMP = 0x00000100; - /// Flexible block group metadata location *ext4* - const uint EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x00000200; - /// EA in inode *ext4* - const uint EXT4_FEATURE_INCOMPAT_EA_INODE = 0x00000400; - /// Data can reside in directory entry *ext4* - const uint EXT4_FEATURE_INCOMPAT_DIRDATA = 0x00001000; - - // Miscellaneous filesystem flags - /// Signed dirhash in use - const uint EXT2_FLAGS_SIGNED_HASH = 0x00000001; - /// Unsigned dirhash in use - const uint EXT2_FLAGS_UNSIGNED_HASH = 0x00000002; - /// Testing development code - const uint EXT2_FLAGS_TEST_FILESYS = 0x00000004; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public Encoding Encoding { get; private set; } - /// - public string Name => Localization.ext2FS_Name_Linux_extended_Filesystem_2_3_and_4; - /// - public Guid Id => new("6AA91B88-150B-4A7B-AD56-F84FB2DF4184"); - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -213,10 +82,6 @@ public sealed class ext2FS : IFilesystem return magic is EXT2_MAGIC or EXT2_MAGIC_OLD; } - const string FS_TYPE_EXT2 = "ext2"; - const string FS_TYPE_EXT3 = "ext3"; - const string FS_TYPE_EXT4 = "ext4"; - /// public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { @@ -747,234 +612,4 @@ public sealed class ext2FS : IFilesystem information = sb.ToString(); } - - /// ext2/3/4 superblock - [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct SuperBlock - { - /// 0x000, inodes on volume - public readonly uint inodes; - /// 0x004, blocks on volume - public readonly uint blocks; - /// 0x008, reserved blocks - public readonly uint reserved_blocks; - /// 0x00C, free blocks count - public readonly uint free_blocks; - /// 0x010, free inodes count - public readonly uint free_inodes; - /// 0x014, first data block - public readonly uint first_block; - /// 0x018, block size - public uint block_size; - /// 0x01C, fragment size - public readonly int frag_size; - /// 0x020, blocks per group - public readonly uint blocks_per_grp; - /// 0x024, fragments per group - public readonly uint flags_per_grp; - /// 0x028, inodes per group - public readonly uint inodes_per_grp; - /// 0x02C, last mount time - public readonly uint mount_t; - /// 0x030, last write time - public readonly uint write_t; - /// 0x034, mounts count - public readonly ushort mount_c; - /// 0x036, max mounts - public readonly short max_mount_c; - /// 0x038, (little endian) - public readonly ushort magic; - /// 0x03A, filesystem state - public readonly ushort state; - /// 0x03C, behaviour on errors - public readonly ushort err_behaviour; - /// 0x03E, From 0.5b onward - public readonly ushort minor_revision; - /// 0x040, last check time - public readonly uint check_t; - /// 0x044, max time between checks - public readonly uint check_inv; - - // From 0.5a onward - /// 0x048, Creation OS - public readonly uint creator_os; - /// 0x04C, Revison level - public readonly uint revision; - /// 0x050, Default UID for reserved blocks - public readonly ushort default_uid; - /// 0x052, Default GID for reserved blocks - public readonly ushort default_gid; - - // From 0.5b onward - /// 0x054, First unreserved inode - public readonly uint first_inode; - /// 0x058, inode size - public readonly ushort inode_size; - /// 0x05A, Block group number of THIS superblock - public readonly ushort block_group_no; - /// 0x05C, Compatible features set - public readonly uint ftr_compat; - /// 0x060, Incompatible features set - public readonly uint ftr_incompat; - - // Found on Linux 2.0.40 - /// 0x064, Read-only compatible features set - public readonly uint ftr_ro_compat; - - // Found on Linux 2.1.132 - /// 0x068, 16 bytes, UUID - public readonly Guid uuid; - /// 0x078, 16 bytes, volume name - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] volume_name; - /// 0x088, 64 bytes, where last mounted - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] last_mount_dir; - /// 0x0C8, Usage bitmap algorithm, for compression - public readonly uint algo_usage_bmp; - /// 0x0CC, Block to try to preallocate - public readonly byte prealloc_blks; - /// 0x0CD, Blocks to try to preallocate for directories - public readonly byte prealloc_dir_blks; - /// 0x0CE, Per-group desc for online growth - public readonly ushort rsrvd_gdt_blocks; - - // Found on Linux 2.4 - // ext3 - /// 0x0D0, 16 bytes, UUID of journal superblock - public readonly Guid journal_uuid; - /// 0x0E0, inode no. of journal file - public readonly uint journal_inode; - /// 0x0E4, device no. of journal file - public readonly uint journal_dev; - /// 0x0E8, Start of list of inodes to delete - public readonly uint last_orphan; - /// 0x0EC, First byte of 128bit HTREE hash seed - public readonly uint hash_seed_1; - /// 0x0F0, Second byte of 128bit HTREE hash seed - public readonly uint hash_seed_2; - /// 0x0F4, Third byte of 128bit HTREE hash seed - public readonly uint hash_seed_3; - /// 0x0F8, Fourth byte of 128bit HTREE hash seed - public readonly uint hash_seed_4; - /// 0x0FC, Hash version - public readonly byte hash_version; - /// 0x0FD, Journal backup type - public readonly byte jnl_backup_type; - /// 0x0FE, Size of group descriptor - public readonly ushort desc_grp_size; - /// 0x100, Default mount options - public readonly uint default_mnt_opts; - /// 0x104, First metablock block group - public readonly uint first_meta_bg; - - // Introduced with ext4, some can be ext3 - /// 0x108, Filesystem creation time - public readonly uint mkfs_t; - - /// Backup of the journal inode - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] - public readonly uint[] jnl_blocks; - - // Following 3 fields are valid if EXT4_FEATURE_COMPAT_64BIT is set - /// 0x14C, High 32bits of blocks no. - public readonly uint blocks_hi; - /// 0x150, High 32bits of reserved blocks no. - public readonly uint reserved_blocks_hi; - /// 0x154, High 32bits of free blocks no. - public readonly uint free_blocks_hi; - /// 0x158, inodes minimal size in bytes - public readonly ushort min_inode_size; - /// 0x15A, Bytes reserved by new inodes - public readonly ushort rsv_inode_size; - /// 0x15C, Flags - public readonly uint flags; - /// 0x160, RAID stride - public readonly ushort raid_stride; - /// 0x162, Waiting seconds in MMP check - public readonly ushort mmp_interval; - /// 0x164, Block for multi-mount protection - public readonly ulong mmp_block; - /// 0x16C, Blocks on all data disks (N*stride) - public readonly uint raid_stripe_width; - /// 0x170, FLEX_BG group size - public readonly byte flex_bg_grp_size; - /// 0x171 Metadata checksum algorithm - public readonly byte checksum_type; - /// 0x172 Versioning level for encryption - public readonly byte encryption_level; - /// 0x173 Padding - public readonly ushort padding; - - // Following are introduced with ext4 - /// 0x174, Kibibytes written in volume lifetime - public readonly ulong kbytes_written; - /// 0x17C, Active snapshot inode number - public readonly uint snapshot_inum; - /// 0x180, Active snapshot sequential ID - public readonly uint snapshot_id; - /// 0x184, Reserved blocks for active snapshot's future use - public readonly ulong snapshot_blocks; - /// 0x18C, inode number of the on-disk start of the snapshot list - public readonly uint snapshot_list; - - // Optional ext4 error-handling features - /// 0x190, total registered filesystem errors - public readonly uint error_count; - /// 0x194, time on first error - public readonly uint first_error_t; - /// 0x198, inode involved in first error - public readonly uint first_error_inode; - /// 0x19C, block involved of first error - public readonly ulong first_error_block; - /// 0x1A0, 32 bytes, function where the error happened - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] first_error_func; - /// 0x1B0, line number where error happened - public readonly uint first_error_line; - /// 0x1B4, time of most recent error - public readonly uint last_error_t; - /// 0x1B8, inode involved in last error - public readonly uint last_error_inode; - /// 0x1BC, line number where error happened - public readonly uint last_error_line; - /// 0x1C0, block involved of last error - public readonly ulong last_error_block; - /// 0x1C8, 32 bytes, function where the error happened - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] last_error_func; - - // End of optional error-handling features - - // 0x1D8, 64 bytes, last used mount options - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - public readonly byte[] mount_options; - - /// Inode for user quota - public readonly uint usr_quota_inum; - /// Inode for group quota - public readonly uint grp_quota_inum; - /// Overhead clusters in volume - public readonly uint overhead_clusters; - /// Groups with sparse_super2 SBs - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly uint[] backup_bgs; - /// Encryption algorithms in use - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - public readonly byte[] encrypt_algos; - /// Salt used for string2key algorithm - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] encrypt_pw_salt; - /// Inode number of lost+found - public readonly uint lpf_inum; - /// Inode number for tracking project quota - public readonly uint prj_quota_inum; - /// crc32c(uuid) if csum_seed is set - public readonly uint checksum_seed; - /// Reserved - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 98)] - public readonly byte[] reserved; - /// crc32c(superblock) - public readonly uint checksum; - } } \ No newline at end of file diff --git a/Aaru.Filesystems/ext2FS/Structs.cs b/Aaru.Filesystems/ext2FS/Structs.cs new file mode 100644 index 000000000..7a5beedc2 --- /dev/null +++ b/Aaru.Filesystems/ext2FS/Structs.cs @@ -0,0 +1,276 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Linux extended filesystem 2, 3 and 4 plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Linux extended filesystem 2, 3 and 4 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the Linux extended filesystem v2, v3 and v4 +[SuppressMessage("ReSharper", "UnusedMember.Local")] + +// ReSharper disable once InconsistentNaming +public sealed partial class ext2FS +{ + /// ext2/3/4 superblock + [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] + struct SuperBlock + { + /// 0x000, inodes on volume + public readonly uint inodes; + /// 0x004, blocks on volume + public readonly uint blocks; + /// 0x008, reserved blocks + public readonly uint reserved_blocks; + /// 0x00C, free blocks count + public readonly uint free_blocks; + /// 0x010, free inodes count + public readonly uint free_inodes; + /// 0x014, first data block + public readonly uint first_block; + /// 0x018, block size + public uint block_size; + /// 0x01C, fragment size + public readonly int frag_size; + /// 0x020, blocks per group + public readonly uint blocks_per_grp; + /// 0x024, fragments per group + public readonly uint flags_per_grp; + /// 0x028, inodes per group + public readonly uint inodes_per_grp; + /// 0x02C, last mount time + public readonly uint mount_t; + /// 0x030, last write time + public readonly uint write_t; + /// 0x034, mounts count + public readonly ushort mount_c; + /// 0x036, max mounts + public readonly short max_mount_c; + /// 0x038, (little endian) + public readonly ushort magic; + /// 0x03A, filesystem state + public readonly ushort state; + /// 0x03C, behaviour on errors + public readonly ushort err_behaviour; + /// 0x03E, From 0.5b onward + public readonly ushort minor_revision; + /// 0x040, last check time + public readonly uint check_t; + /// 0x044, max time between checks + public readonly uint check_inv; + + // From 0.5a onward + /// 0x048, Creation OS + public readonly uint creator_os; + /// 0x04C, Revison level + public readonly uint revision; + /// 0x050, Default UID for reserved blocks + public readonly ushort default_uid; + /// 0x052, Default GID for reserved blocks + public readonly ushort default_gid; + + // From 0.5b onward + /// 0x054, First unreserved inode + public readonly uint first_inode; + /// 0x058, inode size + public readonly ushort inode_size; + /// 0x05A, Block group number of THIS superblock + public readonly ushort block_group_no; + /// 0x05C, Compatible features set + public readonly uint ftr_compat; + /// 0x060, Incompatible features set + public readonly uint ftr_incompat; + + // Found on Linux 2.0.40 + /// 0x064, Read-only compatible features set + public readonly uint ftr_ro_compat; + + // Found on Linux 2.1.132 + /// 0x068, 16 bytes, UUID + public readonly Guid uuid; + /// 0x078, 16 bytes, volume name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] volume_name; + /// 0x088, 64 bytes, where last mounted + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] last_mount_dir; + /// 0x0C8, Usage bitmap algorithm, for compression + public readonly uint algo_usage_bmp; + /// 0x0CC, Block to try to preallocate + public readonly byte prealloc_blks; + /// 0x0CD, Blocks to try to preallocate for directories + public readonly byte prealloc_dir_blks; + /// 0x0CE, Per-group desc for online growth + public readonly ushort rsrvd_gdt_blocks; + + // Found on Linux 2.4 + // ext3 + /// 0x0D0, 16 bytes, UUID of journal superblock + public readonly Guid journal_uuid; + /// 0x0E0, inode no. of journal file + public readonly uint journal_inode; + /// 0x0E4, device no. of journal file + public readonly uint journal_dev; + /// 0x0E8, Start of list of inodes to delete + public readonly uint last_orphan; + /// 0x0EC, First byte of 128bit HTREE hash seed + public readonly uint hash_seed_1; + /// 0x0F0, Second byte of 128bit HTREE hash seed + public readonly uint hash_seed_2; + /// 0x0F4, Third byte of 128bit HTREE hash seed + public readonly uint hash_seed_3; + /// 0x0F8, Fourth byte of 128bit HTREE hash seed + public readonly uint hash_seed_4; + /// 0x0FC, Hash version + public readonly byte hash_version; + /// 0x0FD, Journal backup type + public readonly byte jnl_backup_type; + /// 0x0FE, Size of group descriptor + public readonly ushort desc_grp_size; + /// 0x100, Default mount options + public readonly uint default_mnt_opts; + /// 0x104, First metablock block group + public readonly uint first_meta_bg; + + // Introduced with ext4, some can be ext3 + /// 0x108, Filesystem creation time + public readonly uint mkfs_t; + + /// Backup of the journal inode + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] + public readonly uint[] jnl_blocks; + + // Following 3 fields are valid if EXT4_FEATURE_COMPAT_64BIT is set + /// 0x14C, High 32bits of blocks no. + public readonly uint blocks_hi; + /// 0x150, High 32bits of reserved blocks no. + public readonly uint reserved_blocks_hi; + /// 0x154, High 32bits of free blocks no. + public readonly uint free_blocks_hi; + /// 0x158, inodes minimal size in bytes + public readonly ushort min_inode_size; + /// 0x15A, Bytes reserved by new inodes + public readonly ushort rsv_inode_size; + /// 0x15C, Flags + public readonly uint flags; + /// 0x160, RAID stride + public readonly ushort raid_stride; + /// 0x162, Waiting seconds in MMP check + public readonly ushort mmp_interval; + /// 0x164, Block for multi-mount protection + public readonly ulong mmp_block; + /// 0x16C, Blocks on all data disks (N*stride) + public readonly uint raid_stripe_width; + /// 0x170, FLEX_BG group size + public readonly byte flex_bg_grp_size; + /// 0x171 Metadata checksum algorithm + public readonly byte checksum_type; + /// 0x172 Versioning level for encryption + public readonly byte encryption_level; + /// 0x173 Padding + public readonly ushort padding; + + // Following are introduced with ext4 + /// 0x174, Kibibytes written in volume lifetime + public readonly ulong kbytes_written; + /// 0x17C, Active snapshot inode number + public readonly uint snapshot_inum; + /// 0x180, Active snapshot sequential ID + public readonly uint snapshot_id; + /// 0x184, Reserved blocks for active snapshot's future use + public readonly ulong snapshot_blocks; + /// 0x18C, inode number of the on-disk start of the snapshot list + public readonly uint snapshot_list; + + // Optional ext4 error-handling features + /// 0x190, total registered filesystem errors + public readonly uint error_count; + /// 0x194, time on first error + public readonly uint first_error_t; + /// 0x198, inode involved in first error + public readonly uint first_error_inode; + /// 0x19C, block involved of first error + public readonly ulong first_error_block; + /// 0x1A0, 32 bytes, function where the error happened + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] first_error_func; + /// 0x1B0, line number where error happened + public readonly uint first_error_line; + /// 0x1B4, time of most recent error + public readonly uint last_error_t; + /// 0x1B8, inode involved in last error + public readonly uint last_error_inode; + /// 0x1BC, line number where error happened + public readonly uint last_error_line; + /// 0x1C0, block involved of last error + public readonly ulong last_error_block; + /// 0x1C8, 32 bytes, function where the error happened + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly byte[] last_error_func; + + // End of optional error-handling features + + // 0x1D8, 64 bytes, last used mount options + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] + public readonly byte[] mount_options; + + /// Inode for user quota + public readonly uint usr_quota_inum; + /// Inode for group quota + public readonly uint grp_quota_inum; + /// Overhead clusters in volume + public readonly uint overhead_clusters; + /// Groups with sparse_super2 SBs + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly uint[] backup_bgs; + /// Encryption algorithms in use + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public readonly byte[] encrypt_algos; + /// Salt used for string2key algorithm + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] encrypt_pw_salt; + /// Inode number of lost+found + public readonly uint lpf_inum; + /// Inode number for tracking project quota + public readonly uint prj_quota_inum; + /// crc32c(uuid) if csum_seed is set + public readonly uint checksum_seed; + /// Reserved + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 98)] + public readonly byte[] reserved; + /// crc32c(superblock) + public readonly uint checksum; + } +} \ No newline at end of file diff --git a/Aaru.Filesystems/ext2FS/ext2FS.cs b/Aaru.Filesystems/ext2FS/ext2FS.cs new file mode 100644 index 000000000..dd9841019 --- /dev/null +++ b/Aaru.Filesystems/ext2FS/ext2FS.cs @@ -0,0 +1,59 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : ext2FS.cs +// Author(s) : Natalia Portillo +// +// Component : Linux extended filesystem 2, 3 and 4 plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Linux extended filesystem 2, 3 and 4 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the Linux extended filesystem v2, v3 and v4 +[SuppressMessage("ReSharper", "UnusedMember.Local")] + +// ReSharper disable once InconsistentNaming +public sealed partial class ext2FS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public Encoding Encoding { get; private set; } + /// + public string Name => Localization.ext2FS_Name_Linux_extended_Filesystem_2_3_and_4; + /// + public Guid Id => new("6AA91B88-150B-4A7B-AD56-F84FB2DF4184"); + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file diff --git a/Aaru.Filesystems/extFS/Consts.cs b/Aaru.Filesystems/extFS/Consts.cs new file mode 100644 index 000000000..2737f5c10 --- /dev/null +++ b/Aaru.Filesystems/extFS/Consts.cs @@ -0,0 +1,44 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Linux extended filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the Linux extended filesystem + +// ReSharper disable once InconsistentNaming +public sealed partial class extFS +{ + const int SB_POS = 0x400; + + /// ext superblock magic + const ushort EXT_MAGIC = 0x137D; + + const string FS_TYPE = "ext"; +} \ No newline at end of file diff --git a/Aaru.Filesystems/extFS.cs b/Aaru.Filesystems/extFS/Info.cs similarity index 69% rename from Aaru.Filesystems/extFS.cs rename to Aaru.Filesystems/extFS/Info.cs index 0315579cf..6b603a122 100644 --- a/Aaru.Filesystems/extFS.cs +++ b/Aaru.Filesystems/extFS/Info.cs @@ -2,15 +2,11 @@ // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // -// Filename : extFS.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Linux extended filesystem plugin. // -// --[ Description ] ---------------------------------------------------------- -// -// Identifies the Linux extended filesystem and shows information. -// // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify @@ -31,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; @@ -45,26 +40,8 @@ namespace Aaru.Filesystems; /// Implements detection of the Linux extended filesystem // ReSharper disable once InconsistentNaming -public sealed class extFS : IFilesystem +public sealed partial class extFS { - const int SB_POS = 0x400; - - /// ext superblock magic - const ushort EXT_MAGIC = 0x137D; - - const string FS_TYPE = "ext"; - - /// - public FileSystemType XmlFsType { get; private set; } - /// - public string Name => Localization.extFS_Name; - /// - public Guid Id => new("076CB3A2-08C2-4D69-BC8A-FCAA2E502BE2"); - /// - public Encoding Encoding { get; private set; } - /// - public string Author => Authors.NataliaPortillo; - /// public bool Identify(IMediaImage imagePlugin, Partition partition) { @@ -156,42 +133,4 @@ public sealed class extFS : IFilesystem information = sb.ToString(); } - - /// ext superblock - #pragma warning disable CS0649 - [SuppressMessage("ReSharper", "InconsistentNaming")] - struct SuperBlock - { - /// 0x000, inodes on volume - public uint inodes; - /// 0x004, zones on volume - public uint zones; - /// 0x008, first free block - public uint firstfreeblk; - /// 0x00C, free blocks count - public uint freecountblk; - /// 0x010, first free inode - public uint firstfreeind; - /// 0x014, free inodes count - public uint freecountind; - /// 0x018, first data zone - public uint firstdatazone; - /// 0x01C, log zone size - public uint logzonesize; - /// 0x020, max zone size - public uint maxsize; - /// 0x024, reserved - public uint reserved1; - /// 0x028, reserved - public uint reserved2; - /// 0x02C, reserved - public uint reserved3; - /// 0x030, reserved - public uint reserved4; - /// 0x034, reserved - public uint reserved5; - /// 0x038, 0x137D (little endian) - public ushort magic; - } - #pragma warning restore CS0649 } \ No newline at end of file diff --git a/Aaru.Filesystems/extFS/Structs.cs b/Aaru.Filesystems/extFS/Structs.cs new file mode 100644 index 000000000..7e59521c3 --- /dev/null +++ b/Aaru.Filesystems/extFS/Structs.cs @@ -0,0 +1,77 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Linux extended filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System.Diagnostics.CodeAnalysis; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the Linux extended filesystem + +// ReSharper disable once InconsistentNaming +public sealed partial class extFS +{ + /// ext superblock + #pragma warning disable CS0649 + [SuppressMessage("ReSharper", "InconsistentNaming")] + struct SuperBlock + { + /// 0x000, inodes on volume + public uint inodes; + /// 0x004, zones on volume + public uint zones; + /// 0x008, first free block + public uint firstfreeblk; + /// 0x00C, free blocks count + public uint freecountblk; + /// 0x010, first free inode + public uint firstfreeind; + /// 0x014, free inodes count + public uint freecountind; + /// 0x018, first data zone + public uint firstdatazone; + /// 0x01C, log zone size + public uint logzonesize; + /// 0x020, max zone size + public uint maxsize; + /// 0x024, reserved + public uint reserved1; + /// 0x028, reserved + public uint reserved2; + /// 0x02C, reserved + public uint reserved3; + /// 0x030, reserved + public uint reserved4; + /// 0x034, reserved + public uint reserved5; + /// 0x038, 0x137D (little endian) + public ushort magic; + } + #pragma warning restore CS0649 +} \ No newline at end of file diff --git a/Aaru.Filesystems/extFS/extFS.cs b/Aaru.Filesystems/extFS/extFS.cs new file mode 100644 index 000000000..76a2213e7 --- /dev/null +++ b/Aaru.Filesystems/extFS/extFS.cs @@ -0,0 +1,53 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : extFS.cs +// Author(s) : Natalia Portillo +// +// Component : Linux extended filesystem plugin. +// +// --[ 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-2023 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using Aaru.CommonTypes.Interfaces; +using Schemas; + +namespace Aaru.Filesystems; + +// Information from the Linux kernel +/// +/// Implements detection of the Linux extended filesystem + +// ReSharper disable once InconsistentNaming +public sealed partial class extFS : IFilesystem +{ + /// + public FileSystemType XmlFsType { get; private set; } + /// + public string Name => Localization.extFS_Name; + /// + public Guid Id => new("076CB3A2-08C2-4D69-BC8A-FCAA2E502BE2"); + /// + public Encoding Encoding { get; private set; } + /// + public string Author => Authors.NataliaPortillo; +} \ No newline at end of file