chickadee » osxattr

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

osxattr

Batch split and join HFS+ extended attributes.

Overview

osxattr provides a command-line program to split HFS+ extended attributes from filesystem objects into a self-contained format, and a program to rejoin these split attributes. Because the attributes are split into simple files, it is possible to back them up with rsync or other standard backup tools and store them on filesystems without knowledge of EAs. This is the approach espoused by the xbup utility, which inspired this egg.

The extended attribute format is either the standard AppleDouble format which can be read by Apple's own utilities (including NFS), or a special SXML format designed for osxattr.

split-xattr

usage: ./split-xattr [options] [file-base] [xattr-base]
     --attr-mode=FMT        attribute output mode [default: dedicated]
     --list-format=FMT      format of input file list [default: rsync-list-only]
     --no-specials          skip fifos and sockets
     --no-symlinks          skip symlinks (recommended for copyfile on 10.4)
 -n, --dry-run              describe operations only
 -v, --verbose              verbose progress report
 -h, --help                 usage information
 -V, --version              version information

Reads HFS+ metadata from a list of files given on stdin and outputs it to one or many files, depending on the selected output format. Input filenames are relative to file-base (i.e. we chdir to file-base at startup), which defaults to the current directory. xattr-base is prefixed to output filenames, and defaults to empty; by setting it, one may output to a parallel directory structure.

Note that the split operation does not delete any attributes from the files; it just copies them to the output.

The attribute output mode (--attr-mode) may be one of the following:

individual
EAs from filename are written in SXML format to ._@filename.
dedicated
EAs from filename are written in SXML format to .@@/._@filename. That is, a dedicated directory .@@ under the parent of filename.
unified
One record for each input file is written to stdout. (Warning: this method cannot currently be decoded by join-xattr.)
appledouble
Copy Finder Info and the Resource Fork to ._filename in AppleDouble v2 format, using our own packing routines. Other extended attributes are (currently) not copied.
copyfile
Copy all HFS+ metadata to ._filename using the native OS X AppleDouble packer. This may not be 100% reliable on OS X 10.4, but works fine on 10.5. In particular, add --no-symlinks when on 10.4.

The input file list format (--list-format) may be one of the following:

rsync-list-only
the output of rsync --list-only. Useful for rsync backups, because you can run the same command to obtain a list of files and then again to actually back them up.
find
the output of find -print
find0
the output of find -print0

join-xattr

usage: ./join-xattr [options] [file-base] [xattr-base]
     --attr-mode=MODE       attribute input mode [default: dedicated]
     --list-format=FMT      format of input file list [default: rsync-list-only]
     --no-specials          skip fifos and sockets
     --no-symlinks          skip symlinks (recommended for copyfile on 10.4)
 -n, --dry-run              describe operations only
 -v, --verbose              verbose progress report
 -h, --help                 usage information
 -V, --version              version information

Reads a list of files given on stdin and applies the corresponding serialized HFS+ metadata to each. Input filenames have any leading / stripped and are relative to file-base (i.e. we chdir to file-base at startup); file-base defaults to the current directory. xattr-base is prefixed to attribute filenames, and defaults to empty; by setting it, one may apply attributes from a parallel directory structure.

The possible values for the attribute output file format (--attr-mode) and input file list format (--list-format) are the same as for split-xattr. However, note that unified attribute mode is not currently supported.

Examples

Split attributes into .@@/ directories for entire disk

For every directory PATH on the disk, create a directory PATH/.@@ and split attributes from PATH/FILE into PATH/.@@/._@FILE, in SXML format.

rsync -a --list-only --filter '- .@@' --relative / |    \
split-xattr --verbose --list-format=rsync-list-only     \
      --attr-mode=dedicated --no-specials               \
      /

For example, the attributes of /Users/me/myfile are written in SXML to /Users/me/.@@/._@myfile.

Split attributes into ._ files in parallel tree for entire disk

For every directory PATH on the disk, split attributes from PATH/FILE into /._./PATH/._FILE.

rsync -a --list-only --filter='- ._*' --relative / |    \
split-xattr --verbose --list-format=rsync-list-only     \
      --attr-mode=copyfile --no-symlinks --no-specials  \
      /  /._.

The xattr-base option /._. is prepended to every output path, which creates a parallel directory tree that can be backed up and disposed of (for example, /._. could be a ramdisk). If the base option were not provided, attribute files would be written directly inline to PATH/._FILE; that could be what you want, but it will leave a lot of files scattered around.

Here, the attributes of /Users/me/myfile would be written in AppleDouble v2 format to /._./Users/me/._myfile.

License

Copyright (c) 2010 Jim Ursetto. All rights reserved. License: New BSD (3-clause).