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


-- | Bindings to the btrfs API
--   
--   This package provides bindings to the low-level btrfs API (i.e. the
--   <tt>BTRFS_IOC_</tt>* <tt>ioctl</tt>s). Currently, only a subset of the
--   API is supported, including all functions needed to work with
--   subvolumes/snapshots as well as file cloning.
--   
--   In order to build this package, <tt>linux-headers</tt> needs to be
--   installed.
--   
--   Warning: btrfs is still considered experimental. This module is also
--   experimental and may contain serious bugs that may result in data
--   loss. Do not use it on data that has not been backed up yet.
@package btrfs
@version 0.1.2.3

module System.Linux.Btrfs.Time
newtype BtrfsTime
BtrfsTime :: UTCTime -> BtrfsTime
instance Foreign.Storable.Storable System.Linux.Btrfs.Time.BtrfsTime

module System.Linux.Btrfs.UUID
data UUID
UUID :: Word64 -> Word64 -> UUID
toString :: UUID -> String
fromString :: String -> Maybe UUID
instance GHC.Classes.Ord System.Linux.Btrfs.UUID.UUID
instance GHC.Classes.Eq System.Linux.Btrfs.UUID.UUID
instance GHC.Show.Show System.Linux.Btrfs.UUID.UUID
instance Foreign.Storable.Storable System.Linux.Btrfs.UUID.UUID


-- | Most functions in this module come in two flavors: one that operates
--   on file descriptors and another one that operates on file paths. The
--   former can be distinguished by the <tt>Fd</tt> suffix in their names.
module System.Linux.Btrfs.ByteString
type FileSize = Word64
type ObjectType = Word8
type ObjectId = Word64
type InodeNum = ObjectId
type SubvolId = ObjectId
data CompressionType
Zlib :: CompressionType
LZO :: CompressionType
cloneFd :: Fd -> Fd -> IO ()

-- | Clone an entire file to an existing file.
--   
--   Note: calls the <tt>BTRFS_IOC_CLONE</tt>/<tt>FICLONE</tt>
--   <tt>ioctl</tt>.
clone :: RawFilePath -> RawFilePath -> IO ()

-- | Like <a>clone</a> except that it will create or truncate the
--   destination file if necessary. This is similar to <tt>cp
--   --reflink=always</tt>.
--   
--   Note: calls the <tt>BTRFS_IOC_CLONE</tt>/<tt>FICLONE</tt>
--   <tt>ioctl</tt>.
cloneNew :: RawFilePath -> RawFilePath -> IO ()
cloneRangeFd :: Fd -> FileSize -> FileSize -> Fd -> FileSize -> IO ()

-- | Clones a range of bytes from a file to another file. All ranges must
--   be block-aligned.
--   
--   Note: calls the <tt>BTRFS_IOC_CLONE_RANGE</tt>/<tt>FICLONERANGE</tt>
--   <tt>ioctl</tt>.
cloneRange :: RawFilePath -> FileSize -> FileSize -> RawFilePath -> FileSize -> IO ()

-- | The result of a <a>cloneRangeIfSame</a> operation.
data CloneResult

-- | Cloning failed because of an error.
CRError :: IOError -> CloneResult

-- | No cloning was performed because the contents of the source and the
--   destination file differ.
CRDataDiffers :: CloneResult

-- | Cloning succeeded, the returned integer indicates the number of bytes
--   that were deduped.
CRSuccess :: FileSize -> CloneResult
cloneRangeIfSameFd :: Fd -> FileSize -> FileSize -> [(Fd, FileSize)] -> IO [CloneResult]

-- | Similar to <a>cloneRange</a> except that it performs the cloning only
--   if the data ranges contain identical data. Additionally, it accepts
--   multiple destination files. The same thing can be accomplished with
--   <a>cloneRange</a> in conjunction with file locking but this function
--   uses in-kernel locking to guarantee that the deduplicated data is
--   identical at the time of the operation. On the other hand, this
--   function will not clone arbitrarily large ranges; the kernel has an
--   upper limit for the length and if cloning bigger ranges is desired
--   then it has to be called multiple times. Note that cloning may succeed
--   for some of the destination files and fail for others. Because of
--   that, this function returns a list of outcomes, one for each
--   destination file, and no exceptions will be raised for the failed
--   files.
--   
--   Note: calls the
--   <tt>BTRFS_IOC_FILE_EXTENT_SAME</tt>/<tt>FIDEDUPERANGE</tt>
--   <tt>ioctl</tt>.
--   
--   <i>Requires Linux 3.12 or later.</i>
cloneRangeIfSame :: RawFilePath -> FileSize -> FileSize -> [(RawFilePath, FileSize)] -> IO [CloneResult]

-- | Create an (initially) empty new subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_SUBVOL_CREATE</tt> <tt>ioctl</tt>.
createSubvol :: RawFilePath -> IO ()

-- | Destroy (delete) a subvolume. The directory that corresponds to the
--   subvolume is removed asynchronously. As a result, the subvolume may
--   appear again after a crash. If this is not acceptable, call
--   <a>startSync</a> followed by a <a>waitSync</a>, after the
--   <tt>destroySubvol</tt> call.
--   
--   Note: calls the <tt>BTRFS_IOC_SNAP_DESTROY</tt> <tt>ioctl</tt>.
destroySubvol :: RawFilePath -> IO ()
snapshotFd :: Fd -> RawFilePath -> Bool -> IO ()

