-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | POSIX functionality
--   
--   This package gives you access to the set of operating system services
--   standardised by <a>POSIX.1-2008</a> (or the IEEE Portable Operating
--   System Interface for Computing Environments - IEEE Std. 1003.1).
--   
--   The package is not supported under Windows.
@package unix
@version 2.8.5.1


-- | Internal stuff: support for ByteString FilePaths
module System.Posix.ByteString.FilePath

-- | A literal POSIX file path
type RawFilePath = ByteString
withFilePath :: RawFilePath -> (CString -> IO a) -> IO a
peekFilePath :: CString -> IO RawFilePath
peekFilePathLen :: CStringLen -> IO RawFilePath
throwErrnoPathIfMinus1Retry :: (Eq a, Num a) => String -> RawFilePath -> IO a -> IO a
throwErrnoPathIfMinus1Retry_ :: (Eq a, Num a) => String -> RawFilePath -> IO a -> IO ()
throwErrnoPathIfNullRetry :: String -> RawFilePath -> IO (Ptr a) -> IO (Ptr a)
throwErrnoPathIfRetry :: (a -> Bool) -> String -> RawFilePath -> IO a -> IO a

-- | as <a>throwErrno</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPath :: String -> RawFilePath -> IO a

-- | as <a>throwErrnoIf</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIf :: (a -> Bool) -> String -> RawFilePath -> IO a -> IO a

-- | as <a>throwErrnoIf_</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIf_ :: (a -> Bool) -> String -> RawFilePath -> IO a -> IO ()

-- | as <a>throwErrnoIfNull</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIfNull :: String -> RawFilePath -> IO (Ptr a) -> IO (Ptr a)

-- | as <a>throwErrnoIfMinus1</a>, but exceptions include the given path
--   when appropriate.
throwErrnoPathIfMinus1 :: (Eq a, Num a) => String -> RawFilePath -> IO a -> IO a

-- | as <a>throwErrnoIfMinus1_</a>, but exceptions include the given path
--   when appropriate.
throwErrnoPathIfMinus1_ :: (Eq a, Num a) => String -> RawFilePath -> IO a -> IO ()

-- | as <a>throwErrnoTwoPathsIfMinus1_</a>, but exceptions include two
--   paths when appropriate.
throwErrnoTwoPathsIfMinus1_ :: (Eq a, Num a) => String -> RawFilePath -> RawFilePath -> IO a -> IO ()


-- | String-based POSIX directory support
module System.Posix.Directory.ByteString

-- | <tt>createDirectory dir mode</tt> calls <tt>mkdir</tt> to create a new
--   directory, <tt>dir</tt>, with permissions based on <tt>mode</tt>.
createDirectory :: RawFilePath -> FileMode -> IO ()
removeDirectory :: RawFilePath -> IO ()
data DirStream

-- | <tt>openDirStream dir</tt> calls <tt>opendir</tt> to obtain a
--   directory stream for <tt>dir</tt>.
openDirStream :: RawFilePath -> IO DirStream

-- | <tt>readDirStream dp</tt> calls <tt>readdir</tt> to obtain the next
--   directory entry (<tt>struct dirent</tt>) for the open directory stream
--   <tt>dp</tt>, and returns the <tt>d_name</tt> member of that structure.
--   
--   Note that this function returns an empty filepath if the end of the
--   directory stream is reached. For a safer alternative use
--   <a>readDirStreamMaybe</a>.
readDirStream :: DirStream -> IO RawFilePath

-- | <tt>readDirStreamMaybe dp</tt> calls <tt>readdir</tt> to obtain the
--   next directory entry (<tt>struct dirent</tt>) for the open directory
--   stream <tt>dp</tt>. It returns the <tt>d_name</tt> member of that
--   structure wrapped in a <tt>Just d_name</tt> if an entry was read and
--   <tt>Nothing</tt> if the end of the directory stream was reached.
readDirStreamMaybe :: DirStream -> IO (Maybe RawFilePath)

-- | <tt>rewindDirStream dp</tt> calls <tt>rewinddir</tt> to reposition the
--   directory stream <tt>dp</tt> at the beginning of the directory.
rewindDirStream :: DirStream -> IO ()

-- | <tt>closeDirStream dp</tt> calls <tt>closedir</tt> to close the
--   directory stream <tt>dp</tt>.
closeDirStream :: DirStream -> IO ()
data DirStreamOffset
tellDirStream :: DirStream -> IO DirStreamOffset
seekDirStream :: DirStream -> DirStreamOffset -> IO ()

-- | <tt>getWorkingDirectory</tt> calls <tt>getcwd</tt> to obtain the name
--   of the current working directory.
getWorkingDirectory :: IO RawFilePath

-- | <tt>changeWorkingDirectory dir</tt> calls <tt>chdir</tt> to change the
--   current working directory to <tt>dir</tt>.
changeWorkingDirectory :: RawFilePath -> IO ()
changeWorkingDirectoryFd :: Fd -> IO ()

module System.Posix.Directory.Fd

-- | Call <tt>fdopendir</tt> to obtain a directory stream for <tt>fd</tt>.
--   <tt>fd</tt> must not be otherwise used after this.
--   
--   On success, it is owned by the returned <a>DirStream</a>, which should
--   be closed via <a>closeDirStream</a> when no longer needed. On error,
--   the file descriptor is automatically closed and then an exception is
--   thrown. There is no code path in which the file descriptor remains
--   open and yet not owned by a returned <a>DirStream</a>.
--   
--   The input file descriptor must not have been used with
--   <tt>threadWaitRead</tt> or <tt>threadWaitWrite</tt>.
unsafeOpenDirStreamFd :: Fd -> IO DirStream


-- | POSIX directory support (internal module, no PVP guarantees)
module System.Posix.Directory.Internals
newtype DirStream
DirStream :: Ptr CDir -> DirStream
data CDir
data CDirent
newtype DirStreamOffset
DirStreamOffset :: COff -> DirStreamOffset


-- | <tt>dlopen(3)</tt> and friends Derived from <tt>GModule.chs</tt> by
--   M.Weber &amp; M.Chakravarty which is part of c2hs. I left the API more
--   or less the same, mostly the flags are different.
module System.Posix.DynamicLinker.Prim
c_dlopen :: CString -> CInt -> IO (Ptr ())
c_dlsym :: Ptr () -> CString -> IO (FunPtr a)
c_dlerror :: IO CString
c_dlclose :: Ptr () -> IO CInt

-- | On some hosts (e.g. SuSe and Ubuntu Linux) <tt>RTLD_NEXT</tt> (and
--   <tt>RTLD_DEFAULT</tt>) are not visible without setting the macro
--   <tt>_GNU_SOURCE</tt>. Since we don't want to define this macro, you
--   can use the function <a>haveRtldNext</a> to check whether the flag
--   <a>Next</a> is available. Ideally, this will be optimized by the
--   compiler so that it should be as efficient as an <tt>#ifdef</tt>.
--   
--   If you fail to test the flag and use it although it is undefined,
--   <a>packDL</a> will throw an error.
haveRtldNext :: Bool

-- | <i>Deprecated: defaults to True</i>
haveRtldLocal :: Bool
packRTLDFlags :: [RTLDFlags] -> CInt

-- | Flags for <a>dlopen</a>.
data RTLDFlags
RTLD_LAZY :: RTLDFlags
RTLD_NOW :: RTLDFlags
RTLD_GLOBAL :: RTLDFlags
RTLD_LOCAL :: RTLDFlags
packDL :: DL -> Ptr ()

-- | Flags for <a>dlsym</a>. Notice that <a>Next</a> might not be available
--   on your particular platform! Use <a>haveRtldNext</a>.
--   
--   If <tt>RTLD_DEFAULT</tt> is not defined on your platform,
--   <a>packDL</a> <a>Default</a> reduces to <a>nullPtr</a>.
data DL
Null :: DL
Next :: DL
Default :: DL
DLHandle :: Ptr () -> DL
instance GHC.Internal.Read.Read System.Posix.DynamicLinker.Prim.RTLDFlags
instance GHC.Internal.Show.Show System.Posix.DynamicLinker.Prim.DL
instance GHC.Internal.Show.Show System.Posix.DynamicLinker.Prim.RTLDFlags


-- | Dynamic linker support through dlopen()
module System.Posix.DynamicLinker.ByteString
dlopen :: RawFilePath -> [RTLDFlags] -> IO DL

-- | <a>dlsym</a> returns the address binding of the symbol described in
--   <tt>symbol</tt>, as it occurs in the shared object identified by
--   <tt>source</tt>.
dlsym :: DL -> String -> IO (FunPtr a)
dlerror :: IO String
dlclose :: DL -> IO ()
withDL :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO a
withDL_ :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO ()

-- | <a>undl</a> obtains the raw handle. You mustn't do something like
--   <tt>withDL mod flags $ liftM undl &gt;&gt;= p -&gt; use p</tt>
undl :: DL -> Ptr ()


-- | Dynamic linker support through dlopen()
module System.Posix.DynamicLinker
dlopen :: FilePath -> [RTLDFlags] -> IO DL

-- | <a>dlsym</a> returns the address binding of the symbol described in
--   <tt>symbol</tt>, as it occurs in the shared object identified by
--   <tt>source</tt>.
dlsym :: DL -> String -> IO (FunPtr a)
dlerror :: IO String
dlclose :: DL -> IO ()
withDL :: FilePath -> [RTLDFlags] -> (DL -> IO a) -> IO a
withDL_ :: FilePath -> [RTLDFlags] -> (DL -> IO a) -> IO ()

-- | <a>undl</a> obtains the raw handle. You mustn't do something like
--   <tt>withDL mod flags $ liftM undl &gt;&gt;= p -&gt; use p</tt>
undl :: DL -> Ptr ()


-- | DLOpen support, old API Derived from GModule.chs by M.Weber &amp;
--   M.Chakravarty which is part of c2hs I left the API more or less the
--   same, mostly the flags are different.
module System.Posix.DynamicLinker.Module
data Module
moduleOpen :: String -> [RTLDFlags] -> IO Module
moduleSymbol :: Module -> String -> IO (FunPtr a)
moduleClose :: Module -> IO ()
moduleError :: IO String
withModule :: Maybe String -> String -> [RTLDFlags] -> (Module -> IO a) -> IO a
withModule_ :: Maybe String -> String -> [RTLDFlags] -> (Module -> IO a) -> IO ()


-- | DLOpen support, old API Derived from GModule.chs by M.Weber &amp;
--   M.Chakravarty which is part of c2hs I left the API more or less the
--   same, mostly the flags are different.
module System.Posix.DynamicLinker.Module.ByteString
data Module
moduleOpen :: RawFilePath -> [RTLDFlags] -> IO Module
moduleSymbol :: Module -> String -> IO (FunPtr a)
moduleClose :: Module -> IO ()
moduleError :: IO String
withModule :: Maybe String -> String -> [RTLDFlags] -> (Module -> IO a) -> IO a
withModule_ :: Maybe String -> String -> [RTLDFlags] -> (Module -> IO a) -> IO ()


-- | POSIX environment support
module System.Posix.Env

-- | <a>getEnv</a> looks up a variable in the environment.
getEnv :: String -> IO (Maybe String)

-- | <a>getEnvDefault</a> is a wrapper around <a>getEnv</a> where the
--   programmer can specify a fallback if the variable is not found in the
--   environment.
getEnvDefault :: String -> String -> IO String
getEnvironmentPrim :: IO [String]

-- | <a>getEnvironment</a> retrieves the entire environment as a list of
--   <tt>(key,value)</tt> pairs.
getEnvironment :: IO [(String, String)]

-- | <a>setEnvironment</a> resets the entire environment to the given list
--   of <tt>(key,value)</tt> pairs.
setEnvironment :: [(String, String)] -> IO ()

-- | <a>putEnv</a> function takes an argument of the form
--   <tt>name=value</tt> and is equivalent to
--   <tt>setEnv(key,value,True{-overwrite-})</tt>.
putEnv :: String -> IO ()

-- | The <a>setEnv</a> function inserts or resets the environment variable
--   name in the current environment list. If the variable <tt>name</tt>
--   does not exist in the list, it is inserted with the given value. If
--   the variable does exist, the argument <tt>overwrite</tt> is tested; if
--   <tt>overwrite</tt> is <tt>False</tt>, the variable is not reset,
--   otherwise it is reset to the given value.
setEnv :: String -> String -> Bool -> IO ()

-- | The <a>unsetEnv</a> function deletes all instances of the variable
--   name from the environment.
unsetEnv :: String -> IO ()

-- | The <a>clearEnv</a> function clears the environment of all name-value
--   pairs.
clearEnv :: IO ()


-- | POSIX environment support
module System.Posix.Env.ByteString

-- | <a>getEnv</a> looks up a variable in the environment.
getEnv :: ByteString -> IO (Maybe ByteString)

-- | <a>getEnvDefault</a> is a wrapper around <a>getEnv</a> where the
--   programmer can specify a fallback as the second argument, which will
--   be used if the variable is not found in the environment.
getEnvDefault :: ByteString -> ByteString -> IO ByteString
getEnvironmentPrim :: IO [ByteString]

-- | <a>getEnvironment</a> retrieves the entire environment as a list of
--   <tt>(key,value)</tt> pairs.
getEnvironment :: IO [(ByteString, ByteString)]

-- | <a>setEnvironment</a> resets the entire environment to the given list
--   of <tt>(key,value)</tt> pairs.
setEnvironment :: [(ByteString, ByteString)] -> IO ()

-- | <a>putEnv</a> function takes an argument of the form
--   <tt>name=value</tt> and is equivalent to
--   <tt>setEnv(key,value,True{-overwrite-})</tt>.
putEnv :: ByteString -> IO ()

-- | The <a>setEnv</a> function inserts or resets the environment variable
--   name in the current environment list. If the variable <tt>name</tt>
--   does not exist in the list, it is inserted with the given value. If
--   the variable does exist, the argument <tt>overwrite</tt> is tested; if
--   <tt>overwrite</tt> is <tt>False</tt>, the variable is not reset,
--   otherwise it is reset to the given value.
setEnv :: ByteString -> ByteString -> Bool -> IO ()

-- | The <a>unsetEnv</a> function deletes all instances of the variable
--   name from the environment.
unsetEnv :: ByteString -> IO ()

-- | The <a>clearEnv</a> function clears the environment of all name-value
--   pairs.
clearEnv :: IO ()

-- | Computation <a>getArgs</a> returns a list of the program's command
--   line arguments (not including the program name), as
--   <a>ByteString</a>s.
--   
--   Unlike <a>getArgs</a>, this function does no Unicode decoding of the
--   arguments; you get the exact bytes that were passed to the program by
--   the OS. To interpret the arguments as text, some Unicode decoding
--   should be applied.
getArgs :: IO [ByteString]


-- | POSIX environment support
module System.Posix.Env.PosixString

-- | <a>getEnv</a> looks up a variable in the environment.
getEnv :: PosixString -> IO (Maybe PosixString)

-- | <a>getEnvDefault</a> is a wrapper around <a>getEnv</a> where the
--   programmer can specify a fallback as the second argument, which will
--   be used if the variable is not found in the environment.
getEnvDefault :: PosixString -> PosixString -> IO PosixString
getEnvironmentPrim :: IO [PosixString]

-- | <a>getEnvironment</a> retrieves the entire environment as a list of
--   <tt>(key,value)</tt> pairs.
getEnvironment :: IO [(PosixString, PosixString)]

-- | <a>setEnvironment</a> resets the entire environment to the given list
--   of <tt>(key,value)</tt> pairs.
setEnvironment :: [(PosixString, PosixString)] -> IO ()

-- | <a>putEnv</a> function takes an argument of the form
--   <tt>name=value</tt> and is equivalent to
--   <tt>setEnv(key,value,True{-overwrite-})</tt>.
putEnv :: PosixString -> IO ()

-- | The <a>setEnv</a> function inserts or resets the environment variable
--   name in the current environment list. If the variable <tt>name</tt>
--   does not exist in the list, it is inserted with the given value. If
--   the variable does exist, the argument <tt>overwrite</tt> is tested; if
--   <tt>overwrite</tt> is <tt>False</tt>, the variable is not reset,
--   otherwise it is reset to the given value.
setEnv :: PosixString -> PosixString -> Bool -> IO ()

-- | The <a>unsetEnv</a> function deletes all instances of the variable
--   name from the environment.
unsetEnv :: PosixString -> IO ()

-- | The <a>clearEnv</a> function clears the environment of all name-value
--   pairs.
clearEnv :: IO ()

-- | Computation <a>getArgs</a> returns a list of the program's command
--   line arguments (not including the program name), as
--   <a>PosixString</a>s.
--   
--   Unlike <a>getArgs</a>, this function does no Unicode decoding of the
--   arguments; you get the exact bytes that were passed to the program by
--   the OS. To interpret the arguments as text, some Unicode decoding
--   should be applied.
getArgs :: IO [PosixString]


-- | POSIX error support
module System.Posix.Error
throwErrnoPath :: String -> FilePath -> IO a
throwErrnoPathIf :: (a -> Bool) -> String -> FilePath -> IO a -> IO a
throwErrnoPathIf_ :: (a -> Bool) -> String -> FilePath -> IO a -> IO ()
throwErrnoPathIfRetry :: (a -> Bool) -> String -> FilePath -> IO a -> IO a
throwErrnoPathIfNull :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)
throwErrnoPathIfNullRetry :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)
throwErrnoPathIfMinus1 :: (Eq a, Num a) => String -> FilePath -> IO a -> IO a
throwErrnoPathIfMinus1_ :: (Eq a, Num a) => String -> FilePath -> IO a -> IO ()
throwErrnoPathIfMinus1Retry :: (Eq a, Num a) => String -> FilePath -> IO a -> IO a
throwErrnoPathIfMinus1Retry_ :: (Eq a, Num a) => String -> FilePath -> IO a -> IO ()


-- | String-based POSIX directory support
module System.Posix.Directory

-- | <tt>createDirectory dir mode</tt> calls <tt>mkdir</tt> to create a new
--   directory, <tt>dir</tt>, with permissions based on <tt>mode</tt>.
createDirectory :: FilePath -> FileMode -> IO ()
removeDirectory :: FilePath -> IO ()
data DirStream

-- | <tt>openDirStream dir</tt> calls <tt>opendir</tt> to obtain a
--   directory stream for <tt>dir</tt>.
openDirStream :: FilePath -> IO DirStream

-- | <tt>readDirStream dp</tt> calls <tt>readdir</tt> to obtain the next
--   directory entry (<tt>struct dirent</tt>) for the open directory stream
--   <tt>dp</tt>, and returns the <tt>d_name</tt> member of that structure.
--   
--   Note that this function returns an empty filepath if the end of the
--   directory stream is reached. For a safer alternative use
--   <a>readDirStreamMaybe</a>.
readDirStream :: DirStream -> IO FilePath

-- | <tt>readDirStreamMaybe dp</tt> calls <tt>readdir</tt> to obtain the
--   next directory entry (<tt>struct dirent</tt>) for the open directory
--   stream <tt>dp</tt>. It returns the <tt>d_name</tt> member of that
--   structure wrapped in a <tt>Just d_name</tt> if an entry was read and
--   <tt>Nothing</tt> if the end of the directory stream was reached.
readDirStreamMaybe :: DirStream -> IO (Maybe FilePath)

-- | <tt>rewindDirStream dp</tt> calls <tt>rewinddir</tt> to reposition the
--   directory stream <tt>dp</tt> at the beginning of the directory.
rewindDirStream :: DirStream -> IO ()

-- | <tt>closeDirStream dp</tt> calls <tt>closedir</tt> to close the
--   directory stream <tt>dp</tt>.
closeDirStream :: DirStream -> IO ()
data DirStreamOffset
tellDirStream :: DirStream -> IO DirStreamOffset
seekDirStream :: DirStream -> DirStreamOffset -> IO ()

-- | <tt>getWorkingDirectory</tt> calls <tt>getcwd</tt> to obtain the name
--   of the current working directory.
getWorkingDirectory :: IO FilePath

-- | <tt>changeWorkingDirectory dir</tt> calls <tt>chdir</tt> to change the
--   current working directory to <tt>dir</tt>.
changeWorkingDirectory :: FilePath -> IO ()
changeWorkingDirectoryFd :: Fd -> IO ()


-- | POSIX file control support
module System.Posix.Fcntl

-- | Advice parameter for <a>fileAdvise</a> operation.
--   
--   For more details, see documentation of <tt>posix_fadvise(2)</tt>.
data Advice
AdviceNormal :: Advice
AdviceRandom :: Advice
AdviceSequential :: Advice
AdviceWillNeed :: Advice
AdviceDontNeed :: Advice
AdviceNoReuse :: Advice

-- | Performs <tt>posix_fadvise(2)</tt> operation on file-descriptor.
--   
--   If platform does not provide <tt>posix_fadvise(2)</tt>
--   <a>fileAdvise</a> becomes a no-op.
--   
--   (use <tt>#if HAVE_POSIX_FADVISE</tt> CPP guard to detect availability)
fileAdvise :: Fd -> FileOffset -> FileOffset -> Advice -> IO ()

-- | Performs <tt>posix_fallocate(2)</tt> operation on file-descriptor.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>posix_fallocate(2)</tt>.
--   
--   (use <tt>#if HAVE_POSIX_FALLOCATE</tt> CPP guard to detect
--   availability).
fileAllocate :: Fd -> FileOffset -> FileOffset -> IO ()
instance GHC.Classes.Eq System.Posix.Fcntl.Advice


-- | Functions defined by the POSIX standards for manipulating and querying
--   the file system. Names of underlying POSIX functions are indicated
--   whenever possible. A more complete documentation of the POSIX
--   functions together with a more detailed description of different error
--   conditions are usually available in the system's manual pages or from
--   <a>http://www.unix.org/version3/online.html</a> (free registration
--   required).
--   
--   When a function that calls an underlying POSIX function fails, the
--   errno code is converted to an <a>IOError</a> using
--   <a>errnoToIOError</a>. For a list of which errno codes may be
--   generated, consult the POSIX documentation for the underlying
--   function.
module System.Posix.Files.ByteString

-- | Combines the two file modes into one that contains modes that appear
--   in either.
unionFileModes :: FileMode -> FileMode -> FileMode

-- | Combines two file modes into one that only contains modes that appear
--   in both.
intersectFileModes :: FileMode -> FileMode -> FileMode

-- | No permissions.
nullFileMode :: FileMode

-- | Owner has read permission.
ownerReadMode :: FileMode

-- | Owner has write permission.
ownerWriteMode :: FileMode

-- | Owner has execute permission.
ownerExecuteMode :: FileMode

-- | Owner has read, write and execute permission.
ownerModes :: FileMode

-- | Group has read permission.
groupReadMode :: FileMode

-- | Group has write permission.
groupWriteMode :: FileMode

-- | Group has execute permission.
groupExecuteMode :: FileMode

-- | Group has read, write and execute permission.
groupModes :: FileMode

-- | Others have read permission.
otherReadMode :: FileMode

-- | Others have write permission.
otherWriteMode :: FileMode

-- | Others have execute permission.
otherExecuteMode :: FileMode

-- | Others have read, write and execute permission.
otherModes :: FileMode

-- | Set user ID on execution.
setUserIDMode :: FileMode

-- | Set group ID on execution.
setGroupIDMode :: FileMode

-- | Owner, group and others have read and write permission.
stdFileMode :: FileMode

-- | Owner, group and others have read, write and execute permission.
accessModes :: FileMode
fileTypeModes :: FileMode
blockSpecialMode :: FileMode
characterSpecialMode :: FileMode
namedPipeMode :: FileMode
regularFileMode :: FileMode
directoryMode :: FileMode
symbolicLinkMode :: FileMode
socketMode :: FileMode

-- | <tt>setFileMode path mode</tt> changes permission of the file given by
--   <tt>path</tt> to <tt>mode</tt>. This operation may fail with
--   <a>throwErrnoPathIfMinus1_</a> if <tt>path</tt> doesn't exist or if
--   the effective user ID of the current process is not that of the file's
--   owner.
--   
--   Note: calls <tt>chmod</tt>.
setFileMode :: RawFilePath -> FileMode -> IO ()

-- | <tt>setFdMode fd mode</tt> acts like <tt>setFileMode</tt> but uses a
--   file descriptor <tt>fd</tt> instead of a <a>FilePath</a>.
--   
--   Note: calls <tt>fchmod</tt>.
setFdMode :: Fd -> FileMode -> IO ()

-- | <tt>setFileCreationMask mode</tt> sets the file mode creation mask to
--   <tt>mode</tt>. Modes set by this operation are subtracted from files
--   and directories upon creation. The previous file creation mask is
--   returned.
--   
--   Note: calls <tt>umask</tt>.
setFileCreationMask :: FileMode -> IO FileMode

-- | <tt>fileAccess name read write exec</tt> checks if the file (or other
--   file system object) <tt>name</tt> can be accessed for reading, writing
--   and/or executing. To check a permission set the corresponding argument
--   to <a>True</a>.
--   
--   Note: calls <tt>access</tt>.
fileAccess :: RawFilePath -> Bool -> Bool -> Bool -> IO Bool

-- | Checks for the existence of the file.
--   
--   Note: calls <tt>access</tt>.
fileExist :: RawFilePath -> IO Bool

-- | POSIX defines operations to get information, such as owner,
--   permissions, size and access times, about a file. This information is
--   represented by the <a>FileStatus</a> type.
--   
--   Note: see <tt>chmod</tt>.
--   
--   Limitations: Support for high resolution timestamps is filesystem
--   dependent:
--   
--   <ul>
--   <li>HFS+ volumes on OS X only support whole-second times.</li>
--   </ul>
data FileStatus

-- | <tt>getFileStatus path</tt> calls gets the <tt>FileStatus</tt>
--   information (user ID, size, access times, etc.) for the file
--   <tt>path</tt>.
--   
--   Note: calls <tt>stat</tt>.
getFileStatus :: RawFilePath -> IO FileStatus

-- | <tt>getFdStatus fd</tt> acts as <tt>getFileStatus</tt> but uses a file
--   descriptor <tt>fd</tt>.
--   
--   Note: calls <tt>fstat</tt>.
getFdStatus :: Fd -> IO FileStatus

-- | Acts as <a>getFileStatus</a> except when the <a>RawFilePath</a> refers
--   to a symbolic link. In that case the <tt>FileStatus</tt> information
--   of the symbolic link itself is returned instead of that of the file it
--   points to.
--   
--   Note: calls <tt>lstat</tt>.
getSymbolicLinkStatus :: RawFilePath -> IO FileStatus

-- | ID of the device on which this file resides.
deviceID :: FileStatus -> DeviceID

-- | inode number
fileID :: FileStatus -> FileID

-- | File mode (such as permissions).
fileMode :: FileStatus -> FileMode

-- | Number of hard links to this file.
linkCount :: FileStatus -> LinkCount

-- | ID of owner.
fileOwner :: FileStatus -> UserID

-- | ID of group.
fileGroup :: FileStatus -> GroupID

