From: Simon Glass <simon.glass@canonical.com> 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 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- 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. -- 2.43.0