-- | Create a snapshot of an existing subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_SNAP_CREATE_V2</tt> <tt>ioctl</tt>.
snapshot :: RawFilePath -> RawFilePath -> Bool -> IO ()
getSubvolReadOnlyFd :: Fd -> IO Bool

-- | Is the subvolume read-only?
--   
--   Note: calls the <tt>BTRFS_IOC_SUBVOL_GETFLAGS</tt> <tt>ioctl</tt>.
getSubvolReadOnly :: RawFilePath -> IO Bool
setSubvolReadOnlyFd :: Fd -> Bool -> IO ()

-- | Make a subvolume read-only (or read-write).
--   
--   Note: calls the <tt>BTRFS_IOC_SUBVOL_GETFLAGS</tt> and
--   <tt>BTRFS_IOC_SUBVOL_SETFLAGS</tt> <tt>ioctl</tt>s.
setSubvolReadOnly :: RawFilePath -> Bool -> IO ()
getSubvolFd :: Fd -> IO SubvolId

-- | Find the id of the subvolume where the given file resides. This is
--   merely a wrapper around <a>lookupInode</a> provided for convenience.
getSubvol :: RawFilePath -> IO SubvolId
lookupSubvolFd :: Fd -> SubvolId -> IO (SubvolId, InodeNum, RawFilePath)

-- | Given the id of a subvolume, find the id of the parent subvolume, the
--   inode number of the directory containing it, and its name. This is a
--   wrapper around <a>treeSearch</a>.
lookupSubvol :: RawFilePath -> SubvolId -> IO (SubvolId, InodeNum, RawFilePath)
resolveSubvolFd :: Fd -> SubvolId -> IO RawFilePath

-- | Given the id of a subvolume, find its path relative to the root of the
--   volume. This function calls <a>lookupSubvol</a> recursively.
resolveSubvol :: RawFilePath -> SubvolId -> IO RawFilePath

-- | The id the root subvolume.
rootSubvol :: SubvolId
listSubvolsFd :: Fd -> IO [(SubvolId, SubvolId, InodeNum, RawFilePath)]

-- | Find all subvolumes of the given volume. For each subvolume found, it
--   returns: its id, the id of its parent subvolume, the inode number of
--   the directory containing it, and its name. This is a wrapper around
--   <a>treeSearch</a>.
listSubvols :: RawFilePath -> IO [(SubvolId, SubvolId, InodeNum, RawFilePath)]
listSubvolPathsFd :: Fd -> IO [(SubvolId, SubvolId, RawFilePath)]

-- | Find all subvolumes of the given volume. For each subvolume found, it
--   returns: its id, the id of its parent subvolume, and its path relative
--   to the root of the volume. This is a wrapper around <a>treeSearch</a>
--   and <a>resolveSubvol</a>.
listSubvolPaths :: RawFilePath -> IO [(SubvolId, SubvolId, RawFilePath)]
childSubvolsFd :: Fd -> SubvolId -> IO [(SubvolId, InodeNum, RawFilePath)]

-- | Find all child subvolumes of the given subvolume. For each child,
--   returns its id, the inode number of the directory containing it, and
--   its name. This is a wrapper around <a>treeSearch</a>.
childSubvols :: RawFilePath -> SubvolId -> IO [(SubvolId, InodeNum, RawFilePath)]
childSubvolPathsFd :: Fd -> SubvolId -> IO [(SubvolId, RawFilePath)]

-- | Find all child subvolumes of the given subvolume. For each child,
--   returns its id and its path relative to the root of the parent. This
--   is a wrapper around <a>treeSearch</a> and <a>lookupInode</a>.
childSubvolPaths :: RawFilePath -> SubvolId -> IO [(SubvolId, RawFilePath)]

-- | Information about a subvolume.
data SubvolInfo
SubvolInfo :: Word64 -> Maybe Word64 -> Maybe Word64 -> Bool -> Maybe UUID -> Maybe UUID -> Maybe UUID -> Maybe Word64 -> Maybe Word64 -> Maybe Word64 -> Maybe Word64 -> Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime -> SubvolInfo

-- | The generation when the subvolume was last modified.
[siGeneration] :: SubvolInfo -> Word64

-- | The generation when the most recent snapshot of this subvolume was
--   taken.
[siLastSnapshot] :: SubvolInfo -> Maybe Word64

-- | The generation of the snapshot parent at the time when the snapshot
--   was taken. Defined if only if this is a snapshot.
[siParSnapGen] :: SubvolInfo -> Maybe Word64

-- | Is this a read-only subvolume?
[siReadOnly] :: SubvolInfo -> Bool

-- | The UUID of the subvolume.
[siUuid] :: SubvolInfo -> Maybe UUID

-- | The UUID of the snapshot parent.
[siPUuid] :: SubvolInfo -> Maybe UUID

