linux-xattr-0.1.1.0: Read, set and list extended attributes

Portabilityportable
Stabilityexperimental
MaintainerNicola Squartini <tensor5@gmail.com>
Safe HaskellSafe

System.Linux.XAttr

Contents

Description

linux-xattr provides bindings to the Linux syscalls for reading and manipulating extended attributes (setxattr, getxattr, listxattr and removexattr).

Each function in this module has two variants: one with the name prefixed by __l__ and one prefixed by __fd__. Both of these are identical to the original version except that the __l__-variant does not follow symbolic link but acts on the link itself, and the __fd__-variant take a file descriptor as argument rather than a FilePath.

Moreover, every function has an xxx__UserXAttr__ variant for working transparently in the __user__ namespace of extended attributes, without worrying about the user. prefix: these functions automatically prepends the string user. to the Name of the attribute when Name is an input value, or strip the prefix user. from it when Name is a returned value. See the documentation of each individual function for details.

Synopsis

Set extended attributes

Functions in this section call the setxattr syscall.

setXAttr :: FilePath -> Name -> Value -> IO ()Source

Set the Value of the extended attribute identified by Name and associated with the given FilePath in the filesystem.

lSetXAttr :: FilePath -> Name -> Value -> IO ()Source

Set the Value of the extended attribute identified by Name and associated with the given FilePath in the filesystem (do not follow symbolic links).

fdSetXAttr :: Fd -> Name -> Value -> IO ()Source

Set the Value of the extended attribute identified by Name and associated with the given file descriptor in the filesystem.

Set extended user attributes

Create extended attributes

Functions in this section call the setxattr syscall with the flag XATTR_CREATE.

createXAttr :: FilePath -> Name -> Value -> IO ()Source

Identical to setXAttr, but if the attribute already exists fail with isAlreadyExistsError.

lCreateXAttr :: FilePath -> Name -> Value -> IO ()Source

Identical to lSetXAttr, but if the attribute already exists fail with isAlreadyExistsError.

fdCreateXAttr :: Fd -> Name -> Value -> IO ()Source

Identical to fdSetXAttr, but if the attribute already exists fail with isAlreadyExistsError.

Create extended user attributes

Replace extended attributes

Functions in this section call the setxattr syscall with the flag XATTR_REPLACE.

replaceXAttr :: FilePath -> Name -> Value -> IO ()Source

Identical to setXAttr, but if the attribute does not exist fail with isDoesNotExistError.

lReplaceXAttr :: FilePath -> Name -> Value -> IO ()Source

Identical to lSetXAttr, but if the attribute does not exist fail with isDoesNotExistError.

fdReplaceXAttr :: Fd -> Name -> Value -> IO ()Source

Identical to fdSetXAttr, but if the attribute does not exist fail with isDoesNotExistError.

Replace extended user attributes

Retrieve extended attributes

Functions in this section call the getxattr syscall.

getXAttr :: FilePath -> Name -> IO ValueSource

Retrieve the Value of the extended attribute identified by Name and associated with the given FilePath in the filesystem, or fail with isDoesNotExistError if the attribute does not exist.

lGetXAttr :: FilePath -> Name -> IO ValueSource

Retrieve the Value of the extended attribute identified by Name and associated with the given FilePath in the filesystem, or fail with isDoesNotExistError if the attribute does not exist (do not follow symbolic links).

fdGetXAttr :: Fd -> Name -> IO ValueSource

Retrieve the Value of the extended attribute identified by Name and associated with the given file descriptor in the filesystem, or fail with isDoesNotExistError if the attribute does not exist.

Retrieve extended user attributes

List extended attributes

Functions in this section call the listxattr syscall.

listXAttr :: FilePath -> IO [Name]Source

Get the list of extended attribute Names associated with the given FilePath in the filesystem.

lListXAttr :: FilePath -> IO [Name]Source

Get the list of extended attribute Names associated with the given FilePath in the filesystem (do not follow symbolic links).

fdListXAttr :: Fd -> IO [Name]Source

Get the list of extended attribute Names associated with the given file descriptor in the filesystem.

List extended user attributes

These functions only list those extended attributes with Name beginning with user.. The user. prefix is removed from each Name in the output list.

Remove extended attributes

Functions in this section call the removexattr syscall.

removeXAttr :: FilePath -> Name -> IO ()Source

Remove the extended attribute identified by Name and associated with the given FilePath in the filesystem, or fail with isDoesNotExistError if the attribute does not exist.

lRemoveXAttr :: FilePath -> Name -> IO ()Source

Remove the extended attribute identified by Name and associated with the given FilePath in the filesystem, or fail with isDoesNotExistError if the attribute does not exist (do not follow symbolic links).

fdRemoveXAttr :: Fd -> Name -> IO ()Source

Remove the extended attribute identified by Name and associated with the given file descriptor in the filesystem, or fail with isDoesNotExistError if the attribute does not exist.

Remove extended user attributes

Types for extended attributes

type Name = StringSource

Name of extended attribute.

type Value = ByteStringSource

Value of extended attribute.