Skip to contentSkip to conversation

package/zfs: fix uclibc support

PATCH Applied Thomas Perale via buildroot 1 participant 2 messages Oct 20 – Oct 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/zfs: fix uclibc support

Buildroot commit [1] fixed ZFS support for uclibc 1.0.57. This commit has been cherry picked in LTS branch 2025.02.x as the same error occured in that target branch.

At the time the master branch was based on 2.4.1 while 2025.02.x branch was based on ZFS version 2.3.2

The ZFS version present on the master branch included a number of upstream commit [2][3] not present in 2025.02.x. Those commits adds the infrastructure to properly support statx in both uclibc and glibc.

Later a follow up commit [4] has been commited upstream.

This commit backport this set of commit to fix the uclibc support for zfs. Those patches change the autoconf files and thus needs to be regen.

[1] b6884913ae package/zfs: add patch to fix build with uclibc >= 1.0.57
[2] https://github.com/openzfs/zfs/commit/523d9d6007effb01bf6a44f9942158f47a65e2b2
[3] https://github.com/openzfs/zfs/commit/ccf5a8a6fcfdfbdaa2f0fdca5d787958224bf06d
[4] https://github.com/openzfs/zfs/commit/2b930f63f85c11ad2f8c7f0bfbc5c7337ee5b1a5

---
 ...nt-on-path-based-unmount-using-statx.patch | 92 +++++++++++++++++++
 ...e-sys-stat-h-instead-of-linux-stat-h.patch | 82 +++++++++++++++++
 ...04-config-fix-STATX_MNT_ID-detection.patch | 41 +++++++++
 ...s-cmd-statx.c-avoid-statx-conflicts.patch} |  0
 package/zfs/zfs.mk                            |  5 +
 5 files changed, 220 insertions(+)
 create mode 100644 package/zfs/0002-validate-mountpoint-on-path-based-unmount-using-statx.patch
 create mode 100644 package/zfs/0003-linux-use-sys-stat-h-instead-of-linux-stat-h.patch
 create mode 100644 package/zfs/0004-config-fix-STATX_MNT_ID-detection.patch
 rename package/zfs/{0001-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch => 0005-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch} (100%)