-- | The UUID of the source subvolume that this subvolume was received
--   from. This is always defined for received subvolumes.
[siReceivedUuid] :: SubvolInfo -> Maybe UUID

-- | The generation when an inode was last modified.
[siCTransId] :: SubvolInfo -> Maybe Word64

-- | The generation when the subvolume was created.
[siOTransId] :: SubvolInfo -> Maybe Word64

-- | The generation of the source subvolume that this subvolume was
--   received from. This is always defined for received subvolumes.
[siSTransId] :: SubvolInfo -> Maybe Word64

-- | The generation when the subvolume was received. This is always defined
--   for received subvolumes.
[siRTransId] :: SubvolInfo -> Maybe Word64

-- | The time when an inode was last modified.
[siCTime] :: SubvolInfo -> Maybe UTCTime

-- | The time when the subvolume was created.
[siOTime] :: SubvolInfo -> Maybe UTCTime

-- | The timestamp that corresponds to <a>siSTransId</a>.
[siSTime] :: SubvolInfo -> Maybe UTCTime

-- | The time when the subvolume was received. This is always defined for
--   received subvolumes.
[siRTime] :: SubvolInfo -> Maybe UTCTime
getSubvolInfoFd :: Fd -> SubvolId -> IO SubvolInfo

-- | Retrieve information about a subvolume. This is a wrapper around
--   <a>treeSearch</a>.
getSubvolInfo :: RawFilePath -> SubvolId -> IO SubvolInfo
getSubvolByUuidFd :: Fd -> UUID -> IO SubvolId

-- | Find the id of a subvolume, given its UUID. This is a wrapper around
--   <a>treeSearch</a>.
--   
--   <i>Requires Linux 3.12 or later.</i>
getSubvolByUuid :: RawFilePath -> UUID -> IO SubvolId
getSubvolByReceivedUuidFd :: Fd -> UUID -> IO SubvolId

-- | Find the id of a subvolume, given its <a>siReceivedUuid</a>. This is a
--   wrapper around <a>treeSearch</a>.
--   
--   <i>Requires Linux 3.12 or later.</i>
getSubvolByReceivedUuid :: RawFilePath -> UUID -> IO SubvolId
getDefaultSubvolFd :: Fd -> IO SubvolId

-- | Find the id of the default subvolume. This is a wrapper around
--   <a>treeSearch</a>.
getDefaultSubvol :: RawFilePath -> IO SubvolId
setDefaultSubvolFd :: Fd -> ObjectId -> IO ()

-- | Set the default subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_DEFAULT_SUBVOL</tt> <tt>ioctl</tt>.
setDefaultSubvol :: RawFilePath -> SubvolId -> IO ()
defragFd :: Fd -> IO ()

-- | Defrag a single file.
--   
--   Note: calls the <tt>BTRFS_IOC_DEFRAG</tt> <tt>ioctl</tt>.
defrag :: RawFilePath -> IO ()

-- | Argument to the <a>defragRange</a> operation.
data DefragRangeArgs
DefragRangeArgs :: FileSize -> FileSize -> Word32 -> Maybe CompressionType -> Bool -> DefragRangeArgs

-- | Beginning of the defrag range.
[draStart] :: DefragRangeArgs -> FileSize

-- | Number of bytes to defrag, use <a>maxBound</a> to say all.
[draLength] :: DefragRangeArgs -> FileSize

-- | Any extent of size bigger or equal to this number will be considered
--   already defragged. Use 0 for the kernel default.
[draExtentThreshold] :: DefragRangeArgs -> Word32

-- | Compress the file while defragmenting.
[draCompress] :: DefragRangeArgs -> Maybe CompressionType

-- | Flush data to disk immediately after defragmenting.
[draFlush] :: DefragRangeArgs -> Bool

-- | Defaults for <a>defragRange</a>. Selects the entire file, no
--   compression, and no flushing.
defaultDefragRangeArgs :: DefragRangeArgs
defragRangeFd :: Fd -> DefragRangeArgs -> IO ()

-- | Defrag a range within a single file.
--   
--   Note: calls the <tt>BTRFS_IOC_DEFRAG_RANGE</tt> <tt>ioctl</tt>.
defragRange :: RawFilePath -> DefragRangeArgs -> IO ()
syncFd :: Fd -> IO ()

-- | Sync the file system identified by the supplied path. The
--   <a>FilePath</a> can refer to any file in the file system.
--   
--   Note: calls the <tt>BTRFS_IOC_SYNC</tt> <tt>ioctl</tt>.
sync :: RawFilePath -> IO ()
startSyncFd :: Fd -> IO ()

-- | Initiate a sync for the file system identified by the supplied path.
--   
--   Note: calls the <tt>BTRFS_IOC_START_SYNC</tt> <tt>ioctl</tt>.
startSync :: RawFilePath -> IO ()
waitSyncFd :: Fd -> IO ()

-- | Wait until the sync operation completes.
--   
--   Note: calls the <tt>BTRFS_IOC_WAIT_SYNC</tt> <tt>ioctl</tt>.
waitSync :: RawFilePath -> IO ()
resolveLogicalFd :: Fd -> FileSize -> IO ([(InodeNum, FileSize, SubvolId)], Int)

