notes

Extended attributes come back on the files (milestone 57)

Name: provisional. After the parent's own heading.

How the recovery tool notes/host-recovery.md describes puts a file's extended attributes back on the extracted file, what it is honest about, a transcript, how it is proven, and its BUGS. It was built as part of milestone 57 (partitioning and formatting a real drive, and extended attributes).

An image written by nife carries a directory in its root called .extended-attributes, holding one small file per node that has extended attributes, named for that node's TreePtr id in hex. redoxfs_host ls shows it, extract copies it out, and upstream's FUSE mount would too.

That the store is visible here is deliberate rather than a leak, and both halves are worth saying:

But a blob called 0000002a is not a recovery. The tool now puts the attributes back on the extracted files, which is the half that decides whether the backup did its job. Time Machine's sparsebundle carries Apple's metadata in exactly these attributes. So the part of the backup a Mac needs in order to make sense of the rest was the part that used to come out unreadable.

setxattr on macOS, lsetxattr on Linux, neither following a symlink. Directories get theirs as well as files. ls marks an entry that carries attributes with @, which is the same marker macOS ls -l uses, and xattr renders or dumps them without extracting anything.

Three things it is honest about, because §42 is the rule here too

§42 (a filesystem declares what it offers and must be truthful) applies to the recovery tool too.

The type code cannot come along. No host filesystem has a per-attribute type word, so the u32 kind is dropped, each non-RAW one is named on stderr, and the count is in the summary. It is not lost: the raw store is still extracted beside the tree, and that is where the codes live. That is what makes "dropped" honest rather than lossy.

Nothing about attributes can fail an extraction. A damaged blob, a name Linux refuses for want of a user. prefix, an attribute on a symlink (which Linux refuses outright), a destination filesystem that holds none at all: each is reported, counted, and walked past. A recovery that abandoned a hundred thousand files over one bad blob would be worse than the gap it fixes.

The counts are printed even when they are zero, and that is the important one. "0 attributes reattached" on a backup you know carried some is the line that tells you the destination filesystem cannot hold them. A summary that mentioned attributes only when the number was non-zero would read identically to a backup that never had any, which is the failure this whole feature exists to prevent: a recovery that looks complete and is not.

EXAMPLES

A whole recovery, on a Mac, with the attributes on the other end. This is a real transcript.

$ redoxfs_host ls backup.img /
dir         4096  .extended-attributes
dir         4096  nested
file@         13  photo.jpg

$ redoxfs_host xattr backup.img photo.jpg
         6  kind 0x43535452 'CSTR'  user.com.apple.metadata:_kMDItemUserTags
        32  kind 0x00000000  user.com.apple.FinderInfo

$ redoxfs_host xattr backup.img photo.jpg user.com.apple.metadata:_kMDItemUserTags
Family

$ redoxfs_host extract backup.img / recovered
redoxfs_host: recovered/photo.jpg: attribute user.com.apple.metadata:_kMDItemUserTags kept its
  6 bytes but not its type code 0x43535452; host filesystems have no field for it (see
  .extended-attributes in the extracted tree)
extracted / to recovered: 4 files, 3 directories, 0 symlinks, 165 bytes,
  3 attributes reattached, 1 type codes dropped

$ xattr -l recovered/photo.jpg
com.apple.provenance:
user.com.apple.FinderInfo:
user.com.apple.metadata:_kMDItemUserTags: Family

The last command is macOS's own xattr(1), not ours, which is the point of running it: the attribute is on the file according to a program this project did not write. (com.apple.provenance is the Mac's own addition to a freshly written file, not something out of the image.)

How the reattachment is proven

tools/redoxfs_host/tests/attributes.rs, and the shape of it is again the argument.

BUGS