use Linux::UserXAttr qw/:all/; $success=setxattr $filename_or_handle, $name, $value, $flags; $success=lsetxattr $filename, $name, $value, $flags; $value=getxattr $filename_or_handle, $name; $value=lgetxattr $filename, $name; @names=listxattr $filename_or_handle; @names=llistxattr $filename; $success=removexattr $filename_or_handle, $name; $success=lremovexattr $filename, $name;
Due to varying support in different kernels the test suite of this module is really simple. It verfies that the functions and constants are exported but does not call the actual syscalls. If you smell a wumpus try "strace", e.g.:
strace perl -MLinux::UserXAttr=:all -le 'setxattr qw/. user.name value/'
and look up the syscall like:
setxattr(".", "user.name", "value", 5, 0) = 0
creates or modifies the extended attribute $name and sets its value to $value. $flags can be used to refine the semantics of the operation. The 2 constants are allowed "XATTR_CREATE" and "XATTR_REPLACE".
For more information see the setxattr(2) manpage.
$filename_or_handle may be a file or directory name or an open file or directory handle.
On success true is returned. On failure the empty list is returned and $! set accordingly.
Note, support for extended attributes and particularly for $flags may vary for different kernels.
$success=lsetxattr $filename, $name, $value, $flags
same as "setxattr" but fails if $filename is a symlink.
$value=getxattr $filename_or_handle, $name
reads an extended attribute.
On failure the empty list is returned and $! set accordingly.
$value=lgetxattr $filename, $name
same as "getxattr" but fails if $filename is a symlink.
@names=listxattr $filename_or_handle
returns a list of names of extended attributes.
@names=llistxattr $filename
same as "listxattr" but fails if $filename is a symlink.
$success=removexattr $filename_or_handle, $name
removes the extended attribute $name.
On success true is returned. On failure the empty list is returned and $! set accordingly.
$success=lremovexattr $filename, $name
same as "removexattr" but fails if $filename is a symlink.
On demand all functions and constants are exported.
Export tags
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.3 or, at your option, any later version of Perl 5 you may have available.