{-# OPTIONS_GHC -optc-D__USE_GNU #-}
{-# LINE 1 "Foundation/System/Bindings/Linux.hsc" #-}
-----------------------------------------------------------------------------
{-# LINE 2 "Foundation/System/Bindings/Linux.hsc" #-}
-- |
-- Module      :  Foundation.System.Bindings.Linux
-- Copyright   :  (c) Vincent Hanquez 2014-2017
-- License     :  BSD-style
--
-- Maintainer  :  Vincent Hanquez
-- Stability   :  provisional
-- Portability :  non-portable (requires Linux)
--
-- Functions defined only for linux
--
-----------------------------------------------------------------------------
{-# OPTIONS_HADDOCK hide #-}
module Foundation.System.Bindings.Linux
   where

import Foundation.Internal.Base
import Foreign.C.Types
import Foundation.System.Bindings.PosixDef


{-# LINE 23 "Foundation/System/Bindings/Linux.hsc" #-}


{-# LINE 25 "Foundation/System/Bindings/Linux.hsc" #-}

{-# LINE 26 "Foundation/System/Bindings/Linux.hsc" #-}

{-# LINE 27 "Foundation/System/Bindings/Linux.hsc" #-}

type CInotifyFlags = CInt
type CInotifyMask = CInt
type CWatchDescriptor = CInt

sysLinux_O_TMPFILE
    :: COpenFlags

{-# LINE 35 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_O_TMPFILE   = (4259840)
{-# LINE 36 "Foundation/System/Bindings/Linux.hsc" #-}

{-# LINE 39 "Foundation/System/Bindings/Linux.hsc" #-}


{-# LINE 41 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_NONBLOCK :: CInotifyFlags
sysLinux_IN_NONBLOCK = (2048)
{-# LINE 43 "Foundation/System/Bindings/Linux.hsc" #-}

{-# LINE 44 "Foundation/System/Bindings/Linux.hsc" #-}


{-# LINE 46 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_CLOEXEC :: CInotifyFlags
sysLinux_IN_CLOEXEC  = (524288)
{-# LINE 48 "Foundation/System/Bindings/Linux.hsc" #-}

{-# LINE 49 "Foundation/System/Bindings/Linux.hsc" #-}

sysLinux_IN_ACCESS
    , sysLinux_IN_ATTRIB
    , sysLinux_IN_CLOSE_WRITE
    , sysLinux_IN_CLOSE_NOWRITE
    , sysLinux_IN_CREATE
    , sysLinux_IN_DELETE
    , sysLinux_IN_DELETE_SELF
    , sysLinux_IN_MODIFY
    , sysLinux_IN_MOVE_SELF
    , sysLinux_IN_MOVED_FROM
    , sysLinux_IN_MOVED_TO :: CInotifyMask
sysLinux_IN_ACCESS = (1)
{-# LINE 62 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_ATTRIB = (4)
{-# LINE 63 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_CLOSE_WRITE = (8)
{-# LINE 64 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_CLOSE_NOWRITE = (16)
{-# LINE 65 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_CREATE = (256)
{-# LINE 66 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_DELETE = (512)
{-# LINE 67 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_DELETE_SELF = (1024)
{-# LINE 68 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_MODIFY = (2)
{-# LINE 69 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_MOVE_SELF = (2048)
{-# LINE 70 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_MOVED_FROM = (64)
{-# LINE 71 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_MOVED_TO = (128)
{-# LINE 72 "Foundation/System/Bindings/Linux.hsc" #-}

-- extra mask at add_watch time
sysLinux_IN_OPEN
    , sysLinux_IN_DONT_FOLLOW
    , sysLinux_IN_MASK_ADD
    , sysLinux_IN_ONESHOT
    , sysLinux_IN_ONLYDIR :: CInotifyMask
sysLinux_IN_OPEN = (32)
{-# LINE 80 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_DONT_FOLLOW = (33554432)
{-# LINE 81 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_MASK_ADD = (536870912)
{-# LINE 82 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_ONESHOT = (2147483648)
{-# LINE 83 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_ONLYDIR = (16777216)
{-# LINE 84 "Foundation/System/Bindings/Linux.hsc" #-}


{-# LINE 86 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_EXCL_UNLINK :: CInotifyMask
sysLinux_IN_EXCL_UNLINK = (67108864)
{-# LINE 88 "Foundation/System/Bindings/Linux.hsc" #-}

{-# LINE 89 "Foundation/System/Bindings/Linux.hsc" #-}

-- only found in mask
sysLinux_IN_IGNORED
    , sysLinux_IN_ISDIR
    , sysLinux_IN_Q_OVERFLOW
    , sysLinux_IN_UNMOUNT :: CInotifyMask
sysLinux_IN_IGNORED = (32768)
{-# LINE 96 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_ISDIR = (1073741824)
{-# LINE 97 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_Q_OVERFLOW = (16384)
{-# LINE 98 "Foundation/System/Bindings/Linux.hsc" #-}
sysLinux_IN_UNMOUNT = (8192)
{-# LINE 99 "Foundation/System/Bindings/Linux.hsc" #-}

cinotifyEventSize :: CSize
cinotifyEventSize = 16

foreign import ccall unsafe "inotify_init1"
    sysLinuxInotifyInit :: CInotifyFlags -> IO CFd
foreign import ccall unsafe "inotify_add_watch"
    sysLinuxInotifyAddWatch :: CFd -> Ptr CChar -> CInotifyMask -> IO CWatchDescriptor
foreign import ccall unsafe "inotify_rm_watch"
    sysLinuxInotifyRmWatch :: CFd -> CWatchDescriptor -> IO Int