btrfs-progs: build, add basic build test for library

Basic test based on snapper code that uses the send stream API.

Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: build, add make target for a build test

A quick check that everything still builds.

Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: build, gather utilities that are not built by default

Add them to build test and to clean rules.

Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: build, update the clean rule

Remove duplicate files, add extra progs, add library test binaries.

Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: update .gitignore

Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: fix compiler warning

gcc 4.9.0 gives warnings about possibly uninitialized values when
compiling with function inlining and optimization level two enabled
(CFLAGS="-finline-functions -O2").

Initializing the values fixes the warning. Hope this is correct.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: add the ability to delete items

Somtetimes you just need to delete an item, add that functionality to
btrfs-corrupt-block.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: don't fail on log tree opening with PARTIAL

We were failing to fsck a volume because we couldn't open the log tree, which is
not helpful.  Make us skip erroring out if we are using OPEN_CTREE_PARTIAL since
it isn't a mandatory tree.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: spit out the broken file when ignoring errors

It's nice to ignore errors on restore, but spit out the filename so the user
knows which files of his aren't going to look right.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: make zero-log use partial open

Because seriously, we only want to kill the tree log.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: add a message to know zero log ran successfully

If there are errors when opening the fs because of PARTIAL we could think that
the zero-log didn't actually work.  Add a printf so we know that it was
successfull.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: add ability to replace missing dir item/dir indexes

If we have everything except the dir item and dir index we can easily replace
them, so add this ability to btrfsck.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: fix missing inode items

If we have all the other items but no inode item we can recreate it for the most
part, with the exception of the permissions and ownership.  Add this ability to
btrfsck.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: create missing root dirid

If we just don't have the root dirid stuff go ahead and re-create it, since it
is easily recreated.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Btrfs-progs: test images for new btrfsck functionality

These test the recreating of missing dir item/dir index pairs, fixing the no
rootdir inode item and no inode item for normal files.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
btrfs-progs: Check sb_bytenr with device size before scanning one device.

When using btrfs check with -s option, if using '-s 2' on a small
device which doesn't have the third superblock, "No valid Btrfs found"
will be output, but it is not appropriate.

So check sb_bytenr against device size before scanning a device and
output proper error message.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: use canonical name for device in btrfs fi show when mounted

When using lvm volumes to check fstests: btrfs/006, it fails like:
     Label: 'TestLabel.006'  uuid: <UUID>
     	Total devices <EXACTNUM> FS bytes used <SIZE>
     	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
    +	devid <DEVID> size <SIZE> used <SIZE> path /dev/dm-4
    +	devid <DEVID> size <SIZE> used <SIZE> path /dev/dm-5
    +	devid <DEVID> size <SIZE> used <SIZE> path /dev/dm-6

The /dev/dm-* points to lvm volumes, use @canonicalize_path() to convert them
and we will make it through. Of course we should do the same thing for dev stat.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: use proper size for argv0 substitution

Make run from a long base path will overflow the argv0 buffer during
tests. Otherwise, this would happen for all the standalone binaries that
use set_argv0.

Original report:
https://bbs.archlinux.org/viewtopic.php?id=189861

Reported-by: WorMzy Tykashi <wormzy.tykashi@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: fix compiler warning

gcc 4.9.0 gives a warning: array subscript is above array bounds

Checking for "greater or equal" instead of just "equal" fixes this.

The warning is a false positive, appears with -ftree-vrp, but we'd
rather fix it to avoid noise during build.

http://www.mail-archive.com/linux-btrfs%40vger.kernel.org/msg34338.html

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-progs: use system attr instead of attr library

We use the attr version provided by system in other places already,
now we can remove dependency on the separate attr library.

Signed-off-by: David Sterba <dsterba@suse.cz>