-- | Given a physical offset, look for any inodes that this byte belongs
--   to. For each inode, it returns the inode number, the logical offset
--   (i.e. the offset within the inode), and the subvolume id. If a large
--   number of inodes is found, then not all of them will be returned by
--   this function. This is due to a current limitation in the kernel. The
--   integer returned along with list of inodes indicates the number of
--   inodes found but not included in the list.
--   
--   Note: calls the <tt>BTRFS_IOC_LOGICAL_INO</tt> <tt>ioctl</tt>.
resolveLogical :: RawFilePath -> FileSize -> IO ([(InodeNum, FileSize, SubvolId)], Int)
resolveInodeFd :: Fd -> InodeNum -> IO ([RawFilePath], Int)

-- | Find the file path(s) given an inode number. Returns a list of file
--   paths and an integer indicating the number of paths found but not
--   included in the resulting list. This is because of a limitation in the
--   kernel (it will not return an arbitrarily large list). The paths
--   returned are relative to the root of the subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_INO_PATHS</tt> <tt>ioctl</tt>.
resolveInode :: RawFilePath -> InodeNum -> IO ([RawFilePath], Int)
lookupInodeFd :: Fd -> SubvolId -> InodeNum -> IO (SubvolId, RawFilePath)

-- | Find the path of a file given its inode number and the id of the
--   subvolume. If multiple files share the same inode number, only one of
--   them is returned. The id of the subvolume is also returned. This is
--   useful when 0 is given for the <a>SubvolId</a> argument (also see
--   <a>getSubvol</a> for this case).
--   
--   Note: calls the <tt>BTRFS_IOC_INO_LOOKUP</tt> <tt>ioctl</tt>.
lookupInode :: RawFilePath -> SubvolId -> InodeNum -> IO (SubvolId, RawFilePath)
getFileNoCOWFd :: Fd -> IO Bool

-- | Determine whether the NOCOW flag is enabled for the specified file.
--   
--   Note: calls the <tt>FS_IOC_GETFLAGS</tt> <tt>ioctl</tt>.
getFileNoCOW :: RawFilePath -> IO Bool
setFileNoCOWFd :: Fd -> Bool -> IO ()

-- | Set or clear the NOCOW flag for the specified file. If the file is not
--   empty, this has no effect and no error will be reported.
--   
--   Note: calls the <tt>FS_IOC_GETFLAGS</tt> and <tt>FS_IOC_GETFLAGS</tt>
--   <tt>ioctl</tt>s.
setFileNoCOW :: RawFilePath -> Bool -> IO ()
data SearchKey
SearchKey :: ObjectId -> ObjectId -> ObjectType -> Word64 -> ObjectId -> ObjectType -> Word64 -> Word64 -> Word64 -> SearchKey
[skTreeId] :: SearchKey -> ObjectId
[skMinObjectId] :: SearchKey -> ObjectId
[skMinType] :: SearchKey -> ObjectType
[skMinOffset] :: SearchKey -> Word64
[skMaxObjectId] :: SearchKey -> ObjectId
[skMaxType] :: SearchKey -> ObjectType
[skMaxOffset] :: SearchKey -> Word64
[skMinTransId] :: SearchKey -> Word64
[skMaxTransId] :: SearchKey -> Word64
defaultSearchKey :: SearchKey
data SearchHeader
SearchHeader :: Word64 -> ObjectId -> Word64 -> ObjectType -> Word32 -> SearchHeader
[shTransId] :: SearchHeader -> Word64
[shObjectId] :: SearchHeader -> ObjectId
[shOffset] :: SearchHeader -> Word64
[shType] :: SearchHeader -> ObjectType
[shLen] :: SearchHeader -> Word32
treeSearchFd :: Fd -> SearchKey -> Int -> (SearchHeader -> Ptr i -> IO ()) -> IO ()
treeSearch :: RawFilePath -> SearchKey -> Int -> (SearchHeader -> Ptr i -> IO ()) -> IO ()
treeSearchListFd :: Fd -> SearchKey -> (SearchHeader -> Ptr i -> IO (Maybe a)) -> IO [a]
treeSearchList :: RawFilePath -> SearchKey -> (SearchHeader -> Ptr i -> IO (Maybe a)) -> IO [a]
findFirstItemFd :: Fd -> SearchKey -> (SearchHeader -> Ptr i -> IO a) -> IO a
findFirstItem :: RawFilePath -> SearchKey -> (SearchHeader -> Ptr i -> IO a) -> IO a
instance GHC.Classes.Eq System.Linux.Btrfs.ByteString.SearchHeader
instance GHC.Show.Show System.Linux.Btrfs.ByteString.SearchHeader
instance GHC.Classes.Eq System.Linux.Btrfs.ByteString.SearchKey
instance GHC.Show.Show System.Linux.Btrfs.ByteString.SearchKey
instance GHC.Classes.Eq System.Linux.Btrfs.ByteString.DefragRangeArgs
instance GHC.Show.Show System.Linux.Btrfs.ByteString.DefragRangeArgs
instance GHC.Classes.Eq System.Linux.Btrfs.ByteString.SubvolInfo
instance GHC.Show.Show System.Linux.Btrfs.ByteString.SubvolInfo
instance GHC.Classes.Eq System.Linux.Btrfs.ByteString.CloneResult
instance GHC.Show.Show System.Linux.Btrfs.ByteString.CloneResult
instance GHC.Enum.Bounded System.Linux.Btrfs.ByteString.CompressionType
instance GHC.Enum.Enum System.Linux.Btrfs.ByteString.CompressionType
instance GHC.Classes.Eq System.Linux.Btrfs.ByteString.CompressionType
instance GHC.Read.Read System.Linux.Btrfs.ByteString.CompressionType
instance GHC.Show.Show System.Linux.Btrfs.ByteString.CompressionType
instance Foreign.Storable.Storable System.Linux.Btrfs.ByteString.SameExtentInfoOut
instance Foreign.Storable.Storable System.Linux.Btrfs.ByteString.SameExtentInfoIn


