{-# LINE 1 "src/System/LibFuse3/Internal.hsc" #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
module System.LibFuse3.Internal where
import Control.Applicative ((<|>))
import Control.Exception (Exception, SomeException, bracket_, catch, finally, fromException, handle)
import Control.Monad (unless, void)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import Data.Bits ((.&.), (.|.))
import Data.Foldable (traverse_)
import Data.Maybe (fromJust)
import Foreign
( FunPtr
, Ptr
, StablePtr
, allocaBytes
, castPtrToStablePtr
, castStablePtrToPtr
, copyArray
, deRefStablePtr
, free
, freeHaskellFunPtr
, freeStablePtr
, maybeWith
, newStablePtr
, nullFunPtr
, nullPtr
, peek
, peekArray
, peekByteOff
, poke
, pokeByteOff
, with
)
import Foreign.C (CInt(CInt), CString, Errno, eFAULT, eINVAL, eIO, eNOSYS, eOK, getErrno, peekCString, resetErrno, throwErrno, withCStringLen)
import GHC.IO.Handle (hDuplicateTo)
import System.Clock (TimeSpec)
import System.Environment (getArgs, getProgName)
import System.Exit (ExitCode(ExitFailure, ExitSuccess), exitFailure, exitSuccess, exitWith)
import System.IO (IOMode(ReadMode, WriteMode), SeekMode(AbsoluteSeek, RelativeSeek, SeekFromEnd), hPutStrLn, stderr, stdin, stdout, withFile)
import System.LibFuse3.FileStat (FileStat)
import System.LibFuse3.FileSystemStats (FileSystemStats)
import System.LibFuse3.FuseConfig (FuseConfig, fromCFuseConfig, toCFuseConfig)
import System.LibFuse3.Internal.Resource (daemonizeResourceT, resMallocBytes, resNew, resNewArray, resNewCString, resNewFilePath)
import System.LibFuse3.Utils (pokeCStringLen0, testBitSet, unErrno)
import System.Posix.Directory (changeWorkingDirectory)
import System.Posix.Files (blockSpecialMode, characterSpecialMode, directoryMode, namedPipeMode, regularFileMode, socketMode, symbolicLinkMode)
import System.Posix.IO (OpenFileFlags, OpenMode(ReadOnly, ReadWrite, WriteOnly), defaultFileFlags)
import System.Posix.Internals (c_access, peekFilePath, withFilePath)
import System.Posix.Process (createSession)
import System.Posix.Types (ByteCount, COff(COff), CSsize, DeviceID, FileMode, FileOffset, GroupID, UserID)
import Text.Printf (hPrintf, printf)
import qualified Control.Monad.Trans.Resource as Res
import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as BU
import qualified System.LibFuse3.Internal.C as C
import qualified System.Posix.IO
import qualified System.Posix.Signals as Signals
data EntryType
= Unknown
| NamedPipe
| CharacterSpecial
| Directory
| BlockSpecial
| RegularFile
| SymbolicLink
| Socket
deriving (EntryType -> EntryType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntryType -> EntryType -> Bool
$c/= :: EntryType -> EntryType -> Bool
== :: EntryType -> EntryType -> Bool
$c== :: EntryType -> EntryType -> Bool
Eq, Int -> EntryType -> ShowS
[EntryType] -> ShowS
EntryType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntryType] -> ShowS
$cshowList :: [EntryType] -> ShowS
show :: EntryType -> String
$cshow :: EntryType -> String
showsPrec :: Int -> EntryType -> ShowS
$cshowsPrec :: Int -> EntryType -> ShowS
Show)
entryTypeToFileMode :: EntryType -> FileMode
entryTypeToFileMode :: EntryType -> FileMode
entryTypeToFileMode EntryType
Unknown = FileMode
0
entryTypeToFileMode EntryType
NamedPipe = FileMode
namedPipeMode
entryTypeToFileMode EntryType
CharacterSpecial = FileMode
characterSpecialMode
entryTypeToFileMode EntryType
Directory = FileMode
directoryMode
entryTypeToFileMode EntryType
BlockSpecial = FileMode
blockSpecialMode
entryTypeToFileMode EntryType
RegularFile = FileMode
regularFileMode
entryTypeToFileMode EntryType
SymbolicLink = FileMode
symbolicLinkMode
entryTypeToFileMode EntryType
Socket = FileMode
socketMode
fileModeToEntryType :: FileMode -> EntryType
fileModeToEntryType :: FileMode -> EntryType
fileModeToEntryType FileMode
mode
| FileMode
fileType forall a. Eq a => a -> a -> Bool
== FileMode
namedPipeMode = EntryType
NamedPipe
| FileMode
fileType forall a. Eq a => a -> a -> Bool
== FileMode
characterSpecialMode = EntryType
CharacterSpecial
| FileMode
fileType forall a. Eq a => a -> a -> Bool
== FileMode
directoryMode = EntryType
Directory
| FileMode
fileType forall a. Eq a => a -> a -> Bool
== FileMode
blockSpecialMode = EntryType
BlockSpecial
| FileMode
fileType forall a. Eq a => a -> a -> Bool
== FileMode
regularFileMode = EntryType
RegularFile
| FileMode
fileType forall a. Eq a => a -> a -> Bool
== FileMode
symbolicLinkMode = EntryType
SymbolicLink
| FileMode
fileType forall a. Eq a => a -> a -> Bool
== FileMode
socketMode = EntryType
Socket
| Bool
otherwise = EntryType
Unknown
where
fileType :: FileMode
fileType = FileMode
mode forall a. Bits a => a -> a -> a
.&. (FileMode
61440)
{-# LINE 106 "src/System/LibFuse3/Internal.hsc" #-}
data SyncType
= FullSync
| DataSync
deriving (SyncType -> SyncType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SyncType -> SyncType -> Bool
$c/= :: SyncType -> SyncType -> Bool
== :: SyncType -> SyncType -> Bool
$c== :: SyncType -> SyncType -> Bool
Eq, Int -> SyncType -> ShowS
[SyncType] -> ShowS
SyncType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SyncType] -> ShowS
$cshowList :: [SyncType] -> ShowS
show :: SyncType -> String
$cshow :: SyncType -> String
showsPrec :: Int -> SyncType -> ShowS
$cshowsPrec :: Int -> SyncType -> ShowS
Show)
data AccessMode
= FileOK
| PermOK Bool Bool Bool
deriving (AccessMode -> AccessMode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessMode -> AccessMode -> Bool
$c/= :: AccessMode -> AccessMode -> Bool
== :: AccessMode -> AccessMode -> Bool
$c== :: AccessMode -> AccessMode -> Bool
Eq, Int -> AccessMode -> ShowS
[AccessMode] -> ShowS
AccessMode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessMode] -> ShowS
$cshowList :: [AccessMode] -> ShowS
show :: AccessMode -> String
$cshow :: AccessMode -> String
showsPrec :: Int -> AccessMode -> ShowS
$cshowsPrec :: Int -> AccessMode -> ShowS
Show)
data SetxattrFlag
= SetxattrDefault
| SetxattrCreate
| SetxattrReplace
deriving (SetxattrFlag -> SetxattrFlag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetxattrFlag -> SetxattrFlag -> Bool
$c/= :: SetxattrFlag -> SetxattrFlag -> Bool
== :: SetxattrFlag -> SetxattrFlag -> Bool
$c== :: SetxattrFlag -> SetxattrFlag -> Bool
Eq, Int -> SetxattrFlag -> ShowS
[SetxattrFlag] -> ShowS
SetxattrFlag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetxattrFlag] -> ShowS
$cshowList :: [SetxattrFlag] -> ShowS
show :: SetxattrFlag -> String
$cshow :: SetxattrFlag -> String
showsPrec :: Int -> SetxattrFlag -> ShowS
$cshowsPrec :: Int -> SetxattrFlag -> ShowS
Show)
access :: FilePath -> AccessMode -> IO ()
access :: String -> AccessMode -> IO ()
access String
path AccessMode
mode = do
Errno
e <- String -> AccessMode -> IO Errno
accessErrno String
path AccessMode
mode
if Errno
e forall a. Eq a => a -> a -> Bool
== Errno
eOK
then forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
else forall a. String -> IO a
throwErrno String
"access"
accessErrno :: FilePath -> AccessMode -> IO Errno
accessErrno :: String -> AccessMode -> IO Errno
accessErrno String
path AccessMode
mode = forall a. String -> (CString -> IO a) -> IO a
withFilePath String
path forall a b. (a -> b) -> a -> b
$ \CString
cPath -> do
let cMode :: CInt
cMode = case AccessMode
mode of
AccessMode
FileOK -> CInt
0
{-# LINE 152 "src/System/LibFuse3/Internal.hsc" #-}
PermOK Bool
r Bool
w Bool
x ->
(if Bool
r then (CInt
4) else CInt
0) forall a. Bits a => a -> a -> a
.|.
{-# LINE 154 "src/System/LibFuse3/Internal.hsc" #-}
(if Bool
w then (CInt
2) else CInt
0) forall a. Bits a => a -> a -> a
.|.
{-# LINE 155 "src/System/LibFuse3/Internal.hsc" #-}
(if Bool
x then (CInt
1) else CInt
0)
{-# LINE 156 "src/System/LibFuse3/Internal.hsc" #-}
resetErrno
CInt
ret <- CString -> CInt -> IO CInt
c_access CString
cPath CInt
cMode
if CInt
ret forall a. Eq a => a -> a -> Bool
== CInt
0
then forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
else IO Errno
getErrno
data FuseOperations fh dh = FuseOperations
{
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
fuseGetattr :: Maybe (FilePath -> Maybe fh -> IO (Either Errno FileStat))
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> IO (Either Errno String))
fuseReadlink :: Maybe (FilePath -> IO (Either Errno FilePath))
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> FileMode -> DeviceID -> IO Errno)
fuseMknod :: Maybe (FilePath -> FileMode -> DeviceID -> IO Errno)
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> FileMode -> IO Errno)
fuseMkdir :: Maybe (FilePath -> FileMode -> IO Errno)
,
forall fh dh. FuseOperations fh dh -> Maybe (String -> IO Errno)
fuseUnlink :: Maybe (FilePath -> IO Errno)
,
forall fh dh. FuseOperations fh dh -> Maybe (String -> IO Errno)
fuseRmdir :: Maybe (FilePath -> IO Errno)
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseSymlink :: Maybe (FilePath -> FilePath -> IO Errno)
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseRename :: Maybe (FilePath -> FilePath -> IO Errno)
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseLink :: Maybe (FilePath -> FilePath -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> FileMode -> IO Errno)
fuseChmod :: Maybe (FilePath -> Maybe fh -> FileMode -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
fuseChown :: Maybe (FilePath -> Maybe fh -> UserID -> GroupID -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
fuseTruncate :: Maybe (FilePath -> Maybe fh -> FileOffset -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
fuseOpen :: Maybe (FilePath -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
fuseRead :: Maybe (FilePath -> fh -> ByteCount -> FileOffset -> IO (Either Errno B.ByteString))
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
fuseWrite :: Maybe (FilePath -> fh -> B.ByteString -> FileOffset -> IO (Either Errno CInt))
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> IO (Either Errno FileSystemStats))
fuseStatfs :: Maybe (String -> IO (Either Errno FileSystemStats))
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> fh -> IO Errno)
fuseFlush :: Maybe (FilePath -> fh -> IO Errno)
,
forall fh dh. FuseOperations fh dh -> Maybe (String -> fh -> IO ())
fuseRelease :: Maybe (FilePath -> fh -> IO ())
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> fh -> SyncType -> IO Errno)
fuseFsync :: Maybe (FilePath -> fh -> SyncType -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> String -> ByteString -> SetxattrFlag -> IO Errno)
fuseSetxattr :: Maybe (FilePath -> String -> B.ByteString -> SetxattrFlag -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> String -> IO (Either Errno ByteString))
fuseGetxattr :: Maybe (FilePath -> String -> IO (Either Errno B.ByteString))
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> IO (Either Errno [String]))
fuseListxattr :: Maybe (FilePath -> IO (Either Errno [String]))
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseRemovexattr :: Maybe (FilePath -> String -> IO Errno)
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> IO (Either Errno dh))
fuseOpendir :: Maybe (FilePath -> IO (Either Errno dh))
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
fuseReaddir :: Maybe (FilePath -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> dh -> IO Errno)
fuseReleasedir :: Maybe (FilePath -> dh -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> dh -> SyncType -> IO Errno)
fuseFsyncdir :: Maybe (FilePath -> dh -> SyncType -> IO Errno)
,
forall fh dh.
FuseOperations fh dh -> Maybe (FuseConfig -> IO FuseConfig)
fuseInit :: Maybe (FuseConfig -> IO FuseConfig)
,
forall fh dh. FuseOperations fh dh -> Maybe (IO ())
fuseDestroy :: Maybe (IO ())
,
forall fh dh.
FuseOperations fh dh -> Maybe (String -> AccessMode -> IO Errno)
fuseAccess :: Maybe (FilePath -> AccessMode -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
fuseCreate :: Maybe (FilePath -> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
,
forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
fuseUtimens :: Maybe (FilePath -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
fuseFallocate :: Maybe (FilePath -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
fuseCopyFileRange :: Maybe (FilePath -> fh -> FileOffset -> FilePath -> fh -> FileOffset -> ByteCount -> CInt -> IO (Either Errno CSsize))
,
forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
fuseLseek :: Maybe (FilePath -> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
}
defaultFuseOperations :: FuseOperations fh dh
defaultFuseOperations :: forall fh dh. FuseOperations fh dh
defaultFuseOperations = forall fh dh.
Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
-> Maybe (String -> IO (Either Errno String))
-> Maybe (String -> FileMode -> DeviceID -> IO Errno)
-> Maybe (String -> FileMode -> IO Errno)
-> Maybe (String -> IO Errno)
-> Maybe (String -> IO Errno)
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> Maybe fh -> FileMode -> IO Errno)
-> Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
-> Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
-> Maybe
(String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
-> Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
-> Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
-> Maybe (String -> IO (Either Errno FileSystemStats))
-> Maybe (String -> fh -> IO Errno)
-> Maybe (String -> fh -> IO ())
-> Maybe (String -> fh -> SyncType -> IO Errno)
-> Maybe
(String -> String -> ByteString -> SetxattrFlag -> IO Errno)
-> Maybe (String -> String -> IO (Either Errno ByteString))
-> Maybe (String -> IO (Either Errno [String]))
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> IO (Either Errno dh))
-> Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
-> Maybe (String -> dh -> IO Errno)
-> Maybe (String -> dh -> SyncType -> IO Errno)
-> Maybe (FuseConfig -> IO FuseConfig)
-> Maybe (IO ())
-> Maybe (String -> AccessMode -> IO Errno)
-> Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
-> Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
-> Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
-> Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
-> Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
-> FuseOperations fh dh
FuseOperations forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing
mergeLFuseOperations :: FuseOperations fh dh -> FuseOperations fh dh -> FuseOperations fh dh
mergeLFuseOperations :: forall fh dh.
FuseOperations fh dh
-> FuseOperations fh dh -> FuseOperations fh dh
mergeLFuseOperations
(FuseOperations Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
a1 Maybe (String -> IO (Either Errno String))
a2 Maybe (String -> FileMode -> DeviceID -> IO Errno)
a3 Maybe (String -> FileMode -> IO Errno)
a4 Maybe (String -> IO Errno)
a5 Maybe (String -> IO Errno)
a6 Maybe (String -> String -> IO Errno)
a7 Maybe (String -> String -> IO Errno)
a8 Maybe (String -> String -> IO Errno)
a9 Maybe (String -> Maybe fh -> FileMode -> IO Errno)
a10 Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
a11 Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
a12 Maybe (String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
a13 Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
a14 Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
a15 Maybe (String -> IO (Either Errno FileSystemStats))
a16 Maybe (String -> fh -> IO Errno)
a17 Maybe (String -> fh -> IO ())
a18 Maybe (String -> fh -> SyncType -> IO Errno)
a19 Maybe (String -> String -> ByteString -> SetxattrFlag -> IO Errno)
a20 Maybe (String -> String -> IO (Either Errno ByteString))
a21 Maybe (String -> IO (Either Errno [String]))
a22 Maybe (String -> String -> IO Errno)
a23 Maybe (String -> IO (Either Errno dh))
a24 Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
a25 Maybe (String -> dh -> IO Errno)
a26 Maybe (String -> dh -> SyncType -> IO Errno)
a27 Maybe (FuseConfig -> IO FuseConfig)
a28 Maybe (IO ())
a29 Maybe (String -> AccessMode -> IO Errno)
a30 Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
a31 Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
a32 Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
a33 Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
a34 Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
a35)
(FuseOperations Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
b1 Maybe (String -> IO (Either Errno String))
b2 Maybe (String -> FileMode -> DeviceID -> IO Errno)
b3 Maybe (String -> FileMode -> IO Errno)
b4 Maybe (String -> IO Errno)
b5 Maybe (String -> IO Errno)
b6 Maybe (String -> String -> IO Errno)
b7 Maybe (String -> String -> IO Errno)
b8 Maybe (String -> String -> IO Errno)
b9 Maybe (String -> Maybe fh -> FileMode -> IO Errno)
b10 Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
b11 Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
b12 Maybe (String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
b13 Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
b14 Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
b15 Maybe (String -> IO (Either Errno FileSystemStats))
b16 Maybe (String -> fh -> IO Errno)
b17 Maybe (String -> fh -> IO ())
b18 Maybe (String -> fh -> SyncType -> IO Errno)
b19 Maybe (String -> String -> ByteString -> SetxattrFlag -> IO Errno)
b20 Maybe (String -> String -> IO (Either Errno ByteString))
b21 Maybe (String -> IO (Either Errno [String]))
b22 Maybe (String -> String -> IO Errno)
b23 Maybe (String -> IO (Either Errno dh))
b24 Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
b25 Maybe (String -> dh -> IO Errno)
b26 Maybe (String -> dh -> SyncType -> IO Errno)
b27 Maybe (FuseConfig -> IO FuseConfig)
b28 Maybe (IO ())
b29 Maybe (String -> AccessMode -> IO Errno)
b30 Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
b31 Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
b32 Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
b33 Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
b34 Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
b35)
= forall fh dh.
Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
-> Maybe (String -> IO (Either Errno String))
-> Maybe (String -> FileMode -> DeviceID -> IO Errno)
-> Maybe (String -> FileMode -> IO Errno)
-> Maybe (String -> IO Errno)
-> Maybe (String -> IO Errno)
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> Maybe fh -> FileMode -> IO Errno)
-> Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
-> Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
-> Maybe
(String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
-> Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
-> Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
-> Maybe (String -> IO (Either Errno FileSystemStats))
-> Maybe (String -> fh -> IO Errno)
-> Maybe (String -> fh -> IO ())
-> Maybe (String -> fh -> SyncType -> IO Errno)
-> Maybe
(String -> String -> ByteString -> SetxattrFlag -> IO Errno)
-> Maybe (String -> String -> IO (Either Errno ByteString))
-> Maybe (String -> IO (Either Errno [String]))
-> Maybe (String -> String -> IO Errno)
-> Maybe (String -> IO (Either Errno dh))
-> Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
-> Maybe (String -> dh -> IO Errno)
-> Maybe (String -> dh -> SyncType -> IO Errno)
-> Maybe (FuseConfig -> IO FuseConfig)
-> Maybe (IO ())
-> Maybe (String -> AccessMode -> IO Errno)
-> Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
-> Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
-> Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
-> Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
-> Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
-> FuseOperations fh dh
FuseOperations (Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
a1 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
b1) (Maybe (String -> IO (Either Errno String))
a2 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> IO (Either Errno String))
b2) (Maybe (String -> FileMode -> DeviceID -> IO Errno)
a3 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> FileMode -> DeviceID -> IO Errno)
b3) (Maybe (String -> FileMode -> IO Errno)
a4 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> FileMode -> IO Errno)
b4) (Maybe (String -> IO Errno)
a5 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> IO Errno)
b5) (Maybe (String -> IO Errno)
a6 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> IO Errno)
b6) (Maybe (String -> String -> IO Errno)
a7 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> String -> IO Errno)
b7) (Maybe (String -> String -> IO Errno)
a8 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> String -> IO Errno)
b8) (Maybe (String -> String -> IO Errno)
a9 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> String -> IO Errno)
b9) (Maybe (String -> Maybe fh -> FileMode -> IO Errno)
a10 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> Maybe fh -> FileMode -> IO Errno)
b10) (Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
a11 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
b11) (Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
a12 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
b12) (Maybe (String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
a13 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
b13) (Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
a14 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
b14) (Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
a15 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
b15) (Maybe (String -> IO (Either Errno FileSystemStats))
a16 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> IO (Either Errno FileSystemStats))
b16) (Maybe (String -> fh -> IO Errno)
a17 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> fh -> IO Errno)
b17) (Maybe (String -> fh -> IO ())
a18 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> fh -> IO ())
b18) (Maybe (String -> fh -> SyncType -> IO Errno)
a19 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> fh -> SyncType -> IO Errno)
b19) (Maybe (String -> String -> ByteString -> SetxattrFlag -> IO Errno)
a20 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> String -> ByteString -> SetxattrFlag -> IO Errno)
b20) (Maybe (String -> String -> IO (Either Errno ByteString))
a21 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> String -> IO (Either Errno ByteString))
b21) (Maybe (String -> IO (Either Errno [String]))
a22 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> IO (Either Errno [String]))
b22) (Maybe (String -> String -> IO Errno)
a23 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> String -> IO Errno)
b23) (Maybe (String -> IO (Either Errno dh))
a24 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> IO (Either Errno dh))
b24) (Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
a25 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
b25) (Maybe (String -> dh -> IO Errno)
a26 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> dh -> IO Errno)
b26) (Maybe (String -> dh -> SyncType -> IO Errno)
a27 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> dh -> SyncType -> IO Errno)
b27) (Maybe (FuseConfig -> IO FuseConfig)
a28 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (FuseConfig -> IO FuseConfig)
b28) (Maybe (IO ())
a29 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (IO ())
b29) (Maybe (String -> AccessMode -> IO Errno)
a30 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> AccessMode -> IO Errno)
b30) (Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
a31 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
b31) (Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
a32 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
b32) (Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
a33 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
b33) (Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
a34 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
b34) (Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
a35 forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
b35)
resCFuseOperations
:: forall fh dh e
. Exception e
=> FuseOperations fh dh
-> ExceptionHandler e
-> ResourceT IO (Ptr C.FuseOperations)
resCFuseOperations :: forall fh dh e.
Exception e =>
FuseOperations fh dh
-> ExceptionHandler e -> ResourceT IO (Ptr FuseOperations)
resCFuseOperations FuseOperations fh dh
ops ExceptionHandler e
handlerRaw = do
FunPtr CGetattr
fuseGetattr <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CGetattr -> IO (FunPtr CGetattr)
C.mkGetattr (String -> Maybe fh -> IO (Either Errno FileStat)) -> CGetattr
wrapGetattr (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> IO (Either Errno FileStat))
fuseGetattr FuseOperations fh dh
ops)
FunPtr CReadlink
fuseReadlink <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CReadlink -> IO (FunPtr CReadlink)
C.mkReadlink (String -> IO (Either Errno String)) -> CReadlink
wrapReadlink (forall fh dh.
FuseOperations fh dh -> Maybe (String -> IO (Either Errno String))
fuseReadlink FuseOperations fh dh
ops)
FunPtr CMknod
fuseMknod <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CMknod -> IO (FunPtr CMknod)
C.mkMknod (String -> FileMode -> DeviceID -> IO Errno) -> CMknod
wrapMknod (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> FileMode -> DeviceID -> IO Errno)
fuseMknod FuseOperations fh dh
ops)
FunPtr CMkdir
fuseMkdir <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CMkdir -> IO (FunPtr CMkdir)
C.mkMkdir (String -> FileMode -> IO Errno) -> CMkdir
wrapMkdir (forall fh dh.
FuseOperations fh dh -> Maybe (String -> FileMode -> IO Errno)
fuseMkdir FuseOperations fh dh
ops)
FunPtr CUnlink
fuseUnlink <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CUnlink -> IO (FunPtr CUnlink)
C.mkUnlink (String -> IO Errno) -> CUnlink
wrapUnlink (forall fh dh. FuseOperations fh dh -> Maybe (String -> IO Errno)
fuseUnlink FuseOperations fh dh
ops)
FunPtr CUnlink
fuseRmdir <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CUnlink -> IO (FunPtr CUnlink)
C.mkRmdir (String -> IO Errno) -> CUnlink
wrapRmdir (forall fh dh. FuseOperations fh dh -> Maybe (String -> IO Errno)
fuseRmdir FuseOperations fh dh
ops)
FunPtr CSymlink
fuseSymlink <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CSymlink -> IO (FunPtr CSymlink)
C.mkSymlink (String -> String -> IO Errno) -> CSymlink
wrapSymlink (forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseSymlink FuseOperations fh dh
ops)
FunPtr CRename
fuseRename <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CRename -> IO (FunPtr CRename)
C.mkRename (String -> String -> IO Errno) -> CRename
wrapRename (forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseRename FuseOperations fh dh
ops)
FunPtr CSymlink
fuseLink <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CSymlink -> IO (FunPtr CSymlink)
C.mkLink (String -> String -> IO Errno) -> CSymlink
wrapLink (forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseLink FuseOperations fh dh
ops)
FunPtr CChmod
fuseChmod <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CChmod -> IO (FunPtr CChmod)
C.mkChmod (String -> Maybe fh -> FileMode -> IO Errno) -> CChmod
wrapChmod (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> FileMode -> IO Errno)
fuseChmod FuseOperations fh dh
ops)
FunPtr CChown
fuseChown <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CChown -> IO (FunPtr CChown)
C.mkChown (String -> Maybe fh -> UserID -> GroupID -> IO Errno) -> CChown
wrapChown (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> UserID -> GroupID -> IO Errno)
fuseChown FuseOperations fh dh
ops)
FunPtr CTruncate
fuseTruncate <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CTruncate -> IO (FunPtr CTruncate)
C.mkTruncate (String -> Maybe fh -> FileOffset -> IO Errno) -> CTruncate
wrapTruncate (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> FileOffset -> IO Errno)
fuseTruncate FuseOperations fh dh
ops)
FunPtr COpen
fuseOpen <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC COpen -> IO (FunPtr COpen)
C.mkOpen (String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
-> COpen
wrapOpen (forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
fuseOpen FuseOperations fh dh
ops)
FunPtr CRead
fuseRead <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CRead -> IO (FunPtr CRead)
C.mkRead (String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
-> CRead
wrapRead (forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
fuseRead FuseOperations fh dh
ops)
FunPtr CRead
fuseWrite <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CRead -> IO (FunPtr CRead)
C.mkWrite (String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
-> CRead
wrapWrite (forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
fuseWrite FuseOperations fh dh
ops)
FunPtr CStatfs
fuseStatfs <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CStatfs -> IO (FunPtr CStatfs)
C.mkStatfs (String -> IO (Either Errno FileSystemStats)) -> CStatfs
wrapStatfs (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> IO (Either Errno FileSystemStats))
fuseStatfs FuseOperations fh dh
ops)
FunPtr COpen
fuseFlush <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC COpen -> IO (FunPtr COpen)
C.mkFlush (String -> fh -> IO Errno) -> COpen
wrapFlush (forall fh dh.
FuseOperations fh dh -> Maybe (String -> fh -> IO Errno)
fuseFlush FuseOperations fh dh
ops)
FunPtr COpen
fuseRelease <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC COpen -> IO (FunPtr COpen)
C.mkRelease (String -> fh -> IO ()) -> COpen
wrapRelease (forall fh dh. FuseOperations fh dh -> Maybe (String -> fh -> IO ())
fuseRelease FuseOperations fh dh
ops)
FunPtr CFsync
fuseFsync <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CFsync -> IO (FunPtr CFsync)
C.mkFsync (String -> fh -> SyncType -> IO Errno) -> CFsync
wrapFsync (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> fh -> SyncType -> IO Errno)
fuseFsync FuseOperations fh dh
ops)
FunPtr CSetxattr
fuseSetxattr <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CSetxattr -> IO (FunPtr CSetxattr)
C.mkSetxattr (String -> String -> ByteString -> SetxattrFlag -> IO Errno)
-> CSetxattr
wrapSetxattr (forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> String -> ByteString -> SetxattrFlag -> IO Errno)
fuseSetxattr FuseOperations fh dh
ops)
FunPtr CGetxattr
fuseGetxattr <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CGetxattr -> IO (FunPtr CGetxattr)
C.mkGetxattr (String -> String -> IO (Either Errno ByteString)) -> CGetxattr
wrapGetxattr (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> String -> IO (Either Errno ByteString))
fuseGetxattr FuseOperations fh dh
ops)
FunPtr CReadlink
fuseListxattr <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CReadlink -> IO (FunPtr CReadlink)
C.mkListxattr (String -> IO (Either Errno [String])) -> CReadlink
wrapListxattr (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> IO (Either Errno [String]))
fuseListxattr FuseOperations fh dh
ops)
FunPtr CSymlink
fuseRemovexattr <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CSymlink -> IO (FunPtr CSymlink)
C.mkRemovexattr (String -> String -> IO Errno) -> CSymlink
wrapRemovexattr (forall fh dh.
FuseOperations fh dh -> Maybe (String -> String -> IO Errno)
fuseRemovexattr FuseOperations fh dh
ops)
FunPtr COpen
fuseOpendir <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC COpen -> IO (FunPtr COpen)
C.mkOpendir (String -> IO (Either Errno dh)) -> COpen
wrapOpendir (forall fh dh.
FuseOperations fh dh -> Maybe (String -> IO (Either Errno dh))
fuseOpendir FuseOperations fh dh
ops)
FunPtr CReaddir
fuseReaddir <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CReaddir -> IO (FunPtr CReaddir)
C.mkReaddir (String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
-> CReaddir
wrapReaddir (forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
fuseReaddir FuseOperations fh dh
ops)
FunPtr COpen
fuseReleasedir <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC COpen -> IO (FunPtr COpen)
C.mkReleasedir (String -> dh -> IO Errno) -> COpen
wrapReleasedir (forall fh dh.
FuseOperations fh dh -> Maybe (String -> dh -> IO Errno)
fuseReleasedir FuseOperations fh dh
ops)
FunPtr CFsync
fuseFsyncdir <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CFsync -> IO (FunPtr CFsync)
C.mkFsyncdir (String -> dh -> SyncType -> IO Errno) -> CFsync
wrapFsyncdir (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> dh -> SyncType -> IO Errno)
fuseFsyncdir FuseOperations fh dh
ops)
FunPtr CInit
fuseInit <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CInit -> IO (FunPtr CInit)
C.mkInit (FuseConfig -> IO FuseConfig) -> CInit
wrapInit (forall fh dh.
FuseOperations fh dh -> Maybe (FuseConfig -> IO FuseConfig)
fuseInit FuseOperations fh dh
ops)
FunPtr CDestroy
fuseDestroy <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CDestroy -> IO (FunPtr CDestroy)
C.mkDestroy IO () -> CDestroy
wrapDestroy (forall fh dh. FuseOperations fh dh -> Maybe (IO ())
fuseDestroy FuseOperations fh dh
ops)
FunPtr (CString -> CInt -> IO CInt)
fuseAccess <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC (CString -> CInt -> IO CInt)
-> IO (FunPtr (CString -> CInt -> IO CInt))
C.mkAccess (String -> AccessMode -> IO Errno) -> CString -> CInt -> IO CInt
wrapAccess (forall fh dh.
FuseOperations fh dh -> Maybe (String -> AccessMode -> IO Errno)
fuseAccess FuseOperations fh dh
ops)
FunPtr CChmod
fuseCreate <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CChmod -> IO (FunPtr CChmod)
C.mkCreate (String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
-> CChmod
wrapCreate (forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
fuseCreate FuseOperations fh dh
ops)
FunPtr CUtimens
fuseUtimens <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CUtimens -> IO (FunPtr CUtimens)
C.mkUtimens (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
-> CUtimens
wrapUtimens (forall fh dh.
FuseOperations fh dh
-> Maybe (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
fuseUtimens FuseOperations fh dh
ops)
FunPtr CFallocate
fuseFallocate <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CFallocate -> IO (FunPtr CFallocate)
C.mkFallocate (String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
-> CFallocate
wrapFallocate (forall fh dh.
FuseOperations fh dh
-> Maybe
(String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
fuseFallocate FuseOperations fh dh
ops)
FunPtr CCopyFileRange
fuseCopyFileRange <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CCopyFileRange -> IO (FunPtr CCopyFileRange)
C.mkCopyFileRange (String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
-> CCopyFileRange
wrapCopyFileRange (forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
fuseCopyFileRange FuseOperations fh dh
ops)
FunPtr CLseek
fuseLseek <- forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC CLseek -> IO (FunPtr CLseek)
C.mkLseek (String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
-> CLseek
wrapLseek (forall fh dh.
FuseOperations fh dh
-> Maybe
(String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
fuseLseek FuseOperations fh dh
ops)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall a. Storable a => a -> ResourceT IO (ReleaseKey, Ptr a)
resNew C.FuseOperations
{ fuseLock :: FunPtr CLock
fuseLock = forall a. FunPtr a
nullFunPtr
, fuseBmap :: FunPtr CBmap
fuseBmap = forall a. FunPtr a
nullFunPtr
, fuseIoctl :: FunPtr CIoctl
fuseIoctl = forall a. FunPtr a
nullFunPtr
, fusePoll :: FunPtr CPoll
fusePoll = forall a. FunPtr a
nullFunPtr
, fuseWriteBuf :: FunPtr CWriteBuf
fuseWriteBuf = forall a. FunPtr a
nullFunPtr
, fuseReadBuf :: FunPtr CReadBuf
fuseReadBuf = forall a. FunPtr a
nullFunPtr
, fuseFlock :: FunPtr CFlock
fuseFlock = forall a. FunPtr a
nullFunPtr
, FunPtr CDestroy
FunPtr CUnlink
FunPtr CSymlink
FunPtr CGetxattr
FunPtr CSetxattr
FunPtr CRename
FunPtr CReadlink
FunPtr CRead
FunPtr CUtimens
FunPtr CGetattr
FunPtr CStatfs
FunPtr CReaddir
FunPtr COpen
FunPtr CCopyFileRange
FunPtr CChown
FunPtr CTruncate
FunPtr CLseek
FunPtr CMkdir
FunPtr CChmod
FunPtr CMknod
FunPtr (CString -> CInt -> IO CInt)
FunPtr CFsync
FunPtr CFallocate
FunPtr CInit
fuseLseek :: FunPtr CLseek
fuseCopyFileRange :: FunPtr CCopyFileRange
fuseFallocate :: FunPtr CFallocate
fuseUtimens :: FunPtr CUtimens
fuseCreate :: FunPtr CChmod
fuseAccess :: FunPtr (CString -> CInt -> IO CInt)
fuseDestroy :: FunPtr CDestroy
fuseInit :: FunPtr CInit
fuseFsyncdir :: FunPtr CFsync
fuseReleasedir :: FunPtr COpen
fuseReaddir :: FunPtr CReaddir
fuseOpendir :: FunPtr COpen
fuseRemovexattr :: FunPtr CSymlink
fuseListxattr :: FunPtr CReadlink
fuseGetxattr :: FunPtr CGetxattr
fuseSetxattr :: FunPtr CSetxattr
fuseFsync :: FunPtr CFsync
fuseRelease :: FunPtr COpen
fuseFlush :: FunPtr COpen
fuseStatfs :: FunPtr CStatfs
fuseWrite :: FunPtr CRead
fuseRead :: FunPtr CRead
fuseOpen :: FunPtr COpen
fuseTruncate :: FunPtr CTruncate
fuseChown :: FunPtr CChown
fuseChmod :: FunPtr CChmod
fuseLink :: FunPtr CSymlink
fuseRename :: FunPtr CRename
fuseSymlink :: FunPtr CSymlink
fuseRmdir :: FunPtr CUnlink
fuseUnlink :: FunPtr CUnlink
fuseMkdir :: FunPtr CMkdir
fuseMknod :: FunPtr CMknod
fuseReadlink :: FunPtr CReadlink
fuseGetattr :: FunPtr CGetattr
fuseLseek :: FunPtr CLseek
fuseCopyFileRange :: FunPtr CCopyFileRange
fuseFallocate :: FunPtr CFallocate
fuseUtimens :: FunPtr CUtimens
fuseCreate :: FunPtr CChmod
fuseAccess :: FunPtr (CString -> CInt -> IO CInt)
fuseDestroy :: FunPtr CDestroy
fuseInit :: FunPtr CInit
fuseFsyncdir :: FunPtr CFsync
fuseReleasedir :: FunPtr COpen
fuseReaddir :: FunPtr CReaddir
fuseOpendir :: FunPtr COpen
fuseRemovexattr :: FunPtr CSymlink
fuseListxattr :: FunPtr CReadlink
fuseGetxattr :: FunPtr CGetxattr
fuseSetxattr :: FunPtr CSetxattr
fuseFsync :: FunPtr CFsync
fuseRelease :: FunPtr COpen
fuseFlush :: FunPtr COpen
fuseStatfs :: FunPtr CStatfs
fuseWrite :: FunPtr CRead
fuseRead :: FunPtr CRead
fuseOpen :: FunPtr COpen
fuseTruncate :: FunPtr CTruncate
fuseChown :: FunPtr CChown
fuseChmod :: FunPtr CChmod
fuseLink :: FunPtr CSymlink
fuseRename :: FunPtr CRename
fuseSymlink :: FunPtr CSymlink
fuseRmdir :: FunPtr CUnlink
fuseUnlink :: FunPtr CUnlink
fuseMkdir :: FunPtr CMkdir
fuseMknod :: FunPtr CMknod
fuseReadlink :: FunPtr CReadlink
fuseGetattr :: FunPtr CGetattr
..
}
where
handler :: ExceptionHandler SomeException
handler :: ExceptionHandler SomeException
handler SomeException
se = case forall e. Exception e => SomeException -> Maybe e
fromException SomeException
se of
Maybe e
Nothing -> ExceptionHandler SomeException
defaultExceptionHandler SomeException
se
Just e
e -> ExceptionHandler e
handlerRaw e
e forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`catch` ExceptionHandler SomeException
defaultExceptionHandler
resC :: (cfunc -> IO (FunPtr cfunc)) -> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC :: forall cfunc hsfunc.
(cfunc -> IO (FunPtr cfunc))
-> (hsfunc -> cfunc) -> Maybe hsfunc -> ResourceT IO (FunPtr cfunc)
resC cfunc -> IO (FunPtr cfunc)
_ hsfunc -> cfunc
_ Maybe hsfunc
Nothing = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. FunPtr a
nullFunPtr
resC cfunc -> IO (FunPtr cfunc)
mkMeth hsfunc -> cfunc
wrapMeth (Just hsfunc
hsfunc) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
MonadResource m =>
IO a -> (a -> IO ()) -> m (ReleaseKey, a)
Res.allocate (cfunc -> IO (FunPtr cfunc)
mkMeth forall a b. (a -> b) -> a -> b
$ hsfunc -> cfunc
wrapMeth hsfunc
hsfunc) forall a. FunPtr a -> IO ()
freeHaskellFunPtr
handleAsFuseError :: IO Errno -> IO CInt
handleAsFuseError :: IO Errno -> IO CInt
handleAsFuseError = IO (Either Errno CInt) -> IO CInt
handleAsFuseErrorResult forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. a -> Either a b
Left
handleAsFuseErrorResult :: IO (Either Errno CInt) -> IO CInt
handleAsFuseErrorResult :: IO (Either Errno CInt) -> IO CInt
handleAsFuseErrorResult = forall a. Integral a => IO (Either Errno a) -> IO a
handleAsFuseErrorIntegral
handleAsFuseErrorCSsize :: IO (Either Errno CSsize) -> IO CSsize
handleAsFuseErrorCSsize :: IO (Either Errno CSsize) -> IO CSsize
handleAsFuseErrorCSsize = forall a. Integral a => IO (Either Errno a) -> IO a
handleAsFuseErrorIntegral
handleAsFuseErrorCOff :: IO (Either Errno COff) -> IO COff
handleAsFuseErrorCOff :: IO (Either Errno FileOffset) -> IO FileOffset
handleAsFuseErrorCOff = forall a. Integral a => IO (Either Errno a) -> IO a
handleAsFuseErrorIntegral
handleAsFuseErrorIntegral :: Integral a => IO (Either Errno a) -> IO a
handleAsFuseErrorIntegral :: forall a. Integral a => IO (Either Errno a) -> IO a
handleAsFuseErrorIntegral = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => a -> a
negate forall b c a. (b -> c) -> (a -> b) -> a -> c
. Errno -> CInt
unErrno) forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e a. Exception e => (e -> IO a) -> IO a -> IO a
handle (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. a -> Either a b
Left forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExceptionHandler SomeException
handler)
peekFilePathOrEmpty :: CString -> IO FilePath
peekFilePathOrEmpty :: CString -> IO String
peekFilePathOrEmpty CString
pFilePath
| CString
pFilePath forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr = forall (f :: * -> *) a. Applicative f => a -> f a
pure String
""
| Bool
otherwise = CString -> IO String
peekFilePath CString
pFilePath
peekOpenFileFlagsAndMode :: Ptr C.FuseFileInfo -> IO (OpenFileFlags, OpenMode)
peekOpenFileFlagsAndMode :: Ptr FuseFileInfo -> IO (OpenFileFlags, OpenMode)
peekOpenFileFlagsAndMode Ptr FuseFileInfo
pFuseFileInfo = do
(CInt
flags :: CInt) <- ((\Ptr FuseFileInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr FuseFileInfo
hsc_ptr Int
0)) Ptr FuseFileInfo
pFuseFileInfo
{-# LINE 498 "src/System/LibFuse3/Internal.hsc" #-}
let openFileFlags = defaultFileFlags
{ System.Posix.IO.append = testBitSet flags (1024)
{-# LINE 500 "src/System/LibFuse3/Internal.hsc" #-}
, System.Posix.IO.nonBlock = testBitSet flags (2048)
{-# LINE 501 "src/System/LibFuse3/Internal.hsc" #-}
, System.Posix.IO.trunc = testBitSet flags (512)
{-# LINE 502 "src/System/LibFuse3/Internal.hsc" #-}
}
openMode
| testBitSet flags (2) = ReadWrite
{-# LINE 505 "src/System/LibFuse3/Internal.hsc" #-}
| testBitSet flags (1) = WriteOnly
{-# LINE 506 "src/System/LibFuse3/Internal.hsc" #-}
| otherwise = ReadOnly
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OpenFileFlags
openFileFlags, OpenMode
openMode)
wrapGetattr :: (FilePath -> Maybe fh -> IO (Either Errno FileStat)) -> C.CGetattr
wrapGetattr :: (String -> Maybe fh -> IO (Either Errno FileStat)) -> CGetattr
wrapGetattr String -> Maybe fh -> IO (Either Errno FileStat)
go CString
pFilePath Ptr FileStat
pStat Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
Maybe fh
mfh <- forall fh. Ptr FuseFileInfo -> IO (Maybe fh)
getFH Ptr FuseFileInfo
pFuseFileInfo
String -> Maybe fh -> IO (Either Errno FileStat)
go String
filePath Maybe fh
mfh forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
errno
Right FileStat
stat -> do
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr FileStat
pStat FileStat
stat
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapReadlink :: (FilePath -> IO (Either Errno FilePath)) -> C.CReadlink
wrapReadlink :: (String -> IO (Either Errno String)) -> CReadlink
wrapReadlink String -> IO (Either Errno String)
go CString
pFilePath CString
pBuf ByteCount
bufSize = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> IO (Either Errno String)
go String
filePath forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
errno
Right String
target -> do
CStringLen -> String -> IO ()
pokeCStringLen0 (CString
pBuf, (forall a b. (Integral a, Num b) => a -> b
fromIntegral ByteCount
bufSize)) String
target
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapMknod :: (FilePath -> FileMode -> DeviceID -> IO Errno) -> C.CMknod
wrapMknod :: (String -> FileMode -> DeviceID -> IO Errno) -> CMknod
wrapMknod String -> FileMode -> DeviceID -> IO Errno
go CString
pFilePath FileMode
mode DeviceID
dev = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> FileMode -> DeviceID -> IO Errno
go String
filePath FileMode
mode DeviceID
dev
wrapMkdir :: (FilePath -> FileMode -> IO Errno) -> C.CMkdir
wrapMkdir :: (String -> FileMode -> IO Errno) -> CMkdir
wrapMkdir String -> FileMode -> IO Errno
go CString
pFilePath FileMode
mode = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> FileMode -> IO Errno
go String
filePath FileMode
mode
wrapUnlink :: (FilePath -> IO Errno) -> C.CUnlink
wrapUnlink :: (String -> IO Errno) -> CUnlink
wrapUnlink String -> IO Errno
go CString
pFilePath = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> IO Errno
go String
filePath
wrapRmdir :: (FilePath -> IO Errno) -> C.CRmdir
wrapRmdir :: (String -> IO Errno) -> CUnlink
wrapRmdir String -> IO Errno
go CString
pFilePath = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> IO Errno
go String
filePath
wrapSymlink :: (FilePath -> FilePath -> IO Errno) -> C.CSymlink
wrapSymlink :: (String -> String -> IO Errno) -> CSymlink
wrapSymlink String -> String -> IO Errno
go CString
pSource CString
pDestination = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
source <- CString -> IO String
peekFilePath CString
pSource
String
destination <- CString -> IO String
peekFilePath CString
pDestination
String -> String -> IO Errno
go String
source String
destination
wrapRename :: (FilePath -> FilePath -> IO Errno) -> C.CRename
wrapRename :: (String -> String -> IO Errno) -> CRename
wrapRename String -> String -> IO Errno
go CString
pOld CString
pNew CUInt
_flags = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
old <- CString -> IO String
peekFilePath CString
pOld
String
new <- CString -> IO String
peekFilePath CString
pNew
String -> String -> IO Errno
go String
old String
new
wrapLink :: (FilePath -> FilePath -> IO Errno) -> C.CLink
wrapLink :: (String -> String -> IO Errno) -> CSymlink
wrapLink String -> String -> IO Errno
go CString
pSource CString
pDestination = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
source <- CString -> IO String
peekFilePath CString
pSource
String
destination <- CString -> IO String
peekFilePath CString
pDestination
String -> String -> IO Errno
go String
source String
destination
wrapChmod :: (FilePath -> Maybe fh -> FileMode -> IO Errno) -> C.CChmod
wrapChmod :: (String -> Maybe fh -> FileMode -> IO Errno) -> CChmod
wrapChmod String -> Maybe fh -> FileMode -> IO Errno
go CString
pFilePath FileMode
mode Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
Maybe fh
mfh <- forall fh. Ptr FuseFileInfo -> IO (Maybe fh)
getFH Ptr FuseFileInfo
pFuseFileInfo
String -> Maybe fh -> FileMode -> IO Errno
go String
filePath Maybe fh
mfh FileMode
mode
wrapChown :: (FilePath -> Maybe fh -> UserID -> GroupID -> IO Errno) -> C.CChown
wrapChown :: (String -> Maybe fh -> UserID -> GroupID -> IO Errno) -> CChown
wrapChown String -> Maybe fh -> UserID -> GroupID -> IO Errno
go CString
pFilePath UserID
uid GroupID
gid Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
Maybe fh
mfh <- forall fh. Ptr FuseFileInfo -> IO (Maybe fh)
getFH Ptr FuseFileInfo
pFuseFileInfo
String -> Maybe fh -> UserID -> GroupID -> IO Errno
go String
filePath Maybe fh
mfh UserID
uid GroupID
gid
wrapTruncate :: (FilePath -> Maybe fh -> FileOffset -> IO Errno) -> C.CTruncate
wrapTruncate :: (String -> Maybe fh -> FileOffset -> IO Errno) -> CTruncate
wrapTruncate String -> Maybe fh -> FileOffset -> IO Errno
go CString
pFilePath FileOffset
off Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
Maybe fh
mfh <- forall fh. Ptr FuseFileInfo -> IO (Maybe fh)
getFH Ptr FuseFileInfo
pFuseFileInfo
String -> Maybe fh -> FileOffset -> IO Errno
go String
filePath Maybe fh
mfh FileOffset
off
wrapOpen :: (FilePath -> OpenMode -> OpenFileFlags -> IO (Either Errno fh)) -> C.COpen
wrapOpen :: (String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh))
-> COpen
wrapOpen String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh)
go CString
pFilePath Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
(OpenFileFlags
openFileFlags, OpenMode
openMode) <- Ptr FuseFileInfo -> IO (OpenFileFlags, OpenMode)
peekOpenFileFlagsAndMode Ptr FuseFileInfo
pFuseFileInfo
String -> OpenMode -> OpenFileFlags -> IO (Either Errno fh)
go String
filePath OpenMode
openMode OpenFileFlags
openFileFlags forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
errno
Right fh
fh -> do
forall fh. Ptr FuseFileInfo -> fh -> IO ()
newFH Ptr FuseFileInfo
pFuseFileInfo fh
fh
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapRead :: (FilePath -> fh -> ByteCount -> FileOffset -> IO (Either Errno B.ByteString)) -> C.CRead
wrapRead :: (String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString))
-> CRead
wrapRead String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString)
go CString
pFilePath CString
pBuf ByteCount
bufSize FileOffset
off Ptr FuseFileInfo
pFuseFileInfo = IO (Either Errno CInt) -> IO CInt
handleAsFuseErrorResult forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
fh
fh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
String
-> fh -> ByteCount -> FileOffset -> IO (Either Errno ByteString)
go String
filePath fh
fh ByteCount
bufSize FileOffset
off forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left Errno
errno
Right ByteString
bytes -> forall a. ByteString -> (CStringLen -> IO a) -> IO a
BU.unsafeUseAsCStringLen ByteString
bytes forall a b. (a -> b) -> a -> b
$ \(CString
pBytes, Int
bytesLen) -> do
let len :: Int
len = Int
bytesLen forall a. Ord a => a -> a -> a
`min` forall a b. (Integral a, Num b) => a -> b
fromIntegral ByteCount
bufSize
forall a. Storable a => Ptr a -> Ptr a -> Int -> IO ()
copyArray CString
pBuf CString
pBytes Int
len
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len
wrapWrite :: (FilePath -> fh -> B.ByteString -> FileOffset -> IO (Either Errno CInt)) -> C.CWrite
wrapWrite :: (String
-> fh -> ByteString -> FileOffset -> IO (Either Errno CInt))
-> CRead
wrapWrite String -> fh -> ByteString -> FileOffset -> IO (Either Errno CInt)
go CString
pFilePath CString
pBuf ByteCount
bufSize FileOffset
off Ptr FuseFileInfo
pFuseFileInfo = IO (Either Errno CInt) -> IO CInt
handleAsFuseErrorResult forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
fh
fh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
ByteString
buf <- CStringLen -> IO ByteString
BU.unsafePackCStringLen (CString
pBuf, forall a b. (Integral a, Num b) => a -> b
fromIntegral ByteCount
bufSize)
String -> fh -> ByteString -> FileOffset -> IO (Either Errno CInt)
go String
filePath fh
fh ByteString
buf FileOffset
off
wrapStatfs :: (String -> IO (Either Errno FileSystemStats)) -> C.CStatfs
wrapStatfs :: (String -> IO (Either Errno FileSystemStats)) -> CStatfs
wrapStatfs String -> IO (Either Errno FileSystemStats)
go CString
pStr Ptr FileSystemStats
pStatVFS = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
str <- CString -> IO String
peekFilePath CString
pStr
String -> IO (Either Errno FileSystemStats)
go String
str forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
errno
Right FileSystemStats
statvfs -> do
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr FileSystemStats
pStatVFS FileSystemStats
statvfs
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapFlush :: (FilePath -> fh -> IO Errno) -> C.CFlush
wrapFlush :: (String -> fh -> IO Errno) -> COpen
wrapFlush String -> fh -> IO Errno
go CString
pFilePath Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
fh
fh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
String -> fh -> IO Errno
go String
filePath fh
fh
wrapRelease :: (FilePath -> fh -> IO ()) -> C.CRelease
wrapRelease :: (String -> fh -> IO ()) -> COpen
wrapRelease String -> fh -> IO ()
go CString
pFilePath Ptr FuseFileInfo
pFuseFileInfo = IO CInt
go' forall a b. IO a -> IO b -> IO a
`finally` Ptr FuseFileInfo -> IO ()
delFH Ptr FuseFileInfo
pFuseFileInfo
where
go' :: IO CInt
go' = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
fh
fh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
String -> fh -> IO ()
go String
filePath fh
fh
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapFsync :: (FilePath -> fh -> SyncType -> IO Errno) -> C.CFsync
wrapFsync :: (String -> fh -> SyncType -> IO Errno) -> CFsync
wrapFsync String -> fh -> SyncType -> IO Errno
go CString
pFilePath CInt
isDataSync Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
fh
fh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
String -> fh -> SyncType -> IO Errno
go String
filePath fh
fh (if CInt
isDataSync forall a. Eq a => a -> a -> Bool
/= CInt
0 then SyncType
DataSync else SyncType
FullSync)
wrapSetxattr :: (FilePath -> String -> B.ByteString -> SetxattrFlag -> IO Errno) -> C.CSetxattr
wrapSetxattr :: (String -> String -> ByteString -> SetxattrFlag -> IO Errno)
-> CSetxattr
wrapSetxattr String -> String -> ByteString -> SetxattrFlag -> IO Errno
go CString
pFilePath CString
pName CString
pValue ByteCount
valueSize CInt
cFlags = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String
name <- CString -> IO String
peekCString CString
pName
ByteString
value <- CStringLen -> IO ByteString
BU.unsafePackCStringLen (CString
pValue, forall a b. (Integral a, Num b) => a -> b
fromIntegral ByteCount
valueSize)
let eflag :: Either Errno SetxattrFlag
eflag = case CInt
cFlags of
CInt
0 -> forall a b. b -> Either a b
Right SetxattrFlag
SetxattrDefault
(CInt
1) -> forall a b. b -> Either a b
Right SetxattrFlag
SetxattrCreate
{-# LINE 654 "src/System/LibFuse3/Internal.hsc" #-}
(CInt
2) -> forall a b. b -> Either a b
Right SetxattrFlag
SetxattrReplace
{-# LINE 655 "src/System/LibFuse3/Internal.hsc" #-}
CInt
_ -> forall a b. a -> Either a b
Left Errno
eINVAL
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall (f :: * -> *) a. Applicative f => a -> f a
pure (String -> String -> ByteString -> SetxattrFlag -> IO Errno
go String
filePath String
name ByteString
value) Either Errno SetxattrFlag
eflag
wrapGetxattr :: (FilePath -> String -> IO (Either Errno B.ByteString)) -> C.CGetxattr
wrapGetxattr :: (String -> String -> IO (Either Errno ByteString)) -> CGetxattr
wrapGetxattr String -> String -> IO (Either Errno ByteString)
go CString
pFilePath CString
pName CString
pValueBuf ByteCount
bufSize = IO (Either Errno CInt) -> IO CInt
handleAsFuseErrorResult forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String
name <- CString -> IO String
peekCString CString
pName
String -> String -> IO (Either Errno ByteString)
go String
filePath String
name forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left Errno
errno
Right ByteString
bytes
| ByteCount
bufSize forall a. Eq a => a -> a -> Bool
== ByteCount
0 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
bytes
| Bool
otherwise -> forall a. ByteString -> (CStringLen -> IO a) -> IO a
BU.unsafeUseAsCStringLen ByteString
bytes forall a b. (a -> b) -> a -> b
$ \(CString
pBytes, Int
bytesLen) -> do
let len :: Int
len = Int
bytesLen forall a. Ord a => a -> a -> a
`min` forall a b. (Integral a, Num b) => a -> b
fromIntegral ByteCount
bufSize
forall a. Storable a => Ptr a -> Ptr a -> Int -> IO ()
copyArray CString
pValueBuf CString
pBytes Int
len
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len
wrapListxattr :: (FilePath -> IO (Either Errno [String])) -> C.CListxattr
wrapListxattr :: (String -> IO (Either Errno [String])) -> CReadlink
wrapListxattr String -> IO (Either Errno [String])
go CString
pFilePath CString
pBuf ByteCount
bufSize = IO (Either Errno CInt) -> IO CInt
handleAsFuseErrorResult forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> IO (Either Errno [String])
go String
filePath forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left Errno
errno
Right [String]
names -> forall a. String -> (CStringLen -> IO a) -> IO a
withCStringLen (forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall a. Semigroup a => a -> a -> a
<> String
"\0") [String]
names) forall a b. (a -> b) -> a -> b
$ \(CString
pNames, Int
namesLen) ->
if ByteCount
bufSize forall a. Eq a => a -> a -> Bool
== ByteCount
0
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
namesLen
else do
let len :: Int
len = Int
namesLen forall a. Ord a => a -> a -> a
`min` forall a b. (Integral a, Num b) => a -> b
fromIntegral ByteCount
bufSize
forall a. Storable a => Ptr a -> Ptr a -> Int -> IO ()
copyArray CString
pBuf CString
pNames Int
len
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len
wrapRemovexattr :: (FilePath -> String -> IO Errno) -> C.CRemovexattr
wrapRemovexattr :: (String -> String -> IO Errno) -> CSymlink
wrapRemovexattr String -> String -> IO Errno
go CString
pFilePath CString
pName = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String
name <- CString -> IO String
peekCString CString
pName
String -> String -> IO Errno
go String
filePath String
name
wrapOpendir :: (FilePath -> IO (Either Errno dh)) -> C.COpendir
wrapOpendir :: (String -> IO (Either Errno dh)) -> COpen
wrapOpendir String -> IO (Either Errno dh)
go CString
pFilePath Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> IO (Either Errno dh)
go String
filePath forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
errno
Right dh
dh -> do
forall fh. Ptr FuseFileInfo -> fh -> IO ()
newFH Ptr FuseFileInfo
pFuseFileInfo dh
dh
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapReaddir :: (FilePath -> dh -> IO (Either Errno [(String, Maybe FileStat)])) -> C.CReaddir
wrapReaddir :: (String -> dh -> IO (Either Errno [(String, Maybe FileStat)]))
-> CReaddir
wrapReaddir String -> dh -> IO (Either Errno [(String, Maybe FileStat)])
go CString
pFilePath Ptr FuseFillDirBuf
pBuf FunPtr FuseFillDir
pFillDir FileOffset
_off Ptr FuseFileInfo
pFuseFileInfo FuseFillDirFlags
_readdirFlags = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
dh
dh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
let fillDir :: FuseFillDir
fillDir = FunPtr FuseFillDir -> FuseFillDir
peekFuseFillDir FunPtr FuseFillDir
pFillDir
fillEntry :: (FilePath, Maybe FileStat) -> IO ()
fillEntry :: (String, Maybe FileStat) -> IO ()
fillEntry (String
fileName, Maybe FileStat
fileStat) =
forall a. String -> (CString -> IO a) -> IO a
withFilePath String
fileName forall a b. (a -> b) -> a -> b
$ \CString
pFileName ->
forall a b c.
(a -> (Ptr b -> IO c) -> IO c)
-> Maybe a -> (Ptr b -> IO c) -> IO c
maybeWith forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Maybe FileStat
fileStat forall a b. (a -> b) -> a -> b
$ \Ptr FileStat
pFileStat -> do
CInt
_ <- FuseFillDir
fillDir Ptr FuseFillDirBuf
pBuf CString
pFileName Ptr FileStat
pFileStat FileOffset
0 FuseFillDirFlags
0
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
String -> dh -> IO (Either Errno [(String, Maybe FileStat)])
go String
filePath dh
dh forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
errno
Right [(String, Maybe FileStat)]
entries -> do
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ (String, Maybe FileStat) -> IO ()
fillEntry [(String, Maybe FileStat)]
entries
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapReleasedir :: (FilePath -> dh -> IO Errno) -> C.CReleasedir
wrapReleasedir :: (String -> dh -> IO Errno) -> COpen
wrapReleasedir String -> dh -> IO Errno
go CString
pFilePath Ptr FuseFileInfo
pFuseFileInfo = IO CInt
go' forall a b. IO a -> IO b -> IO a
`finally` Ptr FuseFileInfo -> IO ()
delFH Ptr FuseFileInfo
pFuseFileInfo
where
go' :: IO CInt
go' = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
dh
dh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
String -> dh -> IO Errno
go String
filePath dh
dh
wrapFsyncdir :: (FilePath -> dh -> SyncType -> IO Errno) -> C.CFsyncdir
wrapFsyncdir :: (String -> dh -> SyncType -> IO Errno) -> CFsync
wrapFsyncdir String -> dh -> SyncType -> IO Errno
go CString
pFilePath CInt
isDataSync Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
dh
dh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
String -> dh -> SyncType -> IO Errno
go String
filePath dh
dh (if CInt
isDataSync forall a. Eq a => a -> a -> Bool
/= CInt
0 then SyncType
DataSync else SyncType
FullSync)
wrapInit :: (FuseConfig -> IO FuseConfig) -> C.CInit
wrapInit :: (FuseConfig -> IO FuseConfig) -> CInit
wrapInit FuseConfig -> IO FuseConfig
go Ptr FuseConnInfo
_fuseConnInfo Ptr FuseConfig
pFuseConfig = do
()
_ <- forall e a. Exception e => (e -> IO a) -> IO a -> IO a
handle (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExceptionHandler SomeException
handler) forall a b. (a -> b) -> a -> b
$ do
FuseConfig
fuseConfigOld <- FuseConfig -> FuseConfig
fromCFuseConfig forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Storable a => Ptr a -> IO a
peek Ptr FuseConfig
pFuseConfig
FuseConfig
fuseConfigNew <- FuseConfig -> IO FuseConfig
go FuseConfig
fuseConfigOld
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr FuseConfig
pFuseConfig forall a b. (a -> b) -> a -> b
$ FuseConfig -> FuseConfig
toCFuseConfig FuseConfig
fuseConfigNew
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Ptr a
nullPtr
wrapDestroy :: IO () -> C.CDestroy
wrapDestroy :: IO () -> CDestroy
wrapDestroy IO ()
go Ptr ()
_privateData = forall e a. Exception e => (e -> IO a) -> IO a -> IO a
handle (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExceptionHandler SomeException
handler) IO ()
go
wrapAccess :: (FilePath -> AccessMode -> IO Errno) -> C.CAccess
wrapAccess :: (String -> AccessMode -> IO Errno) -> CString -> CInt -> IO CInt
wrapAccess String -> AccessMode -> IO Errno
go CString
pFilePath CInt
mode = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
String -> AccessMode -> IO Errno
go String
filePath AccessMode
accessMode
where
accessMode :: AccessMode
accessMode
| forall a. Bits a => a -> a -> Bool
testBitSet CInt
mode (CInt
0) = AccessMode
FileOK
{-# LINE 754 "src/System/LibFuse3/Internal.hsc" #-}
| otherwise = PermOK
(testBitSet mode (4))
{-# LINE 756 "src/System/LibFuse3/Internal.hsc" #-}
(testBitSet mode (2))
{-# LINE 757 "src/System/LibFuse3/Internal.hsc" #-}
(testBitSet mode (1))
{-# LINE 758 "src/System/LibFuse3/Internal.hsc" #-}
wrapCreate :: (FilePath -> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh)) -> C.CCreate
wrapCreate :: (String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh))
-> CChmod
wrapCreate String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh)
go CString
pFilePath FileMode
mode Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
(OpenFileFlags
openFileFlags, OpenMode
openMode) <- Ptr FuseFileInfo -> IO (OpenFileFlags, OpenMode)
peekOpenFileFlagsAndMode Ptr FuseFileInfo
pFuseFileInfo
String
-> OpenMode -> FileMode -> OpenFileFlags -> IO (Either Errno fh)
go String
filePath OpenMode
openMode FileMode
mode OpenFileFlags
openFileFlags forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left Errno
errno -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
errno
Right fh
fh -> do
forall fh. Ptr FuseFileInfo -> fh -> IO ()
newFH Ptr FuseFileInfo
pFuseFileInfo fh
fh
forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eOK
wrapUtimens :: (FilePath -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno) -> C.CUtimens
wrapUtimens :: (String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno)
-> CUtimens
wrapUtimens String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno
go CString
pFilePath Ptr TimeSpec
arrTs Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePathOrEmpty CString
pFilePath
Maybe fh
mfh <- forall fh. Ptr FuseFileInfo -> IO (Maybe fh)
getFH Ptr FuseFileInfo
pFuseFileInfo
[TimeSpec
atime, TimeSpec
mtime] <- forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray Int
2 Ptr TimeSpec
arrTs
String -> Maybe fh -> TimeSpec -> TimeSpec -> IO Errno
go String
filePath Maybe fh
mfh TimeSpec
atime TimeSpec
mtime
wrapFallocate :: (FilePath -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno) -> C.CFallocate
wrapFallocate :: (String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno)
-> CFallocate
wrapFallocate String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno
go CString
pFilePath CInt
mode FileOffset
offset FileOffset
len Ptr FuseFileInfo
pFuseFileInfo = IO Errno -> IO CInt
handleAsFuseError forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
fh
fh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
String -> fh -> CInt -> FileOffset -> FileOffset -> IO Errno
go String
filePath fh
fh CInt
mode FileOffset
offset FileOffset
len
wrapCopyFileRange :: (FilePath -> fh -> FileOffset -> FilePath -> fh -> FileOffset -> ByteCount -> CInt -> IO (Either Errno CSsize)) -> C.CCopyFileRange
wrapCopyFileRange :: (String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize))
-> CCopyFileRange
wrapCopyFileRange String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize)
go CString
pFilePathIn Ptr FuseFileInfo
pFuseFileInfoIn FileOffset
offsetIn CString
pFilePathOut Ptr FuseFileInfo
pFuseFileInfoOut FileOffset
offsetOut ByteCount
size CInt
flags = IO (Either Errno CSsize) -> IO CSsize
handleAsFuseErrorCSsize forall a b. (a -> b) -> a -> b
$ do
String
filePathIn <- CString -> IO String
peekFilePath CString
pFilePathIn
fh
fhIn <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfoIn
String
filePathOut <- CString -> IO String
peekFilePath CString
pFilePathOut
fh
fhOut <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfoOut
String
-> fh
-> FileOffset
-> String
-> fh
-> FileOffset
-> ByteCount
-> CInt
-> IO (Either Errno CSsize)
go String
filePathIn fh
fhIn FileOffset
offsetIn String
filePathOut fh
fhOut FileOffset
offsetOut ByteCount
size CInt
flags
wrapLseek :: (FilePath -> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset)) -> C.CLseek
wrapLseek :: (String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset))
-> CLseek
wrapLseek String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset)
go CString
pFilePath FileOffset
offset CInt
whence Ptr FuseFileInfo
pFuseFileInfo = IO (Either Errno FileOffset) -> IO FileOffset
handleAsFuseErrorCOff forall a b. (a -> b) -> a -> b
$ do
String
filePath <- CString -> IO String
peekFilePath CString
pFilePath
fh
fh <- forall fh. Ptr FuseFileInfo -> IO fh
getFHJust Ptr FuseFileInfo
pFuseFileInfo
let emode :: Either Errno SeekMode
emode = case CInt
whence of
(CInt
0) -> forall a b. b -> Either a b
Right SeekMode
AbsoluteSeek
{-# LINE 796 "src/System/LibFuse3/Internal.hsc" #-}
(CInt
1) -> forall a b. b -> Either a b
Right SeekMode
RelativeSeek
{-# LINE 797 "src/System/LibFuse3/Internal.hsc" #-}
(CInt
2) -> forall a b. b -> Either a b
Right SeekMode
SeekFromEnd
{-# LINE 798 "src/System/LibFuse3/Internal.hsc" #-}
CInt
_ -> forall a b. a -> Either a b
Left Errno
eINVAL
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left) (String
-> fh -> FileOffset -> SeekMode -> IO (Either Errno FileOffset)
go String
filePath fh
fh FileOffset
offset) Either Errno SeekMode
emode
_dummyToSuppressWarnings :: StablePtr a
_dummyToSuppressWarnings :: forall a. StablePtr a
_dummyToSuppressWarnings = forall a. HasCallStack => String -> a
error String
"dummy" Errno
eNOSYS
resFuseArgs :: String -> [String] -> ResourceT IO (Ptr C.FuseArgs)
resFuseArgs :: String -> [String] -> ResourceT IO (Ptr FuseArgs)
resFuseArgs String
prog [String]
args = do
let allArgs :: [String]
allArgs = (String
progforall a. a -> [a] -> [a]
:[String]
args)
argc :: Int
argc = forall (t :: * -> *) a. Foldable t => t a -> Int
length [String]
allArgs
[CString]
cArgs <- forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ResourceT IO (ReleaseKey, CString)
resNewCString) [String]
allArgs
Ptr CString
pArgv <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall a. Storable a => [a] -> ResourceT IO (ReleaseKey, Ptr a)
resNewArray [CString]
cArgs
Ptr FuseArgs
fuseArgs <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall a. Int -> ResourceT IO (ReleaseKey, Ptr a)
resMallocBytes ((Int
24))
{-# LINE 813 "src/System/LibFuse3/Internal.hsc" #-}
liftIO $ do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) fuseArgs argc
{-# LINE 815 "src/System/LibFuse3/Internal.hsc" #-}
((\hsc_ptr -> pokeByteOff hsc_ptr 8)) fuseArgs pArgv
{-# LINE 816 "src/System/LibFuse3/Internal.hsc" #-}
((\hsc_ptr -> pokeByteOff hsc_ptr 16)) fuseArgs (0::CInt)
{-# LINE 817 "src/System/LibFuse3/Internal.hsc" #-}
_ <- Res.register $ C.fuse_opt_free_args fuseArgs
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr FuseArgs
fuseArgs
fuseParseCommandLine :: Ptr C.FuseArgs -> IO (Either ExitCode FuseMainArgs)
fuseParseCommandLine :: Ptr FuseArgs -> IO (Either ExitCode FuseMainArgs)
fuseParseCommandLine Ptr FuseArgs
pArgs =
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes ((Int
48)) forall a b. (a -> b) -> a -> b
$ \Ptr FuseCmdlineOpts
pOpts -> do
{-# LINE 832 "src/System/LibFuse3/Internal.hsc" #-}
retval <- C.fuse_parse_cmdline pArgs pOpts
if retval /= 0
then pure $ Left $ ExitFailure 1
else go pOpts
where
go :: Ptr b -> IO (Either ExitCode (Bool, String, c))
go Ptr b
pOpts = do
CString
pMountPoint <- ((\Ptr b
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr b
hsc_ptr Int
16)) Ptr b
pOpts
{-# LINE 840 "src/System/LibFuse3/Internal.hsc" #-}
showHelp <- (/= (0 :: CInt)) <$> ((\hsc_ptr -> peekByteOff hsc_ptr 28)) pOpts
{-# LINE 841 "src/System/LibFuse3/Internal.hsc" #-}
showVersion <- (/= (0 :: CInt)) <$> ((\hsc_ptr -> peekByteOff hsc_ptr 24)) pOpts
{-# LINE 842 "src/System/LibFuse3/Internal.hsc" #-}
let freeMountPoint :: IO ()
freeMountPoint = forall a. Ptr a -> IO ()
free CString
pMountPoint
forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. IO a -> IO b -> IO a
finally IO ()
freeMountPoint forall a b. (a -> b) -> a -> b
$ case () of
()
_ | Bool
showHelp -> do
forall r. PrintfType r => String -> r
printf String
"usage: %s [options] <mountpoint>\n\n" forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO String
getProgName
IO ()
C.fuse_cmdline_help
Ptr FuseArgs -> IO ()
C.fuse_lib_help Ptr FuseArgs
pArgs
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left ExitCode
ExitSuccess
| Bool
showVersion -> do
String
ver <- CString -> IO String
peekCString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO CString
C.fuse_pkgversion
forall r. PrintfType r => String -> r
printf String
"FUSE library version %s\n" String
ver
IO ()
C.fuse_lowlevel_version
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left ExitCode
ExitSuccess
| CString
pMountPoint forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr -> do
String
progName <- IO String
getProgName
forall r. HPrintfType r => Handle -> String -> r
hPrintf Handle
stderr String
"usage: %s [options] <mountpoint>\n" String
progName
forall r. HPrintfType r => Handle -> String -> r
hPrintf Handle
stderr String
" %s --help\n" String
progName
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ Int -> ExitCode
ExitFailure Int
1
| Bool
otherwise -> do
String
mountPoint <- CString -> IO String
peekFilePath CString
pMountPoint
Bool
foreground <- (forall a. Eq a => a -> a -> Bool
/= (CInt
0 :: CInt)) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((\Ptr b
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr b
hsc_ptr Int
4)) Ptr b
pOpts
{-# LINE 863 "src/System/LibFuse3/Internal.hsc" #-}
c
cloneFd <- ((\Ptr b
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr b
hsc_ptr Int
32)) Ptr b
pOpts
{-# LINE 864 "src/System/LibFuse3/Internal.hsc" #-}
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right (Bool
foreground, String
mountPoint, c
cloneFd)
fuseParseCommandLineOrExit :: Ptr C.FuseArgs -> IO FuseMainArgs
fuseParseCommandLineOrExit :: Ptr FuseArgs -> IO FuseMainArgs
fuseParseCommandLineOrExit Ptr FuseArgs
pArgs = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. ExitCode -> IO a
exitWith forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr FuseArgs -> IO (Either ExitCode FuseMainArgs)
fuseParseCommandLine Ptr FuseArgs
pArgs
fuseDaemonize :: ResourceT IO a -> ResourceT IO b
fuseDaemonize :: forall a b. ResourceT IO a -> ResourceT IO b
fuseDaemonize ResourceT IO a
job = forall a b. ResourceT IO a -> ResourceT IO b
daemonizeResourceT forall a b. (a -> b) -> a -> b
$ do
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
ProcessGroupID
_ <- IO ProcessGroupID
createSession
String -> IO ()
changeWorkingDirectory String
"/"
forall r. String -> IOMode -> (Handle -> IO r) -> IO r
withFile String
"/dev/null" IOMode
WriteMode forall a b. (a -> b) -> a -> b
$ \Handle
devNullOut -> do
Handle -> Handle -> IO ()
hDuplicateTo Handle
devNullOut Handle
stdout
Handle -> Handle -> IO ()
hDuplicateTo Handle
devNullOut Handle
stderr
forall r. String -> IOMode -> (Handle -> IO r) -> IO r
withFile String
"/dev/null" IOMode
ReadMode forall a b. (a -> b) -> a -> b
$ \Handle
devNullIn -> do
Handle -> Handle -> IO ()
hDuplicateTo Handle
devNullIn Handle
stdin
a
_ <- ResourceT IO a
job
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. IO a
exitSuccess
withSignalHandlers :: IO () -> IO a -> IO a
withSignalHandlers :: forall a. IO () -> IO a -> IO a
withSignalHandlers IO ()
exitHandler = forall a b c. IO a -> IO b -> IO c -> IO c
bracket_ IO ()
setHandlers IO ()
resetHandlers
where
setHandlers :: IO ()
setHandlers = do
let sigHandler :: Handler
sigHandler = IO () -> Handler
Signals.Catch IO ()
exitHandler
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigINT Handler
sigHandler forall a. Maybe a
Nothing
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigHUP Handler
sigHandler forall a. Maybe a
Nothing
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigTERM Handler
sigHandler forall a. Maybe a
Nothing
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigPIPE Handler
Signals.Ignore forall a. Maybe a
Nothing
resetHandlers :: IO ()
resetHandlers = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigINT Handler
Signals.Default forall a. Maybe a
Nothing
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigHUP Handler
Signals.Default forall a. Maybe a
Nothing
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigTERM Handler
Signals.Default forall a. Maybe a
Nothing
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ CInt -> Handler -> Maybe SignalSet -> IO Handler
Signals.installHandler CInt
Signals.sigPIPE Handler
Signals.Default forall a. Maybe a
Nothing
type FuseMainArgs = (Bool, String, CInt)
fuseMainReal
:: Ptr C.StructFuse
-> FuseMainArgs
-> ResourceT IO a
fuseMainReal :: forall a. Ptr StructFuse -> FuseMainArgs -> ResourceT IO a
fuseMainReal = \Ptr StructFuse
pFuse (Bool
foreground, String
mountPt, CInt
cloneFd) -> do
let run :: IO a -> ResourceT IO a
run = if Bool
foreground
then \IO a
io -> forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ String -> IO ()
changeWorkingDirectory String
"/" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> IO a
io
else forall a b. ResourceT IO a -> ResourceT IO b
fuseDaemonize forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
CString
cMountPt <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ String -> ResourceT IO (ReleaseKey, CString)
resNewFilePath String
mountPt
CInt
mountResult <- forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
MonadResource m =>
IO a -> (a -> IO ()) -> m (ReleaseKey, a)
Res.allocate (Ptr StructFuse -> CUnlink
C.fuse_mount Ptr StructFuse
pFuse CString
cMountPt) (\CInt
_ -> Ptr StructFuse -> IO ()
C.fuse_unmount Ptr StructFuse
pFuse)
if CInt
mountResult forall a. Eq a => a -> a -> Bool
== CInt
0
then forall {a}. IO a -> ResourceT IO a
run forall a b. (a -> b) -> a -> b
$ forall {b}. Ptr StructFuse -> CInt -> IO b
procMain Ptr StructFuse
pFuse CInt
cloneFd
else forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"fuse_mount failed"
where
procMain :: Ptr StructFuse -> CInt -> IO b
procMain Ptr StructFuse
pFuse CInt
cloneFd = do
Ptr FuseSession
session <- Ptr StructFuse -> IO (Ptr FuseSession)
C.fuse_get_session Ptr StructFuse
pFuse
forall a. IO () -> IO a -> IO a
withSignalHandlers (Ptr FuseSession -> IO ()
C.fuse_session_exit Ptr FuseSession
session) forall a b. (a -> b) -> a -> b
$ do
Int
retVal <- Ptr StructFuse -> CInt -> IO Int
C.fuse_loop_mt_31 Ptr StructFuse
pFuse CInt
cloneFd
if Int
retVal forall a. Eq a => a -> a -> Bool
== Int
0
then forall a. IO a
exitSuccess
else forall a. IO a
exitFailure
fuseRun :: Exception e => String -> [String] -> FuseOperations fh dh -> ExceptionHandler e -> IO a
fuseRun :: forall e fh dh a.
Exception e =>
String
-> [String] -> FuseOperations fh dh -> ExceptionHandler e -> IO a
fuseRun String
prog [String]
args FuseOperations fh dh
ops ExceptionHandler e
handler = forall (m :: * -> *) a. MonadUnliftIO m => ResourceT m a -> m a
runResourceT forall a b. (a -> b) -> a -> b
$ do
Ptr FuseArgs
pArgs <- String -> [String] -> ResourceT IO (Ptr FuseArgs)
resFuseArgs String
prog [String]
args
FuseMainArgs
mainArgs <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr FuseArgs -> IO FuseMainArgs
fuseParseCommandLineOrExit Ptr FuseArgs
pArgs
Ptr FuseOperations
pOp <- forall fh dh e.
Exception e =>
FuseOperations fh dh
-> ExceptionHandler e -> ResourceT IO (Ptr FuseOperations)
resCFuseOperations FuseOperations fh dh
ops ExceptionHandler e
handler
Ptr StructFuse
pFuse <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
MonadResource m =>
IO a -> (a -> IO ()) -> m (ReleaseKey, a)
Res.allocate
(forall a.
Ptr FuseArgs
-> Ptr FuseOperations -> ByteCount -> Ptr a -> IO (Ptr StructFuse)
C.fuse_new Ptr FuseArgs
pArgs Ptr FuseOperations
pOp ((ByteCount
336)) forall a. Ptr a
nullPtr)
{-# LINE 956 "src/System/LibFuse3/Internal.hsc" #-}
(\p -> unless (p == nullPtr) $ C.fuse_destroy p)
if Ptr StructFuse
pFuse forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
then forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a. IO a
exitFailure
else forall a. Ptr StructFuse -> FuseMainArgs -> ResourceT IO a
fuseMainReal Ptr StructFuse
pFuse FuseMainArgs
mainArgs
fuseMain :: Exception e => FuseOperations fh dh -> ExceptionHandler e -> IO ()
fuseMain :: forall e fh dh.
Exception e =>
FuseOperations fh dh -> ExceptionHandler e -> IO ()
fuseMain FuseOperations fh dh
ops ExceptionHandler e
handler = do
String
prog <- IO String
getProgName
[String]
args <- IO [String]
getArgs
forall e fh dh a.
Exception e =>
String
-> [String] -> FuseOperations fh dh -> ExceptionHandler e -> IO a
fuseRun String
prog [String]
args FuseOperations fh dh
ops ExceptionHandler e
handler
type ExceptionHandler e = e -> IO Errno
defaultExceptionHandler :: ExceptionHandler SomeException
defaultExceptionHandler :: ExceptionHandler SomeException
defaultExceptionHandler SomeException
e = Handle -> String -> IO ()
hPutStrLn Handle
stderr (forall a. Show a => a -> String
show SomeException
e) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (f :: * -> *) a. Applicative f => a -> f a
pure Errno
eIO
where
_dummyToSuppressWarnings :: t
_dummyToSuppressWarnings = forall a. HasCallStack => String -> a
error String
"dummy" Errno
eFAULT
getFH :: Ptr C.FuseFileInfo -> IO (Maybe fh)
getFH :: forall fh. Ptr FuseFileInfo -> IO (Maybe fh)
getFH Ptr FuseFileInfo
pFuseFileInfo
| Ptr FuseFileInfo
pFuseFileInfo forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
| Bool
otherwise = do
Ptr ()
sptr <- ((\Ptr FuseFileInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr FuseFileInfo
hsc_ptr Int
16)) Ptr FuseFileInfo
pFuseFileInfo
{-# LINE 1000 "src/System/LibFuse3/Internal.hsc" #-}
if Ptr ()
sptr forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
then forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
else forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. StablePtr a -> IO a
deRefStablePtr forall a b. (a -> b) -> a -> b
$ forall a. Ptr () -> StablePtr a
castPtrToStablePtr Ptr ()
sptr
getFHJust :: Ptr C.FuseFileInfo -> IO fh
getFHJust :: forall fh. Ptr FuseFileInfo -> IO fh
getFHJust = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. HasCallStack => Maybe a -> a
fromJust forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall fh. Ptr FuseFileInfo -> IO (Maybe fh)
getFH
newFH :: Ptr C.FuseFileInfo -> fh -> IO ()
newFH :: forall fh. Ptr FuseFileInfo -> fh -> IO ()
newFH Ptr FuseFileInfo
pFuseFileInfo fh
fh = do
StablePtr fh
sptr <- forall a. a -> IO (StablePtr a)
newStablePtr fh
fh
((\Ptr FuseFileInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr FuseFileInfo
hsc_ptr Int
16)) Ptr FuseFileInfo
pFuseFileInfo forall a b. (a -> b) -> a -> b
$ forall a. StablePtr a -> Ptr ()
castStablePtrToPtr StablePtr fh
sptr
{-# LINE 1033 "src/System/LibFuse3/Internal.hsc" #-}
delFH :: Ptr C.FuseFileInfo -> IO ()
delFH :: Ptr FuseFileInfo -> IO ()
delFH Ptr FuseFileInfo
pFuseFileInfo = do
Ptr ()
sptr <- ((\Ptr FuseFileInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr FuseFileInfo
hsc_ptr Int
16)) Ptr FuseFileInfo
pFuseFileInfo
{-# LINE 1038 "src/System/LibFuse3/Internal.hsc" #-}
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Ptr ()
sptr forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr) forall a b. (a -> b) -> a -> b
$
forall a. StablePtr a -> IO ()
freeStablePtr forall a b. (a -> b) -> a -> b
$ forall a. Ptr () -> StablePtr a
castPtrToStablePtr Ptr ()
sptr
foreign import ccall "dynamic"
peekFuseFillDir :: FunPtr C.FuseFillDir -> C.FuseFillDir