From patchwork Tue Dec 23 01:16:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1064 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452616; bh=K4W74nOznzmbyCzWPXEXjLi/vmRllYmcXfqZVqkh9LY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ukUN5a6mr4lnxItlPBUEbf4YK8dJ9lww+Az62GaurQmwiI2nld89VlP6vxE7YYv4u 2Op/5Ca11HwDLP0DZLTh4mCz4YOS5Rev78BbTUU9XmC6g9oIPmAw4/6VXjWOvHlmxd UgBib54F5pQK3l/iL+aRsCXlHW6T0L0HvBFtcTkETDb5xuWvTO/AQJHRM/gFtiyzZB qAgenvCUL0N3yJ6dQchFG0o9SoAb46KiaCEB6ez3PfdO6VQX7IZMdNsHhj90yMoDOi dswjGHtj4DNtRwLHNPBfG91D2pYJGaLdtQj35suj1EXASyjWyShJmQjb4BRmFijY0j fYFt3N0nwh/JA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A0E864D8D for ; Mon, 22 Dec 2025 18:16:56 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rEnLTWA67yL7 for ; Mon, 22 Dec 2025 18:16:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452616; bh=K4W74nOznzmbyCzWPXEXjLi/vmRllYmcXfqZVqkh9LY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ukUN5a6mr4lnxItlPBUEbf4YK8dJ9lww+Az62GaurQmwiI2nld89VlP6vxE7YYv4u 2Op/5Ca11HwDLP0DZLTh4mCz4YOS5Rev78BbTUU9XmC6g9oIPmAw4/6VXjWOvHlmxd UgBib54F5pQK3l/iL+aRsCXlHW6T0L0HvBFtcTkETDb5xuWvTO/AQJHRM/gFtiyzZB qAgenvCUL0N3yJ6dQchFG0o9SoAb46KiaCEB6ez3PfdO6VQX7IZMdNsHhj90yMoDOi dswjGHtj4DNtRwLHNPBfG91D2pYJGaLdtQj35suj1EXASyjWyShJmQjb4BRmFijY0j fYFt3N0nwh/JA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 716B264D46 for ; Mon, 22 Dec 2025 18:16:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452613; bh=ADlK4B9YGfUBaJvrqWQLM25F8Nr2dPRmYqVPGGdSReQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bIkr9jrG1b0B1/h8riPtO8yve+dgZh8PMwFiu4VuXOHR/dcrX7bElGOXzzRFRmjLv xeXp1HWIvGnMlJS5UHw0rA79cjgiK/Cq5LTEHs6C83OrJBGyBDxUsvHI8VWCxnXelY tDsjDeJV5DotuwFGFJY+29r6WAaLIehBZx0FduXyGWvYVvqoetpckmkppOb+Yn6Lb3 waoU0+S9nr7srwO+Wu0ovDNakdMC/WarlToVL/k5KP7uI4AjM1tn/UKVS5daNvZ2OX IIOFhMixEbSZh2VA6DiKJNyV/tnUEyBI/NbBni2CtoXMhkTQaD09PRXGRIl8L7A8Uo n+wyPwpdlcteA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C2CAC64DAB; Mon, 22 Dec 2025 18:16:53 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id OYsFVmeEQtlj; Mon, 22 Dec 2025 18:16:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452608; bh=TlCxr3ICwi2Z0mOOHGwOGT1n4BbiktiKFJu5Ltku5ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1TdKYxBe/I7h6tbiNS60hsrtJk9MzBZMgP4ndHPl0ZTMWXMrmj1kA3zNInhrt2Z0 j7e/4inGWbJ7JDg0U2Ip+Ej0DxMAleQExQ3PmJtFcyDbMyKNnyDK7nBla+PjI0gtJJ 8y695h9y15LgO2BIc/5dmJ3zKkZvat8zF4HiVvUZnuUBkfQ1q1VvLKHEMt7xht8OK9 zsTSToIxwIbcl/woC1ZpyWQ3RDY3FKDcqhyE2Ym/+2hWrWwg+lr7JF6qbEsOAJr2pf 6P+admKiblrTkZqb0/iBaNktq4Va5b3kYYc+cznsgViL/iSO3Fe9CNciX2ug9w8Seu fcE2ifHXCcr/w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4540D64DBA; Mon, 22 Dec 2025 18:16:48 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:20 -0700 Message-ID: <20251223011632.380026-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UB6ASFU6ZMV3I2BHLIIYFWEJKQMQTGTD X-Message-ID-Hash: UB6ASFU6ZMV3I2BHLIIYFWEJKQMQTGTD X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/12] ext4l: Document __CHAR_UNSIGNED__ behavior for directory hashing List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add documentation explaining how ext4's directory hash algorithm selection works based on the platform's char signedness. GCC automatically defines __CHAR_UNSIGNED__ on platforms where char is unsigned (e.g., ARM), which affects the hash algorithm used. The filesystem stores the hash variant in the superblock flags, ensuring correct operation regardless of the mounting platform. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 5c6e65b6e76..4b7b5d02c82 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -48,6 +48,22 @@ #define EXT4L_PRINTF 1 #endif +/* + * __CHAR_UNSIGNED__ - directory hash algorithm selection + * + * The ext4 filesystem uses different hash algorithms for directory indexing + * depending on whether the platform's 'char' type is signed or unsigned. + * GCC automatically defines __CHAR_UNSIGNED__ on platforms where char is + * unsigned (e.g., ARM), and leaves it undefined where char is signed + * (e.g., x86/sandbox). + * + * The filesystem stores EXT2_FLAGS_UNSIGNED_HASH or EXT2_FLAGS_SIGNED_HASH + * in the superblock to record which hash variant was used when the filesystem + * was created, ensuring correct behavior regardless of the mounting platform. + * + * See super.c:5123 and ioctl.c:1489 for the hash algorithm selection code. + */ + /* * Override no_printk to avoid format warnings in disabled debug prints. * The Linux kernel uses sector_t as u64, but U-Boot uses unsigned long.