| Copyright | © 2013-2014 Nicola Squartini |
|---|---|
| License | BSD3 |
| Maintainer | Nicola Squartini <tensor5@gmail.com> |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
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 xxxUserXAttr 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 of the attribute when Name is an
input value, or strip the prefix Name"user." from it when is a
returned value. See the documentation of each individual function for
details.Name
- setXAttr :: FilePath -> Name -> Value -> IO ()
- lSetXAttr :: FilePath -> Name -> Value -> IO ()
- fdSetXAttr :: Fd -> Name -> Value -> IO ()
- setUserXAttr :: FilePath -> Name -> Value -> IO ()
- lSetUserXAttr :: FilePath -> Name -> Value -> IO ()
- fdSetUserXAttr :: Fd -> Name -> Value -> IO ()
- createXAttr :: FilePath -> Name -> Value -> IO ()
- lCreateXAttr :: FilePath -> Name -> Value -> IO ()
- fdCreateXAttr :: Fd -> Name -> Value -> IO ()
- createUserXAttr :: FilePath -> Name -> Value -> IO ()
- lCreateUserXAttr :: FilePath -> Name -> Value -> IO ()
- fdCreateUserXAttr :: Fd -> Name -> Value -> IO ()
- replaceXAttr :: FilePath -> Name -> Value -> IO ()
- lReplaceXAttr :: FilePath -> Name -> Value -> IO ()
- fdReplaceXAttr :: Fd -> Name -> Value -> IO ()
- replaceUserXAttr :: FilePath -> Name -> Value -> IO ()
- lReplaceUserXAttr :: FilePath -> Name -> Value -> IO ()
- fdReplaceUserXAttr :: Fd -> Name -> Value -> IO ()
- getXAttr :: FilePath -> Name -> IO Value
- lGetXAttr :: FilePath -> Name -> IO Value
- fdGetXAttr :: Fd -> Name -> IO Value
- getUserXAttr :: FilePath -> Name -> IO Value
- lGetUserXAttr :: FilePath -> Name -> IO Value
- fdGetUserXAttr :: Fd -> Name -> IO Value
- listXAttr :: FilePath -> IO [Name]
- lListXAttr :: FilePath -> IO [Name]
- fdListXAttr :: Fd -> IO [Name]
- listUserXAttr :: FilePath -> IO [Name]
- lListUserXAttr :: FilePath -> IO [Name]
- fdListUserXAttr :: Fd -> IO [Name]
- removeXAttr :: FilePath -> Name -> IO ()
- lRemoveXAttr :: FilePath -> Name -> IO ()
- fdRemoveXAttr :: Fd -> Name -> IO ()
- removeUserXAttr :: FilePath -> Name -> IO ()
- lRemoveUserXAttr :: FilePath -> Name -> IO ()
- fdRemoveUserXAttr :: Fd -> Name -> IO ()
- type Name = String
- type Value = ByteString
Set extended attributes
Functions in this section call the
setxattr
syscall.
Set extended user attributes
setUserXAttr :: FilePath -> Name -> Value -> IO () Source
setUserXAttr"/some/path" "foo" "bar" =setXAttr"/some/path" "user.foo" "bar"
lSetUserXAttr :: FilePath -> Name -> Value -> IO () Source
lSetUserXAttr"/some/link" "foo" "bar" =lSetXAttr"/some/link" "user.foo" "bar"
fdSetUserXAttr :: Fd -> Name -> Value -> IO () Source
fdSetUserXAttr(Fdn) "foo" "bar" =fdSetXAttr(Fdn) "user.foo" "bar"
Create extended attributes
Functions in this section call the
setxattr
syscall with the flag XATTR_CREATE.
createXAttr :: FilePath -> Name -> Value -> IO () Source
Identical to , but if the attribute already exists fail with
setXAttr.isAlreadyExistsError
lCreateXAttr :: FilePath -> Name -> Value -> IO () Source
Identical to , but if the attribute already exists fail with
lSetXAttr.isAlreadyExistsError
fdCreateXAttr :: Fd -> Name -> Value -> IO () Source
Identical to , but if the attribute already exists fail with
fdSetXAttr.isAlreadyExistsError
Create extended user attributes
createUserXAttr :: FilePath -> Name -> Value -> IO () Source
createUserXAttr"/some/path" "foo" "bar" =createXAttr"/some/path" "user.foo" "bar"
lCreateUserXAttr :: FilePath -> Name -> Value -> IO () Source
lCreateUserXAttr"/some/link" "foo" "bar" =lCreateXAttr"/some/link" "user.foo" "bar"
fdCreateUserXAttr :: Fd -> Name -> Value -> IO () Source
fdCreateUserXAttr(Fdn) "foo" "bar" =fdCreateXAttr(Fdn) "user.foo" "bar"
Replace extended attributes
Functions in this section call the
setxattr
syscall with the flag XATTR_REPLACE.
replaceXAttr :: FilePath -> Name -> Value -> IO () Source
Identical to , but if the attribute does not exist fail with
setXAttr.isDoesNotExistError
lReplaceXAttr :: FilePath -> Name -> Value -> IO () Source
Identical to , but if the attribute does not exist fail with
lSetXAttr.isDoesNotExistError
fdReplaceXAttr :: Fd -> Name -> Value -> IO () Source
Identical to , but if the attribute does not exist fail with
fdSetXAttr.isDoesNotExistError
Replace extended user attributes
replaceUserXAttr :: FilePath -> Name -> Value -> IO () Source
replaceUserXAttr"/some/path" "foo" "bar" =replaceXAttr"/some/path" "user.foo" "bar"
lReplaceUserXAttr :: FilePath -> Name -> Value -> IO () Source
lReplaceUserXAttr"/some/link" "foo" "bar" =lReplaceXAttr"/some/link" "user.foo" "bar"
fdReplaceUserXAttr :: Fd -> Name -> Value -> IO () Source
fdReplaceUserXAttr(Fdn) "foo" "bar" =fdReplaceXAttr(Fdn) "user.foo" "bar"
Retrieve extended attributes
Functions in this section call the
getxattr
syscall.
getXAttr :: FilePath -> Name -> IO Value Source
Retrieve the of the extended attribute identified by Value and
associated with the given Name in the filesystem, or fail with
FilePath if the attribute does not exist.isDoesNotExistError
lGetXAttr :: FilePath -> Name -> IO Value Source
Retrieve the of the extended attribute identified by Value and
associated with the given Name in the filesystem, or fail with
FilePath if the attribute does not exist (do
not follow symbolic links).isDoesNotExistError
fdGetXAttr :: Fd -> Name -> IO Value Source
Retrieve the of the extended attribute identified by Value and
associated with the given file descriptor in the filesystem, or fail with
Name if the attribute does not exist.isDoesNotExistError
Retrieve extended user attributes
getUserXAttr :: FilePath -> Name -> IO Value Source
getUserXAttr"/some/path" "foo" =getXAttr"/some/path" "user.foo"
lGetUserXAttr :: FilePath -> Name -> IO Value Source
lGetUserXAttr"/some/link" "foo" =lGetXAttr"/some/link" "user.foo"
fdGetUserXAttr :: Fd -> Name -> IO Value Source
fdGetUserXAttr(Fdn) "foo" =fdGetXAttr(Fdn) "user.foo"
List extended attributes
Functions in this section call the
listxattr
syscall.
lListXAttr :: FilePath -> IO [Name] Source
fdListXAttr :: Fd -> IO [Name] Source
Get the list of extended attribute s associated with the given file
descriptor in the filesystem.Name
List extended user attributes
These functions only list those extended attributes with
beginning with Name"user.". The "user." prefix is removed from each
in the output list.Name
listUserXAttr :: FilePath -> IO [Name] Source
>>>listXAttr"/some/path" ["user.foo","user.bar"] >>>listUserXAttr"/some/path" ["foo","bar"]
lListUserXAttr :: FilePath -> IO [Name] Source
>>>lListXAttr"/some/link" ["user.foo","user.bar"] >>>lListUserXAttr"/some/link" ["foo","bar"]
fdListUserXAttr :: Fd -> IO [Name] Source
>>>fdListXAttr(Fdn) ["user.foo","user.bar"] >>>fdListUserXAttr(Fdn) ["foo","bar"]
Remove extended attributes
Functions in this section call the
removexattr
syscall.
removeXAttr :: FilePath -> Name -> IO () Source
Remove the extended attribute identified by and associated with
the given Name in the filesystem, or fail with
FilePath if the attribute does not exist.isDoesNotExistError
lRemoveXAttr :: FilePath -> Name -> IO () Source
Remove the extended attribute identified by and associated with
the given Name in the filesystem, or fail with
FilePath if the attribute does not exist (do
not follow symbolic links).isDoesNotExistError
fdRemoveXAttr :: Fd -> Name -> IO () Source
Remove the extended attribute identified by and associated with
the given file descriptor in the filesystem, or fail with
Name if the attribute does not exist.isDoesNotExistError
Remove extended user attributes
removeUserXAttr :: FilePath -> Name -> IO () Source
removeUserXAttr"/some/path" "foo" =removeXAttr"/some/path" "user.foo"
lRemoveUserXAttr :: FilePath -> Name -> IO () Source
lRemoveUserXAttr"/some/link" "foo" =lRemoveXAttr"/some/link" "user.foo"
fdRemoveUserXAttr :: Fd -> Name -> IO () Source
fdRemoveUserXAttr(Fdn) "foo" =fdRemoveXAttr(Fdn) "user.foo"
Types for extended attributes
type Value = ByteString Source
Value of extended attribute.