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 <behlendorf1@llnl.gov>
Tested-By: Achill Gilgenast <achill@achill.org>
Signed-off-by: classabbyamp <dev@placeviolette.net>
Closes #17675
This commit is contained in:
classabbyamp 2025-08-27 17:42:32 -04:00 committed by Brian Behlendorf
parent 04d991dbc4
commit 31b9646681
3 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -25,6 +25,6 @@
#ifndef _SPL_STAT_H
#define _SPL_STAT_H
#include <linux/stat.h>
#include <sys/stat.h>
#endif /* SPL_STAT_H */

View File

@ -33,7 +33,7 @@
#ifdef HAVE_STATX
#include <fcntl.h>
#include <linux/stat.h>
#include <sys/stat.h>
#endif
/*