erofs-utils: fix endianness issue

JIRA: https://issues.redhat.com/browse/RHEL-86463

Fix endianness issue.

Resolves: RHEL-86463
Signed-off-by: Abhi Das <adas@redhat.com>
This commit is contained in:
Abhi Das 2025-05-20 10:53:24 -05:00
parent af442a837f
commit 2aa346911c
2 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,60 @@
From d55344291092b69a2ba6f11dbcda52fa534ac124 Mon Sep 17 00:00:00 2001
From: Alexander Egorenkov <egorenar@linux.ibm.com>
Date: Tue, 29 Apr 2025 09:30:52 +0200
Subject: erofs-utils: fix endiannes issue
Macros __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined in
user space header 'endian.h'. Not including this header results in
the condition #if __BYTE_ORDER == __LITTLE_ENDIAN being always true,
even on BE architectures (e.g. s390x). Due to this bug the compressor
library was built for LE byte-order on BE arch s390x.
Fixes: bc99c763e3fe ("erofs-utils: switch to effective unaligned access")
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Ian Kent <raven@themaw.net>
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
Link: https://lore.kernel.org/r/20250429073052.53681-1-egorenar@linux.ibm.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
configure.ac | 1 +
include/erofs/defs.h | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/configure.ac b/configure.ac
index 6e1e7a1..88f1cbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,6 +194,7 @@ AC_ARG_WITH(selinux,
AC_CHECK_HEADERS(m4_flatten([
dirent.h
execinfo.h
+ endian.h
fcntl.h
getopt.h
inttypes.h
diff --git a/include/erofs/defs.h b/include/erofs/defs.h
index 051a270..21e0f09 100644
--- a/include/erofs/defs.h
+++ b/include/erofs/defs.h
@@ -24,6 +24,21 @@ extern "C"
#include <config.h>
#endif
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#else
+/* Use GNU C predefined macros as a fallback */
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER __BYTE_ORDER__
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
+#endif
+#endif
+
#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
#endif

View File

@ -11,7 +11,7 @@
Name: erofs-utils
Version: 1.8.4
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Utilities for working with EROFS
License: GPL-2.0-only AND GPL-2.0-or-later AND (GPL-2.0-only OR Apache-2.0) AND (GPL-2.0-or-later OR Apache-2.0) AND (GPL-2.0-only OR BSD-2-Clause) AND (GPL-2.0-or-later OR BSD-2-Clause) AND Unlicense
@ -19,6 +19,7 @@ URL: https://erofs.docs.kernel.org/
Source: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/snapshot/%{name}-%{version}.tar.gz
Patch: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/patch/?id=06875b3f2182eab24b81083dfde542f778b201cc#/%{name}-1.8.4-fragdedupe-inode-support.patch
Patch: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/patch/?id=d55344291092b69a2ba6f11dbcda52fa534ac124#/%{name}-1.8.4-fix-endianness-issue.patch
BuildRequires: %[ "%{toolchain}" == "clang" ? "clang compiler-rt" : "gcc" ]
BuildRequires: libtool
@ -98,6 +99,10 @@ autoreconf -fi
%changelog
* Mon May 05 2025 Abhi Das <adas@redhat.com> - 1.8.4-3
- erofs-utils: fix endianness issue
Resolves: RHEL-86463
* Thu Jan 02 2025 Neal Gompa <ngompa@centosproject.org> - 1.8.4-2
- Rebase to 1.8.4-2 for performance and compression fixes
Resolves: RHEL-72588