-- | Most functions in this module come in two flavors: one that operates
--   on file descriptors and another one that operates on file paths. The
--   former can be distinguished by the <tt>Fd</tt> suffix in their names.
module System.Linux.Btrfs
type FileSize = Word64
type ObjectType = Word8
type ObjectId = Word64
type InodeNum = ObjectId
type SubvolId = ObjectId
data CompressionType
Zlib :: CompressionType
LZO :: CompressionType
cloneFd :: Fd -> Fd -> IO ()

-- | Clone an entire file to an existing file.
--   
--   Note: calls the <tt>BTRFS_IOC_CLONE</tt>/<tt>FICLONE</tt>
--   <tt>ioctl</tt>.
clone :: FilePath -> FilePath -> IO ()

-- | Like <a>clone</a> except that it will create or truncate the
--   destination file if necessary. This is similar to <tt>cp
--   --reflink=always</tt>.
--   
--   Note: calls the <tt>BTRFS_IOC_CLONE</tt>/<tt>FICLONE</tt>
--   <tt>ioctl</tt>.
cloneNew :: FilePath -> FilePath -> IO ()
cloneRangeFd :: Fd -> FileSize -> FileSize -> Fd -> FileSize -> IO ()

-- | Clones a range of bytes from a file to another file. All ranges must
--   be block-aligned.
--   
--   Note: calls the <tt>BTRFS_IOC_CLONE_RANGE</tt>/<tt>FICLONERANGE</tt>
--   <tt>ioctl</tt>.
cloneRange :: FilePath -> FileSize -> FileSize -> FilePath -> FileSize -> IO ()

-- | The result of a <a>cloneRangeIfSame</a> operation.
data CloneResult

-- | Cloning failed because of an error.
CRError :: IOError -> CloneResult

-- | No cloning was performed because the contents of the source and the
--   destination file differ.
CRDataDiffers :: CloneResult

-- | Cloning succeeded, the returned integer indicates the number of bytes
--   that were deduped.
CRSuccess :: FileSize -> CloneResult
cloneRangeIfSameFd :: Fd -> FileSize -> FileSize -> [(Fd, FileSize)] -> IO [CloneResult]

-- | Similar to <a>cloneRange</a> except that it performs the cloning only
--   if the data ranges contain identical data. Additionally, it accepts
--   multiple destination files. The same thing can be accomplished with
--   <a>cloneRange</a> in conjunction with file locking but this function
--   uses in-kernel locking to guarantee that the deduplicated data is
--   identical at the time of the operation. On the other hand, this
--   function will not clone arbitrarily large ranges; the kernel has an
--   upper limit for the length and if cloning bigger ranges is desired
--   then it has to be called multiple times. Note that cloning may succeed
--   for some of the destination files and fail for others. Because of
--   that, this function returns a list of outcomes, one for each
--   destination file, and no exceptions will be raised for the failed
--   files.
--   
--   Note: calls the
--   <tt>BTRFS_IOC_FILE_EXTENT_SAME</tt>/<tt>FIDEDUPERANGE</tt>
--   <tt>ioctl</tt>.
--   
--   <i>Requires Linux 3.12 or later.</i>
cloneRangeIfSame :: FilePath -> FileSize -> FileSize -> [(FilePath, FileSize)] -> IO [CloneResult]

-- | Create an (initially) empty new subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_SUBVOL_CREATE</tt> <tt>ioctl</tt>.
createSubvol :: FilePath -> IO ()

-- | Destroy (delete) a subvolume. The directory that corresponds to the
--   subvolume is removed asynchronously. As a result, the subvolume may
--   appear again after a crash. If this is not acceptable, call
--   <a>startSync</a> followed by a <a>waitSync</a>, after the
--   <tt>destroySubvol</tt> call.
--   
--   Note: calls the <tt>BTRFS_IOC_SNAP_DESTROY</tt> <tt>ioctl</tt>.
destroySubvol :: FilePath -> IO ()
snapshotFd :: Fd -> FilePath -> Bool -> IO ()

-- | Create a snapshot of an existing subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_SNAP_CREATE_V2</tt> <tt>ioctl</tt>.
snapshot :: FilePath -> FilePath -> Bool -> IO ()
getSubvolReadOnlyFd :: Fd -> IO Bool