package/zfs/0002-validate-mountpoint-on-path-based-unmount-using-statx.patch new file +92 -0
new file mode 100644
index 0000000000..4f1fcb75b4
@@ -0,0 +1,92 @@
+From 523d9d6007effb01bf6a44f9942158f47a65e2b2 Mon Sep 17 00:00:00 2001
+From: Ameer Hamza <[email protected]>
+Date: Wed, 9 Jul 2025 07:10:00 +0500
+Subject: [PATCH] Validate mountpoint on path-based unmount using statx
+
+Use statx to verify that path-based unmounts proceed only if the
+mountpoint reported by statx matches the MNTTAB entry reported by
+libzfs, aborting the operation if they differ. Align
+`zfs umount /path` behavior with `zfs umount dataset`.
+
+Reviewed-by: Alexander Motin <[email protected]>
+Signed-off-by: Ameer Hamza <[email protected]>
+Closes #17481
+
+Upstream: https://github.com/openzfs/zfs/commit/523d9d6007effb01bf6a44f9942158f47a65e2b2
+[thomas: stripped to only add support for the statx infrastructure]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ config/user-statx.m4                   | 34 ++++++++++++++++++++++++
+ config/user.m4                         |  1 +
+ 5 files changed, 89 insertions(+), 6 deletions(-)
+ create mode 100644 config/user-statx.m4
+
+diff --git a/config/user-statx.m4 b/config/user-statx.m4
+new file mode 100644
+index 000000000000..0315f93e0c20
+--- /dev/null
++++ b/config/user-statx.m4
+@@ -0,0 +1,34 @@
++dnl #
++dnl # Check for statx() function and STATX_MNT_ID availability
++dnl #
++AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
++	AC_CHECK_HEADERS([linux/stat.h],
++		[have_stat_headers=yes],
++		[have_stat_headers=no])
++
++	AS_IF([test "x$have_stat_headers" = "xyes"], [
++		AC_CHECK_FUNC([statx], [
++			AC_DEFINE([HAVE_STATX], [1], [statx() is available])
++
++			dnl Check for STATX_MNT_ID availability
++			AC_MSG_CHECKING([for STATX_MNT_ID])
++			AC_COMPILE_IFELSE([
++				AC_LANG_PROGRAM([[
++					#include <linux/stat.h>
++				]], [[
++					struct statx stx;
++					int mask = STATX_MNT_ID;
++					(void)mask;
++					(void)stx.stx_mnt_id;
++				]])
++			], [
++				AC_MSG_RESULT([yes])
++				AC_DEFINE([HAVE_STATX_MNT_ID], [1], [STATX_MNT_ID is available])
++			], [
++				AC_MSG_RESULT([no])
++			])
++		])
++	], [
++		AC_MSG_WARN([linux/stat.h not found; skipping statx support])
++	])
++])  dnl end AC_DEFUN
+diff --git a/config/user.m4 b/config/user.m4
+index badd920d2b8a..62e59ed94437 100644
+--- a/config/user.m4
++++ b/config/user.m4
+@@ -17,6 +17,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
+ 		ZFS_AC_CONFIG_USER_LIBUDEV
+ 		ZFS_AC_CONFIG_USER_LIBUUID
+ 		ZFS_AC_CONFIG_USER_LIBBLKID
++		ZFS_AC_CONFIG_USER_STATX
+ 	])
+ 	ZFS_AC_CONFIG_USER_LIBTIRPC
+ 	ZFS_AC_CONFIG_USER_LIBCRYPTO
+diff --git a/lib/libspl/include/os/linux/sys/stat.h b/lib/libspl/include/os/linux/sys/stat.h
+index 488554f4e844..a605af962a6d 100644
+--- a/lib/libspl/include/os/linux/sys/stat.h
++++ b/lib/libspl/include/os/linux/sys/stat.h
+@@ -31,6 +31,11 @@
+ 
+ #include <sys/mount.h> /* for BLKGETSIZE64 */
+ 
++#ifdef HAVE_STATX
++#include <fcntl.h>
++#include <linux/stat.h>
++#endif
++
+ /*
+  * Emulate Solaris' behavior of returning the block device size in fstat64().
+  */
+
package/zfs/0003-linux-use-sys-stat-h-instead-of-linux-stat-h.patch new file +82 -0

82 lines not on this page · raw message

package/zfs/0004-config-fix-STATX_MNT_ID-detection.patch new file +41 -0

41 lines not on this page · raw message

package/zfs/0005-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch renamed from package/zfs/0001-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch +0 -0
similarity index 100%
rename from package/zfs/0001-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch
rename to package/zfs/0005-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch
package/zfs/zfs.mk +5 -0
index bdd7b2a3b0..e6c8f98af9 100644
@@ -14,6 +14,11 @@ ZFS_CPE_ID_PRODUCT = openzfs
 
 ZFS_DEPENDENCIES = libaio openssl udev util-linux zlib libcurl linux
 
+# 0002-validate-mountpoint-on-path-based-unmount-using-statx.patch
+# 0003-linux-use-sys-stat-h-instead-of-linux-stat-h.patch
+# 0004-config-fix-STATX_MNT_ID-detection.patch
+ZFS_AUTORECONF = YES
+
 # sysvinit installs only a commented-out modules-load.d/ config file
 ZFS_CONF_OPTS = \
 	--with-linux=$(LINUX_DIR) \
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

In reply of:

Quoted 16 lines

Buildroot commit [1] fixed ZFS support for uclibc 1.0.57. This commit has been cherry picked in LTS branch 2025.02.x as the same error occured in that target branch.

At the time the master branch was based on 2.4.1 while 2025.02.x branch was based on ZFS version 2.3.2

The ZFS version present on the master branch included a number of upstream commit [2][3] not present in 2025.02.x. Those commits adds the infrastructure to properly support statx in both uclibc and glibc.

Later a follow up commit [4] has been commited upstream.

This commit backport this set of commit to fix the uclibc support for zfs. Those patches change the autoconf files and thus needs to be regen.

Quoted 6 lines

