Expand description
§extattr
Yet another Extended Attributes library for Rust.
§Why another crate for EA? Any difference from xattr
?
Extended Attributes syscalls vary across implementations, for example, to set an EA:
// Linux
int setxattr(const char *path, const char *name, const void *value,
size_t size, int flags);
// FreeBSD
ssize_t extattr_set_file(const char *path, int attrnamespace,
const char *attrname, const void *data, size_t nbytes);
// macOS
int setxattr(const char *path, const char *name, void *value, size_t size,
u_int32_t position, int options);
xattr
erases differences in those APIs and provides a consistent, rusty
interface.
ⓘ
// A consistent API that would work on every OS
pub fn set<N, P>(path: P, name: N, value: &[u8]) -> Result<()>
extattr
aims to provide bindings close to the native one.
ⓘ
// Linux
pub fn setxattr<P, S, B>(
path: P,
name: S,
value: B,
flags: Flags,
) -> Result<()>
// FreeBSD
pub fn extattr_set_file<P, S, B>(
path: P,
attrnamespace: AttrNamespace,
attrname: S,
data: B
) -> Result<()>
// macOS
pub fn setxattr<P, S, B>(
path: P,
name: S,
value: B,
position: u32,
options: Options
) -> Result<()>
In most cases, you would like to use xattr
instead of extattr
. However, if
you are on Linux and want to use that extra flags
argument, or you are on macOS
and want to use the arguments position
and options
, then extattr
probably
is a good choice:)
Structs§
- Flags
flags
used when setting EAs
Enums§
- Attr
Namespace attrnamespace
argument
Functions§
- extattr_
delete_ fd - Deletes the extended attribute specified in
attrnamespace
andattrname
for the file referred by the open file descriptorfd
. - extattr_
delete_ file - Deletes the extended attribute specified in
attrnamespace
andattrname
for the file referred bypath
. Ifpath
is a symlink, it will be dereferenced. - extattr_
delete_ link - Deletes the extended attribute specified in
attrnamespace
andattrname
for the file referred bypath
. Ifpath
is a symlink, extended attribute will be removed from the link itself. - extattr_
get_ fd - Retrieves the value of the specified extended attribute for the file specified
in the open file descriptor
fd
. - extattr_
get_ file - Retrieves the value of the specified extended attribute for the file specified
in
path
. Ifpath
is a symlink, it will be dereferenced. - extattr_
get_ link - Retrieves the value of the specified extended attribute for the file specified
in
path
. Ifpath
is a symlink, EA value of the link itself will be returned. - extattr_
list_ fd - Returns a list of attribute names present in the requested namespace for
the file specified in the open file descriptor
fd
. - extattr_
list_ file - Returns a list of attribute names present in the requested namespace for
the file specified in
path
. Ifpath
is a symlink, it will be dereferenced. - extattr_
list_ link - Returns a list of attribute names present in the requested namespace for
the file specified in
path
. Ifpath
is a symlink, EA names for the link itself will be returned. - extattr_
set_ fd - Sets the value of the specified extended attribute to the data described by
data
for the file referred by the open file descriptorfd
. - extattr_
set_ file - Sets the value of the specified extended attribute to the data described by
data
for the file referred bypath
. Ifpath
is a symlink, it will be dereferenced. - extattr_
set_ link - Sets the value of the specified extended attribute to the data described by
data
for the file referred bypath
. Ifpath
is a symlink, EA of the link itself will be set. - fgetxattr
- Retrieves the value of the extended attribute identified by
name
and associated with the file specified by the open file descriptorfd
in the filesystem. - flistxattr
- Retrieves the list of extended attribute names associated with the file
specified by the open file descriptor
fd
in the filesystem. - fremovexattr
- Removes the extended attribute identified by
name
and associated with the file specified by the open file descriptorfd
. - fsetxattr
- Sets the
value
of the extended attribute identified byname
and associated with the file specified by the open file descriptorfd
. - getxattr
- Retrieves the value of the extended attribute identified by
name
and associated with the givenpath
in the filesystem. Ifpath
is a symbolic link, it will be dereferenced. - lgetxattr
- Retrieves the value of the extended attribute identified by
name
and associated with the givenpath
in the filesystem. Ifpath
is a symbolic link, the list of names associated with the link itself will be returned. - listxattr
- Retrieves the list of extended attribute names associated with the given
path
in the filesystem. Ifpath
is a symbolic link, it will be dereferenced. - llistxattr
- Retrieves the list of extended attribute names associated with the given
path
in the filesystem. Ifpath
is a symbolic link, the list of names associated with the link itself will be returned. - lremovexattr
- Removes the extended attribute identified by
name
and associated with the givenpath
in the filesystem. Ifpath
is a symbolic link, extended attribute is removed from the link itself. - lsetxattr
- Sets the
value
of the extended attribute identified byname
and associated with the givenpath
in the filesystem. Ifpath
is a symbolic link, the extended attribute is set on the link itself. - removexattr
- Removes the extended attribute identified by
name
and associated with the givenpath
in the filesystem. Ifpath
is a symbolic link, it will be dereferenced. - setxattr
- Sets the
value
of the extended attribute identified byname
and associated with the givenpath
in the filesystem. Ifpath
is a symbolic link, it will be dereferenced.
Type Aliases§
- Result
- Customized
Result
type forextattr
.