|
| 1 | +From 0f90c740b0264512cd1eea611a3c3571fb68d9c7 Mon Sep 17 00:00:00 2001 |
| 2 | +From: classabbyamp < [email protected]> |
| 3 | +Date: Wed, 27 Aug 2025 09:14:55 -0400 |
| 4 | +Subject: [PATCH] linux: use sys/stat.h instead of linux/stat.h |
| 5 | + |
| 6 | +glibc includes linux/stat.h for statx, but musl defines its own statx |
| 7 | +struct and associated constants, which does not include STATX_MNT_ID |
| 8 | +yet. Thus, including linux/stat.h directly should be avoided for |
| 9 | +maximum libc compatibility. |
| 10 | + |
| 11 | +Tested on: |
| 12 | + - glibc: x86_64, i686, aarch64, armv7l, armv6l |
| 13 | + - musl: x86_64, aarch64, armv7l, armv6l |
| 14 | + |
| 15 | +Signed-off-by: classabbyamp < [email protected]> |
| 16 | +--- |
| 17 | + config/user-statx.m4 | 6 +++--- |
| 18 | + include/os/linux/spl/sys/stat.h | 2 +- |
| 19 | + lib/libspl/include/os/linux/sys/stat.h | 2 +- |
| 20 | + 3 files changed, 5 insertions(+), 5 deletions(-) |
| 21 | + |
| 22 | +diff --git a/config/user-statx.m4 b/config/user-statx.m4 |
| 23 | +index 0315f93e0c20..1ba74a40e9b8 100644 |
| 24 | +--- a/config/user-statx.m4 |
| 25 | ++++ b/config/user-statx.m4 |
| 26 | +@@ -2,7 +2,7 @@ dnl # |
| 27 | + dnl # Check for statx() function and STATX_MNT_ID availability |
| 28 | + dnl # |
| 29 | + AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [ |
| 30 | +- AC_CHECK_HEADERS([linux/stat.h], |
| 31 | ++ AC_CHECK_HEADERS([sys/stat.h], |
| 32 | + [have_stat_headers=yes], |
| 33 | + [have_stat_headers=no]) |
| 34 | + |
| 35 | +@@ -14,7 +14,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [ |
| 36 | + AC_MSG_CHECKING([for STATX_MNT_ID]) |
| 37 | + AC_COMPILE_IFELSE([ |
| 38 | + AC_LANG_PROGRAM([[ |
| 39 | +- #include <linux/stat.h> |
| 40 | ++ #include <sys/stat.h> |
| 41 | + ]], [[ |
| 42 | + struct statx stx; |
| 43 | + int mask = STATX_MNT_ID; |
| 44 | +@@ -29,6 +29,6 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [ |
| 45 | + ]) |
| 46 | + ]) |
| 47 | + ], [ |
| 48 | +- AC_MSG_WARN([linux/stat.h not found; skipping statx support]) |
| 49 | ++ AC_MSG_WARN([sys/stat.h not found; skipping statx support]) |
| 50 | + ]) |
| 51 | + ]) dnl end AC_DEFUN |
| 52 | +diff --git a/include/os/linux/spl/sys/stat.h b/include/os/linux/spl/sys/stat.h |
| 53 | +index 087389b57b34..ad2815e46394 100644 |
| 54 | +--- a/include/os/linux/spl/sys/stat.h |
| 55 | ++++ b/include/os/linux/spl/sys/stat.h |
| 56 | +@@ -25,6 +25,6 @@ |
| 57 | + #ifndef _SPL_STAT_H |
| 58 | + #define _SPL_STAT_H |
| 59 | + |
| 60 | +-#include <linux/stat.h> |
| 61 | ++#include <sys/stat.h> |
| 62 | + |
| 63 | + #endif /* SPL_STAT_H */ |
| 64 | +diff --git a/lib/libspl/include/os/linux/sys/stat.h b/lib/libspl/include/os/linux/sys/stat.h |
| 65 | +index a605af962a6d..13cc0b46ac93 100644 |
| 66 | +--- a/lib/libspl/include/os/linux/sys/stat.h |
| 67 | ++++ b/lib/libspl/include/os/linux/sys/stat.h |
| 68 | +@@ -33,7 +33,7 @@ |
| 69 | + |
| 70 | + #ifdef HAVE_STATX |
| 71 | + #include <fcntl.h> |
| 72 | +-#include <linux/stat.h> |
| 73 | ++#include <sys/stat.h> |
| 74 | + #endif |
| 75 | + |
| 76 | + /* |
0 commit comments