From 96726cf28785d915ed03417f77fd8bdc600f7d3e Mon Sep 17 00:00:00 2001 From: voidlizard Date: Fri, 22 Aug 2025 15:49:52 +0300 Subject: [PATCH] macos fsync issues --- .../lib/HBS2/Storage/NCQ3/Internal/Fsync.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fsync.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fsync.hs index 6dbd7765..a6a3ac35 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fsync.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fsync.hs @@ -7,17 +7,22 @@ import Foreign.C.Types import System.Posix.Types import System.Posix.Unistd (fileSynchronise) -foreign import capi unsafe "unistd.h fsync" - c_fsync :: CInt -> IO CInt +#ifdef darwin_HOST_OS -#if defined(darwin_HOST_OS) foreign import capi unsafe "fcntl.h fcntl" - c_fcntl :: CInt -> CInt -> CInt -> IO CInt + c_fcntl_raw :: CInt -> CInt -> CInt -> IO CInt foreign import capi unsafe "fcntl.h value F_FULLFSYNC" f_FULLFSYNC :: CInt + +c_fcntl :: CInt -> CInt -> CInt -> IO () +c_fcntl fd cmd arg = do + _ <- c_fcntl_raw fd cmd arg + pure () + #endif + fileSynchronisePortable :: Fd -> IO () fileSynchronisePortable fd@(Fd fdi) = do #if defined(darwin_HOST_OS)