Crate xattr

source ·
Expand description

A pure-Rust library to manage extended attributes.

It provides support for manipulating extended attributes (xattrs) on modern Unix filesystems. See the attr(5) manpage for more details.

An extension trait FileExt is provided to directly work with standard File objects and file descriptors.

NOTE: In case of a symlink as path argument, all methods in this library work on the symlink itself without de-referencing it.

let mut xattrs = xattr::list("/").unwrap().peekable();

if xattrs.peek().is_none() {
    println!("no xattr set on root");

println!("Extended attributes:");
for attr in xattrs {
    println!(" - {:?}", attr);




  • Extension trait to manipulate extended attributes on File-like objects.


  • Get an extended attribute for the specified file.
  • List extended attributes attached to the specified file.
  • Remove an extended attribute from the specified file.
  • Set an extended attribute on the specified file.