-- | Describes the device that this file represents.
specialDeviceID :: FileStatus -> DeviceID

-- | Size of the file in bytes. If this file is a symbolic link the size is
--   the length of the pathname it contains.
fileSize :: FileStatus -> FileOffset

-- | Time of last access.
accessTime :: FileStatus -> EpochTime

-- | Time of last modification.
modificationTime :: FileStatus -> EpochTime

-- | Time of last status change (i.e. owner, group, link count, mode,
--   etc.).
statusChangeTime :: FileStatus -> EpochTime

-- | Time of last access in sub-second resolution. Depends on the timestamp
--   resolution of the underlying filesystem.
accessTimeHiRes :: FileStatus -> POSIXTime

-- | Time of last modification in sub-second resolution. Depends on the
--   timestamp resolution of the underlying filesystem.
modificationTimeHiRes :: FileStatus -> POSIXTime

-- | Time of last status change (i.e. owner, group, link count, mode, etc.)
--   in sub-second resolution. Depends on the timestamp resolution of the
--   underlying filesystem.
statusChangeTimeHiRes :: FileStatus -> POSIXTime

-- | Checks if this file is a block device.
isBlockDevice :: FileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDevice :: FileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipe :: FileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFile :: FileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectory :: FileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLink :: FileStatus -> Bool

-- | Checks if this file is a socket device.
isSocket :: FileStatus -> Bool

-- | Gives the preferred block size for efficient filesystem I/O in bytes.
--   Returns <tt>Nothing</tt> if <tt>st_blocksize</tt> is not supported on
--   this platform.
fileBlockSize :: FileStatus -> Maybe CBlkSize

-- | Number of blocks allocated for this file, in units of 512-bytes.
--   Returns <tt>Nothing</tt> if <tt>st_blocks</tt> is not supported on
--   this platform.
fileBlocks :: FileStatus -> Maybe CBlkCnt
newtype ExtendedFileStatus

-- | The constructor is considered internal and may change.
ExtendedFileStatus :: ForeignPtr CStatx -> ExtendedFileStatus
newtype CAttributes
CAttributes :: Word64 -> CAttributes

-- | Whether <tt>statx</tt> is available on this platform and
--   <tt>getExtendedFileStatus</tt> and related functions will work.
haveStatx :: Bool

-- | Gets extended file status information.
--   
--   The target file to open is identified in one of the following ways:
--   
--   <ul>
--   <li>If <tt>pathname</tt> begins with a slash, then it is an absolute
--   pathname that identifies the target file. In this case, <tt>dirfd</tt>
--   is ignored</li>
--   <li>If <tt>pathname</tt> is a string that begins with a character
--   other than a slash and <tt>dirfd</tt> is a file descriptor that refers
--   to a directory, then pathname is a relative pathname that is
--   interpreted relative to the directory referred to by dirfd. (See
--   <tt>openat(2)</tt> for an explanation of why this is useful.)</li>
--   <li>If <tt>pathname</tt> is an empty string and the <a>EmptyPath</a>
--   flag is specified in flags (see below), then the target file is the
--   one referred to by the file descriptor <tt>dirfd</tt>.</li>
--   </ul>
--   
--   Note: calls <tt>statx</tt>.
getExtendedFileStatus :: Maybe Fd -> RawFilePath -> StatxFlags -> StatxMask -> IO ExtendedFileStatus

-- | Statx flags.
--   
--   See the pattern synonyms for possible flags. These are combined via
--   <a>(&lt;&gt;)</a>. Flags can be tested via <a>(.&amp;.)</a>.
--   
--   The following flags influence pathname-based lookup:
--   
--   <ul>
--   <li><a>EmptyPath</a></li>
--   <li><a>NoAutoMount</a></li>
--   <li><a>SymlinkNoFollow</a></li>
--   </ul>
--   
--   The following flags can be used to control what sort of
--   synchronization the kernel will do when querying a file on a remote
--   filesystem:
--   
--   <ul>
--   <li><a>SyncAsStat</a></li>
--   <li><a>ForceSync</a></li>
--   <li><a>DontSync</a></li>
--   </ul>
newtype StatxFlags
StatxFlags :: CInt -> StatxFlags
defaultStatxFlags :: StatxFlags

-- | If pathname to <tt>getExtendedFileStatus</tt> is an empty string,
--   operate on the file referred to by the 'Maybe Fd' argument.
--   
--   In this case, it can refer to any type of file, not just a directory.
pattern EmptyPath :: StatxFlags

-- | Don't automount the terminal ("basename") component of pathname if it
--   is a directory that is an automount point. This allows the caller to
--   gather attributes of an automount point (rather than the location it
--   would mount). This flag can be used in tools that scan directories to
--   prevent mass-automounting of a directory of automount points. This
--   flag has no effect if the mount point has already been mounted over.
pattern NoAutoMount :: StatxFlags

-- | If pathname is a symbolic link, do not dereference it: instead return
--   information about the link itself, like <tt>lstat(2)</tt>.
pattern SymlinkNoFollow :: StatxFlags

-- | Do whatever <tt>stat(2)</tt> does. This is the default and is very
--   much filesystem-specific.
pattern SyncAsStat :: StatxFlags

-- | Force the attributes to be synchronized with the server. This may
--   require that a network filesystem perform a data writeback to get the
--   timestamps correct.
pattern ForceSync :: StatxFlags

-- | Don't synchronize anything, but rather just take whatever the system
--   has cached if possible. This may mean that the information returned is
--   approximate, but, on a network filesystem, it may not involve a round
--   trip to the server - even if no lease is held.
pattern DontSync :: StatxFlags

-- | Mask argument to <tt>statx</tt>. It's used to tell the kernel which
--   fields the caller is interested in.
--   
--   See the pattern synonyms for possible masks. These are combined via
--   <tt>(&lt;&gt;)</tt>. Masks can be tested via <a>(.&amp;.)</a>.
newtype StatxMask
StatxMask :: CInt -> StatxMask
defaultStatxMask :: StatxMask

-- | Want <tt>stx_mode &amp; S_IFMT</tt>.
pattern StatxType :: StatxMask

-- | Want <tt>stx_mode &amp; ~S_IFMT</tt>.
pattern StatxMode :: StatxMask

-- | Want <tt>stx_nlink</tt>.
pattern StatxNlink :: StatxMask

-- | Want <tt>stx_uid</tt>.
pattern StatxUid :: StatxMask

-- | Want <tt>stx_gid</tt>.
pattern StatxGid :: StatxMask

-- | Want <tt>stx_atime</tt>.
pattern StatxAtime :: StatxMask

-- | Want <tt>stx_mtime</tt>.
pattern StatxMtime :: StatxMask

-- | Want <tt>stx_ctime</tt>.
pattern StatxCtime :: StatxMask

-- | Want <tt>stx_ino</tt>.
pattern StatxIno :: StatxMask

-- | Want <tt>stx_size</tt>.
pattern StatxSize :: StatxMask

-- | Want <tt>stx_blocks</tt>.
pattern StatxBlocks :: StatxMask

-- | Want all of the above.
pattern StatxBasicStats :: StatxMask

-- | Want <tt>stx_btime</tt>.
pattern StatxBtime :: StatxMask

-- | Want <tt>stx_mnt_id</tt>.
pattern StatxMntId :: StatxMask

-- | Want all currently available fields.
pattern StatxAll :: StatxMask

-- | The "preferred" block size for efficient filesystem I/O. (Writing to a
--   file in smaller chunks may cause an inefficient read-mod‐ify-rewrite.)

-- | <i>Warning: fileBlockSizeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileBlockSizeX :: ExtendedFileStatus -> CBlkSize

-- | The number of hard links on a file.

-- | <i>Warning: linkCountX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
linkCountX :: ExtendedFileStatus -> CNlink

-- | Te user ID of the owner of the file.

-- | <i>Warning: fileOwnerX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileOwnerX :: ExtendedFileStatus -> UserID

-- | The ID of the group owner of the file.

-- | <i>Warning: fileGroupX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileGroupX :: ExtendedFileStatus -> GroupID

-- | The file type and mode. See <tt>inode(7)</tt> for details.

-- | <i>Warning: fileModeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileModeX :: ExtendedFileStatus -> FileMode

-- | The inode number of the file.