-- | Is the subvolume read-only?
--   
--   Note: calls the <tt>BTRFS_IOC_SUBVOL_GETFLAGS</tt> <tt>ioctl</tt>.
getSubvolReadOnly :: FilePath -> IO Bool
setSubvolReadOnlyFd :: Fd -> Bool -> IO ()

-- | Make a subvolume read-only (or read-write).
--   
--   Note: calls the <tt>BTRFS_IOC_SUBVOL_GETFLAGS</tt> and
--   <tt>BTRFS_IOC_SUBVOL_SETFLAGS</tt> <tt>ioctl</tt>s.
setSubvolReadOnly :: FilePath -> Bool -> IO ()
getSubvolFd :: Fd -> IO SubvolId

-- | Find the id of the subvolume where the given file resides. This is
--   merely a wrapper around <a>lookupInode</a> provided for convenience.
getSubvol :: FilePath -> IO SubvolId
lookupSubvolFd :: Fd -> SubvolId -> IO (SubvolId, InodeNum, FilePath)

-- | Given the id of a subvolume, find the id of the parent subvolume, the
--   inode number of the directory containing it, and its name. This is a
--   wrapper around <a>treeSearch</a>.
lookupSubvol :: FilePath -> SubvolId -> IO (SubvolId, InodeNum, FilePath)
resolveSubvolFd :: Fd -> SubvolId -> IO FilePath

-- | Given the id of a subvolume, find its path relative to the root of the
--   volume. This function calls <a>lookupSubvol</a> recursively.
resolveSubvol :: FilePath -> SubvolId -> IO FilePath

-- | The id the root subvolume.
rootSubvol :: SubvolId
listSubvolsFd :: Fd -> IO [(SubvolId, SubvolId, InodeNum, FilePath)]

-- | Find all subvolumes of the given volume. For each subvolume found, it
--   returns: its id, the id of its parent subvolume, the inode number of
--   the directory containing it, and its name. This is a wrapper around
--   <a>treeSearch</a>.
listSubvols :: FilePath -> IO [(SubvolId, SubvolId, InodeNum, FilePath)]
listSubvolPathsFd :: Fd -> IO [(SubvolId, SubvolId, FilePath)]

-- | Find all subvolumes of the given volume. For each subvolume found, it
--   returns: its id, the id of its parent subvolume, and its path relative
--   to the root of the volume. This is a wrapper around <a>treeSearch</a>
--   and <a>resolveSubvol</a>.
listSubvolPaths :: FilePath -> IO [(SubvolId, SubvolId, FilePath)]
childSubvolsFd :: Fd -> SubvolId -> IO [(SubvolId, InodeNum, FilePath)]

-- | Find all child subvolumes of the given subvolume. For each child,
--   returns its id, the inode number of the directory containing it, and
--   its name. This is a wrapper around <a>treeSearch</a>.
childSubvols :: FilePath -> SubvolId -> IO [(SubvolId, InodeNum, FilePath)]
childSubvolPathsFd :: Fd -> SubvolId -> IO [(SubvolId, FilePath)]

-- | Find all child subvolumes of the given subvolume. For each child,
--   returns its id and its path relative to the root of the parent. This
--   is a wrapper around <a>treeSearch</a> and <a>lookupInode</a>.
childSubvolPaths :: FilePath -> SubvolId -> IO [(SubvolId, FilePath)]

-- | Information about a subvolume.
data SubvolInfo
SubvolInfo :: Word64 -> Maybe Word64 -> Maybe Word64 -> Bool -> Maybe UUID -> Maybe UUID -> Maybe UUID -> Maybe Word64 -> Maybe Word64 -> Maybe Word64 -> Maybe Word64 -> Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime -> SubvolInfo

-- | The generation when the subvolume was last modified.
[siGeneration] :: SubvolInfo -> Word64

-- | The generation when the most recent snapshot of this subvolume was
--   taken.
[siLastSnapshot] :: SubvolInfo -> Maybe Word64

-- | The generation of the snapshot parent at the time when the snapshot
--   was taken. Defined if only if this is a snapshot.
[siParSnapGen] :: SubvolInfo -> Maybe Word64

-- | Is this a read-only subvolume?
[siReadOnly] :: SubvolInfo -> Bool

-- | The UUID of the subvolume.
[siUuid] :: SubvolInfo -> Maybe UUID

-- | The UUID of the snapshot parent.
[siPUuid] :: SubvolInfo -> Maybe UUID

-- | The UUID of the source subvolume that this subvolume was received
--   from. This is always defined for received subvolumes.
[siReceivedUuid] :: SubvolInfo -> Maybe UUID

-- | The generation when an inode was last modified.
[siCTransId] :: SubvolInfo -> Maybe Word64

-- | The generation when the subvolume was created.
[siOTransId] :: SubvolInfo -> Maybe Word64

-- | The generation of the source subvolume that this subvolume was
--   received from. This is always defined for received subvolumes.
[siSTransId] :: SubvolInfo -> Maybe Word64

-- | The generation when the subvolume was received. This is always defined
--   for received subvolumes.
[siRTransId] :: SubvolInfo -> Maybe Word64