[1] b6884913ae package/zfs: add patch to fix build with uclibc >= 1.0.57
[2] https://github.com/openzfs/zfs/commit/523d9d6007effb01bf6a44f9942158f47a65e2b2
[3] https://github.com/openzfs/zfs/commit/ccf5a8a6fcfdfbdaa2f0fdca5d787958224bf06d
[4] https://github.com/openzfs/zfs/commit/2b930f63f85c11ad2f8c7f0bfbc5c7337ee5b1a5

Applied to 2025.02.x. Thanks

Quoted 255 lines
---
 ...nt-on-path-based-unmount-using-statx.patch | 92 +++++++++++++++++++
 ...e-sys-stat-h-instead-of-linux-stat-h.patch | 82 +++++++++++++++++
 ...04-config-fix-STATX_MNT_ID-detection.patch | 41 +++++++++
 ...s-cmd-statx.c-avoid-statx-conflicts.patch} |  0
 package/zfs/zfs.mk                            |  5 +
 5 files changed, 220 insertions(+)
 create mode 100644 package/zfs/0002-validate-mountpoint-on-path-based-unmount-using-statx.patch
 create mode 100644 package/zfs/0003-linux-use-sys-stat-h-instead-of-linux-stat-h.patch
 create mode 100644 package/zfs/0004-config-fix-STATX_MNT_ID-detection.patch
 rename package/zfs/{0001-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch => 0005-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch} (100%)