-- | <i>Warning: fileIDX: not available on this platform, will throw error
--   (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileIDX :: ExtendedFileStatus -> FileID

-- | The size of the file (if it is a regular file or a symbolic link) in
--   bytes. The size of a symbolic link is the length of the pathname it
--   contains, without a terminating null byte.

-- | <i>Warning: fileSizeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileSizeX :: ExtendedFileStatus -> Word64

-- | The number of blocks allocated to the file on the medium, in 512-byte
--   units. (This may be smaller than stx_size/512 when the file has
--   holes.)

-- | <i>Warning: fileBlocksX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileBlocksX :: ExtendedFileStatus -> Word64

-- | The file's last access timestamp.

-- | <i>Warning: accessTimeHiResX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
accessTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's creation timestamp.

-- | <i>Warning: creationTimeHiResX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
creationTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's last status change timestamp.

-- | <i>Warning: statusChangeTimeHiResX: not available on this platform,
--   will throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
statusChangeTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's last modification timestamp.

-- | <i>Warning: modificationTimeHiResX: not available on this platform,
--   will throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
modificationTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | ID of the device on which this file resides.

-- | <i>Warning: deviceIDX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
deviceIDX :: ExtendedFileStatus -> DeviceID

-- | Describes the device that this file represents.

-- | <i>Warning: specialDeviceIDX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
specialDeviceIDX :: ExtendedFileStatus -> DeviceID

-- | The mount ID of the mount containing the file. This is the same number
--   reported by name_to_handle_at(2) and corresponds to the number in the
--   first field in one of the records in <i>proc</i>self/mountinfo.

-- | <i>Warning: mountIDX: not available on this platform, will throw error
--   (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
mountIDX :: ExtendedFileStatus -> Word64

-- | The file is compressed by the filesystem and may take extra resources
--   to access. This is an extended attribute.

-- | <i>Warning: fileCompressedX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileCompressedX :: ExtendedFileStatus -> Bool

-- | The file cannot be modified: it cannot be deleted or renamed, no hard
--   links can be created to this file and no data can be written to it.
--   See <tt>chattr(1)</tt>. This is an extended attribute.

-- | <i>Warning: fileImmutableX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileImmutableX :: ExtendedFileStatus -> Bool

-- | The file can only be opened in append mode for writing. Random access
--   writing is not permitted. See <tt>chattr(1)</tt>. This is an extended
--   attribute.

-- | <i>Warning: fileAppendX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileAppendX :: ExtendedFileStatus -> Bool

-- | File is not a candidate for backup when a backup program such as
--   <tt>dump(8)</tt> is run. See <tt>chattr(1)</tt>. This is an extended
--   attribute.

-- | <i>Warning: fileNoDumpX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileNoDumpX :: ExtendedFileStatus -> Bool

-- | A key is required for the file to be encrypted by the filesystem. This
--   is an extended attribute.

-- | <i>Warning: fileEncryptedX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileEncryptedX :: ExtendedFileStatus -> Bool

-- | The file has fs-verity enabled. It cannot be written to, and all reads
--   from it will be verified against a cryptographic hash that covers the
--   entire file (e.g., via a Merkle tree). This is an extended attribute.
--   Since Linux 5.5.

-- | <i>Warning: fileVerityX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileVerityX :: ExtendedFileStatus -> Bool

-- | The file is in the DAX (cpu direct access) state. This is an extended
--   attribute. Since Linux 5.8.

-- | <i>Warning: fileDaxX: not available on this platform, will default to
--   <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileDaxX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a block device.
isBlockDeviceX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDeviceX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipeX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFileX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectoryX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLinkX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a socket device.
isSocketX :: ExtendedFileStatus -> Bool

-- | <tt>createNamedPipe fifo mode</tt> creates a new named pipe,
--   <tt>fifo</tt>, with permissions based on <tt>mode</tt>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the pipe.
--   
--   Note: calls <tt>mkfifo</tt>.
createNamedPipe :: RawFilePath -> FileMode -> IO ()

-- | <tt>createDevice path mode dev</tt> creates either a regular or a
--   special file depending on the value of <tt>mode</tt> (and
--   <tt>dev</tt>). <tt>mode</tt> will normally be either
--   <a>blockSpecialMode</a> or <a>characterSpecialMode</a>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the file.
--   
--   Note: calls <tt>mknod</tt>.
createDevice :: RawFilePath -> FileMode -> DeviceID -> IO ()

-- | <tt>createLink old new</tt> creates a new path, <tt>new</tt>, linked
--   to an existing file, <tt>old</tt>.
--   
--   Note: calls <tt>link</tt>.
createLink :: RawFilePath -> RawFilePath -> IO ()

-- | <tt>removeLink path</tt> removes the link named <tt>path</tt>.
--   
--   Note: calls <tt>unlink</tt>.
removeLink :: RawFilePath -> IO ()

-- | <tt>createSymbolicLink file1 file2</tt> creates a symbolic link named
--   <tt>file2</tt> which points to the file <tt>file1</tt>.
--   
--   Symbolic links are interpreted at run-time as if the contents of the
--   link had been substituted into the path being followed to find a file
--   or directory.
--   
--   Note: calls <tt>symlink</tt>.
createSymbolicLink :: RawFilePath -> RawFilePath -> IO ()

-- | Reads the <tt>RawFilePath</tt> pointed to by the symbolic link and
--   returns it.
--   
--   Note: calls <tt>readlink</tt>.
readSymbolicLink :: RawFilePath -> IO RawFilePath

-- | <tt>rename old new</tt> renames a file or directory from <tt>old</tt>
--   to <tt>new</tt>.
--   
--   Note: calls <tt>rename</tt>.
rename :: RawFilePath -> RawFilePath -> IO ()

-- | <tt>setOwnerAndGroup path uid gid</tt> changes the owner and group of
--   <tt>path</tt> to <tt>uid</tt> and <tt>gid</tt>, respectively.
--   
--   If <tt>uid</tt> or <tt>gid</tt> is specified as -1, then that ID is
--   not changed.
--   
--   Note: calls <tt>chown</tt>.
setOwnerAndGroup :: RawFilePath -> UserID -> GroupID -> IO ()

-- | Acts as <tt>setOwnerAndGroup</tt> but uses a file descriptor instead
--   of a <a>FilePath</a>.
--   
--   Note: calls <tt>fchown</tt>.
setFdOwnerAndGroup :: Fd -> UserID -> GroupID -> IO ()

-- | Acts as <a>setOwnerAndGroup</a> but does not follow symlinks (and thus
--   changes permissions on the link itself).
--   
--   Note: calls <tt>lchown</tt>.
setSymbolicLinkOwnerAndGroup :: RawFilePath -> UserID -> GroupID -> IO ()

-- | <tt>setFileTimes path atime mtime</tt> sets the access and
--   modification times associated with file <tt>path</tt> to
--   <tt>atime</tt> and <tt>mtime</tt>, respectively.
--   
--   Note: calls <tt>utime</tt>.
setFileTimes :: RawFilePath -> EpochTime -> EpochTime -> IO ()

-- | Like <a>setFileTimes</a> but timestamps can have sub-second
--   resolution.
--   
--   Note: calls <tt>utimensat</tt> or <tt>utimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setFileTimesHiRes :: RawFilePath -> POSIXTime -> POSIXTime -> IO ()

-- | Like <tt>setFileTimesHiRes</tt> but uses a file descriptor instead of
--   a path. This operation is not supported on all platforms. On these
--   platforms, this function will raise an exception.
--   
--   Note: calls <tt>futimens</tt> or <tt>futimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setFdTimesHiRes :: Fd -> POSIXTime -> POSIXTime -> IO ()

-- | Like <a>setFileTimesHiRes</a> but does not follow symbolic links. This
--   operation is not supported on all platforms. On these platforms, this
--   function will raise an exception.
--   
--   Note: calls <tt>utimensat</tt> or <tt>lutimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setSymbolicLinkTimesHiRes :: RawFilePath -> POSIXTime -> POSIXTime -> IO ()

-- | <tt>touchFile path</tt> sets the access and modification times
--   associated with file <tt>path</tt> to the current time.
--   
--   Note: calls <tt>utime</tt>.
touchFile :: RawFilePath -> IO ()

-- | Like <tt>touchFile</tt> but uses a file descriptor instead of a path.
--   This operation is not supported on all platforms. On these platforms,
--   this function will raise an exception.
--   
--   Note: calls <tt>futimes</tt>.
touchFd :: Fd -> IO ()

-- | Like <a>touchFile</a> but does not follow symbolic links. This
--   operation is not supported on all platforms. On these platforms, this
--   function will raise an exception.
--   
--   Note: calls <tt>lutimes</tt>.
touchSymbolicLink :: RawFilePath -> IO ()

-- | Truncates the file down to the specified length. If the file was
--   larger than the given length before this operation was performed the
--   extra is lost.
--   
--   Note: calls <tt>truncate</tt>.
setFileSize :: RawFilePath -> FileOffset -> IO ()

-- | Acts as <tt>setFileSize</tt> but uses a file descriptor instead of a
--   <a>FilePath</a>.
--   
--   Note: calls <tt>ftruncate</tt>.
setFdSize :: Fd -> FileOffset -> IO ()
data PathVar
FileSizeBits :: PathVar
LinkLimit :: PathVar
InputLineLimit :: PathVar
InputQueueLimit :: PathVar
FileNameLimit :: PathVar
PathNameLimit :: PathVar
PipeBufferLimit :: PathVar
SymbolicLinkLimit :: PathVar
SetOwnerAndGroupIsRestricted :: PathVar
FileNamesAreNotTruncated :: PathVar
VDisableChar :: PathVar
AsyncIOAvailable :: PathVar
PrioIOAvailable :: PathVar
SyncIOAvailable :: PathVar

-- | <tt>getPathVar var path</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with file or
--   directory <tt>path</tt>. For defined file limits, <tt>getPathVar</tt>
--   returns the associated value. For defined file options, the result of
--   <tt>getPathVar</tt> is undefined, but not failure.
--   
--   Note: calls <tt>pathconf</tt>.
getPathVar :: RawFilePath -> PathVar -> IO Limit

-- | <tt>getFdPathVar var fd</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with the file
--   or directory attached to the open channel <tt>fd</tt>. For defined
--   file limits, <tt>getFdPathVar</tt> returns the associated value. For
--   defined file options, the result of <tt>getFdPathVar</tt> is
--   undefined, but not failure.
--   
--   Note: calls <tt>fpathconf</tt>.
getFdPathVar :: Fd -> PathVar -> IO Limit


-- | Functions defined by the POSIX standards for manipulating and querying
--   the file system. Names of underlying POSIX functions are indicated
--   whenever possible. A more complete documentation of the POSIX
--   functions together with a more detailed description of different error
--   conditions are usually available in the system's manual pages or from
--   <a>http://www.unix.org/version3/online.html</a> (free registration
--   required).
--   
--   When a function that calls an underlying POSIX function fails, the
--   errno code is converted to an <a>IOError</a> using
--   <a>errnoToIOError</a>. For a list of which errno codes may be
--   generated, consult the POSIX documentation for the underlying
--   function.
module System.Posix.Files

-- | Combines the two file modes into one that contains modes that appear
--   in either.
unionFileModes :: FileMode -> FileMode -> FileMode

-- | Combines two file modes into one that only contains modes that appear
--   in both.
intersectFileModes :: FileMode -> FileMode -> FileMode

-- | No permissions.
nullFileMode :: FileMode

-- | Owner has read permission.
ownerReadMode :: FileMode

-- | Owner has write permission.
ownerWriteMode :: FileMode

-- | Owner has execute permission.
ownerExecuteMode :: FileMode

-- | Owner has read, write and execute permission.
ownerModes :: FileMode

-- | Group has read permission.
groupReadMode :: FileMode

-- | Group has write permission.
groupWriteMode :: FileMode

-- | Group has execute permission.
groupExecuteMode :: FileMode

-- | Group has read, write and execute permission.
groupModes :: FileMode

-- | Others have read permission.
otherReadMode :: FileMode

-- | Others have write permission.
otherWriteMode :: FileMode

-- | Others have execute permission.
otherExecuteMode :: FileMode

-- | Others have read, write and execute permission.
otherModes :: FileMode

-- | Set user ID on execution.
setUserIDMode :: FileMode

-- | Set group ID on execution.
setGroupIDMode :: FileMode

-- | Owner, group and others have read and write permission.
stdFileMode :: FileMode

-- | Owner, group and others have read, write and execute permission.
accessModes :: FileMode
fileTypeModes :: FileMode
blockSpecialMode :: FileMode
characterSpecialMode :: FileMode
namedPipeMode :: FileMode
regularFileMode :: FileMode
directoryMode :: FileMode
symbolicLinkMode :: FileMode
socketMode :: FileMode

-- | <tt>setFileMode path mode</tt> changes permission of the file given by
--   <tt>path</tt> to <tt>mode</tt>. This operation may fail with
--   <a>throwErrnoPathIfMinus1_</a> if <tt>path</tt> doesn't exist or if
--   the effective user ID of the current process is not that of the file's
--   owner.
--   
--   Note: calls <tt>chmod</tt>.
setFileMode :: FilePath -> FileMode -> IO ()

-- | <tt>setFdMode fd mode</tt> acts like <tt>setFileMode</tt> but uses a
--   file descriptor <tt>fd</tt> instead of a <a>FilePath</a>.
--   
--   Note: calls <tt>fchmod</tt>.
setFdMode :: Fd -> FileMode -> IO ()

-- | <tt>setFileCreationMask mode</tt> sets the file mode creation mask to
--   <tt>mode</tt>. Modes set by this operation are subtracted from files
--   and directories upon creation. The previous file creation mask is
--   returned.
--   
--   Note: calls <tt>umask</tt>.
setFileCreationMask :: FileMode -> IO FileMode

-- | <tt>fileAccess name read write exec</tt> checks if the file (or other
--   file system object) <tt>name</tt> can be accessed for reading, writing
--   and/or executing. To check a permission set the corresponding argument
--   to <a>True</a>.
--   
--   Note: calls <tt>access</tt>.
fileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool

-- | Checks for the existence of the file.
--   
--   Note: calls <tt>access</tt>.
fileExist :: FilePath -> IO Bool

-- | POSIX defines operations to get information, such as owner,
--   permissions, size and access times, about a file. This information is
--   represented by the <a>FileStatus</a> type.
--   
--   Note: see <tt>chmod</tt>.
--   
--   Limitations: Support for high resolution timestamps is filesystem
--   dependent:
--   
--   <ul>
--   <li>HFS+ volumes on OS X only support whole-second times.</li>
--   </ul>
newtype FileStatus

-- | The constructor is considered internal and may change.
FileStatus :: ForeignPtr CStat -> FileStatus

-- | <tt>getFileStatus path</tt> calls gets the <tt>FileStatus</tt>
--   information (user ID, size, access times, etc.) for the file
--   <tt>path</tt>.
--   
--   Note: calls <tt>stat</tt>.
getFileStatus :: FilePath -> IO FileStatus

-- | <tt>getFdStatus fd</tt> acts as <tt>getFileStatus</tt> but uses a file
--   descriptor <tt>fd</tt>.
--   
--   Note: calls <tt>fstat</tt>.
getFdStatus :: Fd -> IO FileStatus

-- | Acts as <a>getFileStatus</a> except when the <a>FilePath</a> refers to
--   a symbolic link. In that case the <tt>FileStatus</tt> information of
--   the symbolic link itself is returned instead of that of the file it
--   points to.
--   
--   Note: calls <tt>lstat</tt>.
getSymbolicLinkStatus :: FilePath -> IO FileStatus

-- | ID of the device on which this file resides.
deviceID :: FileStatus -> DeviceID

-- | inode number
fileID :: FileStatus -> FileID

-- | File mode (such as permissions).
fileMode :: FileStatus -> FileMode

-- | Number of hard links to this file.
linkCount :: FileStatus -> LinkCount

-- | ID of owner.
fileOwner :: FileStatus -> UserID

-- | ID of group.
fileGroup :: FileStatus -> GroupID

-- | Describes the device that this file represents.
specialDeviceID :: FileStatus -> DeviceID

-- | Size of the file in bytes. If this file is a symbolic link the size is
--   the length of the pathname it contains.
fileSize :: FileStatus -> FileOffset

-- | Time of last access.
accessTime :: FileStatus -> EpochTime

-- | Time of last modification.
modificationTime :: FileStatus -> EpochTime

-- | Time of last status change (i.e. owner, group, link count, mode,
--   etc.).
statusChangeTime :: FileStatus -> EpochTime

-- | Time of last access in sub-second resolution. Depends on the timestamp
--   resolution of the underlying filesystem.
accessTimeHiRes :: FileStatus -> POSIXTime

-- | Time of last modification in sub-second resolution. Depends on the
--   timestamp resolution of the underlying filesystem.
modificationTimeHiRes :: FileStatus -> POSIXTime

-- | Time of last status change (i.e. owner, group, link count, mode, etc.)
--   in sub-second resolution. Depends on the timestamp resolution of the
--   underlying filesystem.
statusChangeTimeHiRes :: FileStatus -> POSIXTime

-- | Checks if this file is a block device.
isBlockDevice :: FileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDevice :: FileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipe :: FileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFile :: FileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectory :: FileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLink :: FileStatus -> Bool

-- | Checks if this file is a socket device.
isSocket :: FileStatus -> Bool

-- | Gives the preferred block size for efficient filesystem I/O in bytes.
--   Returns <tt>Nothing</tt> if <tt>st_blocksize</tt> is not supported on
--   this platform.
fileBlockSize :: FileStatus -> Maybe CBlkSize

-- | Number of blocks allocated for this file, in units of 512-bytes.
--   Returns <tt>Nothing</tt> if <tt>st_blocks</tt> is not supported on
--   this platform.
fileBlocks :: FileStatus -> Maybe CBlkCnt
newtype ExtendedFileStatus

-- | The constructor is considered internal and may change.
ExtendedFileStatus :: ForeignPtr CStatx -> ExtendedFileStatus
newtype CAttributes
CAttributes :: Word64 -> CAttributes

-- | Whether <tt>statx</tt> is available on this platform and
--   <tt>getExtendedFileStatus</tt> and related functions will work.
haveStatx :: Bool

-- | Gets extended file status information.
--   
--   The target file to open is identified in one of the following ways:
--   
--   <ul>
--   <li>If <tt>pathname</tt> begins with a slash, then it is an absolute
--   pathname that identifies the target file. In this case, <tt>dirfd</tt>
--   is ignored</li>
--   <li>If <tt>pathname</tt> is a string that begins with a character
--   other than a slash and <tt>dirfd</tt> is a file descriptor that refers
--   to a directory, then pathname is a relative pathname that is
--   interpreted relative to the directory referred to by dirfd. (See
--   <tt>openat(2)</tt> for an explanation of why this is useful.)</li>
--   <li>If <tt>pathname</tt> is an empty string and the <a>EmptyPath</a>
--   flag is specified in flags (see below), then the target file is the
--   one referred to by the file descriptor <tt>dirfd</tt>.</li>
--   </ul>
--   
--   Note: calls <tt>statx</tt>.
getExtendedFileStatus :: Maybe Fd -> FilePath -> StatxFlags -> StatxMask -> IO ExtendedFileStatus

-- | Statx flags.
--   
--   See the pattern synonyms for possible flags. These are combined via
--   <a>(&lt;&gt;)</a>. Flags can be tested via <a>(.&amp;.)</a>.
--   
--   The following flags influence pathname-based lookup:
--   
--   <ul>
--   <li><a>EmptyPath</a></li>
--   <li><a>NoAutoMount</a></li>
--   <li><a>SymlinkNoFollow</a></li>
--   </ul>
--   
--   The following flags can be used to control what sort of
--   synchronization the kernel will do when querying a file on a remote
--   filesystem:
--   
--   <ul>
--   <li><a>SyncAsStat</a></li>
--   <li><a>ForceSync</a></li>
--   <li><a>DontSync</a></li>
--   </ul>
newtype StatxFlags
StatxFlags :: CInt -> StatxFlags
defaultStatxFlags :: StatxFlags

-- | If pathname to <tt>getExtendedFileStatus</tt> is an empty string,
--   operate on the file referred to by the 'Maybe Fd' argument.
--   
--   In this case, it can refer to any type of file, not just a directory.
pattern EmptyPath :: StatxFlags

-- | Don't automount the terminal ("basename") component of pathname if it
--   is a directory that is an automount point. This allows the caller to
--   gather attributes of an automount point (rather than the location it
--   would mount). This flag can be used in tools that scan directories to
--   prevent mass-automounting of a directory of automount points. This
--   flag has no effect if the mount point has already been mounted over.
pattern NoAutoMount :: StatxFlags

-- | If pathname is a symbolic link, do not dereference it: instead return
--   information about the link itself, like <tt>lstat(2)</tt>.
pattern SymlinkNoFollow :: StatxFlags

-- | Do whatever <tt>stat(2)</tt> does. This is the default and is very
--   much filesystem-specific.
pattern SyncAsStat :: StatxFlags

-- | Force the attributes to be synchronized with the server. This may
--   require that a network filesystem perform a data writeback to get the
--   timestamps correct.
pattern ForceSync :: StatxFlags

-- | Don't synchronize anything, but rather just take whatever the system
--   has cached if possible. This may mean that the information returned is
--   approximate, but, on a network filesystem, it may not involve a round
--   trip to the server - even if no lease is held.
pattern DontSync :: StatxFlags

-- | Mask argument to <tt>statx</tt>. It's used to tell the kernel which
--   fields the caller is interested in.
--   
--   See the pattern synonyms for possible masks. These are combined via
--   <tt>(&lt;&gt;)</tt>. Masks can be tested via <a>(.&amp;.)</a>.
newtype StatxMask
StatxMask :: CInt -> StatxMask
defaultStatxMask :: StatxMask

-- | Want <tt>stx_mode &amp; S_IFMT</tt>.
pattern StatxType :: StatxMask

-- | Want <tt>stx_mode &amp; ~S_IFMT</tt>.
pattern StatxMode :: StatxMask

-- | Want <tt>stx_nlink</tt>.
pattern StatxNlink :: StatxMask

-- | Want <tt>stx_uid</tt>.
pattern StatxUid :: StatxMask

-- | Want <tt>stx_gid</tt>.
pattern StatxGid :: StatxMask

-- | Want <tt>stx_atime</tt>.
pattern StatxAtime :: StatxMask

-- | Want <tt>stx_mtime</tt>.
pattern StatxMtime :: StatxMask

-- | Want <tt>stx_ctime</tt>.
pattern StatxCtime :: StatxMask

-- | Want <tt>stx_ino</tt>.
pattern StatxIno :: StatxMask

-- | Want <tt>stx_size</tt>.
pattern StatxSize :: StatxMask

-- | Want <tt>stx_blocks</tt>.
pattern StatxBlocks :: StatxMask

-- | Want all of the above.
pattern StatxBasicStats :: StatxMask

-- | Want <tt>stx_btime</tt>.
pattern StatxBtime :: StatxMask

-- | Want <tt>stx_mnt_id</tt>.
pattern StatxMntId :: StatxMask

-- | Want all currently available fields.
pattern StatxAll :: StatxMask

-- | The "preferred" block size for efficient filesystem I/O. (Writing to a
--   file in smaller chunks may cause an inefficient read-mod‐ify-rewrite.)

-- | <i>Warning: fileBlockSizeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileBlockSizeX :: ExtendedFileStatus -> CBlkSize

-- | The number of hard links on a file.

-- | <i>Warning: linkCountX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
linkCountX :: ExtendedFileStatus -> CNlink

-- | Te user ID of the owner of the file.

-- | <i>Warning: fileOwnerX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileOwnerX :: ExtendedFileStatus -> UserID

-- | The ID of the group owner of the file.

-- | <i>Warning: fileGroupX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileGroupX :: ExtendedFileStatus -> GroupID

-- | The file type and mode. See <tt>inode(7)</tt> for details.

-- | <i>Warning: fileModeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileModeX :: ExtendedFileStatus -> FileMode

-- | The inode number of the file.

-- | <i>Warning: fileIDX: not available on this platform, will throw error
--   (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileIDX :: ExtendedFileStatus -> FileID

-- | The size of the file (if it is a regular file or a symbolic link) in
--   bytes. The size of a symbolic link is the length of the pathname it
--   contains, without a terminating null byte.

-- | <i>Warning: fileSizeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileSizeX :: ExtendedFileStatus -> Word64

-- | The number of blocks allocated to the file on the medium, in 512-byte
--   units. (This may be smaller than stx_size/512 when the file has
--   holes.)

-- | <i>Warning: fileBlocksX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileBlocksX :: ExtendedFileStatus -> Word64

-- | The file's last access timestamp.

-- | <i>Warning: accessTimeHiResX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
accessTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's creation timestamp.

-- | <i>Warning: creationTimeHiResX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
creationTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's last status change timestamp.

-- | <i>Warning: statusChangeTimeHiResX: not available on this platform,
--   will throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
statusChangeTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's last modification timestamp.

-- | <i>Warning: modificationTimeHiResX: not available on this platform,
--   will throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
modificationTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | ID of the device on which this file resides.

-- | <i>Warning: deviceIDX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
deviceIDX :: ExtendedFileStatus -> DeviceID

-- | Describes the device that this file represents.

-- | <i>Warning: specialDeviceIDX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
specialDeviceIDX :: ExtendedFileStatus -> DeviceID

-- | The mount ID of the mount containing the file. This is the same number
--   reported by name_to_handle_at(2) and corresponds to the number in the
--   first field in one of the records in <i>proc</i>self/mountinfo.

-- | <i>Warning: mountIDX: not available on this platform, will throw error
--   (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
mountIDX :: ExtendedFileStatus -> Word64

-- | The file is compressed by the filesystem and may take extra resources
--   to access. This is an extended attribute.

-- | <i>Warning: fileCompressedX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileCompressedX :: ExtendedFileStatus -> Bool

-- | The file cannot be modified: it cannot be deleted or renamed, no hard
--   links can be created to this file and no data can be written to it.
--   See <tt>chattr(1)</tt>. This is an extended attribute.

-- | <i>Warning: fileImmutableX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileImmutableX :: ExtendedFileStatus -> Bool

-- | The file can only be opened in append mode for writing. Random access
--   writing is not permitted. See <tt>chattr(1)</tt>. This is an extended
--   attribute.

-- | <i>Warning: fileAppendX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileAppendX :: ExtendedFileStatus -> Bool

-- | File is not a candidate for backup when a backup program such as
--   <tt>dump(8)</tt> is run. See <tt>chattr(1)</tt>. This is an extended
--   attribute.

-- | <i>Warning: fileNoDumpX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileNoDumpX :: ExtendedFileStatus -> Bool

-- | A key is required for the file to be encrypted by the filesystem. This
--   is an extended attribute.

-- | <i>Warning: fileEncryptedX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileEncryptedX :: ExtendedFileStatus -> Bool

-- | The file has fs-verity enabled. It cannot be written to, and all reads
--   from it will be verified against a cryptographic hash that covers the
--   entire file (e.g., via a Merkle tree). This is an extended attribute.
--   Since Linux 5.5.

-- | <i>Warning: fileVerityX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileVerityX :: ExtendedFileStatus -> Bool

-- | The file is in the DAX (cpu direct access) state. This is an extended
--   attribute. Since Linux 5.8.

-- | <i>Warning: fileDaxX: not available on this platform, will default to
--   <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileDaxX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a block device.
isBlockDeviceX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDeviceX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipeX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFileX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectoryX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLinkX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a socket device.
isSocketX :: ExtendedFileStatus -> Bool

-- | <tt>createNamedPipe fifo mode</tt> creates a new named pipe,
--   <tt>fifo</tt>, with permissions based on <tt>mode</tt>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the pipe.
--   
--   Note: calls <tt>mkfifo</tt>.
createNamedPipe :: FilePath -> FileMode -> IO ()

-- | <tt>createDevice path mode dev</tt> creates either a regular or a
--   special file depending on the value of <tt>mode</tt> (and
--   <tt>dev</tt>). <tt>mode</tt> will normally be either
--   <a>blockSpecialMode</a> or <a>characterSpecialMode</a>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the file.
--   
--   Note: calls <tt>mknod</tt>.
createDevice :: FilePath -> FileMode -> DeviceID -> IO ()

-- | <tt>createLink old new</tt> creates a new path, <tt>new</tt>, linked
--   to an existing file, <tt>old</tt>.
--   
--   Note: calls <tt>link</tt>.
createLink :: FilePath -> FilePath -> IO ()

-- | <tt>removeLink path</tt> removes the link named <tt>path</tt>.
--   
--   Note: calls <tt>unlink</tt>.
removeLink :: FilePath -> IO ()

-- | <tt>createSymbolicLink name1 name2</tt> creates a symbolic link named
--   <tt>name2</tt> which points to the file <tt>name1</tt>.
--   
--   Symbolic links are interpreted at run-time as if the contents of the
--   link had been substituted into the path being followed to find a file
--   or directory.
--   
--   Note: calls <tt>symlink</tt>.
createSymbolicLink :: FilePath -> FilePath -> IO ()

-- | Reads the <tt>FilePath</tt> pointed to by the symbolic link and
--   returns it.
--   
--   Note: calls <tt>readlink</tt>.
readSymbolicLink :: FilePath -> IO FilePath

-- | <tt>rename old new</tt> renames a file or directory from <tt>old</tt>
--   to <tt>new</tt>.
--   
--   Note: calls <tt>rename</tt>.
rename :: FilePath -> FilePath -> IO ()

-- | <tt>setOwnerAndGroup path uid gid</tt> changes the owner and group of
--   <tt>path</tt> to <tt>uid</tt> and <tt>gid</tt>, respectively.
--   
--   If <tt>uid</tt> or <tt>gid</tt> is specified as -1, then that ID is
--   not changed.
--   
--   Note: calls <tt>chown</tt>.
setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()

-- | Acts as <tt>setOwnerAndGroup</tt> but uses a file descriptor instead
--   of a <a>FilePath</a>.
--   
--   Note: calls <tt>fchown</tt>.
setFdOwnerAndGroup :: Fd -> UserID -> GroupID -> IO ()

-- | Acts as <a>setOwnerAndGroup</a> but does not follow symlinks (and thus
--   changes permissions on the link itself).
--   
--   Note: calls <tt>lchown</tt>.
setSymbolicLinkOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()

-- | <tt>setFileTimes path atime mtime</tt> sets the access and
--   modification times associated with file <tt>path</tt> to
--   <tt>atime</tt> and <tt>mtime</tt>, respectively.
--   
--   Note: calls <tt>utime</tt>.
setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()

-- | Like <a>setFileTimes</a> but timestamps can have sub-second
--   resolution.
--   
--   Note: calls <tt>utimensat</tt> or <tt>utimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setFileTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()

-- | Like <tt>setFileTimesHiRes</tt> but uses a file descriptor instead of
--   a path. This operation is not supported on all platforms. On these
--   platforms, this function will raise an exception.
--   
--   Note: calls <tt>futimens</tt> or <tt>futimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setFdTimesHiRes :: Fd -> POSIXTime -> POSIXTime -> IO ()

-- | Like <a>setFileTimesHiRes</a> but does not follow symbolic links. This
--   operation is not supported on all platforms. On these platforms, this
--   function will raise an exception.
--   
--   Note: calls <tt>utimensat</tt> or <tt>lutimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setSymbolicLinkTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()

-- | <tt>touchFile path</tt> sets the access and modification times
--   associated with file <tt>path</tt> to the current time.
--   
--   Note: calls <tt>utime</tt>.
touchFile :: FilePath -> IO ()

-- | Like <tt>touchFile</tt> but uses a file descriptor instead of a path.
--   This operation is not supported on all platforms. On these platforms,
--   this function will raise an exception.
--   
--   Note: calls <tt>futimes</tt>.
touchFd :: Fd -> IO ()

-- | Like <a>touchFile</a> but does not follow symbolic links. This
--   operation is not supported on all platforms. On these platforms, this
--   function will raise an exception.
--   
--   Note: calls <tt>lutimes</tt>.
touchSymbolicLink :: FilePath -> IO ()

-- | Truncates the file down to the specified length. If the file was
--   larger than the given length before this operation was performed the
--   extra is lost.
--   
--   Note: calls <tt>truncate</tt>.
setFileSize :: FilePath -> FileOffset -> IO ()

-- | Acts as <tt>setFileSize</tt> but uses a file descriptor instead of a
--   <a>FilePath</a>.
--   
--   Note: calls <tt>ftruncate</tt>.
setFdSize :: Fd -> FileOffset -> IO ()
data PathVar
FileSizeBits :: PathVar
LinkLimit :: PathVar
InputLineLimit :: PathVar
InputQueueLimit :: PathVar
FileNameLimit :: PathVar
PathNameLimit :: PathVar
PipeBufferLimit :: PathVar
SymbolicLinkLimit :: PathVar
SetOwnerAndGroupIsRestricted :: PathVar
FileNamesAreNotTruncated :: PathVar
VDisableChar :: PathVar
AsyncIOAvailable :: PathVar
PrioIOAvailable :: PathVar
SyncIOAvailable :: PathVar

-- | <tt>getPathVar var path</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with file or
--   directory <tt>path</tt>. For defined file limits, <tt>getPathVar</tt>
--   returns the associated value. For defined file options, the result of
--   <tt>getPathVar</tt> is undefined, but not failure.
--   
--   Note: calls <tt>pathconf</tt>.
getPathVar :: FilePath -> PathVar -> IO Limit

-- | <tt>getFdPathVar var fd</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with the file
--   or directory attached to the open channel <tt>fd</tt>. For defined
--   file limits, <tt>getFdPathVar</tt> returns the associated value. For
--   defined file options, the result of <tt>getFdPathVar</tt> is
--   undefined, but not failure.
--   
--   Note: calls <tt>fpathconf</tt>.
getFdPathVar :: Fd -> PathVar -> IO Limit


-- | POSIX IO support. These types and functions correspond to the unix
--   functions open(2), close(2), etc. For more portable functions which
--   are more like fopen(3) and friends from stdio.h, see <a>System.IO</a>.
module System.Posix.IO.ByteString
stdInput :: Fd
stdOutput :: Fd
stdError :: Fd
data OpenMode
ReadOnly :: OpenMode
WriteOnly :: OpenMode
ReadWrite :: OpenMode

-- | Correspond to some of the int flags from C's fcntl.h.
data OpenFileFlags
OpenFileFlags :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe FileMode -> Bool -> Bool -> Bool -> OpenFileFlags

-- | O_APPEND
[append] :: OpenFileFlags -> Bool

-- | O_EXCL, result is undefined if O_CREAT is False
--   
--   <b>NOTE</b>: Result is undefined if <a>creat</a> is <a>Nothing</a>.
[exclusive] :: OpenFileFlags -> Bool

-- | O_NOCTTY
[noctty] :: OpenFileFlags -> Bool

-- | O_NONBLOCK
[nonBlock] :: OpenFileFlags -> Bool

-- | O_TRUNC
[trunc] :: OpenFileFlags -> Bool

-- | O_NOFOLLOW
[nofollow] :: OpenFileFlags -> Bool

-- | O_CREAT
[creat] :: OpenFileFlags -> Maybe FileMode

-- | O_CLOEXEC
[cloexec] :: OpenFileFlags -> Bool

-- | O_DIRECTORY
[directory] :: OpenFileFlags -> Bool

-- | O_SYNC
[sync] :: OpenFileFlags -> Bool

-- | Default values for the <a>OpenFileFlags</a> type.
--   
--   Each field of <a>OpenFileFlags</a> is either <a>False</a> or
--   <a>Nothing</a> respectively.
defaultFileFlags :: OpenFileFlags

-- | Open and optionally create this file. See <a>Files</a> for information
--   on how to use the <a>FileMode</a> type.
openFd :: RawFilePath -> OpenMode -> OpenFileFlags -> IO Fd

-- | Open a file relative to an optional directory file descriptor.
--   
--   Directory file descriptors can be used to avoid some race conditions
--   when navigating changing directory trees, or to retain access to a
--   portion of the directory tree that would otherwise become inaccessible
--   after dropping privileges.
openFdAt :: Maybe Fd -> RawFilePath -> OpenMode -> OpenFileFlags -> IO Fd

-- | Create and open this file in WriteOnly mode. A special case of
--   <a>openFd</a>. See <a>Files</a> for information on how to use the
--   <a>FileMode</a> type.
createFile :: RawFilePath -> FileMode -> IO Fd

-- | Create and open a file for write-only, with default flags, relative an
--   optional directory file-descriptor.
--   
--   Directory file descriptors can be used to avoid some race conditions
--   when navigating changing directory trees, or to retain access to a
--   portion of the directory tree that would otherwise become inaccessible
--   after dropping privileges.
createFileAt :: Maybe Fd -> RawFilePath -> FileMode -> IO Fd

-- | Close this file descriptor. May throw an exception if this is an
--   invalid descriptor.
closeFd :: Fd -> IO ()

-- | Read data from an <a>Fd</a> and return it as a <a>ByteString</a>.
--   Throws an exception if this is an invalid descriptor, or EOF has been
--   reached.
fdRead :: Fd -> ByteCount -> IO ByteString

-- | Write a <a>ByteString</a> to an <a>Fd</a>.
fdWrite :: Fd -> ByteString -> IO ByteCount

-- | Read data from an <a>Fd</a> into memory. This is exactly equivalent to
--   the POSIX <tt>read</tt> function.
fdReadBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | Write data from memory to an <a>Fd</a>. This is exactly equivalent to
--   the POSIX <tt>write</tt> function.
fdWriteBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | May throw an exception if this is an invalid descriptor.
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
data FdOption

-- | O_APPEND
AppendOnWrite :: FdOption

-- | FD_CLOEXEC
CloseOnExec :: FdOption

-- | O_NONBLOCK
NonBlockingRead :: FdOption

-- | O_SYNC
SynchronousWrites :: FdOption

-- | May throw an exception if this is an invalid descriptor.
queryFdOption :: Fd -> FdOption -> IO Bool

-- | May throw an exception if this is an invalid descriptor.
setFdOption :: Fd -> FdOption -> Bool -> IO ()
type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset)
data LockRequest
ReadLock :: LockRequest
WriteLock :: LockRequest
Unlock :: LockRequest

-- | May throw an exception if this is an invalid descriptor.
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))

-- | May throw an exception if this is an invalid descriptor.
setLock :: Fd -> FileLock -> IO ()

-- | May throw an exception if this is an invalid descriptor.
waitToSetLock :: Fd -> FileLock -> IO ()

-- | The <a>createPipe</a> function creates a pair of connected file
--   descriptors. The first component is the fd to read from, the second is
--   the write end. Although pipes may be bidirectional, this behaviour is
--   not portable and programmers should use two separate pipes for this
--   purpose. May throw an exception if this is an invalid descriptor.
createPipe :: IO (Fd, Fd)

-- | May throw an exception if this is an invalid descriptor.
dup :: Fd -> IO Fd

-- | May throw an exception if this is an invalid descriptor.
dupTo :: Fd -> Fd -> IO Fd

-- | Extracts the <a>Fd</a> from a <a>Handle</a>. This function has the
--   side effect of closing the <a>Handle</a> (and flushing its write
--   buffer, if necessary), without closing the underlying <a>Fd</a>.
--   
--   <b>Warning:</b> This means you take over ownership of the underlying
--   <a>Fd</a>. <a>hClose</a> on the <a>Handle</a> will no longer have any
--   effect. This will break common patterns to avoid file descriptor
--   leaks, such as using <a>hClose</a> in the cleanup action of
--   <tt>Control.Exception.bracket</tt>, making it a silent no-op. Be sure
--   to close the returned <a>Fd</a> yourself to not leak it.
handleToFd :: Handle -> IO Fd

-- | Converts an <a>Fd</a> into a <a>Handle</a> that can be used with the
--   standard Haskell IO library (see <a>System.IO</a>).
fdToHandle :: Fd -> IO Handle


-- | POSIX IO support. These types and functions correspond to the unix
--   functions open(2), close(2), etc. For more portable functions which
--   are more like fopen(3) and friends from stdio.h, see <a>System.IO</a>.
module System.Posix.IO
stdInput :: Fd
stdOutput :: Fd
stdError :: Fd
data OpenMode
ReadOnly :: OpenMode
WriteOnly :: OpenMode
ReadWrite :: OpenMode

-- | Correspond to some of the int flags from C's fcntl.h.
data OpenFileFlags
OpenFileFlags :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe FileMode -> Bool -> Bool -> Bool -> OpenFileFlags

-- | O_APPEND
[append] :: OpenFileFlags -> Bool

-- | O_EXCL, result is undefined if O_CREAT is False
--   
--   <b>NOTE</b>: Result is undefined if <a>creat</a> is <a>Nothing</a>.
[exclusive] :: OpenFileFlags -> Bool

-- | O_NOCTTY
[noctty] :: OpenFileFlags -> Bool

-- | O_NONBLOCK
[nonBlock] :: OpenFileFlags -> Bool

-- | O_TRUNC
[trunc] :: OpenFileFlags -> Bool

-- | O_NOFOLLOW
[nofollow] :: OpenFileFlags -> Bool

-- | O_CREAT
[creat] :: OpenFileFlags -> Maybe FileMode

-- | O_CLOEXEC
[cloexec] :: OpenFileFlags -> Bool

-- | O_DIRECTORY
[directory] :: OpenFileFlags -> Bool

-- | O_SYNC
[sync] :: OpenFileFlags -> Bool

-- | Default values for the <a>OpenFileFlags</a> type.
--   
--   Each field of <a>OpenFileFlags</a> is either <a>False</a> or
--   <a>Nothing</a> respectively.
defaultFileFlags :: OpenFileFlags

-- | Open and optionally create this file. See <a>Files</a> for information
--   on how to use the <a>FileMode</a> type.
openFd :: FilePath -> OpenMode -> OpenFileFlags -> IO Fd

-- | Open a file relative to an optional directory file descriptor.
--   
--   Directory file descriptors can be used to avoid some race conditions
--   when navigating changing directory trees, or to retain access to a
--   portion of the directory tree that would otherwise become inaccessible
--   after dropping privileges.
openFdAt :: Maybe Fd -> FilePath -> OpenMode -> OpenFileFlags -> IO Fd

-- | Create and open this file in WriteOnly mode. A special case of
--   <a>openFd</a>. See <a>Files</a> for information on how to use the
--   <a>FileMode</a> type.
createFile :: FilePath -> FileMode -> IO Fd

-- | Create and open a file for write-only, with default flags, relative an
--   optional directory file-descriptor.
--   
--   Directory file descriptors can be used to avoid some race conditions
--   when navigating changing directory trees, or to retain access to a
--   portion of the directory tree that would otherwise become inaccessible
--   after dropping privileges.
createFileAt :: Maybe Fd -> FilePath -> FileMode -> IO Fd

-- | Close this file descriptor. May throw an exception if this is an
--   invalid descriptor.
closeFd :: Fd -> IO ()

-- | Read data from an <a>Fd</a> and convert it to a <a>String</a> using
--   the locale encoding. Throws an exception if this is an invalid
--   descriptor, or EOF has been reached.

-- | <i>Deprecated: This function is scheduled to be dropped in favor of
--   <a>fdRead</a>, because decoding e.g. UTF-8 streams partially is
--   unsafe.</i>
fdRead :: Fd -> ByteCount -> IO (String, ByteCount)

-- | Write a <a>String</a> to an <a>Fd</a> using the locale encoding.
fdWrite :: Fd -> String -> IO ByteCount

-- | Read data from an <a>Fd</a> into memory. This is exactly equivalent to
--   the POSIX <tt>read</tt> function.
fdReadBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | Write data from memory to an <a>Fd</a>. This is exactly equivalent to
--   the POSIX <tt>write</tt> function.
fdWriteBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | May throw an exception if this is an invalid descriptor.
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
data FdOption

-- | O_APPEND
AppendOnWrite :: FdOption

-- | FD_CLOEXEC
CloseOnExec :: FdOption

-- | O_NONBLOCK
NonBlockingRead :: FdOption

-- | O_SYNC
SynchronousWrites :: FdOption

-- | May throw an exception if this is an invalid descriptor.
queryFdOption :: Fd -> FdOption -> IO Bool

-- | May throw an exception if this is an invalid descriptor.
setFdOption :: Fd -> FdOption -> Bool -> IO ()
type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset)
data LockRequest
ReadLock :: LockRequest
WriteLock :: LockRequest
Unlock :: LockRequest

-- | May throw an exception if this is an invalid descriptor.
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))

-- | May throw an exception if this is an invalid descriptor.
setLock :: Fd -> FileLock -> IO ()

-- | May throw an exception if this is an invalid descriptor.
waitToSetLock :: Fd -> FileLock -> IO ()

-- | The <a>createPipe</a> function creates a pair of connected file
--   descriptors. The first component is the fd to read from, the second is
--   the write end. Although pipes may be bidirectional, this behaviour is
--   not portable and programmers should use two separate pipes for this
--   purpose. May throw an exception if this is an invalid descriptor.
createPipe :: IO (Fd, Fd)

-- | May throw an exception if this is an invalid descriptor.
dup :: Fd -> IO Fd

-- | May throw an exception if this is an invalid descriptor.
dupTo :: Fd -> Fd -> IO Fd

-- | Extracts the <a>Fd</a> from a <a>Handle</a>. This function has the
--   side effect of closing the <a>Handle</a> (and flushing its write
--   buffer, if necessary), without closing the underlying <a>Fd</a>.
--   
--   <b>Warning:</b> This means you take over ownership of the underlying
--   <a>Fd</a>. <a>hClose</a> on the <a>Handle</a> will no longer have any
--   effect. This will break common patterns to avoid file descriptor
--   leaks, such as using <a>hClose</a> in the cleanup action of
--   <tt>Control.Exception.bracket</tt>, making it a silent no-op. Be sure
--   to close the returned <a>Fd</a> yourself to not leak it.
handleToFd :: Handle -> IO Fd