-- | The time when an inode was last modified.
[siCTime] :: SubvolInfo -> Maybe UTCTime

-- | The time when the subvolume was created.
[siOTime] :: SubvolInfo -> Maybe UTCTime

-- | The timestamp that corresponds to <a>siSTransId</a>.
[siSTime] :: SubvolInfo -> Maybe UTCTime

-- | The time when the subvolume was received. This is always defined for
--   received subvolumes.
[siRTime] :: SubvolInfo -> Maybe UTCTime
getSubvolInfoFd :: Fd -> SubvolId -> IO SubvolInfo

-- | Retrieve information about a subvolume. This is a wrapper around
--   <a>treeSearch</a>.
getSubvolInfo :: FilePath -> SubvolId -> IO SubvolInfo
getSubvolByUuidFd :: Fd -> UUID -> IO SubvolId

-- | Find the id of a subvolume, given its UUID. This is a wrapper around
--   <a>treeSearch</a>.
--   
--   <i>Requires Linux 3.12 or later.</i>
getSubvolByUuid :: FilePath -> UUID -> IO SubvolId
getSubvolByReceivedUuidFd :: Fd -> UUID -> IO SubvolId

-- | Find the id of a subvolume, given its <a>siReceivedUuid</a>. This is a
--   wrapper around <a>treeSearch</a>.
--   
--   <i>Requires Linux 3.12 or later.</i>
getSubvolByReceivedUuid :: FilePath -> UUID -> IO SubvolId
getDefaultSubvolFd :: Fd -> IO SubvolId

-- | Find the id of the default subvolume. This is a wrapper around
--   <a>treeSearch</a>.
getDefaultSubvol :: FilePath -> IO SubvolId
setDefaultSubvolFd :: Fd -> ObjectId -> IO ()

-- | Set the default subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_DEFAULT_SUBVOL</tt> <tt>ioctl</tt>.
setDefaultSubvol :: FilePath -> SubvolId -> IO ()
defragFd :: Fd -> IO ()

-- | Defrag a single file.
--   
--   Note: calls the <tt>BTRFS_IOC_DEFRAG</tt> <tt>ioctl</tt>.
defrag :: FilePath -> IO ()

-- | Argument to the <a>defragRange</a> operation.
data DefragRangeArgs
DefragRangeArgs :: FileSize -> FileSize -> Word32 -> Maybe CompressionType -> Bool -> DefragRangeArgs

-- | Beginning of the defrag range.
[draStart] :: DefragRangeArgs -> FileSize

-- | Number of bytes to defrag, use <a>maxBound</a> to say all.
[draLength] :: DefragRangeArgs -> FileSize

-- | Any extent of size bigger or equal to this number will be considered
--   already defragged. Use 0 for the kernel default.
[draExtentThreshold] :: DefragRangeArgs -> Word32

-- | Compress the file while defragmenting.
[draCompress] :: DefragRangeArgs -> Maybe CompressionType

-- | Flush data to disk immediately after defragmenting.
[draFlush] :: DefragRangeArgs -> Bool

-- | Defaults for <a>defragRange</a>. Selects the entire file, no
--   compression, and no flushing.
defaultDefragRangeArgs :: DefragRangeArgs
defragRangeFd :: Fd -> DefragRangeArgs -> IO ()

-- | Defrag a range within a single file.
--   
--   Note: calls the <tt>BTRFS_IOC_DEFRAG_RANGE</tt> <tt>ioctl</tt>.
defragRange :: FilePath -> DefragRangeArgs -> IO ()
syncFd :: Fd -> IO ()

-- | Sync the file system identified by the supplied path. The
--   <a>FilePath</a> can refer to any file in the file system.
--   
--   Note: calls the <tt>BTRFS_IOC_SYNC</tt> <tt>ioctl</tt>.
sync :: FilePath -> IO ()
startSyncFd :: Fd -> IO ()

-- | Initiate a sync for the file system identified by the supplied path.
--   
--   Note: calls the <tt>BTRFS_IOC_START_SYNC</tt> <tt>ioctl</tt>.
startSync :: FilePath -> IO ()
waitSyncFd :: Fd -> IO ()

-- | Wait until the sync operation completes.
--   
--   Note: calls the <tt>BTRFS_IOC_WAIT_SYNC</tt> <tt>ioctl</tt>.
waitSync :: FilePath -> IO ()
resolveLogicalFd :: Fd -> FileSize -> IO ([(InodeNum, FileSize, SubvolId)], Int)

-- | Given a physical offset, look for any inodes that this byte belongs
--   to. For each inode, it returns the inode number, the logical offset
--   (i.e. the offset within the inode), and the subvolume id. If a large
--   number of inodes is found, then not all of them will be returned by
--   this function. This is due to a current limitation in the kernel. The
--   integer returned along with list of inodes indicates the number of
--   inodes found but not included in the list.
--   
--   Note: calls the <tt>BTRFS_IOC_LOGICAL_INO</tt> <tt>ioctl</tt>.
resolveLogical :: FilePath -> FileSize -> IO ([(InodeNum, FileSize, SubvolId)], Int)
resolveInodeFd :: Fd -> InodeNum -> IO ([FilePath], Int)

