Linux::UserXAttr - Support for extended file attributes on Linux
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;
This module implements a very thin layer around the extended attributes syscalls on Linux. See setxattr(2), getxattr(2), listxattr(2) and removexattr(2) for more information.
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
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.
$name
$value
$flags
XATTR_CREATE
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.
$filename_or_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.
same as setxattr but fails if $filename is a symlink.
setxattr
$filename
reads an extended attribute.
On failure the empty list is returned and $! set accordingly.
same as getxattr but fails if $filename is a symlink.
getxattr
returns a list of names of extended attributes.
same as listxattr but fails if $filename is a symlink.
listxattr
removes the extended attribute $name.
same as removexattr but fails if $filename is a symlink.
removexattr
None by default.
On demand all functions and constants are exported.
exports XATTR_CREATE and XATTR_REPLACE
exports setxattr, lsetxattr, getxattr, lgetxattr, listxattr, llistxattr, removexattr and lremovexattr.
lsetxattr
lgetxattr
llistxattr
lremovexattr
all of the above
Linux manual.
Torsten Förtsch, <torsten.foertsch@gmx.net>
Copyright (C) 2011 by Torsten Förtsch
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.
To install Linux::UserXAttr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::UserXAttr
CPAN shell
perl -MCPAN -e shell install Linux::UserXAttr
For more information on module installation, please visit the detailed CPAN module installation guide.