-- | Converts an <a>Fd</a> into a <a>Handle</a> that can be used with the
--   standard Haskell IO library (see <a>System.IO</a>).
fdToHandle :: Fd -> IO Handle


-- | Internal stuff: support for ByteString FilePaths
module System.Posix.PosixPath.FilePath
withFilePath :: PosixPath -> (CString -> IO a) -> IO a
peekFilePath :: CString -> IO PosixPath
peekFilePathLen :: CStringLen -> IO PosixPath
throwErrnoPathIfMinus1Retry :: (Eq a, Num a) => String -> PosixPath -> IO a -> IO a
throwErrnoPathIfMinus1Retry_ :: (Eq a, Num a) => String -> PosixPath -> IO a -> IO ()
throwErrnoPathIfNullRetry :: String -> PosixPath -> IO (Ptr a) -> IO (Ptr a)
throwErrnoPathIfRetry :: (a -> Bool) -> String -> PosixPath -> IO a -> IO a

-- | as <a>throwErrno</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPath :: String -> PosixPath -> IO a

-- | as <a>throwErrnoIf</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIf :: (a -> Bool) -> String -> PosixPath -> IO a -> IO a

-- | as <a>throwErrnoIf_</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIf_ :: (a -> Bool) -> String -> PosixPath -> IO a -> IO ()

-- | as <a>throwErrnoIfNull</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIfNull :: String -> PosixPath -> IO (Ptr a) -> IO (Ptr a)

-- | as <a>throwErrnoIfMinus1</a>, but exceptions include the given path
--   when appropriate.
throwErrnoPathIfMinus1 :: (Eq a, Num a) => String -> PosixPath -> IO a -> IO a

-- | as <a>throwErrnoIfMinus1_</a>, but exceptions include the given path
--   when appropriate.
throwErrnoPathIfMinus1_ :: (Eq a, Num a) => String -> PosixPath -> IO a -> IO ()

-- | as <a>throwErrnoTwoPathsIfMinus1_</a>, but exceptions include two
--   paths when appropriate.
throwErrnoTwoPathsIfMinus1_ :: (Eq a, Num a) => String -> PosixPath -> PosixPath -> IO a -> IO ()


-- | POSIX IO support. These types and functions correspond to the unix
--   functions open(2), close(2), etc. For more portable functions which
--   are more like fopen(3) and friends from stdio.h, see <a>System.IO</a>.
module System.Posix.IO.PosixString
stdInput :: Fd
stdOutput :: Fd
stdError :: Fd
data OpenMode
ReadOnly :: OpenMode
WriteOnly :: OpenMode
ReadWrite :: OpenMode

-- | Correspond to some of the int flags from C's fcntl.h.
data OpenFileFlags
OpenFileFlags :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe FileMode -> Bool -> Bool -> Bool -> OpenFileFlags

-- | O_APPEND
[append] :: OpenFileFlags -> Bool

-- | O_EXCL, result is undefined if O_CREAT is False
--   
--   <b>NOTE</b>: Result is undefined if <a>creat</a> is <a>Nothing</a>.
[exclusive] :: OpenFileFlags -> Bool

-- | O_NOCTTY
[noctty] :: OpenFileFlags -> Bool

-- | O_NONBLOCK
[nonBlock] :: OpenFileFlags -> Bool

-- | O_TRUNC
[trunc] :: OpenFileFlags -> Bool

-- | O_NOFOLLOW
[nofollow] :: OpenFileFlags -> Bool

-- | O_CREAT
[creat] :: OpenFileFlags -> Maybe FileMode

-- | O_CLOEXEC
[cloexec] :: OpenFileFlags -> Bool

-- | O_DIRECTORY
[directory] :: OpenFileFlags -> Bool

-- | O_SYNC
[sync] :: OpenFileFlags -> Bool

-- | Default values for the <a>OpenFileFlags</a> type.
--   
--   Each field of <a>OpenFileFlags</a> is either <a>False</a> or
--   <a>Nothing</a> respectively.
defaultFileFlags :: OpenFileFlags

-- | Open and optionally create this file. See <a>Files</a> for information
--   on how to use the <a>FileMode</a> type.
openFd :: PosixPath -> OpenMode -> OpenFileFlags -> IO Fd

-- | Open a file relative to an optional directory file descriptor.
--   
--   Directory file descriptors can be used to avoid some race conditions
--   when navigating changing directory trees, or to retain access to a
--   portion of the directory tree that would otherwise become inaccessible
--   after dropping privileges.
openFdAt :: Maybe Fd -> PosixPath -> OpenMode -> OpenFileFlags -> IO Fd

-- | Create and open this file in WriteOnly mode. A special case of
--   <a>openFd</a>. See <a>Files</a> for information on how to use the
--   <a>FileMode</a> type.
createFile :: PosixPath -> FileMode -> IO Fd

-- | Create and open a file for write-only, with default flags, relative an
--   optional directory file-descriptor.
--   
--   Directory file descriptors can be used to avoid some race conditions
--   when navigating changing directory trees, or to retain access to a
--   portion of the directory tree that would otherwise become inaccessible
--   after dropping privileges.
createFileAt :: Maybe Fd -> PosixPath -> FileMode -> IO Fd

-- | Close this file descriptor. May throw an exception if this is an
--   invalid descriptor.
closeFd :: Fd -> IO ()

-- | Read data from an <a>Fd</a> and return it as a <a>ByteString</a>.
--   Throws an exception if this is an invalid descriptor, or EOF has been
--   reached.
fdRead :: Fd -> ByteCount -> IO ByteString

-- | Write a <a>ByteString</a> to an <a>Fd</a>.
fdWrite :: Fd -> ByteString -> IO ByteCount

-- | Read data from an <a>Fd</a> into memory. This is exactly equivalent to
--   the POSIX <tt>read</tt> function.
fdReadBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | Write data from memory to an <a>Fd</a>. This is exactly equivalent to
--   the POSIX <tt>write</tt> function.
fdWriteBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | May throw an exception if this is an invalid descriptor.
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
data FdOption

-- | O_APPEND
AppendOnWrite :: FdOption

-- | FD_CLOEXEC
CloseOnExec :: FdOption

-- | O_NONBLOCK
NonBlockingRead :: FdOption

-- | O_SYNC
SynchronousWrites :: FdOption

-- | May throw an exception if this is an invalid descriptor.
queryFdOption :: Fd -> FdOption -> IO Bool

-- | May throw an exception if this is an invalid descriptor.
setFdOption :: Fd -> FdOption -> Bool -> IO ()
type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset)
data LockRequest
ReadLock :: LockRequest
WriteLock :: LockRequest
Unlock :: LockRequest

-- | May throw an exception if this is an invalid descriptor.
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))

-- | May throw an exception if this is an invalid descriptor.
setLock :: Fd -> FileLock -> IO ()

-- | May throw an exception if this is an invalid descriptor.
waitToSetLock :: Fd -> FileLock -> IO ()

-- | The <a>createPipe</a> function creates a pair of connected file
--   descriptors. The first component is the fd to read from, the second is
--   the write end. Although pipes may be bidirectional, this behaviour is
--   not portable and programmers should use two separate pipes for this
--   purpose. May throw an exception if this is an invalid descriptor.
createPipe :: IO (Fd, Fd)

-- | May throw an exception if this is an invalid descriptor.
dup :: Fd -> IO Fd

-- | May throw an exception if this is an invalid descriptor.
dupTo :: Fd -> Fd -> IO Fd

-- | Extracts the <a>Fd</a> from a <a>Handle</a>. This function has the
--   side effect of closing the <a>Handle</a> (and flushing its write
--   buffer, if necessary), without closing the underlying <a>Fd</a>.
--   
--   <b>Warning:</b> This means you take over ownership of the underlying
--   <a>Fd</a>. <a>hClose</a> on the <a>Handle</a> will no longer have any
--   effect. This will break common patterns to avoid file descriptor
--   leaks, such as using <a>hClose</a> in the cleanup action of
--   <tt>Control.Exception.bracket</tt>, making it a silent no-op. Be sure
--   to close the returned <a>Fd</a> yourself to not leak it.
handleToFd :: Handle -> IO Fd

-- | Converts an <a>Fd</a> into a <a>Handle</a> that can be used with the
--   standard Haskell IO library (see <a>System.IO</a>).
fdToHandle :: Fd -> IO Handle


-- | Functions defined by the POSIX standards for manipulating and querying
--   the file system. Names of underlying POSIX functions are indicated
--   whenever possible. A more complete documentation of the POSIX
--   functions together with a more detailed description of different error
--   conditions are usually available in the system's manual pages or from
--   <a>http://www.unix.org/version3/online.html</a> (free registration
--   required).
--   
--   When a function that calls an underlying POSIX function fails, the
--   errno code is converted to an <a>IOError</a> using
--   <a>errnoToIOError</a>. For a list of which errno codes may be
--   generated, consult the POSIX documentation for the underlying
--   function.
module System.Posix.Files.PosixString

-- | Combines the two file modes into one that contains modes that appear
--   in either.
unionFileModes :: FileMode -> FileMode -> FileMode

-- | Combines two file modes into one that only contains modes that appear
--   in both.
intersectFileModes :: FileMode -> FileMode -> FileMode

-- | No permissions.
nullFileMode :: FileMode

-- | Owner has read permission.
ownerReadMode :: FileMode

-- | Owner has write permission.
ownerWriteMode :: FileMode

-- | Owner has execute permission.
ownerExecuteMode :: FileMode

-- | Owner has read, write and execute permission.
ownerModes :: FileMode

-- | Group has read permission.
groupReadMode :: FileMode

-- | Group has write permission.
groupWriteMode :: FileMode

-- | Group has execute permission.
groupExecuteMode :: FileMode

-- | Group has read, write and execute permission.
groupModes :: FileMode

-- | Others have read permission.
otherReadMode :: FileMode

-- | Others have write permission.
otherWriteMode :: FileMode

-- | Others have execute permission.
otherExecuteMode :: FileMode

-- | Others have read, write and execute permission.
otherModes :: FileMode

-- | Set user ID on execution.
setUserIDMode :: FileMode

-- | Set group ID on execution.
setGroupIDMode :: FileMode

-- | Owner, group and others have read and write permission.
stdFileMode :: FileMode

-- | Owner, group and others have read, write and execute permission.
accessModes :: FileMode
fileTypeModes :: FileMode
blockSpecialMode :: FileMode
characterSpecialMode :: FileMode
namedPipeMode :: FileMode
regularFileMode :: FileMode
directoryMode :: FileMode
symbolicLinkMode :: FileMode
socketMode :: FileMode

-- | <tt>setFileMode path mode</tt> changes permission of the file given by
--   <tt>path</tt> to <tt>mode</tt>. This operation may fail with
--   <a>throwErrnoPathIfMinus1_</a> if <tt>path</tt> doesn't exist or if
--   the effective user ID of the current process is not that of the file's
--   owner.
--   
--   Note: calls <tt>chmod</tt>.
setFileMode :: PosixPath -> FileMode -> IO ()

-- | <tt>setFdMode fd mode</tt> acts like <tt>setFileMode</tt> but uses a
--   file descriptor <tt>fd</tt> instead of a <a>FilePath</a>.
--   
--   Note: calls <tt>fchmod</tt>.
setFdMode :: Fd -> FileMode -> IO ()

-- | <tt>setFileCreationMask mode</tt> sets the file mode creation mask to
--   <tt>mode</tt>. Modes set by this operation are subtracted from files
--   and directories upon creation. The previous file creation mask is
--   returned.
--   
--   Note: calls <tt>umask</tt>.
setFileCreationMask :: FileMode -> IO FileMode

-- | <tt>fileAccess name read write exec</tt> checks if the file (or other
--   file system object) <tt>name</tt> can be accessed for reading, writing
--   and/or executing. To check a permission set the corresponding argument
--   to <a>True</a>.
--   
--   Note: calls <tt>access</tt>.
fileAccess :: PosixPath -> Bool -> Bool -> Bool -> IO Bool

-- | Checks for the existence of the file.
--   
--   Note: calls <tt>access</tt>.
fileExist :: PosixPath -> IO Bool

-- | POSIX defines operations to get information, such as owner,
--   permissions, size and access times, about a file. This information is
--   represented by the <a>FileStatus</a> type.
--   
--   Note: see <tt>chmod</tt>.
--   
--   Limitations: Support for high resolution timestamps is filesystem
--   dependent:
--   
--   <ul>
--   <li>HFS+ volumes on OS X only support whole-second times.</li>
--   </ul>
data FileStatus

-- | <tt>getFileStatus path</tt> calls gets the <tt>FileStatus</tt>
--   information (user ID, size, access times, etc.) for the file
--   <tt>path</tt>.
--   
--   Note: calls <tt>stat</tt>.
getFileStatus :: PosixPath -> IO FileStatus

-- | <tt>getFdStatus fd</tt> acts as <tt>getFileStatus</tt> but uses a file
--   descriptor <tt>fd</tt>.
--   
--   Note: calls <tt>fstat</tt>.
getFdStatus :: Fd -> IO FileStatus

-- | Acts as <a>getFileStatus</a> except when the <a>PosixPath</a> refers
--   to a symbolic link. In that case the <tt>FileStatus</tt> information
--   of the symbolic link itself is returned instead of that of the file it
--   points to.
--   
--   Note: calls <tt>lstat</tt>.
getSymbolicLinkStatus :: PosixPath -> IO FileStatus

-- | ID of the device on which this file resides.
deviceID :: FileStatus -> DeviceID

-- | inode number
fileID :: FileStatus -> FileID

-- | File mode (such as permissions).
fileMode :: FileStatus -> FileMode

-- | Number of hard links to this file.
linkCount :: FileStatus -> LinkCount

-- | ID of owner.
fileOwner :: FileStatus -> UserID

-- | ID of group.
fileGroup :: FileStatus -> GroupID

-- | Describes the device that this file represents.
specialDeviceID :: FileStatus -> DeviceID

-- | Size of the file in bytes. If this file is a symbolic link the size is
--   the length of the pathname it contains.
fileSize :: FileStatus -> FileOffset

-- | Time of last access.
accessTime :: FileStatus -> EpochTime

-- | Time of last modification.
modificationTime :: FileStatus -> EpochTime

-- | Time of last status change (i.e. owner, group, link count, mode,
--   etc.).
statusChangeTime :: FileStatus -> EpochTime

-- | Time of last access in sub-second resolution. Depends on the timestamp
--   resolution of the underlying filesystem.
accessTimeHiRes :: FileStatus -> POSIXTime

-- | Time of last modification in sub-second resolution. Depends on the
--   timestamp resolution of the underlying filesystem.
modificationTimeHiRes :: FileStatus -> POSIXTime

-- | Time of last status change (i.e. owner, group, link count, mode, etc.)
--   in sub-second resolution. Depends on the timestamp resolution of the
--   underlying filesystem.
statusChangeTimeHiRes :: FileStatus -> POSIXTime

-- | Checks if this file is a block device.
isBlockDevice :: FileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDevice :: FileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipe :: FileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFile :: FileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectory :: FileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLink :: FileStatus -> Bool

-- | Checks if this file is a socket device.
isSocket :: FileStatus -> Bool
newtype ExtendedFileStatus

-- | The constructor is considered internal and may change.
ExtendedFileStatus :: ForeignPtr CStatx -> ExtendedFileStatus
newtype CAttributes
CAttributes :: Word64 -> CAttributes

-- | Whether <tt>statx</tt> is available on this platform and
--   <tt>getExtendedFileStatus</tt> and related functions will work.
haveStatx :: Bool

-- | Gets extended file status information.
--   
--   The target file to open is identified in one of the following ways:
--   
--   <ul>
--   <li>If <tt>pathname</tt> begins with a slash, then it is an absolute
--   pathname that identifies the target file. In this case, <tt>dirfd</tt>
--   is ignored</li>
--   <li>If <tt>pathname</tt> is a string that begins with a character
--   other than a slash and <tt>dirfd</tt> is a file descriptor that refers
--   to a directory, then pathname is a relative pathname that is
--   interpreted relative to the directory referred to by dirfd. (See
--   <tt>openat(2)</tt> for an explanation of why this is useful.)</li>
--   <li>If <tt>pathname</tt> is an empty string and the <a>EmptyPath</a>
--   flag is specified in flags (see below), then the target file is the
--   one referred to by the file descriptor <tt>dirfd</tt>.</li>
--   </ul>
--   
--   Note: calls <tt>statx</tt>.
getExtendedFileStatus :: Maybe Fd -> PosixPath -> StatxFlags -> StatxMask -> IO ExtendedFileStatus

-- | Statx flags.
--   
--   See the pattern synonyms for possible flags. These are combined via
--   <a>(&lt;&gt;)</a>. Flags can be tested via <a>(.&amp;.)</a>.
--   
--   The following flags influence pathname-based lookup:
--   
--   <ul>
--   <li><a>EmptyPath</a></li>
--   <li><a>NoAutoMount</a></li>
--   <li><a>SymlinkNoFollow</a></li>
--   </ul>
--   
--   The following flags can be used to control what sort of
--   synchronization the kernel will do when querying a file on a remote
--   filesystem:
--   
--   <ul>
--   <li><a>SyncAsStat</a></li>
--   <li><a>ForceSync</a></li>
--   <li><a>DontSync</a></li>
--   </ul>
newtype StatxFlags
StatxFlags :: CInt -> StatxFlags
defaultStatxFlags :: StatxFlags

-- | If pathname to <tt>getExtendedFileStatus</tt> is an empty string,
--   operate on the file referred to by the 'Maybe Fd' argument.
--   
--   In this case, it can refer to any type of file, not just a directory.
pattern EmptyPath :: StatxFlags

-- | Don't automount the terminal ("basename") component of pathname if it
--   is a directory that is an automount point. This allows the caller to
--   gather attributes of an automount point (rather than the location it
--   would mount). This flag can be used in tools that scan directories to
--   prevent mass-automounting of a directory of automount points. This
--   flag has no effect if the mount point has already been mounted over.
pattern NoAutoMount :: StatxFlags

-- | If pathname is a symbolic link, do not dereference it: instead return
--   information about the link itself, like <tt>lstat(2)</tt>.
pattern SymlinkNoFollow :: StatxFlags

-- | Do whatever <tt>stat(2)</tt> does. This is the default and is very
--   much filesystem-specific.
pattern SyncAsStat :: StatxFlags

-- | Force the attributes to be synchronized with the server. This may
--   require that a network filesystem perform a data writeback to get the
--   timestamps correct.
pattern ForceSync :: StatxFlags

-- | Don't synchronize anything, but rather just take whatever the system
--   has cached if possible. This may mean that the information returned is
--   approximate, but, on a network filesystem, it may not involve a round
--   trip to the server - even if no lease is held.
pattern DontSync :: StatxFlags

-- | Mask argument to <tt>statx</tt>. It's used to tell the kernel which
--   fields the caller is interested in.
--   
--   See the pattern synonyms for possible masks. These are combined via
--   <tt>(&lt;&gt;)</tt>. Masks can be tested via <a>(.&amp;.)</a>.
newtype StatxMask
StatxMask :: CInt -> StatxMask
defaultStatxMask :: StatxMask

-- | Want <tt>stx_mode &amp; S_IFMT</tt>.
pattern StatxType :: StatxMask

-- | Want <tt>stx_mode &amp; ~S_IFMT</tt>.
pattern StatxMode :: StatxMask

-- | Want <tt>stx_nlink</tt>.
pattern StatxNlink :: StatxMask

-- | Want <tt>stx_uid</tt>.
pattern StatxUid :: StatxMask

-- | Want <tt>stx_gid</tt>.
pattern StatxGid :: StatxMask

-- | Want <tt>stx_atime</tt>.
pattern StatxAtime :: StatxMask

-- | Want <tt>stx_mtime</tt>.
pattern StatxMtime :: StatxMask

-- | Want <tt>stx_ctime</tt>.
pattern StatxCtime :: StatxMask

-- | Want <tt>stx_ino</tt>.
pattern StatxIno :: StatxMask

-- | Want <tt>stx_size</tt>.
pattern StatxSize :: StatxMask

-- | Want <tt>stx_blocks</tt>.
pattern StatxBlocks :: StatxMask

-- | Want all of the above.
pattern StatxBasicStats :: StatxMask

-- | Want <tt>stx_btime</tt>.
pattern StatxBtime :: StatxMask

-- | Want <tt>stx_mnt_id</tt>.
pattern StatxMntId :: StatxMask

-- | Want all currently available fields.
pattern StatxAll :: StatxMask

-- | The "preferred" block size for efficient filesystem I/O. (Writing to a
--   file in smaller chunks may cause an inefficient read-mod‐ify-rewrite.)

-- | <i>Warning: fileBlockSizeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileBlockSizeX :: ExtendedFileStatus -> CBlkSize

-- | The number of hard links on a file.

-- | <i>Warning: linkCountX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
linkCountX :: ExtendedFileStatus -> CNlink

-- | Te user ID of the owner of the file.

-- | <i>Warning: fileOwnerX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileOwnerX :: ExtendedFileStatus -> UserID

-- | The ID of the group owner of the file.

-- | <i>Warning: fileGroupX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileGroupX :: ExtendedFileStatus -> GroupID

-- | The file type and mode. See <tt>inode(7)</tt> for details.

-- | <i>Warning: fileModeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileModeX :: ExtendedFileStatus -> FileMode

-- | The inode number of the file.