-- | Find the file path(s) given an inode number. Returns a list of file
--   paths and an integer indicating the number of paths found but not
--   included in the resulting list. This is because of a limitation in the
--   kernel (it will not return an arbitrarily large list). The paths
--   returned are relative to the root of the subvolume.
--   
--   Note: calls the <tt>BTRFS_IOC_INO_PATHS</tt> <tt>ioctl</tt>.
resolveInode :: FilePath -> InodeNum -> IO ([FilePath], Int)
lookupInodeFd :: Fd -> SubvolId -> InodeNum -> IO (SubvolId, FilePath)

-- | Find the path of a file given its inode number and the id of the
--   subvolume. If multiple files share the same inode number, only one of
--   them is returned. The id of the subvolume is also returned. This is
--   useful when 0 is given for the <a>SubvolId</a> argument (also see
--   <a>getSubvol</a> for this case).
--   
--   Note: calls the <tt>BTRFS_IOC_INO_LOOKUP</tt> <tt>ioctl</tt>.
lookupInode :: FilePath -> SubvolId -> InodeNum -> IO (SubvolId, FilePath)
getFileNoCOWFd :: Fd -> IO Bool

-- | Determine whether the NOCOW flag is enabled for the specified file.
--   
--   Note: calls the <tt>FS_IOC_GETFLAGS</tt> <tt>ioctl</tt>.
getFileNoCOW :: FilePath -> IO Bool
setFileNoCOWFd :: Fd -> Bool -> IO ()

-- | Set or clear the NOCOW flag for the specified file. If the file is not
--   empty, this has no effect and no error will be reported.
--   
--   Note: calls the <tt>FS_IOC_GETFLAGS</tt> and <tt>FS_IOC_GETFLAGS</tt>
--   <tt>ioctl</tt>s.
setFileNoCOW :: FilePath -> Bool -> IO ()
data SearchKey
SearchKey :: ObjectId -> ObjectId -> ObjectType -> Word64 -> ObjectId -> ObjectType -> Word64 -> Word64 -> Word64 -> SearchKey
[skTreeId] :: SearchKey -> ObjectId
[skMinObjectId] :: SearchKey -> ObjectId
[skMinType] :: SearchKey -> ObjectType
[skMinOffset] :: SearchKey -> Word64
[skMaxObjectId] :: SearchKey -> ObjectId
[skMaxType] :: SearchKey -> ObjectType
[skMaxOffset] :: SearchKey -> Word64
[skMinTransId] :: SearchKey -> Word64
[skMaxTransId] :: SearchKey -> Word64
defaultSearchKey :: SearchKey
data SearchHeader
SearchHeader :: Word64 -> ObjectId -> Word64 -> ObjectType -> Word32 -> SearchHeader
[shTransId] :: SearchHeader -> Word64
[shObjectId] :: SearchHeader -> ObjectId
[shOffset] :: SearchHeader -> Word64
[shType] :: SearchHeader -> ObjectType
[shLen] :: SearchHeader -> Word32
treeSearchFd :: Fd -> SearchKey -> Int -> (SearchHeader -> Ptr i -> IO ()) -> IO ()
treeSearch :: FilePath -> SearchKey -> Int -> (SearchHeader -> Ptr i -> IO ()) -> IO ()
treeSearchListFd :: Fd -> SearchKey -> (SearchHeader -> Ptr i -> IO (Maybe a)) -> IO [a]
treeSearchList :: FilePath -> SearchKey -> (SearchHeader -> Ptr i -> IO (Maybe a)) -> IO [a]
findFirstItemFd :: Fd -> SearchKey -> (SearchHeader -> Ptr i -> IO a) -> IO a
findFirstItem :: FilePath -> SearchKey -> (SearchHeader -> Ptr i -> IO a) -> IO a
instance GHC.Classes.Eq System.Linux.Btrfs.SearchHeader
instance GHC.Show.Show System.Linux.Btrfs.SearchHeader
instance GHC.Classes.Eq System.Linux.Btrfs.SearchKey
instance GHC.Show.Show System.Linux.Btrfs.SearchKey
instance GHC.Classes.Eq System.Linux.Btrfs.DefragRangeArgs
instance GHC.Show.Show System.Linux.Btrfs.DefragRangeArgs
instance GHC.Classes.Eq System.Linux.Btrfs.SubvolInfo
instance GHC.Show.Show System.Linux.Btrfs.SubvolInfo
instance GHC.Classes.Eq System.Linux.Btrfs.CloneResult
instance GHC.Show.Show System.Linux.Btrfs.CloneResult
instance GHC.Enum.Bounded System.Linux.Btrfs.CompressionType
instance GHC.Enum.Enum System.Linux.Btrfs.CompressionType
instance GHC.Classes.Eq System.Linux.Btrfs.CompressionType
instance GHC.Read.Read System.Linux.Btrfs.CompressionType
instance GHC.Show.Show System.Linux.Btrfs.CompressionType
instance Foreign.Storable.Storable System.Linux.Btrfs.SameExtentInfoOut
instance Foreign.Storable.Storable System.Linux.Btrfs.SameExtentInfoIn
