// /*************************************************************************** // 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-2025 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"; }