-- | <i>Warning: fileIDX: not available on this platform, will throw error
--   (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileIDX :: ExtendedFileStatus -> FileID

-- | The size of the file (if it is a regular file or a symbolic link) in
--   bytes. The size of a symbolic link is the length of the pathname it
--   contains, without a terminating null byte.

-- | <i>Warning: fileSizeX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileSizeX :: ExtendedFileStatus -> Word64

-- | The number of blocks allocated to the file on the medium, in 512-byte
--   units. (This may be smaller than stx_size/512 when the file has
--   holes.)

-- | <i>Warning: fileBlocksX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileBlocksX :: ExtendedFileStatus -> Word64

-- | The file's last access timestamp.

-- | <i>Warning: accessTimeHiResX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
accessTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's creation timestamp.

-- | <i>Warning: creationTimeHiResX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
creationTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's last status change timestamp.

-- | <i>Warning: statusChangeTimeHiResX: not available on this platform,
--   will throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
statusChangeTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | The file's last modification timestamp.

-- | <i>Warning: modificationTimeHiResX: not available on this platform,
--   will throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
modificationTimeHiResX :: ExtendedFileStatus -> POSIXTime

-- | ID of the device on which this file resides.

-- | <i>Warning: deviceIDX: not available on this platform, will throw
--   error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
deviceIDX :: ExtendedFileStatus -> DeviceID

-- | Describes the device that this file represents.

-- | <i>Warning: specialDeviceIDX: not available on this platform, will
--   throw error (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
specialDeviceIDX :: ExtendedFileStatus -> DeviceID

-- | The mount ID of the mount containing the file. This is the same number
--   reported by name_to_handle_at(2) and corresponds to the number in the
--   first field in one of the records in <i>proc</i>self/mountinfo.

-- | <i>Warning: mountIDX: not available on this platform, will throw error
--   (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
mountIDX :: ExtendedFileStatus -> Word64

-- | The file is compressed by the filesystem and may take extra resources
--   to access. This is an extended attribute.

-- | <i>Warning: fileCompressedX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileCompressedX :: ExtendedFileStatus -> Bool

-- | The file cannot be modified: it cannot be deleted or renamed, no hard
--   links can be created to this file and no data can be written to it.
--   See <tt>chattr(1)</tt>. This is an extended attribute.

-- | <i>Warning: fileImmutableX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileImmutableX :: ExtendedFileStatus -> Bool

-- | The file can only be opened in append mode for writing. Random access
--   writing is not permitted. See <tt>chattr(1)</tt>. This is an extended
--   attribute.

-- | <i>Warning: fileAppendX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileAppendX :: ExtendedFileStatus -> Bool

-- | File is not a candidate for backup when a backup program such as
--   <tt>dump(8)</tt> is run. See <tt>chattr(1)</tt>. This is an extended
--   attribute.

-- | <i>Warning: fileNoDumpX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileNoDumpX :: ExtendedFileStatus -> Bool

-- | A key is required for the file to be encrypted by the filesystem. This
--   is an extended attribute.

-- | <i>Warning: fileEncryptedX: not available on this platform, will
--   default to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileEncryptedX :: ExtendedFileStatus -> Bool

-- | The file has fs-verity enabled. It cannot be written to, and all reads
--   from it will be verified against a cryptographic hash that covers the
--   entire file (e.g., via a Merkle tree). This is an extended attribute.
--   Since Linux 5.5.

-- | <i>Warning: fileVerityX: not available on this platform, will default
--   to <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileVerityX :: ExtendedFileStatus -> Bool

-- | The file is in the DAX (cpu direct access) state. This is an extended
--   attribute. Since Linux 5.8.

-- | <i>Warning: fileDaxX: not available on this platform, will default to
--   <a>False</a> (CPP guard: <tt>#if HAVE_STATX</tt>)</i>
fileDaxX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a block device.
isBlockDeviceX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDeviceX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipeX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFileX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectoryX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLinkX :: ExtendedFileStatus -> Bool

-- | Checks if this file is a socket device.
isSocketX :: ExtendedFileStatus -> Bool

-- | <tt>createNamedPipe fifo mode</tt> creates a new named pipe,
--   <tt>fifo</tt>, with permissions based on <tt>mode</tt>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the pipe.
--   
--   Note: calls <tt>mkfifo</tt>.
createNamedPipe :: PosixPath -> FileMode -> IO ()

-- | <tt>createDevice path mode dev</tt> creates either a regular or a
--   special file depending on the value of <tt>mode</tt> (and
--   <tt>dev</tt>). <tt>mode</tt> will normally be either
--   <a>blockSpecialMode</a> or <a>characterSpecialMode</a>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the file.
--   
--   Note: calls <tt>mknod</tt>.
createDevice :: PosixPath -> FileMode -> DeviceID -> IO ()

-- | <tt>createLink old new</tt> creates a new path, <tt>new</tt>, linked
--   to an existing file, <tt>old</tt>.
--   
--   Note: calls <tt>link</tt>.
createLink :: PosixPath -> PosixPath -> IO ()

-- | <tt>removeLink path</tt> removes the link named <tt>path</tt>.
--   
--   Note: calls <tt>unlink</tt>.
removeLink :: PosixPath -> IO ()

-- | <tt>createSymbolicLink file1 file2</tt> creates a symbolic link named
--   <tt>file2</tt> which points to the file <tt>file1</tt>.
--   
--   Symbolic links are interpreted at run-time as if the contents of the
--   link had been substituted into the path being followed to find a file
--   or directory.
--   
--   Note: calls <tt>symlink</tt>.
createSymbolicLink :: PosixPath -> PosixPath -> IO ()

-- | Reads the <tt>PosixPath</tt> pointed to by the symbolic link and
--   returns it.
--   
--   Note: calls <tt>readlink</tt>.
readSymbolicLink :: PosixPath -> IO PosixPath

-- | <tt>rename old new</tt> renames a file or directory from <tt>old</tt>
--   to <tt>new</tt>.
--   
--   Note: calls <tt>rename</tt>.
rename :: PosixPath -> PosixPath -> IO ()

-- | <tt>setOwnerAndGroup path uid gid</tt> changes the owner and group of
--   <tt>path</tt> to <tt>uid</tt> and <tt>gid</tt>, respectively.
--   
--   If <tt>uid</tt> or <tt>gid</tt> is specified as -1, then that ID is
--   not changed.
--   
--   Note: calls <tt>chown</tt>.
setOwnerAndGroup :: PosixPath -> UserID -> GroupID -> IO ()

-- | Acts as <tt>setOwnerAndGroup</tt> but uses a file descriptor instead
--   of a <a>FilePath</a>.
--   
--   Note: calls <tt>fchown</tt>.
setFdOwnerAndGroup :: Fd -> UserID -> GroupID -> IO ()

-- | Acts as <a>setOwnerAndGroup</a> but does not follow symlinks (and thus
--   changes permissions on the link itself).
--   
--   Note: calls <tt>lchown</tt>.
setSymbolicLinkOwnerAndGroup :: PosixPath -> UserID -> GroupID -> IO ()

-- | <tt>setFileTimes path atime mtime</tt> sets the access and
--   modification times associated with file <tt>path</tt> to
--   <tt>atime</tt> and <tt>mtime</tt>, respectively.
--   
--   Note: calls <tt>utime</tt>.
setFileTimes :: PosixPath -> EpochTime -> EpochTime -> IO ()

-- | Like <a>setFileTimes</a> but timestamps can have sub-second
--   resolution.
--   
--   Note: calls <tt>utimensat</tt> or <tt>utimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setFileTimesHiRes :: PosixPath -> POSIXTime -> POSIXTime -> IO ()

-- | Like <a>setFileTimesHiRes</a> but does not follow symbolic links. This
--   operation is not supported on all platforms. On these platforms, this
--   function will raise an exception.
--   
--   Note: calls <tt>utimensat</tt> or <tt>lutimes</tt>. Support for high
--   resolution timestamps is filesystem dependent with the following
--   limitations:
--   
--   <ul>
--   <li>HFS+ volumes on OS X truncate the sub-second part of the
--   timestamp.</li>
--   </ul>
setSymbolicLinkTimesHiRes :: PosixPath -> POSIXTime -> POSIXTime -> IO ()

-- | <tt>touchFile path</tt> sets the access and modification times
--   associated with file <tt>path</tt> to the current time.
--   
--   Note: calls <tt>utime</tt>.
touchFile :: PosixPath -> IO ()

-- | Like <tt>touchFile</tt> but uses a file descriptor instead of a path.
--   This operation is not supported on all platforms. On these platforms,
--   this function will raise an exception.
--   
--   Note: calls <tt>futimes</tt>.
touchFd :: Fd -> IO ()

-- | Like <a>touchFile</a> but does not follow symbolic links. This
--   operation is not supported on all platforms. On these platforms, this
--   function will raise an exception.
--   
--   Note: calls <tt>lutimes</tt>.
touchSymbolicLink :: PosixPath -> IO ()

-- | Truncates the file down to the specified length. If the file was
--   larger than the given length before this operation was performed the
--   extra is lost.
--   
--   Note: calls <tt>truncate</tt>.
setFileSize :: PosixPath -> FileOffset -> IO ()

-- | Acts as <tt>setFileSize</tt> but uses a file descriptor instead of a
--   <a>FilePath</a>.
--   
--   Note: calls <tt>ftruncate</tt>.
setFdSize :: Fd -> FileOffset -> IO ()
data PathVar
FileSizeBits :: PathVar
LinkLimit :: PathVar
InputLineLimit :: PathVar
InputQueueLimit :: PathVar
FileNameLimit :: PathVar
PathNameLimit :: PathVar
PipeBufferLimit :: PathVar
SymbolicLinkLimit :: PathVar
SetOwnerAndGroupIsRestricted :: PathVar
FileNamesAreNotTruncated :: PathVar
VDisableChar :: PathVar
AsyncIOAvailable :: PathVar
PrioIOAvailable :: PathVar
SyncIOAvailable :: PathVar

-- | <tt>getPathVar var path</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with file or
--   directory <tt>path</tt>. For defined file limits, <tt>getPathVar</tt>
--   returns the associated value. For defined file options, the result of
--   <tt>getPathVar</tt> is undefined, but not failure.
--   
--   Note: calls <tt>pathconf</tt>.
getPathVar :: PosixPath -> PathVar -> IO Limit

-- | <tt>getFdPathVar var fd</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with the file
--   or directory attached to the open channel <tt>fd</tt>. For defined
--   file limits, <tt>getFdPathVar</tt> returns the associated value. For
--   defined file options, the result of <tt>getFdPathVar</tt> is
--   undefined, but not failure.
--   
--   Note: calls <tt>fpathconf</tt>.
getFdPathVar :: Fd -> PathVar -> IO Limit


-- | PosixPath based POSIX directory support
module System.Posix.Directory.PosixPath

-- | <tt>createDirectory dir mode</tt> calls <tt>mkdir</tt> to create a new
--   directory, <tt>dir</tt>, with permissions based on <tt>mode</tt>.
createDirectory :: PosixPath -> FileMode -> IO ()
removeDirectory :: PosixPath -> IO ()
data DirStream

-- | <tt>openDirStream dir</tt> calls <tt>opendir</tt> to obtain a
--   directory stream for <tt>dir</tt>.
openDirStream :: PosixPath -> IO DirStream

-- | <tt>readDirStream dp</tt> calls <tt>readdir</tt> to obtain the next
--   directory entry (<tt>struct dirent</tt>) for the open directory stream
--   <tt>dp</tt>, and returns the <tt>d_name</tt> member of that structure.
readDirStream :: DirStream -> IO PosixPath

-- | <tt>rewindDirStream dp</tt> calls <tt>rewinddir</tt> to reposition the
--   directory stream <tt>dp</tt> at the beginning of the directory.
rewindDirStream :: DirStream -> IO ()

-- | <tt>closeDirStream dp</tt> calls <tt>closedir</tt> to close the
--   directory stream <tt>dp</tt>.
closeDirStream :: DirStream -> IO ()
data DirStreamOffset
tellDirStream :: DirStream -> IO DirStreamOffset
seekDirStream :: DirStream -> DirStreamOffset -> IO ()

-- | <tt>getWorkingDirectory</tt> calls <tt>getcwd</tt> to obtain the name
--   of the current working directory.
getWorkingDirectory :: IO PosixPath

-- | <tt>changeWorkingDirectory dir</tt> calls <tt>chdir</tt> to change the
--   current working directory to <tt>dir</tt>.
changeWorkingDirectory :: PosixPath -> IO ()
changeWorkingDirectoryFd :: Fd -> IO ()

module System.Posix.Process.Internals
pPrPr_disableITimers :: IO ()
c_execvpe :: CString -> Ptr CString -> Ptr CString -> IO CInt
decipherWaitStatus :: CInt -> IO ProcessStatus

-- | The exit status of a process
data ProcessStatus

-- | the process exited by calling <tt>exit()</tt> or returning from
--   <tt>main</tt>
Exited :: ExitCode -> ProcessStatus

-- | the process was terminated by a signal, the <tt>Bool</tt> is
--   <tt>True</tt> if a core dump was produced
Terminated :: Signal -> Bool -> ProcessStatus

-- | the process was stopped by a signal
Stopped :: Signal -> ProcessStatus
instance GHC.Classes.Eq System.Posix.Process.Internals.ProcessStatus
instance GHC.Classes.Ord System.Posix.Process.Internals.ProcessStatus
instance GHC.Internal.Show.Show System.Posix.Process.Internals.ProcessStatus


-- | POSIX process support. See also the System.Cmd and System.Process
--   modules in the process package.
module System.Posix.Process.ByteString

-- | <a>forkProcess</a> corresponds to the POSIX <tt>fork</tt> system call.
--   The <a>IO</a> action passed as an argument is executed in the child
--   process; no other threads will be copied to the child process. On
--   success, <a>forkProcess</a> returns the child's <a>ProcessID</a> to
--   the parent process; in case of an error, an exception is thrown.
--   
--   The exception masking state of the executed action is inherited (c.f.
--   <tt>forkIO</tt>), see also <a>forkProcessWithUnmask</a> (<i>since:
--   2.7.0.0</i>).
--   
--   <a>forkProcess</a> comes with a giant warning: since any other running
--   threads are not copied into the child process, it's easy to go wrong:
--   e.g. by accessing some shared resource that was held by another thread
--   in the parent.
--   
--   GHC note: <a>forkProcess</a> is not currently very well supported when
--   using multiple capabilities (<tt>+RTS -N</tt>), although it is
--   supported with <tt>-threaded</tt> as long as only one capability is
--   being used.
forkProcess :: IO () -> IO ProcessID

-- | Variant of <a>forkProcess</a> in the style of
--   <tt>forkIOWithUnmask</tt>.
forkProcessWithUnmask :: ((forall a. () => IO a -> IO a) -> IO ()) -> IO ProcessID

-- | <tt><a>executeFile</a> cmd args env</tt> calls one of the
--   <tt>execv*</tt> family, depending on whether or not the current PATH
--   is to be searched for the command, and whether or not an environment
--   is provided to supersede the process's current environment. The
--   basename (leading directory names suppressed) of the command is passed
--   to <tt>execv*</tt> as <tt>arg[0]</tt>; the argument list passed to
--   <a>executeFile</a> therefore begins with <tt>arg[1]</tt>.
executeFile :: RawFilePath -> Bool -> [ByteString] -> Maybe [(ByteString, ByteString)] -> IO a

-- | <tt><a>exitImmediately</a> status</tt> calls <tt>_exit</tt> to
--   terminate the process with the indicated exit <tt>status</tt>. The
--   operation never returns. Since it does not use the Haskell exception
--   system and it cannot be caught.
--   
--   Note: Prior to <tt>unix-2.8.0.0</tt> the type-signature of
--   <a>exitImmediately</a> was <tt>ExitCode -&gt; IO ()</tt>.
exitImmediately :: ExitCode -> IO a

-- | <a>getProcessID</a> calls <tt>getpid</tt> to obtain the
--   <a>ProcessID</a> for the current process.
getProcessID :: IO ProcessID

-- | <a>getParentProcessID</a> calls <tt>getppid</tt> to obtain the
--   <a>ProcessID</a> for the parent of the current process.
getParentProcessID :: IO ProcessID

-- | <a>getProcessGroupID</a> calls <tt>getpgrp</tt> to obtain the
--   <a>ProcessGroupID</a> for the current process.
getProcessGroupID :: IO ProcessGroupID

-- | <tt><a>getProcessGroupIDOf</a> pid</tt> calls <tt>getpgid</tt> to
--   obtain the <a>ProcessGroupID</a> for process <tt>pid</tt>.
getProcessGroupIDOf :: ProcessID -> IO ProcessGroupID

-- | <tt><a>createProcessGroupFor</a> pid</tt> calls <tt>setpgid</tt> to
--   make process <tt>pid</tt> a new process group leader.
createProcessGroupFor :: ProcessID -> IO ProcessGroupID

-- | <tt><a>joinProcessGroup</a> pgid</tt> calls <tt>setpgid</tt> to set
--   the <a>ProcessGroupID</a> of the current process to <tt>pgid</tt>.
joinProcessGroup :: ProcessGroupID -> IO ()

-- | <tt><a>setProcessGroupIDOf</a> pid pgid</tt> calls <tt>setpgid</tt> to
--   set the <tt>ProcessGroupIDOf</tt> for process <tt>pid</tt> to
--   <tt>pgid</tt>.
setProcessGroupIDOf :: ProcessID -> ProcessGroupID -> IO ()

-- | <a>createSession</a> calls <tt>setsid</tt> to create a new session
--   with the current process as session leader.
createSession :: IO ProcessGroupID
data ProcessTimes
ProcessTimes :: ClockTick -> ClockTick -> ClockTick -> ClockTick -> ClockTick -> ProcessTimes
[elapsedTime] :: ProcessTimes -> ClockTick
[userTime] :: ProcessTimes -> ClockTick
[systemTime] :: ProcessTimes -> ClockTick
[childUserTime] :: ProcessTimes -> ClockTick
[childSystemTime] :: ProcessTimes -> ClockTick

-- | <a>getProcessTimes</a> calls <tt>times</tt> to obtain time-accounting
--   information for the current process and its children.
getProcessTimes :: IO ProcessTimes
nice :: Int -> IO ()
getProcessPriority :: ProcessID -> IO Int
getProcessGroupPriority :: ProcessGroupID -> IO Int
getUserPriority :: UserID -> IO Int
setProcessPriority :: ProcessID -> Int -> IO ()
setProcessGroupPriority :: ProcessGroupID -> Int -> IO ()
setUserPriority :: UserID -> Int -> IO ()

-- | The exit status of a process
data ProcessStatus

-- | the process exited by calling <tt>exit()</tt> or returning from
--   <tt>main</tt>
Exited :: ExitCode -> ProcessStatus

-- | the process was terminated by a signal, the <tt>Bool</tt> is
--   <tt>True</tt> if a core dump was produced
Terminated :: Signal -> Bool -> ProcessStatus

-- | the process was stopped by a signal
Stopped :: Signal -> ProcessStatus

-- | <tt><a>getProcessStatus</a> blk stopped pid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> tc</tt>, the
--   <a>ProcessStatus</a> for process <tt>pid</tt> if it is available,
--   <a>Nothing</a> otherwise. If <tt>blk</tt> is <a>False</a>, then
--   <tt>WNOHANG</tt> is set in the options for <tt>waitpid</tt>, otherwise
--   not. If <tt>stopped</tt> is <a>True</a>, then <tt>WUNTRACED</tt> is
--   set in the options for <tt>waitpid</tt>, otherwise not.
getProcessStatus :: Bool -> Bool -> ProcessID -> IO (Maybe ProcessStatus)

-- | <tt><a>getAnyProcessStatus</a> blk stopped</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any child process if a
--   child process has exited, or <a>Nothing</a> if there are child
--   processes but none have exited. If there are no child processes, then
--   <a>getAnyProcessStatus</a> raises an <tt>isDoesNotExistError</tt>
--   exception.
--   
--   If <tt>blk</tt> is <a>False</a>, then <tt>WNOHANG</tt> is set in the
--   options for <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is
--   <a>True</a>, then <tt>WUNTRACED</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not.
getAnyProcessStatus :: Bool -> Bool -> IO (Maybe (ProcessID, ProcessStatus))

-- | <tt><a>getGroupProcessStatus</a> blk stopped pgid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any process in group
--   <tt>pgid</tt> if one is available, or <a>Nothing</a> if there are
--   child processes but none have exited. If there are no child processes,
--   then <a>getGroupProcessStatus</a> raises an
--   <tt>isDoesNotExistError</tt> exception.
--   
--   If <tt>blk</tt> is <a>False</a>, then <tt>WNOHANG</tt> is set in the
--   options for <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is
--   <a>True</a>, then <tt>WUNTRACED</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not.
getGroupProcessStatus :: Bool -> Bool -> ProcessGroupID -> IO (Maybe (ProcessID, ProcessStatus))

-- | <tt><a>createProcessGroup</a> pid</tt> calls <tt>setpgid</tt> to make
--   process <tt>pid</tt> a new process group leader. This function is
--   currently deprecated, and might be changed to making the current
--   process a new process group leader in future versions.

-- | <i>Deprecated: This function is scheduled to be replaced by something
--   different in the future, we therefore recommend that you do not use
--   this version and use <a>createProcessGroupFor</a> instead.</i>
createProcessGroup :: ProcessID -> IO ProcessGroupID

-- | <tt><a>setProcessGroupID</a> pid pgid</tt> calls <tt>setpgid</tt> to
--   set the <a>ProcessGroupID</a> for process <tt>pid</tt> to
--   <tt>pgid</tt>. This function is currently deprecated, and might be
--   changed to setting the <a>ProcessGroupID</a> for the current process
--   in future versions.

-- | <i>Deprecated: This function is scheduled to be replaced by something
--   different in the future, we therefore recommend that you do not use
--   this version and use <a>setProcessGroupIDOf</a> instead.</i>
setProcessGroupID :: ProcessID -> ProcessGroupID -> IO ()


-- | POSIX process support. See also the System.Cmd and System.Process
--   modules in the process package.
module System.Posix.Process

-- | <a>forkProcess</a> corresponds to the POSIX <tt>fork</tt> system call.
--   The <a>IO</a> action passed as an argument is executed in the child
--   process; no other threads will be copied to the child process. On
--   success, <a>forkProcess</a> returns the child's <a>ProcessID</a> to
--   the parent process; in case of an error, an exception is thrown.
--   
--   The exception masking state of the executed action is inherited (c.f.
--   <tt>forkIO</tt>), see also <a>forkProcessWithUnmask</a> (<i>since:
--   2.7.0.0</i>).
--   
--   <a>forkProcess</a> comes with a giant warning: since any other running
--   threads are not copied into the child process, it's easy to go wrong:
--   e.g. by accessing some shared resource that was held by another thread
--   in the parent.
--   
--   GHC note: <a>forkProcess</a> is not currently very well supported when
--   using multiple capabilities (<tt>+RTS -N</tt>), although it is
--   supported with <tt>-threaded</tt> as long as only one capability is
--   being used.
forkProcess :: IO () -> IO ProcessID

-- | Variant of <a>forkProcess</a> in the style of
--   <tt>forkIOWithUnmask</tt>.
forkProcessWithUnmask :: ((forall a. () => IO a -> IO a) -> IO ()) -> IO ProcessID

-- | <tt><a>executeFile</a> cmd args env</tt> calls one of the
--   <tt>execv*</tt> family, depending on whether or not the current PATH
--   is to be searched for the command, and whether or not an environment
--   is provided to supersede the process's current environment. The
--   basename (leading directory names suppressed) of the command is passed
--   to <tt>execv*</tt> as <tt>arg[0]</tt>; the argument list passed to
--   <a>executeFile</a> therefore begins with <tt>arg[1]</tt>.
executeFile :: FilePath -> Bool -> [String] -> Maybe [(String, String)] -> IO a

-- | <tt><a>exitImmediately</a> status</tt> calls <tt>_exit</tt> to
--   terminate the process with the indicated exit <tt>status</tt>. The
--   operation never returns. Since it does not use the Haskell exception
--   system and it cannot be caught.
--   
--   Note: Prior to <tt>unix-2.8.0.0</tt> the type-signature of
--   <a>exitImmediately</a> was <tt>ExitCode -&gt; IO ()</tt>.
exitImmediately :: ExitCode -> IO a

-- | <a>getProcessID</a> calls <tt>getpid</tt> to obtain the
--   <a>ProcessID</a> for the current process.
getProcessID :: IO ProcessID

-- | <a>getParentProcessID</a> calls <tt>getppid</tt> to obtain the
--   <a>ProcessID</a> for the parent of the current process.
getParentProcessID :: IO ProcessID

-- | <a>getProcessGroupID</a> calls <tt>getpgrp</tt> to obtain the
--   <a>ProcessGroupID</a> for the current process.
getProcessGroupID :: IO ProcessGroupID

-- | <tt><a>getProcessGroupIDOf</a> pid</tt> calls <tt>getpgid</tt> to
--   obtain the <a>ProcessGroupID</a> for process <tt>pid</tt>.
getProcessGroupIDOf :: ProcessID -> IO ProcessGroupID

-- | <tt><a>createProcessGroupFor</a> pid</tt> calls <tt>setpgid</tt> to
--   make process <tt>pid</tt> a new process group leader.
createProcessGroupFor :: ProcessID -> IO ProcessGroupID

-- | <tt><a>joinProcessGroup</a> pgid</tt> calls <tt>setpgid</tt> to set
--   the <a>ProcessGroupID</a> of the current process to <tt>pgid</tt>.
joinProcessGroup :: ProcessGroupID -> IO ()

-- | <tt><a>setProcessGroupIDOf</a> pid pgid</tt> calls <tt>setpgid</tt> to
--   set the <tt>ProcessGroupIDOf</tt> for process <tt>pid</tt> to
--   <tt>pgid</tt>.
setProcessGroupIDOf :: ProcessID -> ProcessGroupID -> IO ()

-- | <a>createSession</a> calls <tt>setsid</tt> to create a new session
--   with the current process as session leader.
createSession :: IO ProcessGroupID
data ProcessTimes
ProcessTimes :: ClockTick -> ClockTick -> ClockTick -> ClockTick -> ClockTick -> ProcessTimes
[elapsedTime] :: ProcessTimes -> ClockTick
[userTime] :: ProcessTimes -> ClockTick
[systemTime] :: ProcessTimes -> ClockTick
[childUserTime] :: ProcessTimes -> ClockTick
[childSystemTime] :: ProcessTimes -> ClockTick

-- | <a>getProcessTimes</a> calls <tt>times</tt> to obtain time-accounting
--   information for the current process and its children.
getProcessTimes :: IO ProcessTimes
nice :: Int -> IO ()
getProcessPriority :: ProcessID -> IO Int
getProcessGroupPriority :: ProcessGroupID -> IO Int
getUserPriority :: UserID -> IO Int
setProcessPriority :: ProcessID -> Int -> IO ()
setProcessGroupPriority :: ProcessGroupID -> Int -> IO ()
setUserPriority :: UserID -> Int -> IO ()

-- | The exit status of a process
data ProcessStatus

-- | the process exited by calling <tt>exit()</tt> or returning from
--   <tt>main</tt>
Exited :: ExitCode -> ProcessStatus

-- | the process was terminated by a signal, the <tt>Bool</tt> is
--   <tt>True</tt> if a core dump was produced
Terminated :: Signal -> Bool -> ProcessStatus

-- | the process was stopped by a signal
Stopped :: Signal -> ProcessStatus

-- | <tt><a>getProcessStatus</a> blk stopped pid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> tc</tt>, the
--   <a>ProcessStatus</a> for process <tt>pid</tt> if it is available,
--   <a>Nothing</a> otherwise. If <tt>blk</tt> is <a>False</a>, then
--   <tt>WNOHANG</tt> is set in the options for <tt>waitpid</tt>, otherwise
--   not. If <tt>stopped</tt> is <a>True</a>, then <tt>WUNTRACED</tt> is
--   set in the options for <tt>waitpid</tt>, otherwise not.
getProcessStatus :: Bool -> Bool -> ProcessID -> IO (Maybe ProcessStatus)

-- | <tt><a>getAnyProcessStatus</a> blk stopped</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any child process if a
--   child process has exited, or <a>Nothing</a> if there are child
--   processes but none have exited. If there are no child processes, then
--   <a>getAnyProcessStatus</a> raises an <tt>isDoesNotExistError</tt>
--   exception.
--   
--   If <tt>blk</tt> is <a>False</a>, then <tt>WNOHANG</tt> is set in the
--   options for <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is
--   <a>True</a>, then <tt>WUNTRACED</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not.
getAnyProcessStatus :: Bool -> Bool -> IO (Maybe (ProcessID, ProcessStatus))

-- | <tt><a>getGroupProcessStatus</a> blk stopped pgid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any process in group
--   <tt>pgid</tt> if one is available, or <a>Nothing</a> if there are
--   child processes but none have exited. If there are no child processes,
--   then <a>getGroupProcessStatus</a> raises an
--   <tt>isDoesNotExistError</tt> exception.
--   
--   If <tt>blk</tt> is <a>False</a>, then <tt>WNOHANG</tt> is set in the
--   options for <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is
--   <a>True</a>, then <tt>WUNTRACED</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not.
getGroupProcessStatus :: Bool -> Bool -> ProcessGroupID -> IO (Maybe (ProcessID, ProcessStatus))

-- | <tt><a>createProcessGroup</a> pid</tt> calls <tt>setpgid</tt> to make
--   process <tt>pid</tt> a new process group leader. This function is
--   currently deprecated, and might be changed to making the current
--   process a new process group leader in future versions.

-- | <i>Deprecated: This function is scheduled to be replaced by something
--   different in the future, we therefore recommend that you do not use
--   this version and use <a>createProcessGroupFor</a> instead.</i>
createProcessGroup :: ProcessID -> IO ProcessGroupID

-- | <tt><a>setProcessGroupID</a> pid pgid</tt> calls <tt>setpgid</tt> to
--   set the <a>ProcessGroupID</a> for process <tt>pid</tt> to
--   <tt>pgid</tt>. This function is currently deprecated, and might be
--   changed to setting the <a>ProcessGroupID</a> for the current process
--   in future versions.

-- | <i>Deprecated: This function is scheduled to be replaced by something
--   different in the future, we therefore recommend that you do not use
--   this version and use <a>setProcessGroupIDOf</a> instead.</i>
setProcessGroupID :: ProcessID -> ProcessGroupID -> IO ()


-- | POSIX process support. See also the System.Cmd and System.Process
--   modules in the process package.
module System.Posix.Process.PosixString

-- | <a>forkProcess</a> corresponds to the POSIX <tt>fork</tt> system call.
--   The <a>IO</a> action passed as an argument is executed in the child
--   process; no other threads will be copied to the child process. On
--   success, <a>forkProcess</a> returns the child's <a>ProcessID</a> to
--   the parent process; in case of an error, an exception is thrown.
--   
--   The exception masking state of the executed action is inherited (c.f.
--   <tt>forkIO</tt>), see also <a>forkProcessWithUnmask</a> (<i>since:
--   2.7.0.0</i>).
--   
--   <a>forkProcess</a> comes with a giant warning: since any other running
--   threads are not copied into the child process, it's easy to go wrong:
--   e.g. by accessing some shared resource that was held by another thread
--   in the parent.
--   
--   GHC note: <a>forkProcess</a> is not currently very well supported when
--   using multiple capabilities (<tt>+RTS -N</tt>), although it is
--   supported with <tt>-threaded</tt> as long as only one capability is
--   being used.
forkProcess :: IO () -> IO ProcessID

-- | Variant of <a>forkProcess</a> in the style of
--   <tt>forkIOWithUnmask</tt>.
forkProcessWithUnmask :: ((forall a. () => IO a -> IO a) -> IO ()) -> IO ProcessID

-- | <tt><a>executeFile</a> cmd args env</tt> calls one of the
--   <tt>execv*</tt> family, depending on whether or not the current PATH
--   is to be searched for the command, and whether or not an environment
--   is provided to supersede the process's current environment. The
--   basename (leading directory names suppressed) of the command is passed
--   to <tt>execv*</tt> as <tt>arg[0]</tt>; the argument list passed to
--   <a>executeFile</a> therefore begins with <tt>arg[1]</tt>.
executeFile :: PosixPath -> Bool -> [PosixString] -> Maybe [(PosixString, PosixString)] -> IO a

-- | <tt><a>exitImmediately</a> status</tt> calls <tt>_exit</tt> to
--   terminate the process with the indicated exit <tt>status</tt>. The
--   operation never returns. Since it does not use the Haskell exception
--   system and it cannot be caught.
--   
--   Note: Prior to <tt>unix-2.8.0.0</tt> the type-signature of
--   <a>exitImmediately</a> was <tt>ExitCode -&gt; IO ()</tt>.
exitImmediately :: ExitCode -> IO a

-- | <a>getProcessID</a> calls <tt>getpid</tt> to obtain the
--   <a>ProcessID</a> for the current process.
getProcessID :: IO ProcessID

-- | <a>getParentProcessID</a> calls <tt>getppid</tt> to obtain the
--   <a>ProcessID</a> for the parent of the current process.
getParentProcessID :: IO ProcessID

-- | <a>getProcessGroupID</a> calls <tt>getpgrp</tt> to obtain the
--   <a>ProcessGroupID</a> for the current process.
getProcessGroupID :: IO ProcessGroupID

-- | <tt><a>getProcessGroupIDOf</a> pid</tt> calls <tt>getpgid</tt> to
--   obtain the <a>ProcessGroupID</a> for process <tt>pid</tt>.
getProcessGroupIDOf :: ProcessID -> IO ProcessGroupID

-- | <tt><a>createProcessGroupFor</a> pid</tt> calls <tt>setpgid</tt> to
--   make process <tt>pid</tt> a new process group leader.
createProcessGroupFor :: ProcessID -> IO ProcessGroupID

-- | <tt><a>joinProcessGroup</a> pgid</tt> calls <tt>setpgid</tt> to set
--   the <a>ProcessGroupID</a> of the current process to <tt>pgid</tt>.
joinProcessGroup :: ProcessGroupID -> IO ()

-- | <tt><a>setProcessGroupIDOf</a> pid pgid</tt> calls <tt>setpgid</tt> to
--   set the <tt>ProcessGroupIDOf</tt> for process <tt>pid</tt> to
--   <tt>pgid</tt>.
setProcessGroupIDOf :: ProcessID -> ProcessGroupID -> IO ()

-- | <a>createSession</a> calls <tt>setsid</tt> to create a new session
--   with the current process as session leader.
createSession :: IO ProcessGroupID
data ProcessTimes
ProcessTimes :: ClockTick -> ClockTick -> ClockTick -> ClockTick -> ClockTick -> ProcessTimes
[elapsedTime] :: ProcessTimes -> ClockTick
[userTime] :: ProcessTimes -> ClockTick
[systemTime] :: ProcessTimes -> ClockTick
[childUserTime] :: ProcessTimes -> ClockTick
[childSystemTime] :: ProcessTimes -> ClockTick

-- | <a>getProcessTimes</a> calls <tt>times</tt> to obtain time-accounting
--   information for the current process and its children.
getProcessTimes :: IO ProcessTimes
nice :: Int -> IO ()
getProcessPriority :: ProcessID -> IO Int
getProcessGroupPriority :: ProcessGroupID -> IO Int
getUserPriority :: UserID -> IO Int
setProcessPriority :: ProcessID -> Int -> IO ()
setProcessGroupPriority :: ProcessGroupID -> Int -> IO ()
setUserPriority :: UserID -> Int -> IO ()

-- | The exit status of a process
data ProcessStatus

-- | the process exited by calling <tt>exit()</tt> or returning from
--   <tt>main</tt>
Exited :: ExitCode -> ProcessStatus

-- | the process was terminated by a signal, the <tt>Bool</tt> is
--   <tt>True</tt> if a core dump was produced
Terminated :: Signal -> Bool -> ProcessStatus

-- | the process was stopped by a signal
Stopped :: Signal -> ProcessStatus

-- | <tt><a>getProcessStatus</a> blk stopped pid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> tc</tt>, the
--   <a>ProcessStatus</a> for process <tt>pid</tt> if it is available,
--   <a>Nothing</a> otherwise. If <tt>blk</tt> is <a>False</a>, then
--   <tt>WNOHANG</tt> is set in the options for <tt>waitpid</tt>, otherwise
--   not. If <tt>stopped</tt> is <a>True</a>, then <tt>WUNTRACED</tt> is
--   set in the options for <tt>waitpid</tt>, otherwise not.
getProcessStatus :: Bool -> Bool -> ProcessID -> IO (Maybe ProcessStatus)

-- | <tt><a>getAnyProcessStatus</a> blk stopped</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any child process if a
--   child process has exited, or <a>Nothing</a> if there are child
--   processes but none have exited. If there are no child processes, then
--   <a>getAnyProcessStatus</a> raises an <tt>isDoesNotExistError</tt>
--   exception.
--   
--   If <tt>blk</tt> is <a>False</a>, then <tt>WNOHANG</tt> is set in the
--   options for <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is
--   <a>True</a>, then <tt>WUNTRACED</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not.
getAnyProcessStatus :: Bool -> Bool -> IO (Maybe (ProcessID, ProcessStatus))

-- | <tt><a>getGroupProcessStatus</a> blk stopped pgid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any process in group
--   <tt>pgid</tt> if one is available, or <a>Nothing</a> if there are
--   child processes but none have exited. If there are no child processes,
--   then <a>getGroupProcessStatus</a> raises an
--   <tt>isDoesNotExistError</tt> exception.
--   
--   If <tt>blk</tt> is <a>False</a>, then <tt>WNOHANG</tt> is set in the
--   options for <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is
--   <a>True</a>, then <tt>WUNTRACED</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not.
getGroupProcessStatus :: Bool -> Bool -> ProcessGroupID -> IO (Maybe (ProcessID, ProcessStatus))

-- | <tt><a>createProcessGroup</a> pid</tt> calls <tt>setpgid</tt> to make
--   process <tt>pid</tt> a new process group leader. This function is
--   currently deprecated, and might be changed to making the current
--   process a new process group leader in future versions.

-- | <i>Deprecated: This function is scheduled to be replaced by something
--   different in the future, we therefore recommend that you do not use
--   this version and use <a>createProcessGroupFor</a> instead.</i>
createProcessGroup :: ProcessID -> IO ProcessGroupID

-- | <tt><a>setProcessGroupID</a> pid pgid</tt> calls <tt>setpgid</tt> to
--   set the <a>ProcessGroupID</a> for process <tt>pid</tt> to
--   <tt>pgid</tt>. This function is currently deprecated, and might be
--   changed to setting the <a>ProcessGroupID</a> for the current process
--   in future versions.

-- | <i>Deprecated: This function is scheduled to be replaced by something
--   different in the future, we therefore recommend that you do not use
--   this version and use <a>setProcessGroupIDOf</a> instead.</i>
setProcessGroupID :: ProcessID -> ProcessGroupID -> IO ()


-- | POSIX resource support
module System.Posix.Resource
data ResourceLimit
ResourceLimitInfinity :: ResourceLimit
ResourceLimitUnknown :: ResourceLimit
ResourceLimit :: Integer -> ResourceLimit
data ResourceLimits
ResourceLimits :: ResourceLimit -> ResourceLimit -> ResourceLimits
[softLimit] :: ResourceLimits -> ResourceLimit
[hardLimit] :: ResourceLimits -> ResourceLimit
data Resource
ResourceCoreFileSize :: Resource
ResourceCPUTime :: Resource
ResourceDataSize :: Resource
ResourceFileSize :: Resource
ResourceOpenFiles :: Resource
ResourceStackSize :: Resource
ResourceTotalMemory :: Resource
getResourceLimit :: Resource -> IO ResourceLimits
setResourceLimit :: Resource -> ResourceLimits -> IO ()
instance GHC.Classes.Eq System.Posix.Resource.Resource
instance GHC.Classes.Eq System.Posix.Resource.ResourceLimit
instance GHC.Classes.Eq System.Posix.Resource.ResourceLimits
instance GHC.Internal.Show.Show System.Posix.Resource.Resource
instance GHC.Internal.Show.Show System.Posix.Resource.ResourceLimit
instance GHC.Internal.Show.Show System.Posix.Resource.ResourceLimits


-- | POSIX named semaphore support.
module System.Posix.Semaphore
data OpenSemFlags
OpenSemFlags :: Bool -> Bool -> OpenSemFlags

-- | If true, create the semaphore if it does not yet exist.
[semCreate] :: OpenSemFlags -> Bool

-- | If true, throw an exception if the semaphore already exists.
[semExclusive] :: OpenSemFlags -> Bool
data Semaphore

-- | Open a named semaphore with the given name, flags, mode, and initial
--   value.
semOpen :: String -> OpenSemFlags -> FileMode -> Int -> IO Semaphore

-- | Delete the semaphore with the given name.
semUnlink :: String -> IO ()

-- | Lock the semaphore, blocking until it becomes available. Since this is
--   done through a system call, this will block the *entire runtime*, not
--   just the current thread. If this is not the behaviour you want, use
--   semThreadWait instead.
semWait :: Semaphore -> IO ()

-- | Lock the semaphore, blocking until it becomes available.
--   
--   Unlike <a>semWait</a>, this wait operation can be interrupted with an
--   asynchronous exception (e.g. a call to <a>throwTo</a> from another
--   thread).
semWaitInterruptible :: Semaphore -> IO Bool

-- | Attempt to lock the semaphore without blocking. Immediately return
--   False if it is not available.
semTryWait :: Semaphore -> IO Bool

-- | Poll the semaphore until it is available, then lock it. Unlike
--   semWait, this will block only the current thread rather than the
--   entire process.
semThreadWait :: Semaphore -> IO ()

-- | Unlock the semaphore.
semPost :: Semaphore -> IO ()

-- | Return the semaphore's current value.
semGetValue :: Semaphore -> IO Int


-- | POSIX shared memory support.
module System.Posix.SharedMem
data ShmOpenFlags
ShmOpenFlags :: Bool -> Bool -> Bool -> Bool -> ShmOpenFlags

-- | If true, open the shm object read-write rather than read-only.
[shmReadWrite] :: ShmOpenFlags -> Bool

-- | If true, create the shm object if it does not exist.
[shmCreate] :: ShmOpenFlags -> Bool

-- | If true, throw an exception if the shm object already exists.
[shmExclusive] :: ShmOpenFlags -> Bool

-- | If true, wipe the contents of the shm object after opening it.
[shmTrunc] :: ShmOpenFlags -> Bool

-- | Open a shared memory object with the given name, flags, and mode.
shmOpen :: String -> ShmOpenFlags -> FileMode -> IO Fd

-- | Delete the shared memory object with the given name.
shmUnlink :: String -> IO ()


-- | POSIX signal support
module System.Posix.Signals
type Signal = CInt
nullSignal :: Signal

-- | Alias for <a>sigABRT</a>.
internalAbort :: Signal

-- | Process abort signal.
sigABRT :: CInt

-- | Alias for <a>sigALRM</a>.
realTimeAlarm :: Signal

-- | Alarm clock.
sigALRM :: CInt

-- | Alias for <a>sigBUS</a>.
busError :: Signal

-- | Access to an undefined portion of a memory object.
sigBUS :: CInt

-- | Alias for <a>sigCHLD</a>.
processStatusChanged :: Signal

-- | Child process terminated, stopped, or continued.
sigCHLD :: CInt

-- | Alias for <a>sigCONT</a>.
continueProcess :: Signal

-- | Continue executing, if stopped.
sigCONT :: CInt

-- | Alias for <a>sigFPE</a>.
floatingPointException :: Signal

-- | Erroneous arithmetic operation.
sigFPE :: CInt

-- | Alias for <a>sigHUP</a>.
lostConnection :: Signal

-- | Hangup.
sigHUP :: CInt

-- | Alias for <a>sigILL</a>.
illegalInstruction :: Signal

-- | Illegal instruction.
sigILL :: CInt

-- | Alias for <a>sigINT</a>.
keyboardSignal :: Signal

-- | Terminal interrupt signal.
sigINT :: CInt

-- | Alias for <a>sigKILL</a>.
killProcess :: Signal

-- | Kill (cannot be caught or ignored).
sigKILL :: CInt

-- | Alias for <a>sigPIPE</a>.
openEndedPipe :: Signal

-- | Write on a pipe with no one to read it.
sigPIPE :: CInt

-- | Alias for <a>sigQUIT</a>.
keyboardTermination :: Signal

-- | Terminal quit signal.
sigQUIT :: CInt

-- | Alias for <a>sigSEGV</a>.
segmentationViolation :: Signal

-- | Invalid memory reference.
sigSEGV :: CInt

-- | Alias for <a>sigSTOP</a>.
softwareStop :: Signal

-- | Stop executing (cannot be caught or ignored).
sigSTOP :: CInt

-- | Alias for <a>sigTERM</a>.
softwareTermination :: Signal

-- | Termination signal.
sigTERM :: CInt

-- | Alias for <a>sigTSTP</a>.
keyboardStop :: Signal

-- | Terminal stop signal.
sigTSTP :: CInt

-- | Alias for <a>sigTTIN</a>.
backgroundRead :: Signal

-- | Background process attempting read.
sigTTIN :: CInt

-- | Alias for <a>sigTTOU</a>.
backgroundWrite :: Signal

-- | Background process attempting write.
sigTTOU :: CInt

-- | Alias for <a>sigUSR1</a>.
userDefinedSignal1 :: Signal

-- | User-defined signal 1.
sigUSR1 :: CInt

-- | Alias for <a>sigUSR2</a>.
userDefinedSignal2 :: Signal

-- | User-defined signal 2.
sigUSR2 :: CInt

-- | Alias for <a>sigPROF</a>.
profilingTimerExpired :: Signal

-- | Profiling timer expired.
sigPROF :: CInt

-- | Alias for <a>sigSYS</a>.
badSystemCall :: Signal

-- | Bad system call.
sigSYS :: CInt

-- | Alias for <a>sigTRAP</a>.
breakpointTrap :: Signal

-- | Trace/breakpoint trap.
sigTRAP :: CInt

-- | Alias for <a>sigURG</a>.
urgentDataAvailable :: Signal

-- | High bandwidth data is available at a socket.
sigURG :: CInt

-- | Alias for <a>sigVTALRM</a>.
virtualTimerExpired :: Signal

-- | Virtual timer expired.
sigVTALRM :: CInt

-- | Alias for <a>sigXCPU</a>.
cpuTimeLimitExceeded :: Signal

-- | CPU time limit exceeded.
sigXCPU :: CInt

-- | Alias for <a>sigXFSZ</a>.
fileSizeLimitExceeded :: Signal

-- | File size limit exceeded.
sigXFSZ :: CInt

-- | <tt>raiseSignal int</tt> calls <tt>kill</tt> to signal the current
--   process with interrupt signal <tt>int</tt>.
raiseSignal :: Signal -> IO ()

-- | <tt>signalProcess int pid</tt> calls <tt>kill</tt> to signal process
--   <tt>pid</tt> with interrupt signal <tt>int</tt>.
signalProcess :: Signal -> ProcessID -> IO ()

-- | <tt>signalProcessGroup int pgid</tt> calls <tt>kill</tt> to signal all
--   processes in group <tt>pgid</tt> with interrupt signal <tt>int</tt>.
signalProcessGroup :: Signal -> ProcessGroupID -> IO ()

-- | The actions to perform when a signal is received.
data Handler

-- | Sets the disposition of the signal to <tt>SIG_DFL</tt>, which means we
--   want the default action associated with the signal. For example, the
--   default action for <tt>SIGTERM</tt> (and various other signals) is to
--   terminate the process.
Default :: Handler

-- | Set the disposition of the signal to <tt>SIG_IGN</tt>, which means we
--   want to <i>ignore</i> the signal. Ignored signals will not be
--   delivered to the process, and if also <i>blocked</i> will not be added
--   to the pending set for later delivery (if/when unblocked). Some
--   signals (e.g. <tt>SIGSTOP</tt> and <tt>SIGKILL</tt>) cannot be caught
--   or ignored. not yet: | Hold
Ignore :: Handler

-- | signal handler is not reset
Catch :: IO () -> Handler

-- | signal handler is automatically reset (via <tt>SA_RESETHAND</tt>)
CatchOnce :: IO () -> Handler

CatchInfo :: (SignalInfo -> IO ()) -> Handler

CatchInfoOnce :: (SignalInfo -> IO ()) -> Handler

-- | Information about a received signal (derived from <tt>siginfo_t</tt>).
data SignalInfo
SignalInfo :: Signal -> Errno -> SignalSpecificInfo -> SignalInfo
[siginfoSignal] :: SignalInfo -> Signal
[siginfoError] :: SignalInfo -> Errno
[siginfoSpecific] :: SignalInfo -> SignalSpecificInfo

-- | Information specific to a particular type of signal (derived from
--   <tt>siginfo_t</tt>).
data SignalSpecificInfo
NoSignalSpecificInfo :: SignalSpecificInfo
SigChldInfo :: ProcessID -> UserID -> ProcessStatus -> SignalSpecificInfo
[siginfoPid] :: SignalSpecificInfo -> ProcessID
[siginfoUid] :: SignalSpecificInfo -> UserID
[siginfoStatus] :: SignalSpecificInfo -> ProcessStatus

-- | <tt>installHandler int handler iset</tt> calls <tt>sigaction</tt> to
--   install an interrupt handler for signal <tt>int</tt>. If
--   <tt>handler</tt> is <tt>Default</tt>, <tt>SIG_DFL</tt> is installed;
--   if <tt>handler</tt> is <tt>Ignore</tt>, <tt>SIG_IGN</tt> is installed;
--   if <tt>handler</tt> is <tt>Catch action</tt>, a handler is installed
--   which will invoke <tt>action</tt> in a new thread when (or shortly
--   after) the signal is received. If <tt>iset</tt> is <tt>Just s</tt>,
--   then the <tt>sa_mask</tt> of the <tt>sigaction</tt> structure is set
--   to <tt>s</tt>; otherwise it is cleared. The previously installed
--   signal handler for <tt>int</tt> is returned
installHandler :: Signal -> Handler -> Maybe SignalSet -> IO Handler
data SignalSet
emptySignalSet :: SignalSet
fullSignalSet :: SignalSet

-- | A set of signals reserved for use by the implementation. In GHC, this
--   will normally include either <a>sigVTALRM</a> or <a>sigALRM</a>.
reservedSignals :: SignalSet
addSignal :: Signal -> SignalSet -> SignalSet
infixr 9 `addSignal`
deleteSignal :: Signal -> SignalSet -> SignalSet
infixr 9 `deleteSignal`
inSignalSet :: Signal -> SignalSet -> Bool

-- | <tt>getSignalMask</tt> calls <tt>sigprocmask</tt> to determine the set
--   of interrupts which are currently being blocked.
getSignalMask :: IO SignalSet

-- | <tt>setSignalMask mask</tt> calls <tt>sigprocmask</tt> with
--   <tt>SIG_SETMASK</tt> to block all interrupts in <tt>mask</tt>.
setSignalMask :: SignalSet -> IO ()

-- | <tt>blockSignals mask</tt> calls <tt>sigprocmask</tt> with
--   <tt>SIG_BLOCK</tt> to add all interrupts in <tt>mask</tt> to the set
--   of blocked interrupts.
blockSignals :: SignalSet -> IO ()

-- | <tt>unblockSignals mask</tt> calls <tt>sigprocmask</tt> with
--   <tt>SIG_UNBLOCK</tt> to remove all interrupts in <tt>mask</tt> from
--   the set of blocked interrupts.
unblockSignals :: SignalSet -> IO ()

-- | <tt>scheduleAlarm i</tt> calls <tt>alarm</tt> to schedule a real time
--   alarm at least <tt>i</tt> seconds in the future.
scheduleAlarm :: Int -> IO Int

-- | <tt>getPendingSignals</tt> calls <tt>sigpending</tt> to obtain the set
--   of interrupts which have been received but are currently blocked.
getPendingSignals :: IO SignalSet

-- | <tt>awaitSignal iset</tt> suspends execution until an interrupt is
--   received. If <tt>iset</tt> is <tt>Just s</tt>, <tt>awaitSignal</tt>
--   calls <tt>sigsuspend</tt>, installing <tt>s</tt> as the new signal
--   mask before suspending execution; otherwise, it calls
--   <tt>sigsuspend</tt> with current signal mask. Note that RTS scheduler
--   signal (either <a>virtualTimerExpired</a> or <a>realTimeAlarm</a>)
--   could cause premature termination of this call. It might be necessary
--   to block that signal before invocation of <tt>awaitSignal</tt> with
--   <a>blockSignals</a> <a>reservedSignals</a>.
--   
--   <tt>awaitSignal</tt> returns when signal was received and processed by
--   a signal handler, or if the signal could not be caught. If you have
--   installed any signal handlers with <tt>installHandler</tt>, it may be
--   wise to call <tt>yield</tt> directly after <tt>awaitSignal</tt> to
--   ensure that the signal handler runs as promptly as possible.
awaitSignal :: Maybe SignalSet -> IO ()

-- | Tells the system whether or not to set the <tt>SA_NOCLDSTOP</tt> flag
--   when installing new signal handlers.
setStoppedChildFlag :: Bool -> IO Bool

-- | Queries the current state of the stopped child flag.
queryStoppedChildFlag :: IO Bool


-- | non-POSIX signal support commonly available
module System.Posix.Signals.Exts
sigINFO :: CInt
sigWINCH :: CInt
infoEvent :: Signal
windowChange :: Signal


-- | POSIX temporary file and directory creation functions.
module System.Posix.Temp

-- | Make a unique filename and open it for reading/writing. The returned
--   <a>FilePath</a> is the (possibly relative) path of the created file,
--   which is padded with 6 random characters. The argument is the desired
--   prefix of the filepath of the temporary file to be created.
--   
--   If you aren't using GHC or Hugs then this function simply wraps mktemp
--   and so shouldn't be considered safe.
mkstemp :: String -> IO (FilePath, Handle)

-- | Make a unique filename with a given prefix and suffix and open it for
--   reading/writing. The returned <a>FilePath</a> is the (possibly
--   relative) path of the created file, which contains 6 random characters
--   in between the prefix and suffix. The first argument is the desired
--   prefix of the filepath of the temporary file to be created. The second
--   argument is the suffix of the temporary file to be created.
--   
--   If you are using as system that doesn't support the mkstemps glibc
--   function (supported in glibc &gt; 2.11) then this function simply
--   throws an error.
mkstemps :: String -> String -> IO (FilePath, Handle)

-- | Make a unique directory. The returned <a>FilePath</a> is the path of
--   the created directory, which is padded with 6 random characters. The
--   argument is the desired prefix of the filepath of the temporary
--   directory to be created.
--   
--   If you are using as system that doesn't support the mkdtemp glibc
--   function (supported in glibc &gt; 2.1.91) then this function uses
--   mktemp and so shouldn't be considered safe.
mkdtemp :: String -> IO FilePath


-- | POSIX temporary file and directory creation functions.
module System.Posix.Temp.ByteString

-- | Make a unique filename and open it for reading/writing. The returned
--   <a>RawFilePath</a> is the (possibly relative) path of the created
--   file, which is padded with 6 random characters. The argument is the
--   desired prefix of the filepath of the temporary file to be created.
--   
--   If you aren't using GHC or Hugs then this function simply wraps mktemp
--   and so shouldn't be considered safe.
mkstemp :: ByteString -> IO (RawFilePath, Handle)

-- | <a>mkstemps</a> - make a unique filename with a given prefix and
--   suffix and open it for reading/writing (only safe on GHC &amp; Hugs).
--   The returned <a>RawFilePath</a> is the (possibly relative) path of the
--   created file, which contains 6 random characters in between the prefix
--   and suffix.
mkstemps :: ByteString -> ByteString -> IO (RawFilePath, Handle)

-- | Make a unique directory. The returned <a>RawFilePath</a> is the path
--   of the created directory, which is padded with 6 random characters.
--   The argument is the desired prefix of the filepath of the temporary
--   directory to be created.
--   
--   If you aren't using GHC or Hugs then this function simply wraps mktemp
--   and so shouldn't be considered safe.
mkdtemp :: ByteString -> IO RawFilePath


-- | POSIX temporary file and directory creation functions.
module System.Posix.Temp.PosixString

-- | Make a unique filename and open it for reading/writing. The returned
--   <a>PosixPath</a> is the (possibly relative) path of the created file,
--   which is padded with 6 random characters. The argument is the desired
--   prefix of the filepath of the temporary file to be created.
--   
--   If you aren't using GHC or Hugs then this function simply wraps mktemp
--   and so shouldn't be considered safe.
mkstemp :: PosixString -> IO (PosixPath, Handle)

-- | <a>mkstemps</a> - make a unique filename with a given prefix and
--   suffix and open it for reading/writing (only safe on GHC &amp; Hugs).
--   The returned <a>PosixPath</a> is the (possibly relative) path of the
--   created file, which contains 6 random characters in between the prefix
--   and suffix.
mkstemps :: PosixString -> PosixString -> IO (PosixPath, Handle)

-- | Make a unique directory. The returned <a>PosixPath</a> is the path of
--   the created directory, which is padded with 6 random characters. The
--   argument is the desired prefix of the filepath of the temporary
--   directory to be created.
--   
--   If you aren't using GHC or Hugs then this function simply wraps mktemp
--   and so shouldn't be considered safe.
mkdtemp :: PosixString -> IO PosixPath


-- | POSIX Terminal support
module System.Posix.Terminal.ByteString
data TerminalAttributes

-- | <tt>getTerminalAttributes fd</tt> calls <tt>tcgetattr</tt> to obtain
--   the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt>.
getTerminalAttributes :: Fd -> IO TerminalAttributes
data TerminalState
Immediately :: TerminalState
WhenDrained :: TerminalState
WhenFlushed :: TerminalState

-- | <tt>setTerminalAttributes fd attr ts</tt> calls <tt>tcsetattr</tt> to
--   change the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt> to <tt>attr</tt>, when the terminal is in the state
--   indicated by <tt>ts</tt>.
setTerminalAttributes :: Fd -> TerminalAttributes -> TerminalState -> IO ()
data TerminalMode

-- | <tt>BRKINT</tt> - Signal interrupt on break
InterruptOnBreak :: TerminalMode

-- | <tt>ICRNL</tt> - Map CR to NL on input
MapCRtoLF :: TerminalMode

-- | <tt>IGNBRK</tt> - Ignore break condition
IgnoreBreak :: TerminalMode

-- | <tt>IGNCR</tt> - Ignore CR
IgnoreCR :: TerminalMode

-- | <tt>IGNPAR</tt> - Ignore characters with parity errors
IgnoreParityErrors :: TerminalMode

-- | <tt>INLCR</tt> - Map NL to CR on input
MapLFtoCR :: TerminalMode

-- | <tt>INPCK</tt> - Enable input parity check
CheckParity :: TerminalMode

-- | <tt>ISTRIP</tt> - Strip character
StripHighBit :: TerminalMode

-- | <tt>IXANY</tt> - Enable any character to restart output
RestartOnAny :: TerminalMode

-- | <tt>IXOFF</tt> - Enable start/stop input control
StartStopInput :: TerminalMode

-- | <tt>IXON</tt> - Enable start/stop output control
StartStopOutput :: TerminalMode

-- | <tt>PARMRK</tt> - Mark parity errors
MarkParityErrors :: TerminalMode

-- | <tt>OPOST</tt> - Post-process output
ProcessOutput :: TerminalMode

-- | <tt>ONLCR</tt> - (XSI) Map NL to CR-NL on output
MapLFtoCRLF :: TerminalMode

-- | <tt>OCRNL</tt> - (XSI) Map CR to NL on output
OutputMapCRtoLF :: TerminalMode

-- | <tt>ONOCR</tt> - (XSI) No CR output at column 0
NoCRAtColumnZero :: TerminalMode

-- | <tt>ONLRET</tt> - (XSI) NL performs CR function
ReturnMeansLF :: TerminalMode

-- | <tt>CLOCAL</tt> - Ignore modem status lines
LocalMode :: TerminalMode

-- | <tt>CREAD</tt> - Enable receiver
ReadEnable :: TerminalMode

-- | <tt>CSTOPB</tt> - Send two stop bits, else one
TwoStopBits :: TerminalMode

-- | <tt>HUPCL</tt> - Hang up on last close
HangupOnClose :: TerminalMode

-- | <tt>PARENB</tt> - Parity enable
EnableParity :: TerminalMode

-- | <tt>PARODD</tt> - Odd parity, else even
OddParity :: TerminalMode

-- | <tt>ECHO</tt> - Enable echo
EnableEcho :: TerminalMode

-- | <tt>ECHOE</tt> - Echo erase character as error-correcting backspace
EchoErase :: TerminalMode

-- | <tt>ECHOK</tt> - Echo KILL
EchoKill :: TerminalMode

-- | <tt>ECHONL</tt> - Echo NL
EchoLF :: TerminalMode

-- | <tt>ICANON</tt> - Canonical input (erase and kill processing)
ProcessInput :: TerminalMode

-- | <tt>IEXTEN</tt> - Enable extended input character processing
ExtendedFunctions :: TerminalMode

-- | <tt>ISIG</tt> - Enable signals
KeyboardInterrupts :: TerminalMode

-- | <tt>NOFLSH</tt> - Disable flush after interrupt or quit
NoFlushOnInterrupt :: TerminalMode

-- | <tt>TOSTOP</tt> - Send <tt>SIGTTOU</tt> for background output
BackgroundWriteInterrupt :: TerminalMode
withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
terminalMode :: TerminalMode -> TerminalAttributes -> Bool
bitsPerByte :: TerminalAttributes -> Int
withBits :: TerminalAttributes -> Int -> TerminalAttributes
data ControlCharacter
EndOfFile :: ControlCharacter
EndOfLine :: ControlCharacter
Erase :: ControlCharacter
Interrupt :: ControlCharacter
Kill :: ControlCharacter
Quit :: ControlCharacter
Start :: ControlCharacter
Stop :: ControlCharacter
Suspend :: ControlCharacter
controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char
withCC :: TerminalAttributes -> (ControlCharacter, Char) -> TerminalAttributes
withoutCC :: TerminalAttributes -> ControlCharacter -> TerminalAttributes
inputTime :: TerminalAttributes -> Int
withTime :: TerminalAttributes -> Int -> TerminalAttributes
minInput :: TerminalAttributes -> Int
withMinInput :: TerminalAttributes -> Int -> TerminalAttributes

-- | Serial line baudrate. The set of supported speeds is system-dependent.
--   Portable use of the provided pattern synonyms that are outside the
--   list mandated by POSIX requires <tt>#ifdef</tt> guards.
--   
--   Applications may need to be prepared to encounter speeds not known at
--   compile time, these can be handled generically via the <a>BaudRate</a>
--   constructor. In other words, the provided pattern synonyms are not
--   necessarily a <tt>COMPLETE</tt> set.
--   
--   All non-zero <i>pseudo-terminal</i> baud rates are functionally
--   equivalent, and the <tt>pty</tt> driver may accept any speed within a
--   suitable range. Requested speeds may be rounded up or down to fit into
--   the supported range.
newtype BaudRate
BaudRate :: CSpeed -> BaudRate

-- | Hang up
pattern B0 :: BaudRate

-- | 50 baud
pattern B50 :: BaudRate

-- | 75 baud
pattern B75 :: BaudRate

-- | 110 baud
pattern B110 :: BaudRate

-- | <ol>
--   <li>5 baud</li>
--   </ol>
pattern B134 :: BaudRate

-- | 150 baud
pattern B150 :: BaudRate

-- | 200 baud
pattern B200 :: BaudRate

-- | 300 baud
pattern B300 :: BaudRate

-- | 600 baud
pattern B600 :: BaudRate

-- | 1200 baud
pattern B1200 :: BaudRate

-- | 1800 baud
pattern B1800 :: BaudRate

-- | 2400 baud
pattern B2400 :: BaudRate

-- | 4800 baud
pattern B4800 :: BaudRate

-- | 9600 baud
pattern B9600 :: BaudRate

-- | 19200 baud
pattern B19200 :: BaudRate

-- | 38400 baud
pattern B38400 :: BaudRate

-- | 7200 baud, non-POSIX system-dependent extension
pattern B7200 :: BaudRate

-- | 14400 baud, non-POSIX system-dependent extension
pattern B14400 :: BaudRate

-- | 28800 baud, non-POSIX system-dependent extension
pattern B28800 :: BaudRate

-- | 57600 baud, non-POSIX system-dependent extension
pattern B57600 :: BaudRate

-- | 76800 baud, non-POSIX system-dependent extension
pattern B76800 :: BaudRate

-- | 115200 baud, non-POSIX system-dependent extension
pattern B115200 :: BaudRate

-- | 230400 baud, non-POSIX system-dependent extension
pattern B230400 :: BaudRate

-- | 460800 baud, non-POSIX system-dependent extension
pattern B460800 :: BaudRate

-- | 500000 baud, non-POSIX system-dependent extension
pattern B500000 :: BaudRate

-- | 921600 baud, non-POSIX system-dependent extension
pattern B921600 :: BaudRate

-- | 1000000 baud, non-POSIX system-dependent extension
pattern B1000000 :: BaudRate

-- | 1500000 baud, non-POSIX system-dependent extension
pattern B1500000 :: BaudRate

-- | 2000000 baud, non-POSIX system-dependent extension
pattern B2000000 :: BaudRate

-- | 2500000 baud, non-POSIX system-dependent extension
pattern B2500000 :: BaudRate

-- | 3000000 baud, non-POSIX system-dependent extension
pattern B3000000 :: BaudRate

-- | 3500000 baud, non-POSIX system-dependent extension
pattern B3500000 :: BaudRate

-- | 4000000 baud, non-POSIX system-dependent extension
pattern B4000000 :: BaudRate
inputSpeed :: TerminalAttributes -> BaudRate
withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
outputSpeed :: TerminalAttributes -> BaudRate
withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes

-- | <tt>sendBreak fd duration</tt> calls <tt>tcsendbreak</tt> to transmit
--   a continuous stream of zero-valued bits on <tt>Fd</tt> <tt>fd</tt> for
--   the specified implementation-dependent <tt>duration</tt>.
sendBreak :: Fd -> Int -> IO ()

-- | <tt>drainOutput fd</tt> calls <tt>tcdrain</tt> to block until all
--   output written to <tt>Fd</tt> <tt>fd</tt> has been transmitted.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>tcdrain(3)</tt> (use <tt>#if HAVE_TCDRAIN</tt> CPP guard
--   to detect availability).
drainOutput :: Fd -> IO ()
data QueueSelector
InputQueue :: QueueSelector
OutputQueue :: QueueSelector
BothQueues :: QueueSelector

-- | <tt>discardData fd queues</tt> calls <tt>tcflush</tt> to discard
--   pending input and/or output for <tt>Fd</tt> <tt>fd</tt>, as indicated
--   by the <tt>QueueSelector</tt> <tt>queues</tt>.
discardData :: Fd -> QueueSelector -> IO ()
data FlowAction

-- | TCOOFF
SuspendOutput :: FlowAction

-- | TCOON
RestartOutput :: FlowAction

-- | TCIOFF
TransmitStop :: FlowAction

-- | TCION
TransmitStart :: FlowAction

-- | <tt>controlFlow fd action</tt> calls <tt>tcflow</tt> to control the
--   flow of data on <tt>Fd</tt> <tt>fd</tt>, as indicated by
--   <tt>action</tt>.
controlFlow :: Fd -> FlowAction -> IO ()

-- | <tt>getTerminalProcessGroupID fd</tt> calls <tt>tcgetpgrp</tt> to
--   obtain the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt>.
getTerminalProcessGroupID :: Fd -> IO ProcessGroupID

-- | <tt>setTerminalProcessGroupID fd pgid</tt> calls <tt>tcsetpgrp</tt> to
--   set the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt> to
--   <tt>pgid</tt>.
setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO ()

-- | <tt>queryTerminal fd</tt> calls <tt>isatty</tt> to determine whether
--   or not <tt>Fd</tt> <tt>fd</tt> is associated with a terminal.
queryTerminal :: Fd -> IO Bool

-- | <tt>getTerminalName fd</tt> calls <tt>ttyname</tt> to obtain a name
--   associated with the terminal for <tt>Fd</tt> <tt>fd</tt>. If
--   <tt>fd</tt> is associated with a terminal, <tt>getTerminalName</tt>
--   returns the name of the terminal.
getTerminalName :: Fd -> IO RawFilePath

-- | <tt>getControllingTerminalName</tt> calls <tt>ctermid</tt> to obtain a
--   name associated with the controlling terminal for the process. If a
--   controlling terminal exists, <tt>getControllingTerminalName</tt>
--   returns the name of the controlling terminal.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>ctermid(3)</tt> (use <tt>#if HAVE_CTERMID</tt> CPP guard
--   to detect availability).
getControllingTerminalName :: IO RawFilePath

-- | <tt>openPseudoTerminal</tt> creates a pseudoterminal (pty) pair, and
--   returns the newly created pair as a (<tt>master</tt>, <tt>slave</tt>)
--   tuple.
openPseudoTerminal :: IO (Fd, Fd)

-- | <tt>getSlaveTerminalName</tt> calls <tt>ptsname</tt> to obtain the
--   name of the slave terminal associated with a pseudoterminal pair. The
--   file descriptor to pass in must be that of the master.
getSlaveTerminalName :: Fd -> IO RawFilePath


-- | POSIX Terminal support
module System.Posix.Terminal
data TerminalAttributes

-- | <tt>getTerminalAttributes fd</tt> calls <tt>tcgetattr</tt> to obtain
--   the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt>.
getTerminalAttributes :: Fd -> IO TerminalAttributes
data TerminalState
Immediately :: TerminalState
WhenDrained :: TerminalState
WhenFlushed :: TerminalState

-- | <tt>setTerminalAttributes fd attr ts</tt> calls <tt>tcsetattr</tt> to
--   change the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt> to <tt>attr</tt>, when the terminal is in the state
--   indicated by <tt>ts</tt>.
setTerminalAttributes :: Fd -> TerminalAttributes -> TerminalState -> IO ()
data TerminalMode

-- | <tt>BRKINT</tt> - Signal interrupt on break
InterruptOnBreak :: TerminalMode

-- | <tt>ICRNL</tt> - Map CR to NL on input
MapCRtoLF :: TerminalMode

-- | <tt>IGNBRK</tt> - Ignore break condition
IgnoreBreak :: TerminalMode

-- | <tt>IGNCR</tt> - Ignore CR
IgnoreCR :: TerminalMode

-- | <tt>IGNPAR</tt> - Ignore characters with parity errors
IgnoreParityErrors :: TerminalMode

-- | <tt>INLCR</tt> - Map NL to CR on input
MapLFtoCR :: TerminalMode

-- | <tt>INPCK</tt> - Enable input parity check
CheckParity :: TerminalMode

-- | <tt>ISTRIP</tt> - Strip character
StripHighBit :: TerminalMode

-- | <tt>IXANY</tt> - Enable any character to restart output
RestartOnAny :: TerminalMode

-- | <tt>IXOFF</tt> - Enable start/stop input control
StartStopInput :: TerminalMode

-- | <tt>IXON</tt> - Enable start/stop output control
StartStopOutput :: TerminalMode

-- | <tt>PARMRK</tt> - Mark parity errors
MarkParityErrors :: TerminalMode

-- | <tt>OPOST</tt> - Post-process output
ProcessOutput :: TerminalMode

-- | <tt>ONLCR</tt> - (XSI) Map NL to CR-NL on output
MapLFtoCRLF :: TerminalMode

-- | <tt>OCRNL</tt> - (XSI) Map CR to NL on output
OutputMapCRtoLF :: TerminalMode

-- | <tt>ONOCR</tt> - (XSI) No CR output at column 0
NoCRAtColumnZero :: TerminalMode

-- | <tt>ONLRET</tt> - (XSI) NL performs CR function
ReturnMeansLF :: TerminalMode

-- | <tt>CLOCAL</tt> - Ignore modem status lines
LocalMode :: TerminalMode

-- | <tt>CREAD</tt> - Enable receiver
ReadEnable :: TerminalMode

-- | <tt>CSTOPB</tt> - Send two stop bits, else one
TwoStopBits :: TerminalMode

-- | <tt>HUPCL</tt> - Hang up on last close
HangupOnClose :: TerminalMode

-- | <tt>PARENB</tt> - Parity enable
EnableParity :: TerminalMode

-- | <tt>PARODD</tt> - Odd parity, else even
OddParity :: TerminalMode

-- | <tt>ECHO</tt> - Enable echo
EnableEcho :: TerminalMode

-- | <tt>ECHOE</tt> - Echo erase character as error-correcting backspace
EchoErase :: TerminalMode

-- | <tt>ECHOK</tt> - Echo KILL
EchoKill :: TerminalMode

-- | <tt>ECHONL</tt> - Echo NL
EchoLF :: TerminalMode

-- | <tt>ICANON</tt> - Canonical input (erase and kill processing)
ProcessInput :: TerminalMode

-- | <tt>IEXTEN</tt> - Enable extended input character processing
ExtendedFunctions :: TerminalMode

-- | <tt>ISIG</tt> - Enable signals
KeyboardInterrupts :: TerminalMode

-- | <tt>NOFLSH</tt> - Disable flush after interrupt or quit
NoFlushOnInterrupt :: TerminalMode

-- | <tt>TOSTOP</tt> - Send <tt>SIGTTOU</tt> for background output
BackgroundWriteInterrupt :: TerminalMode
withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
terminalMode :: TerminalMode -> TerminalAttributes -> Bool
bitsPerByte :: TerminalAttributes -> Int
withBits :: TerminalAttributes -> Int -> TerminalAttributes
data ControlCharacter
EndOfFile :: ControlCharacter
EndOfLine :: ControlCharacter
Erase :: ControlCharacter
Interrupt :: ControlCharacter
Kill :: ControlCharacter
Quit :: ControlCharacter
Start :: ControlCharacter
Stop :: ControlCharacter
Suspend :: ControlCharacter
controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char
withCC :: TerminalAttributes -> (ControlCharacter, Char) -> TerminalAttributes
withoutCC :: TerminalAttributes -> ControlCharacter -> TerminalAttributes
inputTime :: TerminalAttributes -> Int
withTime :: TerminalAttributes -> Int -> TerminalAttributes
minInput :: TerminalAttributes -> Int
withMinInput :: TerminalAttributes -> Int -> TerminalAttributes

-- | Serial line baudrate. The set of supported speeds is system-dependent.
--   Portable use of the provided pattern synonyms that are outside the
--   list mandated by POSIX requires <tt>#ifdef</tt> guards.
--   
--   Applications may need to be prepared to encounter speeds not known at
--   compile time, these can be handled generically via the <a>BaudRate</a>
--   constructor. In other words, the provided pattern synonyms are not
--   necessarily a <tt>COMPLETE</tt> set.
--   
--   All non-zero <i>pseudo-terminal</i> baud rates are functionally
--   equivalent, and the <tt>pty</tt> driver may accept any speed within a
--   suitable range. Requested speeds may be rounded up or down to fit into
--   the supported range.
newtype BaudRate
BaudRate :: CSpeed -> BaudRate

-- | Hang up
pattern B0 :: BaudRate

-- | 50 baud
pattern B50 :: BaudRate

-- | 75 baud
pattern B75 :: BaudRate

-- | 110 baud
pattern B110 :: BaudRate

-- | <ol>
--   <li>5 baud</li>
--   </ol>
pattern B134 :: BaudRate

-- | 150 baud
pattern B150 :: BaudRate

-- | 200 baud
pattern B200 :: BaudRate

-- | 300 baud
pattern B300 :: BaudRate

-- | 600 baud
pattern B600 :: BaudRate

-- | 1200 baud
pattern B1200 :: BaudRate

-- | 1800 baud
pattern B1800 :: BaudRate

-- | 2400 baud
pattern B2400 :: BaudRate

-- | 4800 baud
pattern B4800 :: BaudRate

-- | 9600 baud
pattern B9600 :: BaudRate

-- | 19200 baud
pattern B19200 :: BaudRate

-- | 38400 baud
pattern B38400 :: BaudRate

-- | 7200 baud, non-POSIX system-dependent extension
pattern B7200 :: BaudRate

-- | 14400 baud, non-POSIX system-dependent extension
pattern B14400 :: BaudRate

-- | 28800 baud, non-POSIX system-dependent extension
pattern B28800 :: BaudRate

-- | 57600 baud, non-POSIX system-dependent extension
pattern B57600 :: BaudRate

-- | 76800 baud, non-POSIX system-dependent extension
pattern B76800 :: BaudRate

-- | 115200 baud, non-POSIX system-dependent extension
pattern B115200 :: BaudRate

-- | 230400 baud, non-POSIX system-dependent extension
pattern B230400 :: BaudRate

-- | 460800 baud, non-POSIX system-dependent extension
pattern B460800 :: BaudRate

-- | 500000 baud, non-POSIX system-dependent extension
pattern B500000 :: BaudRate

-- | 921600 baud, non-POSIX system-dependent extension
pattern B921600 :: BaudRate

-- | 1000000 baud, non-POSIX system-dependent extension
pattern B1000000 :: BaudRate

-- | 1500000 baud, non-POSIX system-dependent extension
pattern B1500000 :: BaudRate

-- | 2000000 baud, non-POSIX system-dependent extension
pattern B2000000 :: BaudRate

-- | 2500000 baud, non-POSIX system-dependent extension
pattern B2500000 :: BaudRate

-- | 3000000 baud, non-POSIX system-dependent extension
pattern B3000000 :: BaudRate

-- | 3500000 baud, non-POSIX system-dependent extension
pattern B3500000 :: BaudRate

-- | 4000000 baud, non-POSIX system-dependent extension
pattern B4000000 :: BaudRate
inputSpeed :: TerminalAttributes -> BaudRate
withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
outputSpeed :: TerminalAttributes -> BaudRate
withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes

-- | <tt>sendBreak fd duration</tt> calls <tt>tcsendbreak</tt> to transmit
--   a continuous stream of zero-valued bits on <tt>Fd</tt> <tt>fd</tt> for
--   the specified implementation-dependent <tt>duration</tt>.
sendBreak :: Fd -> Int -> IO ()

-- | <tt>drainOutput fd</tt> calls <tt>tcdrain</tt> to block until all
--   output written to <tt>Fd</tt> <tt>fd</tt> has been transmitted.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>tcdrain(3)</tt> (use <tt>#if HAVE_TCDRAIN</tt> CPP guard
--   to detect availability).
drainOutput :: Fd -> IO ()
data QueueSelector
InputQueue :: QueueSelector
OutputQueue :: QueueSelector
BothQueues :: QueueSelector

-- | <tt>discardData fd queues</tt> calls <tt>tcflush</tt> to discard
--   pending input and/or output for <tt>Fd</tt> <tt>fd</tt>, as indicated
--   by the <tt>QueueSelector</tt> <tt>queues</tt>.
discardData :: Fd -> QueueSelector -> IO ()
data FlowAction

-- | TCOOFF
SuspendOutput :: FlowAction

-- | TCOON
RestartOutput :: FlowAction

-- | TCIOFF
TransmitStop :: FlowAction

-- | TCION
TransmitStart :: FlowAction

-- | <tt>controlFlow fd action</tt> calls <tt>tcflow</tt> to control the
--   flow of data on <tt>Fd</tt> <tt>fd</tt>, as indicated by
--   <tt>action</tt>.
controlFlow :: Fd -> FlowAction -> IO ()

-- | <tt>getTerminalProcessGroupID fd</tt> calls <tt>tcgetpgrp</tt> to
--   obtain the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt>.
getTerminalProcessGroupID :: Fd -> IO ProcessGroupID

-- | <tt>setTerminalProcessGroupID fd pgid</tt> calls <tt>tcsetpgrp</tt> to
--   set the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt> to
--   <tt>pgid</tt>.
setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO ()

-- | <tt>queryTerminal fd</tt> calls <tt>isatty</tt> to determine whether
--   or not <tt>Fd</tt> <tt>fd</tt> is associated with a terminal.
queryTerminal :: Fd -> IO Bool

-- | <tt>getTerminalName fd</tt> calls <tt>ttyname</tt> to obtain a name
--   associated with the terminal for <tt>Fd</tt> <tt>fd</tt>. If
--   <tt>fd</tt> is associated with a terminal, <tt>getTerminalName</tt>
--   returns the name of the terminal.
getTerminalName :: Fd -> IO FilePath

-- | <tt>getControllingTerminalName</tt> calls <tt>ctermid</tt> to obtain a
--   name associated with the controlling terminal for the process. If a
--   controlling terminal exists, <tt>getControllingTerminalName</tt>
--   returns the name of the controlling terminal.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>ctermid(3)</tt> (use <tt>#if HAVE_CTERMID</tt> CPP guard
--   to detect availability).
getControllingTerminalName :: IO FilePath

-- | <tt>openPseudoTerminal</tt> creates a pseudoterminal (pty) pair, and
--   returns the newly created pair as a (<tt>master</tt>, <tt>slave</tt>)
--   tuple.
openPseudoTerminal :: IO (Fd, Fd)

-- | <tt>getSlaveTerminalName</tt> calls <tt>ptsname</tt> to obtain the
--   name of the slave terminal associated with a pseudoterminal pair. The
--   file descriptor to pass in must be that of the master.
getSlaveTerminalName :: Fd -> IO FilePath


-- | POSIX Terminal support
module System.Posix.Terminal.PosixString
data TerminalAttributes

-- | <tt>getTerminalAttributes fd</tt> calls <tt>tcgetattr</tt> to obtain
--   the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt>.
getTerminalAttributes :: Fd -> IO TerminalAttributes
data TerminalState
Immediately :: TerminalState
WhenDrained :: TerminalState
WhenFlushed :: TerminalState

-- | <tt>setTerminalAttributes fd attr ts</tt> calls <tt>tcsetattr</tt> to
--   change the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt> to <tt>attr</tt>, when the terminal is in the state
--   indicated by <tt>ts</tt>.
setTerminalAttributes :: Fd -> TerminalAttributes -> TerminalState -> IO ()
data TerminalMode

-- | <tt>BRKINT</tt> - Signal interrupt on break
InterruptOnBreak :: TerminalMode

-- | <tt>ICRNL</tt> - Map CR to NL on input
MapCRtoLF :: TerminalMode

-- | <tt>IGNBRK</tt> - Ignore break condition
IgnoreBreak :: TerminalMode

-- | <tt>IGNCR</tt> - Ignore CR
IgnoreCR :: TerminalMode

-- | <tt>IGNPAR</tt> - Ignore characters with parity errors
IgnoreParityErrors :: TerminalMode

-- | <tt>INLCR</tt> - Map NL to CR on input
MapLFtoCR :: TerminalMode

-- | <tt>INPCK</tt> - Enable input parity check
CheckParity :: TerminalMode

-- | <tt>ISTRIP</tt> - Strip character
StripHighBit :: TerminalMode

-- | <tt>IXANY</tt> - Enable any character to restart output
RestartOnAny :: TerminalMode

-- | <tt>IXOFF</tt> - Enable start/stop input control
StartStopInput :: TerminalMode

-- | <tt>IXON</tt> - Enable start/stop output control
StartStopOutput :: TerminalMode

-- | <tt>PARMRK</tt> - Mark parity errors
MarkParityErrors :: TerminalMode

-- | <tt>OPOST</tt> - Post-process output
ProcessOutput :: TerminalMode

-- | <tt>ONLCR</tt> - (XSI) Map NL to CR-NL on output
MapLFtoCRLF :: TerminalMode

-- | <tt>OCRNL</tt> - (XSI) Map CR to NL on output
OutputMapCRtoLF :: TerminalMode

-- | <tt>ONOCR</tt> - (XSI) No CR output at column 0
NoCRAtColumnZero :: TerminalMode

-- | <tt>ONLRET</tt> - (XSI) NL performs CR function
ReturnMeansLF :: TerminalMode

-- | <tt>CLOCAL</tt> - Ignore modem status lines
LocalMode :: TerminalMode

-- | <tt>CREAD</tt> - Enable receiver
ReadEnable :: TerminalMode

-- | <tt>CSTOPB</tt> - Send two stop bits, else one
TwoStopBits :: TerminalMode

-- | <tt>HUPCL</tt> - Hang up on last close
HangupOnClose :: TerminalMode

-- | <tt>PARENB</tt> - Parity enable
EnableParity :: TerminalMode

-- | <tt>PARODD</tt> - Odd parity, else even
OddParity :: TerminalMode

-- | <tt>ECHO</tt> - Enable echo
EnableEcho :: TerminalMode

-- | <tt>ECHOE</tt> - Echo erase character as error-correcting backspace
EchoErase :: TerminalMode

-- | <tt>ECHOK</tt> - Echo KILL
EchoKill :: TerminalMode

-- | <tt>ECHONL</tt> - Echo NL
EchoLF :: TerminalMode

-- | <tt>ICANON</tt> - Canonical input (erase and kill processing)
ProcessInput :: TerminalMode

-- | <tt>IEXTEN</tt> - Enable extended input character processing
ExtendedFunctions :: TerminalMode

-- | <tt>ISIG</tt> - Enable signals
KeyboardInterrupts :: TerminalMode

-- | <tt>NOFLSH</tt> - Disable flush after interrupt or quit
NoFlushOnInterrupt :: TerminalMode

-- | <tt>TOSTOP</tt> - Send <tt>SIGTTOU</tt> for background output
BackgroundWriteInterrupt :: TerminalMode
withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
terminalMode :: TerminalMode -> TerminalAttributes -> Bool
bitsPerByte :: TerminalAttributes -> Int
withBits :: TerminalAttributes -> Int -> TerminalAttributes
data ControlCharacter
EndOfFile :: ControlCharacter
EndOfLine :: ControlCharacter
Erase :: ControlCharacter
Interrupt :: ControlCharacter
Kill :: ControlCharacter
Quit :: ControlCharacter
Start :: ControlCharacter
Stop :: ControlCharacter
Suspend :: ControlCharacter
controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char
withCC :: TerminalAttributes -> (ControlCharacter, Char) -> TerminalAttributes
withoutCC :: TerminalAttributes -> ControlCharacter -> TerminalAttributes
inputTime :: TerminalAttributes -> Int
withTime :: TerminalAttributes -> Int -> TerminalAttributes
minInput :: TerminalAttributes -> Int
withMinInput :: TerminalAttributes -> Int -> TerminalAttributes

-- | Serial line baudrate. The set of supported speeds is system-dependent.
--   Portable use of the provided pattern synonyms that are outside the
--   list mandated by POSIX requires <tt>#ifdef</tt> guards.
--   
--   Applications may need to be prepared to encounter speeds not known at
--   compile time, these can be handled generically via the <a>BaudRate</a>
--   constructor. In other words, the provided pattern synonyms are not
--   necessarily a <tt>COMPLETE</tt> set.
--   
--   All non-zero <i>pseudo-terminal</i> baud rates are functionally
--   equivalent, and the <tt>pty</tt> driver may accept any speed within a
--   suitable range. Requested speeds may be rounded up or down to fit into
--   the supported range.
newtype BaudRate
BaudRate :: CSpeed -> BaudRate

-- | Hang up
pattern B0 :: BaudRate

-- | 50 baud
pattern B50 :: BaudRate

-- | 75 baud
pattern B75 :: BaudRate

-- | 110 baud
pattern B110 :: BaudRate

-- | <ol>
--   <li>5 baud</li>
--   </ol>
pattern B134 :: BaudRate

-- | 150 baud
pattern B150 :: BaudRate

-- | 200 baud
pattern B200 :: BaudRate

-- | 300 baud
pattern B300 :: BaudRate

-- | 600 baud
pattern B600 :: BaudRate

-- | 1200 baud
pattern B1200 :: BaudRate

-- | 1800 baud
pattern B1800 :: BaudRate

-- | 2400 baud
pattern B2400 :: BaudRate

-- | 4800 baud
pattern B4800 :: BaudRate

-- | 9600 baud
pattern B9600 :: BaudRate

-- | 19200 baud
pattern B19200 :: BaudRate

-- | 38400 baud
pattern B38400 :: BaudRate

-- | 7200 baud, non-POSIX system-dependent extension
pattern B7200 :: BaudRate

-- | 14400 baud, non-POSIX system-dependent extension
pattern B14400 :: BaudRate

-- | 28800 baud, non-POSIX system-dependent extension
pattern B28800 :: BaudRate

-- | 57600 baud, non-POSIX system-dependent extension
pattern B57600 :: BaudRate

-- | 76800 baud, non-POSIX system-dependent extension
pattern B76800 :: BaudRate

-- | 115200 baud, non-POSIX system-dependent extension
pattern B115200 :: BaudRate

-- | 230400 baud, non-POSIX system-dependent extension
pattern B230400 :: BaudRate

-- | 460800 baud, non-POSIX system-dependent extension
pattern B460800 :: BaudRate

-- | 500000 baud, non-POSIX system-dependent extension
pattern B500000 :: BaudRate

-- | 921600 baud, non-POSIX system-dependent extension
pattern B921600 :: BaudRate

-- | 1000000 baud, non-POSIX system-dependent extension
pattern B1000000 :: BaudRate

-- | 1500000 baud, non-POSIX system-dependent extension
pattern B1500000 :: BaudRate

-- | 2000000 baud, non-POSIX system-dependent extension
pattern B2000000 :: BaudRate

-- | 2500000 baud, non-POSIX system-dependent extension
pattern B2500000 :: BaudRate

-- | 3000000 baud, non-POSIX system-dependent extension
pattern B3000000 :: BaudRate

-- | 3500000 baud, non-POSIX system-dependent extension
pattern B3500000 :: BaudRate

-- | 4000000 baud, non-POSIX system-dependent extension
pattern B4000000 :: BaudRate
inputSpeed :: TerminalAttributes -> BaudRate
withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
outputSpeed :: TerminalAttributes -> BaudRate
withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes

-- | <tt>sendBreak fd duration</tt> calls <tt>tcsendbreak</tt> to transmit
--   a continuous stream of zero-valued bits on <tt>Fd</tt> <tt>fd</tt> for
--   the specified implementation-dependent <tt>duration</tt>.
sendBreak :: Fd -> Int -> IO ()

-- | <tt>drainOutput fd</tt> calls <tt>tcdrain</tt> to block until all
--   output written to <tt>Fd</tt> <tt>fd</tt> has been transmitted.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>tcdrain(3)</tt> (use <tt>#if HAVE_TCDRAIN</tt> CPP guard
--   to detect availability).
drainOutput :: Fd -> IO ()
data QueueSelector
InputQueue :: QueueSelector
OutputQueue :: QueueSelector
BothQueues :: QueueSelector

-- | <tt>discardData fd queues</tt> calls <tt>tcflush</tt> to discard
--   pending input and/or output for <tt>Fd</tt> <tt>fd</tt>, as indicated
--   by the <tt>QueueSelector</tt> <tt>queues</tt>.
discardData :: Fd -> QueueSelector -> IO ()
data FlowAction

-- | TCOOFF
SuspendOutput :: FlowAction

-- | TCOON
RestartOutput :: FlowAction

-- | TCIOFF
TransmitStop :: FlowAction

-- | TCION
TransmitStart :: FlowAction

-- | <tt>controlFlow fd action</tt> calls <tt>tcflow</tt> to control the
--   flow of data on <tt>Fd</tt> <tt>fd</tt>, as indicated by
--   <tt>action</tt>.
controlFlow :: Fd -> FlowAction -> IO ()

-- | <tt>getTerminalProcessGroupID fd</tt> calls <tt>tcgetpgrp</tt> to
--   obtain the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt>.
getTerminalProcessGroupID :: Fd -> IO ProcessGroupID

-- | <tt>setTerminalProcessGroupID fd pgid</tt> calls <tt>tcsetpgrp</tt> to
--   set the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt> to
--   <tt>pgid</tt>.
setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO ()

-- | <tt>queryTerminal fd</tt> calls <tt>isatty</tt> to determine whether
--   or not <tt>Fd</tt> <tt>fd</tt> is associated with a terminal.
queryTerminal :: Fd -> IO Bool

-- | <tt>getTerminalName fd</tt> calls <tt>ttyname</tt> to obtain a name
--   associated with the terminal for <tt>Fd</tt> <tt>fd</tt>. If
--   <tt>fd</tt> is associated with a terminal, <tt>getTerminalName</tt>
--   returns the name of the terminal.
getTerminalName :: Fd -> IO PosixPath

-- | <tt>getControllingTerminalName</tt> calls <tt>ctermid</tt> to obtain a
--   name associated with the controlling terminal for the process. If a
--   controlling terminal exists, <tt>getControllingTerminalName</tt>
--   returns the name of the controlling terminal.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>ctermid(3)</tt> (use <tt>#if HAVE_CTERMID</tt> CPP guard
--   to detect availability).
getControllingTerminalName :: IO PosixPath

-- | <tt>openPseudoTerminal</tt> creates a pseudoterminal (pty) pair, and
--   returns the newly created pair as a (<tt>master</tt>, <tt>slave</tt>)
--   tuple.
openPseudoTerminal :: IO (Fd, Fd)

-- | <tt>getSlaveTerminalName</tt> calls <tt>ptsname</tt> to obtain the
--   name of the slave terminal associated with a pseudoterminal pair. The
--   file descriptor to pass in must be that of the master.
getSlaveTerminalName :: Fd -> IO PosixPath


-- | POSIX Time support
module System.Posix.Time

-- | <tt>epochTime</tt> calls <tt>time</tt> to obtain the number of seconds
--   that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970).
epochTime :: IO EpochTime


-- | POSIX miscellaneous stuff, mostly from unistd.h
module System.Posix.Unistd
data SystemID
SystemID :: String -> String -> String -> String -> String -> SystemID
[systemName] :: SystemID -> String
[nodeName] :: SystemID -> String
[release] :: SystemID -> String
[version] :: SystemID -> String
[machine] :: SystemID -> String
getSystemID :: IO SystemID
data SysVar
ArgumentLimit :: SysVar
ChildLimit :: SysVar
ClockTick :: SysVar
GroupLimit :: SysVar
OpenFileLimit :: SysVar
PosixVersion :: SysVar
HasSavedIDs :: SysVar
HasJobControl :: SysVar
getSysVar :: SysVar -> IO Integer

-- | Sleep for the specified duration (in seconds). Returns the time
--   remaining (if the sleep was interrupted by a signal, for example).
--   
--   <i>GHC Note</i>: <a>threadDelay</a> is a better choice. Since GHC uses
--   signals for its internal clock, a call to <a>sleep</a> will usually be
--   interrupted immediately. That makes <a>sleep</a> unusable in a program
--   compiled with GHC, unless the RTS timer is disabled (with <tt>+RTS
--   -V0</tt>). Furthermore, without the <tt>-threaded</tt> option,
--   <a>sleep</a> will block all other user threads. Even with the
--   <tt>-threaded</tt> option, <a>sleep</a> requires a full OS thread to
--   itself. <a>threadDelay</a> has none of these shortcomings.

-- | <i>Warning: This function has several shortcomings (see
--   documentation). Please consider using Control.Concurrent.threadDelay
--   instead.</i>
sleep :: Int -> IO Int

-- | Sleep for the specified duration (in microseconds).
--   
--   <i>GHC Note</i>: <a>threadDelay</a> is a better choice. Without the
--   <tt>-threaded</tt> option, <a>usleep</a> will block all other user
--   threads. Even with the <tt>-threaded</tt> option, <a>usleep</a>
--   requires a full OS thread to itself. <a>threadDelay</a> has neither of
--   these shortcomings.
usleep :: Int -> IO ()

-- | Sleep for the specified duration (in nanoseconds)
--   
--   <i>GHC Note</i>: the comment for <a>usleep</a> also applies here.
nanosleep :: Integer -> IO ()

-- | Performs <tt>fsync(2)</tt> operation on file-descriptor.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>fsync(2)</tt> (use <tt>#if HAVE_FSYNC</tt> CPP guard to
--   detect availability).
fileSynchronise :: Fd -> IO ()

-- | Performs <tt>fdatasync(2)</tt> operation on file-descriptor.
--   
--   Throws <a>IOError</a> ("unsupported operation") if platform does not
--   provide <tt>fdatasync(2)</tt> (use <tt>#if HAVE_FDATASYNC</tt> CPP
--   guard to detect availability).
fileSynchroniseDataOnly :: Fd -> IO ()


-- | POSIX user/group support
module System.Posix.User.ByteString

-- | <tt>getRealUserID</tt> calls <tt>getuid</tt> to obtain the real
--   <tt>UserID</tt> associated with the current process.
getRealUserID :: IO UserID

-- | <tt>getRealGroupID</tt> calls <tt>getgid</tt> to obtain the real
--   <tt>GroupID</tt> associated with the current process.
getRealGroupID :: IO GroupID

-- | <tt>getEffectiveUserID</tt> calls <tt>geteuid</tt> to obtain the
--   effective <tt>UserID</tt> associated with the current process.
getEffectiveUserID :: IO UserID

-- | <tt>getEffectiveGroupID</tt> calls <tt>getegid</tt> to obtain the
--   effective <tt>GroupID</tt> associated with the current process.
getEffectiveGroupID :: IO GroupID

-- | <tt>getGroups</tt> calls <tt>getgroups</tt> to obtain the list of
--   supplementary <tt>GroupID</tt>s associated with the current process.
getGroups :: IO [GroupID]

-- | <tt>getLoginName</tt> calls <tt>getlogin</tt> to obtain the login name
--   associated with the current process.
getLoginName :: IO ByteString

-- | <tt>getEffectiveUserName</tt> gets the name associated with the
--   effective <tt>UserID</tt> of the process.
getEffectiveUserName :: IO ByteString
data GroupEntry
GroupEntry :: ByteString -> ByteString -> GroupID -> [ByteString] -> GroupEntry

-- | The name of this group (gr_name)
[groupName] :: GroupEntry -> ByteString

-- | The password for this group (gr_passwd)
[groupPassword] :: GroupEntry -> ByteString

-- | The unique numeric ID for this group (gr_gid)
[groupID] :: GroupEntry -> GroupID

-- | A list of zero or more usernames that are members (gr_mem)
[groupMembers] :: GroupEntry -> [ByteString]

-- | <tt>getGroupEntryForID gid</tt> calls <tt>getgrgid_r</tt> to obtain
--   the <tt>GroupEntry</tt> information associated with <tt>GroupID</tt>
--   <tt>gid</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such group exists.
getGroupEntryForID :: GroupID -> IO GroupEntry

-- | <tt>getGroupEntryForName name</tt> calls <tt>getgrnam_r</tt> to obtain
--   the <tt>GroupEntry</tt> information associated with the group called
--   <tt>name</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such group exists.
getGroupEntryForName :: ByteString -> IO GroupEntry

-- | <tt>getAllGroupEntries</tt> returns all group entries on the system by
--   repeatedly calling <tt>getgrent</tt>
getAllGroupEntries :: IO [GroupEntry]
data UserEntry
UserEntry :: ByteString -> ByteString -> UserID -> GroupID -> ByteString -> ByteString -> ByteString -> UserEntry

-- | Textual name of this user (pw_name)
[userName] :: UserEntry -> ByteString

-- | Password -- may be empty or fake if shadow is in use (pw_passwd)
[userPassword] :: UserEntry -> ByteString

-- | Numeric ID for this user (pw_uid)
[userID] :: UserEntry -> UserID

-- | Primary group ID (pw_gid)
[userGroupID] :: UserEntry -> GroupID

-- | Usually the real name for the user (pw_gecos)
[userGecos] :: UserEntry -> ByteString

-- | Home directory (pw_dir)
[homeDirectory] :: UserEntry -> ByteString

-- | Default shell (pw_shell)
[userShell] :: UserEntry -> ByteString

-- | <tt>getUserEntryForID uid</tt> calls <tt>getpwuid_r</tt> to obtain the
--   <tt>UserEntry</tt> information associated with <tt>UserID</tt>
--   <tt>uid</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such user exists.
getUserEntryForID :: UserID -> IO UserEntry

-- | <tt>getUserEntryForName name</tt> calls <tt>getpwnam_r</tt> to obtain
--   the <tt>UserEntry</tt> information associated with the user login
--   <tt>name</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such user exists.
getUserEntryForName :: ByteString -> IO UserEntry

-- | <tt>getAllUserEntries</tt> returns all user entries on the system by
--   repeatedly calling <tt>getpwent</tt>
getAllUserEntries :: IO [UserEntry]

-- | <tt>setUserID uid</tt> calls <tt>setuid</tt> to set the real,
--   effective, and saved set-user-id associated with the current process
--   to <tt>uid</tt>.
setUserID :: UserID -> IO ()

-- | <tt>setGroupID gid</tt> calls <tt>setgid</tt> to set the real,
--   effective, and saved set-group-id associated with the current process
--   to <tt>gid</tt>.
setGroupID :: GroupID -> IO ()

-- | <tt>setEffectiveUserID uid</tt> calls <tt>seteuid</tt> to set the
--   effective user-id associated with the current process to <tt>uid</tt>.
--   This does not update the real user-id or set-user-id.
setEffectiveUserID :: UserID -> IO ()

-- | <tt>setEffectiveGroupID uid</tt> calls <tt>setegid</tt> to set the
--   effective group-id associated with the current process to
--   <tt>gid</tt>. This does not update the real group-id or set-group-id.
setEffectiveGroupID :: GroupID -> IO ()

-- | <tt>setGroups</tt> calls <tt>setgroups</tt> to set the list of
--   supplementary <tt>GroupID</tt>s associated with the current process.
setGroups :: [GroupID] -> IO ()


-- | POSIX user/group support
module System.Posix.User

-- | <tt>getRealUserID</tt> calls <tt>getuid</tt> to obtain the real
--   <tt>UserID</tt> associated with the current process.
getRealUserID :: IO UserID

-- | <tt>getRealGroupID</tt> calls <tt>getgid</tt> to obtain the real
--   <tt>GroupID</tt> associated with the current process.
getRealGroupID :: IO GroupID

-- | <tt>getEffectiveUserID</tt> calls <tt>geteuid</tt> to obtain the
--   effective <tt>UserID</tt> associated with the current process.
getEffectiveUserID :: IO UserID

-- | <tt>getEffectiveGroupID</tt> calls <tt>getegid</tt> to obtain the
--   effective <tt>GroupID</tt> associated with the current process.
getEffectiveGroupID :: IO GroupID

-- | <tt>getGroups</tt> calls <tt>getgroups</tt> to obtain the list of
--   supplementary <tt>GroupID</tt>s associated with the current process.
getGroups :: IO [GroupID]

-- | <tt>getLoginName</tt> calls <tt>getlogin</tt> to obtain the login name
--   associated with the current process.
getLoginName :: IO String

-- | <tt>getEffectiveUserName</tt> gets the name associated with the
--   effective <tt>UserID</tt> of the process.
getEffectiveUserName :: IO String
groupName :: GroupEntry -> String
groupPassword :: GroupEntry -> String
groupID :: GroupEntry -> GroupID
groupMembers :: GroupEntry -> [String]

-- | Manually constructing <a>GroupEntry</a> in String modules is
--   discouraged. It will truncate Chars to 8bit. Use <a>ByteString</a>
--   instead.
pattern GroupEntry :: String -> String -> GroupID -> [String] -> GroupEntry

-- | <tt>getGroupEntryForID gid</tt> calls <tt>getgrgid_r</tt> to obtain
--   the <tt>GroupEntry</tt> information associated with <tt>GroupID</tt>
--   <tt>gid</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such group exists.
getGroupEntryForID :: GroupID -> IO GroupEntry

-- | <tt>getGroupEntryForName name</tt> calls <tt>getgrnam_r</tt> to obtain
--   the <tt>GroupEntry</tt> information associated with the group called
--   <tt>name</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such group exists.
getGroupEntryForName :: String -> IO GroupEntry

-- | <tt>getAllGroupEntries</tt> returns all group entries on the system by
--   repeatedly calling <tt>getgrent</tt>
getAllGroupEntries :: IO [GroupEntry]
userName :: UserEntry -> String
userPassword :: UserEntry -> String
userID :: UserEntry -> UserID
userGroupID :: UserEntry -> GroupID
userGecos :: UserEntry -> String
homeDirectory :: UserEntry -> String
userShell :: UserEntry -> String

-- | Manually constructing <a>UserEntry</a> in String modules is
--   discouraged. It will truncate Chars to 8bit. Use <a>ByteString</a>
--   instead.
pattern UserEntry :: String -> String -> UserID -> GroupID -> String -> String -> String -> UserEntry

-- | <tt>getUserEntryForID uid</tt> calls <tt>getpwuid_r</tt> to obtain the
--   <tt>UserEntry</tt> information associated with <tt>UserID</tt>
--   <tt>uid</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such user exists.
getUserEntryForID :: UserID -> IO UserEntry

-- | <tt>getUserEntryForName name</tt> calls <tt>getpwnam_r</tt> to obtain
--   the <tt>UserEntry</tt> information associated with the user login
--   <tt>name</tt>. This operation may fail with <a>isDoesNotExistError</a>
--   if no such user exists.
getUserEntryForName :: String -> IO UserEntry

-- | <tt>getAllUserEntries</tt> returns all user entries on the system by
--   repeatedly calling <tt>getpwent</tt>
getAllUserEntries :: IO [UserEntry]

-- | <tt>setUserID uid</tt> calls <tt>setuid</tt> to set the real,
--   effective, and saved set-user-id associated with the current process
--   to <tt>uid</tt>.
setUserID :: UserID -> IO ()

-- | <tt>setGroupID gid</tt> calls <tt>setgid</tt> to set the real,
--   effective, and saved set-group-id associated with the current process
--   to <tt>gid</tt>.
setGroupID :: GroupID -> IO ()

-- | <tt>setEffectiveUserID uid</tt> calls <tt>seteuid</tt> to set the
--   effective user-id associated with the current process to <tt>uid</tt>.
--   This does not update the real user-id or set-user-id.
setEffectiveUserID :: UserID -> IO ()

-- | <tt>setEffectiveGroupID uid</tt> calls <tt>setegid</tt> to set the
--   effective group-id associated with the current process to
--   <tt>gid</tt>. This does not update the real group-id or set-group-id.
setEffectiveGroupID :: GroupID -> IO ()

-- | <tt>setGroups</tt> calls <tt>setgroups</tt> to set the list of
--   supplementary <tt>GroupID</tt>s associated with the current process.
setGroups :: [GroupID] -> IO ()


-- | <a>POSIX.1-2008</a> support with <tt>ByteString</tt> file paths and
--   environment strings.
--   
--   This module exports exactly the same API as <a>System.Posix</a>,
--   except that all file paths and environment strings are represented by
--   <tt>ByteString</tt> instead of <a>String</a>. The <a>System.Posix</a>
--   API implicitly translates all file paths and environment strings using
--   the locale encoding, whereas this version of the API does no encoding
--   or decoding and works directly in terms of raw bytes.
--   
--   Note that if you do need to interpret file paths or environment
--   strings as text, then some Unicode encoding or decoding should be
--   applied first.
module System.Posix.PosixString

-- | Commonly used Posix string as uninterpreted <tt>char[]</tt> array.
data PosixString

-- | Filepaths are <tt>char[]</tt> data on unix as passed to syscalls.
type PosixPath = PosixString


-- | <a>POSIX.1-2008</a> support with <tt>ByteString</tt> file paths and
--   environment strings.
--   
--   This module exports exactly the same API as <a>System.Posix</a>,
--   except that all file paths and environment strings are represented by
--   <tt>ByteString</tt> instead of <a>String</a>. The <a>System.Posix</a>
--   API implicitly translates all file paths and environment strings using
--   the locale encoding, whereas this version of the API does no encoding
--   or decoding and works directly in terms of raw bytes.
--   
--   Note that if you do need to interpret file paths or environment
--   strings as text, then some Unicode encoding or decoding should be
--   applied first.
module System.Posix.ByteString

-- | A literal POSIX file path
type RawFilePath = ByteString

-- | Flags for <a>dlsym</a>. Notice that <a>Next</a> might not be available
--   on your particular platform! Use <a>haveRtldNext</a>.
--   
--   If <tt>RTLD_DEFAULT</tt> is not defined on your platform,
--   <a>packDL</a> <a>Default</a> reduces to <a>nullPtr</a>.
data DL
Null :: DL
Next :: DL
DLHandle :: Ptr () -> DL
dlopen :: RawFilePath -> [RTLDFlags] -> IO DL

-- | <a>dlsym</a> returns the address binding of the symbol described in
--   <tt>symbol</tt>, as it occurs in the shared object identified by
--   <tt>source</tt>.
dlsym :: DL -> String -> IO (FunPtr a)
dlerror :: IO String
dlclose :: DL -> IO ()
withDL :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO a
withDL_ :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO ()

-- | <a>undl</a> obtains the raw handle. You mustn't do something like
--   <tt>withDL mod flags $ liftM undl &gt;&gt;= p -&gt; use p</tt>
undl :: DL -> Ptr ()
c_dlopen :: CString -> CInt -> IO (Ptr ())
c_dlsym :: Ptr () -> CString -> IO (FunPtr a)
c_dlerror :: IO CString
c_dlclose :: Ptr () -> IO CInt

-- | On some hosts (e.g. SuSe and Ubuntu Linux) <tt>RTLD_NEXT</tt> (and
--   <tt>RTLD_DEFAULT</tt>) are not visible without setting the macro
--   <tt>_GNU_SOURCE</tt>. Since we don't want to define this macro, you
--   can use the function <a>haveRtldNext</a> to check whether the flag
--   <a>Next</a> is available. Ideally, this will be optimized by the
--   compiler so that it should be as efficient as an <tt>#ifdef</tt>.
--   
--   If you fail to test the flag and use it although it is undefined,
--   <a>packDL</a> will throw an error.
haveRtldNext :: Bool

-- | <i>Deprecated: defaults to True</i>
haveRtldLocal :: Bool
packRTLDFlags :: [RTLDFlags] -> CInt

-- | Flags for <a>dlopen</a>.
data RTLDFlags
RTLD_LAZY :: RTLDFlags
RTLD_NOW :: RTLDFlags
RTLD_GLOBAL :: RTLDFlags
RTLD_LOCAL :: RTLDFlags
packDL :: DL -> Ptr ()


-- | <a>POSIX.1-2008</a> support
module System.Posix

-- | Flags for <a>dlsym</a>. Notice that <a>Next</a> might not be available
--   on your particular platform! Use <a>haveRtldNext</a>.
--   
--   If <tt>RTLD_DEFAULT</tt> is not defined on your platform,
--   <a>packDL</a> <a>Default</a> reduces to <a>nullPtr</a>.
data DL
Null :: DL
Next :: DL
DLHandle :: Ptr () -> DL
dlopen :: FilePath -> [RTLDFlags] -> IO DL

-- | <a>dlsym</a> returns the address binding of the symbol described in
--   <tt>symbol</tt>, as it occurs in the shared object identified by
--   <tt>source</tt>.
dlsym :: DL -> String -> IO (FunPtr a)
dlerror :: IO String
dlclose :: DL -> IO ()
withDL :: FilePath -> [RTLDFlags] -> (DL -> IO a) -> IO a
withDL_ :: FilePath -> [RTLDFlags] -> (DL -> IO a) -> IO ()

-- | <a>undl</a> obtains the raw handle. You mustn't do something like
--   <tt>withDL mod flags $ liftM undl &gt;&gt;= p -&gt; use p</tt>
undl :: DL -> Ptr ()
c_dlopen :: CString -> CInt -> IO (Ptr ())
c_dlsym :: Ptr () -> CString -> IO (FunPtr a)
c_dlerror :: IO CString
c_dlclose :: Ptr () -> IO CInt

-- | On some hosts (e.g. SuSe and Ubuntu Linux) <tt>RTLD_NEXT</tt> (and
--   <tt>RTLD_DEFAULT</tt>) are not visible without setting the macro
--   <tt>_GNU_SOURCE</tt>. Since we don't want to define this macro, you
--   can use the function <a>haveRtldNext</a> to check whether the flag
--   <a>Next</a> is available. Ideally, this will be optimized by the
--   compiler so that it should be as efficient as an <tt>#ifdef</tt>.
--   
--   If you fail to test the flag and use it although it is undefined,
--   <a>packDL</a> will throw an error.
haveRtldNext :: Bool

-- | <i>Deprecated: defaults to True</i>
haveRtldLocal :: Bool
packRTLDFlags :: [RTLDFlags] -> CInt

-- | Flags for <a>dlopen</a>.
data RTLDFlags
RTLD_LAZY :: RTLDFlags
RTLD_NOW :: RTLDFlags
RTLD_GLOBAL :: RTLDFlags
RTLD_LOCAL :: RTLDFlags
packDL :: DL -> Ptr ()
