// /*************************************************************************** // 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-2024 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 { #region Nested type: DirectoryEntry /// 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; } #endregion #region Nested type: Inode /// 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; } #endregion #region Nested type: SuperBlock /// 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; } #endregion }