// /*************************************************************************** // 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-2024 Natalia Portillo // ****************************************************************************/ using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using hammer_crc_t = uint; using hammer_off_t = ulong; using hammer_tid_t = ulong; #pragma warning disable 169 namespace Aaru.Filesystems; /// /// Implements detection for the HAMMER filesystem public sealed partial class HAMMER { #region Nested type: HammerBlockMap [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; } #endregion #region Nested type: SuperBlock /// 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; } #endregion }