Depend on the kernel headers, not the ext2 headers, for Linux attr support.

Switch to the kernel FS_* defines (in linux/ext2_fs.h) instead of the
EXT* defines (in ext2fs/ext2_fs.h -- from the ext2fs headers).

Also add FS_NOCOW_FL to the "modifiable flags" mask whenever it's
available.

Reported-by: Yung-Chin Oei <yungchin@yungchin.nl>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Add _open_noatime() and use it bup_get_linux_file_attr().

Reported-by: Yung-Chin Oei <yungchin@yungchin.nl>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Unmount testfs properly during "make clean".

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Save metadata during "bup save".

Record metadata in a hidden/mangled file named .bup in each directory,
so that the metadata for /foo/ is stored in /foo/.bup, with the first
entry being the metadata for foo itself.  Record an empty index file
for each special file so that the index entries and .bupm entries
correspond.

For now, record "/" metadata only when there are no strip/graft
options.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Restore any metadata during "bup restore"; add "bup meta --edit".

Use "bup meta --edit" to test "bup restore" and the new tar/rsync-like
restoration behaviors.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Add preliminary hardlink support for review.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Defer errors when the restore target doesn't support relevant metadata.

When the restore target doesn't support POSIX1e ACLs, extended
attributes, or Linux attributes, handle the failures via add_error()
(i.e. defer them).

Test these cases by creating a loopback VFAT filesystem
(testfs-limited) and using it as a restore target.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Quote EXIT cleanup trap properly in test-meta.sh.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Handle the possibility of a sgid/suid parent dir in one of the meta tests.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Update README regarding metadata support.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Add a metadata() method to Node, File, Symlink, and Dir VFS objects.

The current implementation just populates the self._metadata field of
all of the objects in a directory (and of directory itself) from the
relevant .bupm file whenever metadata() is called on any one of those
objects.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Move tree comparison to t/compare-trees; compare content by default.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Add support for "bup index --exclude-rx <pattern> ...".

When --exclude-rx <pattern> is provided to bup index, exclude any path
matching <pattern>, which must be a Python regular expression
(http://docs.python.org/library/re.html).  The pattern will be
compared against the full path, without anchoring, so "x/y" will match
"ox/yard" or "box/yards".  To exclude the contents of /tmp, but not
the directory itself, use "^/tmp/.".

You may check the behavior at runtime by setting BUP_DEBUG=2 in the
environment.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Add support for "bup restore --exclude-rx <pattern> ...".

When --exclude-rx <pattern> is provided to bup restore, don't restore
any path matching <pattern>, which must be a Python regular expression
(http://docs.python.org/library/re.html).  The pattern will be
compared against the full path, without anchoring, so "x/y" will match
"ox/yard" or "box/yards".  To exclude the contents of /tmp, but not
the directory itself, use "^/tmp/.".

You may check the behavior at runtime by setting BUP_DEBUG=2 in the
environment.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Disallow empty graft points.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Overhaul restore destination handling, and stripping/grafting behavior.

Change restore to respond to source paths like this (assume outdir
corresponds to "." if there no -C argument or to -C outdir):

  /foo/what/ever - extract ever to outdir/ever
  /foo/what/ever/ - extract ever/* to outdir/*
  /foo/what/ever/. - extract ever/. to outdir/. (i.e. outdir == ever).

Also fix handling of top-level commit symlinks.  Previously bup would
just restore /foo/latest as a dummy symlink like this:

   latest -> ../.commit/SHA

Instead, dereference latest and restore the target instead.

Tighten up stripping/grafting with additional argument checks, and
handle any root collisions by creating a fake root dir (see comments
in save-cmd.py).  Bup still doesn't handle other path collisions yet,
i.e. if both /foo/bar and /bar are remapped to /bar.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Redirect t/compare-trees usage to stderr on error.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Don't pass -AX to rsync in t/compare-trees if xattrs aren't supported.

The -AX options won't be available if rsync doesn't report the xattr
capability, so test for that before trying to use them.

Thanks to Yung-Chin Oei <yungchin@yungchin.nl> for the suggested
approach and initial report.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Use python, not groups to grab a user group in t/test-meta.sh.

Group names may actually contain spaces, and since the groups commmand
only reports a space-delimited list of groups on stdout, we had
a problem.

Thanks to "Oei, Yung-Chin" <yungchin@yungchin.nl> and Gabriel Filion
<lelutin@gmail.com> for tracking this down.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Don't pass --tmpdir to mktemp or expect it to have a default template.

BSD mktemp does not understand --tmpdir, and does not have a default
pattern if none is supplied.

Signed-off-by: Yung-Chin Oei <yungchin@yungchin.nl>
Acked-by: Gabriel Filion <lelutin@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>