diff --git a/System/Posix/Files/Common.hsc b/System/Posix/Files/Common.hsc index c0cd6b616de370741bfbfa71e72a30c081008f41..1f44f7d6f3e367fa202f78e57a95b9e42a72be62 100644 --- a/System/Posix/Files/Common.hsc +++ b/System/Posix/Files/Common.hsc @@ -940,7 +940,7 @@ pattern StatxBtime = StatxMask 0 -- | Want @stx_mnt_id@. pattern StatxMntId :: StatxMask -#ifdef STATX_MNT_ID +#ifdef HAVE_STATX_MNT_ID pattern StatxMntId = StatxMask (#const STATX_MNT_ID) #else pattern StatxMntId = StatxMask 0 @@ -1160,11 +1160,11 @@ specialDeviceIDX (ExtendedFileStatus statx) = unsafePerformIO $ do {-# WARNING specialDeviceIDX "specialDeviceIDX: not available on this platform, will throw error (CPP guard: @#if HAVE_SYS_SYSMACROS_H@)" #-} specialDeviceIDX _ = error "specialDeviceIDX not available on this platform" #endif -#ifdef STATX_MNT_ID +#ifdef HAVE_STATX_MNT_ID mountIDX (ExtendedFileStatus statx) = unsafePerformIO $ withForeignPtr statx $ (#peek struct statx, stx_mnt_id) #else -{-# WARNING mountIDX "mountIDX: not available on this platform, will throw error (CPP guard: @#if STATX_MNT_ID@)" #-} +{-# WARNING mountIDX "mountIDX: not available on this platform, will throw error (CPP guard: @#if HAVE_STATX_MNT_ID@)" #-} mountIDX _ = error "mountIDX not available on this platform" #endif fileBlockSizeX (ExtendedFileStatus statx) = unsafePerformIO $ do diff --git a/changelog.md b/changelog.md index 5318270754bf7c9e4c57cc7a22d92b1aa9c6e49b..2f3fdb25f598a3a0e36586ea2ed767c04e139d71 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## 2.8.4.0 *??? 2023* * add `haveStatx` + * fix `statx.stx_mnt_id` detection on buggy glibc, see [GHC #24072](https://gitlab.haskell.org/ghc/ghc/-/issues/24072) ## 2.8.3.0 *Oct 2023* diff --git a/configure.ac b/configure.ac index 978b7ad6d6cf8c81d9459499fce2d5a66648b643..2f36f5244caf96bada794772eb5a2883f0c49327 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,23 @@ AC_CHECK_TYPE([struct rlimit],[AC_DEFINE([HAVE_STRUCT_RLIMIT],[1],[HAVE_STRUCT_R # check for statx AC_CHECK_FUNC([statx], [AC_DEFINE([HAVE_STATX_FUN],[1],[HAVE_STATX_FUN])],[],[#include <sys/stat.h>]) AC_CHECK_TYPE([struct statx],[AC_DEFINE([HAVE_STRUCT_STATX],[1],[HAVE_STRUCT_STATX])],[],[#include <sys/stat.h>]) +AC_MSG_CHECKING(for statx.stx_mnt_id) +AC_LINK_IFELSE([ +AC_LANG_PROGRAM([[#include <sys/stat.h>]], +[[ +struct statx statxbuf; +statx(0, "", 0, STATX_BASIC_STATS | STATX_MNT_ID, &statxbuf); +return statxbuf.stx_mnt_id; +]])], +[ +AC_MSG_RESULT(yes) +AC_DEFINE([HAVE_STATX_MNT_ID], [1], [Define to 1 if statx.stx_mnt_id is available.]) +], +[ +AC_MSG_RESULT(no) +] +) + AC_MSG_CHECKING(for F_GETLK from fcntl.h) AC_EGREP_CPP(yes,