Mattress: a command line tool for working with Linux extended attributes (xattrs)

The comfiest way to work with Linux extended attributes (xattrs) written in pure Rust and made of delicious, fibrous Open Source code.

Mattress provides tools for manipulating xattrs on individual files as well as for working with the filesystem as a document database where the filesystem paths act as primary keys and extended attributes provide non-indexed fields.

History

Mattress was developed in conjunction with the Audiotater audio annotation tool.

License

This software is licensed under GPL version 3 only.

Examples

Mattress operates through a set of subcommands, each with a primary function.

Move

Moves xattr values from one path to another.

Copy

Copies xattr values from one path to another.

Remove

Removes xattr values.

Set

Sets xattr values.

Get

Get and print xattr values for one or more paths.

By default, the get subcommand outputs a tab-separated table with a column order of path, field, value. The value bytes are written to stdout as-is without decoding.

By contrast, when outputting JSON, Mattress attempts to decode values as UTF-8, filling in a default codepoint when the decoding fails.

The get command can also output JSON:

TODO Recursive get that benefits from "table" structure / indexing.

Index

Indexes a "table".

When Mattress acts on a directory as if it were a database table, each file acts as a relational "record" with the primary key coming from the subpath under the table directory.

Each file's extended attributes act as the relational attributes, with an overloadable virtual attribute id that represents the primary key. For each subcomponent $i of the primary key, there is also a virtual attribute id$i.

Table directories created by Mattress also contain a special xattr user.mattress.keyname which gives a user-friendly name for the primary key component represented by that directory.

Examples: