Skip to content

Commit

Permalink
Fix detection of statx.stx_mnt_id on buggy glibc
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Oct 11, 2023
1 parent 3e7dcbc commit 71e5648
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions System/Posix/Files/Common.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
17 changes: 17 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 71e5648

Please sign in to comment.