package/zfs/0002-validate-mountpoint-on-path-based-unmount-using-statx.patch new file +92 -0
new file mode 100644
index 0000000000..4f1fcb75b4
@@ -0,0 +1,92 @@
+From 523d9d6007effb01bf6a44f9942158f47a65e2b2 Mon Sep 17 00:00:00 2001
+From: Ameer Hamza <[email protected]>
+Date: Wed, 9 Jul 2025 07:10:00 +0500
+Subject: [PATCH] Validate mountpoint on path-based unmount using statx
+
+Use statx to verify that path-based unmounts proceed only if the
+mountpoint reported by statx matches the MNTTAB entry reported by
+libzfs, aborting the operation if they differ. Align
+`zfs umount /path` behavior with `zfs umount dataset`.
+
+Reviewed-by: Alexander Motin <[email protected]>
+Signed-off-by: Ameer Hamza <[email protected]>
+Closes #17481
+
+Upstream: https://github.com/openzfs/zfs/commit/523d9d6007effb01bf6a44f9942158f47a65e2b2
+[thomas: stripped to only add support for the statx infrastructure]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ config/user-statx.m4                   | 34 ++++++++++++++++++++++++
+ config/user.m4                         |  1 +
+ 5 files changed, 89 insertions(+), 6 deletions(-)
+ create mode 100644 config/user-statx.m4
+
+diff --git a/config/user-statx.m4 b/config/user-statx.m4
+new file mode 100644
+index 000000000000..0315f93e0c20
+--- /dev/null
++++ b/config/user-statx.m4
+@@ -0,0 +1,34 @@
++dnl #
++dnl # Check for statx() function and STATX_MNT_ID availability
++dnl #
++AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
++	AC_CHECK_HEADERS([linux/stat.h],
++		[have_stat_headers=yes],
++		[have_stat_headers=no])
++
++	AS_IF([test "x$have_stat_headers" = "xyes"], [
++		AC_CHECK_FUNC([statx], [
++			AC_DEFINE([HAVE_STATX], [1], [statx() is available])
++
++			dnl Check for STATX_MNT_ID availability
++			AC_MSG_CHECKING([for STATX_MNT_ID])
++			AC_COMPILE_IFELSE([
++				AC_LANG_PROGRAM([[
++					#include <linux/stat.h>
++				]], [[
++					struct statx stx;
++					int mask = STATX_MNT_ID;
++					(void)mask;
++					(void)stx.stx_mnt_id;
++				]])
++			], [
++				AC_MSG_RESULT([yes])
++				AC_DEFINE([HAVE_STATX_MNT_ID], [1], [STATX_MNT_ID is available])
++			], [
++				AC_MSG_RESULT([no])
++			])
++		])
++	], [
++		AC_MSG_WARN([linux/stat.h not found; skipping statx support])
++	])
++])  dnl end AC_DEFUN
+diff --git a/config/user.m4 b/config/user.m4
+index badd920d2b8a..62e59ed94437 100644
+--- a/config/user.m4
++++ b/config/user.m4
+@@ -17,6 +17,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
+ 		ZFS_AC_CONFIG_USER_LIBUDEV
+ 		ZFS_AC_CONFIG_USER_LIBUUID
+ 		ZFS_AC_CONFIG_USER_LIBBLKID
++		ZFS_AC_CONFIG_USER_STATX
+ 	])
+ 	ZFS_AC_CONFIG_USER_LIBTIRPC
+ 	ZFS_AC_CONFIG_USER_LIBCRYPTO
+diff --git a/lib/libspl/include/os/linux/sys/stat.h b/lib/libspl/include/os/linux/sys/stat.h
+index 488554f4e844..a605af962a6d 100644
+--- a/lib/libspl/include/os/linux/sys/stat.h
++++ b/lib/libspl/include/os/linux/sys/stat.h
+@@ -31,6 +31,11 @@
+ 
+ #include <sys/mount.h> /* for BLKGETSIZE64 */
+ 
++#ifdef HAVE_STATX
++#include <fcntl.h>
++#include <linux/stat.h>
++#endif
++
+ /*
+  * Emulate Solaris' behavior of returning the block device size in fstat64().
+  */
+
package/zfs/0003-linux-use-sys-stat-h-instead-of-linux-stat-h.patch new file +82 -0
new file mode 100644
index 0000000000..1cac841a5a
@@ -0,0 +1,82 @@
+From ccf5a8a6fcfdfbdaa2f0fdca5d787958224bf06d Mon Sep 17 00:00:00 2001
+From: classabbyamp <[email protected]>
+Date: Wed, 27 Aug 2025 17:42:32 -0400
+Subject: [PATCH] linux: use sys/stat.h instead of linux/stat.h
+
+glibc includes linux/stat.h for statx, but musl defines its own statx
+struct and associated constants, which does not include STATX_MNT_ID
+yet. Thus, including linux/stat.h directly should be avoided for
+maximum libc compatibility.
+
+Tested on:
+  - glibc: x86_64, i686, aarch64, armv7l, armv6l
+  - musl: x86_64, aarch64, armv7l, armv6l
+
+Reviewed-by: Brian Behlendorf <[email protected]>
+Tested-By: Achill Gilgenast <[email protected]>
+Signed-off-by: classabbyamp <[email protected]>
+Closes #17675
+
+Upstream: https://github.com/openzfs/zfs/commit/ccf5a8a6fcfdfbdaa2f0fdca5d787958224bf06d
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ config/user-statx.m4                   | 6 +++---
+ include/os/linux/spl/sys/stat.h        | 2 +-
+ lib/libspl/include/os/linux/sys/stat.h | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/config/user-statx.m4 b/config/user-statx.m4
+index 0315f93e0c20..1ba74a40e9b8 100644
+--- a/config/user-statx.m4
++++ b/config/user-statx.m4
+@@ -2,7 +2,7 @@ dnl #
+ dnl # Check for statx() function and STATX_MNT_ID availability
+ dnl #
+ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
+-	AC_CHECK_HEADERS([linux/stat.h],
++	AC_CHECK_HEADERS([sys/stat.h],
+ 		[have_stat_headers=yes],
+ 		[have_stat_headers=no])
+ 
+@@ -14,7 +14,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
+ 			AC_MSG_CHECKING([for STATX_MNT_ID])
+ 			AC_COMPILE_IFELSE([
+ 				AC_LANG_PROGRAM([[
+-					#include <linux/stat.h>
++					#include <sys/stat.h>
+ 				]], [[
+ 					struct statx stx;
+ 					int mask = STATX_MNT_ID;
+@@ -29,6 +29,6 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
+ 			])
+ 		])
+ 	], [
+-		AC_MSG_WARN([linux/stat.h not found; skipping statx support])
++		AC_MSG_WARN([sys/stat.h not found; skipping statx support])
+ 	])
+ ])  dnl end AC_DEFUN
+diff --git a/include/os/linux/spl/sys/stat.h b/include/os/linux/spl/sys/stat.h
+index 087389b57b34..ad2815e46394 100644
+--- a/include/os/linux/spl/sys/stat.h
++++ b/include/os/linux/spl/sys/stat.h
+@@ -25,6 +25,6 @@
+ #ifndef _SPL_STAT_H
+ #define	_SPL_STAT_H
+ 
+-#include <linux/stat.h>
++#include <sys/stat.h>
+ 
+ #endif /* SPL_STAT_H */
+diff --git a/lib/libspl/include/os/linux/sys/stat.h b/lib/libspl/include/os/linux/sys/stat.h
+index a605af962a6d..13cc0b46ac93 100644
+--- a/lib/libspl/include/os/linux/sys/stat.h
++++ b/lib/libspl/include/os/linux/sys/stat.h
+@@ -33,7 +33,7 @@
+ 
+ #ifdef HAVE_STATX
+ #include <fcntl.h>
+-#include <linux/stat.h>
++#include <sys/stat.h>
+ #endif
+ 
+ /*
package/zfs/0004-config-fix-STATX_MNT_ID-detection.patch new file +41 -0
new file mode 100644
index 0000000000..176dca28d2
@@ -0,0 +1,41 @@
+From 2b930f63f85c11ad2f8c7f0bfbc5c7337ee5b1a5 Mon Sep 17 00:00:00 2001
+From: Rob Norris <[email protected]>
+Date: Fri, 13 Mar 2026 03:58:54 +1100
+Subject: [PATCH] config: fix STATX_MNT_ID detection
+
+statx(2) requires _GNU_SOURCE to be defined in order for sys/stat.h to
+produce a definition for struct statx and the STATX_* defines. We get
+that at compile time because we pass -D_GNU_SOURCE through to
+everything, but in the configure check we aren't setting _GNU_SOURCE, so
+we don't find STATX_MNT_ID, and so don't set HAVE_STATX_MNT_ID.
+
+(This was fine before ccf5a8a6fc, because linux/stat.h does not require
+_GNU_SOURCE).
+
+Simple fix: in the check, define _GNU_SOURCE before including
+sys/stat.h.
+
+Sponsored-by: TrueNAS
+Reviewed-by: Ameer Hamza <[email protected]>
+Reviewed-by: Brian Behlendorf <[email protected]>
+Signed-off-by: Rob Norris <[email protected]>
+Closes #18312
+
+Upstream: https://github.com/openzfs/zfs/commit/2b930f63f85c11ad2f8c7f0bfbc5c7337ee5b1a5
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ config/user-statx.m4 | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/config/user-statx.m4 b/config/user-statx.m4
+index b2441631c824..d359f48b8579 100644
+--- a/config/user-statx.m4
++++ b/config/user-statx.m4
+@@ -14,6 +14,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
+ 			AC_MSG_CHECKING([for STATX_MNT_ID])
+ 			AC_COMPILE_IFELSE([
+ 				AC_LANG_PROGRAM([[
++					#define _GNU_SOURCE
+ 					#include <sys/stat.h>
+ 				]], [[
+ 					struct statx stx;
package/zfs/0005-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch renamed from package/zfs/0001-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch +0 -0
similarity index 100%
rename from package/zfs/0001-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch
rename to package/zfs/0005-tests-zfs-tests-cmd-statx.c-avoid-statx-conflicts.patch
package/zfs/zfs.mk +0 -0
index bdd7b2a3b0..e6c8f98af9 100644
@@ -14,6 +14,11 @@ ZFS_CPE_ID_PRODUCT = openzfs
 

package/zfs/zfs.mk ZFS_CPE_ID_PRODUCT = openzfs · line 24

Quoted 10 lines
package/zfs/zfs.mk +5 -0
 ZFS_DEPENDENCIES = libaio openssl udev util-linux zlib libcurl linux
 
+# 0002-validate-mountpoint-on-path-based-unmount-using-statx.patch
+# 0003-linux-use-sys-stat-h-instead-of-linux-stat-h.patch
+# 0004-config-fix-STATX_MNT_ID-detection.patch
+ZFS_AUTORECONF = YES
+
 # sysvinit installs only a commented-out modules-load.d/ config file
 ZFS_CONF_OPTS = \
 	--with-linux=$(LINUX_DIR) \

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot