2017-07-26 04:16:36 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-07-26 04:16:36 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Filename : Structs.cs
|
2017-07-26 04:16:36 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : HAMMER filesystem plugin.
|
2017-07-26 04:16:36 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2017-07-26 04:16:36 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2017-07-26 04:16:36 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
2025-10-21 03:25:11 +01:00
|
|
|
|
using Aaru.CommonTypes.Attributes;
|
2023-10-03 23:22:08 +01:00
|
|
|
|
using hammer_crc_t = uint;
|
|
|
|
|
|
using hammer_off_t = ulong;
|
|
|
|
|
|
using hammer_tid_t = ulong;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
#pragma warning disable 169
|
|
|
|
|
|
|
|
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection for the HAMMER filesystem</summary>
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public sealed partial class HAMMER
|
2017-07-26 04:16:36 +01:00
|
|
|
|
{
|
2023-10-03 23:22:08 +01:00
|
|
|
|
#region Nested type: HammerBlockMap
|
|
|
|
|
|
|
|
|
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
|
|
|
|
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
|
2025-10-21 03:25:11 +01:00
|
|
|
|
[SwapEndian]
|
|
|
|
|
|
partial struct HammerBlockMap
|
2023-10-03 23:22:08 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>zone-2 offset only used by zone-4</summary>
|
|
|
|
|
|
public hammer_off_t phys_offset;
|
|
|
|
|
|
/// <summary>zone-X offset only used by zone-3</summary>
|
|
|
|
|
|
public hammer_off_t first_offset;
|
|
|
|
|
|
/// <summary>zone-X offset for allocation</summary>
|
|
|
|
|
|
public hammer_off_t next_offset;
|
|
|
|
|
|
/// <summary>zone-X offset only used by zone-3</summary>
|
|
|
|
|
|
public hammer_off_t alloc_offset;
|
|
|
|
|
|
public uint reserved01;
|
|
|
|
|
|
public hammer_crc_t entry_crc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Nested type: SuperBlock
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>Hammer superblock</summary>
|
2023-10-03 23:22:08 +01:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
|
2025-10-21 03:25:11 +01:00
|
|
|
|
[SwapEndian]
|
|
|
|
|
|
partial struct SuperBlock
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary><see cref="HAMMER_FSBUF_VOLUME" /> for a valid header</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public ulong vol_signature;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/* These are relative to block device offset, not zone offsets. */
|
|
|
|
|
|
/// <summary>offset of boot area</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public long vol_bot_beg;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>offset of memory log</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public long vol_mem_beg;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>offset of the first buffer in volume</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public long vol_buf_beg;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>offset of volume EOF (on buffer boundary)</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public long vol_buf_end;
|
|
|
|
|
|
public long vol_reserved01;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>identify filesystem</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public Guid vol_fsid;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>identify filesystem type</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public Guid vol_fstype;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>filesystem label</summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public byte[] vol_label;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>volume number within filesystem</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public int vol_no;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>number of volumes making up filesystem</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public int vol_count;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>version control information</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public uint vol_version;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>header crc</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public hammer_crc_t vol_crc;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>volume flags</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public uint vol_flags;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>the root volume number (must be 0)</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public uint vol_rootvol;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public uint[] vol_reserved;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* 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).
|
|
|
|
|
|
*/
|
|
|
|
|
|
/// <summary>total big-blocks when fs is empty</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public long vol0_stat_bigblocks;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>number of free big-blocks</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public long vol0_stat_freebigblocks;
|
|
|
|
|
|
public long vol0_reserved01;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>for statfs only</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public long vol0_stat_inodes;
|
|
|
|
|
|
public long vol0_reserved02;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>B-Tree root offset in zone-8</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public hammer_off_t vol0_btree_root;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <summary>highest partially synchronized TID</summary>
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public hammer_tid_t vol0_next_tid;
|
|
|
|
|
|
public hammer_off_t vol0_reserved03;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Blockmaps for zones. Not all zones use a blockmap. Note that the entire root blockmap is cached in the
|
|
|
|
|
|
/// hammer_mount structure.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public HammerBlockMap[] vol0_blockmap;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>Array of zone-2 addresses for undo FIFO.</summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
|
2025-10-21 03:25:11 +01:00
|
|
|
|
public hammer_off_t[] vol0_undo_array;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
2017-07-26 04:21:47 +01:00
|
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
|
#endregion
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|