Skip to content

Commit ccf5a8a

Browse files
authored
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
1 parent 1da2c30 commit ccf5a8a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

config/user-statx.m4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dnl #
22
dnl # Check for statx() function and STATX_MNT_ID availability
33
dnl #
44
AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
5-
AC_CHECK_HEADERS([linux/stat.h],
5+
AC_CHECK_HEADERS([sys/stat.h],
66
[have_stat_headers=yes],
77
[have_stat_headers=no])
88
@@ -14,7 +14,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
1414
AC_MSG_CHECKING([for STATX_MNT_ID])
1515
AC_COMPILE_IFELSE([
1616
AC_LANG_PROGRAM([[
17-
#include <linux/stat.h>
17+
#include <sys/stat.h>
1818
]], [[
1919
struct statx stx;
2020
int mask = STATX_MNT_ID;
@@ -29,6 +29,6 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_STATX], [
2929
])
3030
])
3131
], [
32-
AC_MSG_WARN([linux/stat.h not found; skipping statx support])
32+
AC_MSG_WARN([sys/stat.h not found; skipping statx support])
3333
])
3434
]) dnl end AC_DEFUN

include/os/linux/spl/sys/stat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
#ifndef _SPL_STAT_H
2626
#define _SPL_STAT_H
2727

28-
#include <linux/stat.h>
28+
#include <sys/stat.h>
2929

3030
#endif /* SPL_STAT_H */

lib/libspl/include/os/linux/sys/stat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#ifdef HAVE_STATX
3535
#include <fcntl.h>
36-
#include <linux/stat.h>
36+
#include <sys/stat.h>
3737
#endif
3838

3939
/*

0 commit comments

Comments
 (0)