@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12-- confirm that the filesystem type is a journaled FS type expected by Project:M36
23-- use statfs on Linux and macOS and GetVolumeInformation on Windows
34-- this could still be fooled with symlinks or by disabling journaling on filesystems that support that
@@ -62,20 +63,26 @@ fsTypeSupportsJournaling path =
6263
6364#elif linux_HOST_OS
6465import Foreign
66+#include "MachDeps.h"
6567--Linux cannot report journaling, so we just check the filesystem type as a proxy
6668type CStatFS = ()
6769foreign import ccall unsafe "sys/vfs.h statfs"
6870 c_statfs :: CString -> Ptr CStatFS -> IO CInt
6971
70−#if sizeof(int) == 8
72+#if WORD_SIZE_IN_BITS == 64
7173type CFSType = Word64
74+sizeofStructStatFS :: Int
75+sizeofStructStatFS = 120
7276#else
77+#error 32-bit not supported due to sizeof struct statfs missing
7378type CFSType = Word32
79+sizeofStructStatFS :: Int
80+sizeofStructStatFS = undefined
7481#endif
7582
7683fsTypeSupportsJournaling :: FilePath -> IO Bool
7784fsTypeSupportsJournaling path = do
78− struct_statfs <- mallocForeignPtrBytes #{size statfs}
85+ struct_statfs <- mallocForeignPtrBytes sizeofStructStatFS
7986 withCString path $ \c_path -> do
8087 withForeignPtr struct_statfs $ \ptr_statfs -> do
8188 throwErrnoIfMinus1_ "statfs" (c_statfs c_path ptr_statfs)