platform/upstream/btrfs-progs.git
11 years agoBtrfs-progs: fix a small memory leak in btrfs-list.c
Stefan Behrens [Tue, 9 Apr 2013 17:08:32 +0000 (19:08 +0200)]
Btrfs-progs: fix a small memory leak in btrfs-list.c

valgrind found this very obvious issue.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
11 years agoBtrfs-progs: close file descriptor in cmds-send.c
Stefan Behrens [Tue, 9 Apr 2013 17:08:31 +0000 (19:08 +0200)]
Btrfs-progs: close file descriptor in cmds-send.c

valgrind found this very obvious issue.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
11 years agoBtrfs-progs: ignore subvols above BTRFS_LAST_FREE_OBJECTID
Stefan Behrens [Tue, 9 Apr 2013 17:08:30 +0000 (19:08 +0200)]
Btrfs-progs: ignore subvols above BTRFS_LAST_FREE_OBJECTID

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
11 years agobtrfs-progs: add quota-related info to usage messages
Koen De Wit [Wed, 27 Mar 2013 13:54:12 +0000 (14:54 +0100)]
btrfs-progs: add quota-related info to usage messages

Extending usage messages with some info on the quota functionality:
     - The -i option of "subvol create" and "subvol snapshot" was not
documented
     - The -c option of "qgroup limit" is the default option
     - The "qouta rescan" command is not yet implemented, while it should be
       executed after enabling quota on a non-empty filesystem.

Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
11 years agoBtrfs-progs: add a free space cache checker to fsck V2
Josef Bacik [Thu, 4 Apr 2013 13:57:50 +0000 (09:57 -0400)]
Btrfs-progs: add a free space cache checker to fsck V2

In trying to track down a weird tree log problem I wanted to make sure that the
free space cache was actually valid, which we currently have no way of doing.
So this patch adds a bunch of support for the free space cache code and then a
checker to fsck.  Basically we go through and if we can actually load the free
space cache then we will walk the extent tree and verify that the free space
cache exactly matches what is in the extent tree.  Hopefully this will always be
correct, the only time it wouldn't is if the extent tree is corrupt or we have
some sort of awful bug in the free space cache.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agobtrfs-progs: do not enable extended refs in mkfs by default
David Sterba [Tue, 9 Apr 2013 17:19:50 +0000 (19:19 +0200)]
btrfs-progs: do not enable extended refs in mkfs by default

This extref feature (lifting the single file hardlink limitation) is new
and not backward compatible with older kernels that are still in wide
use.

For now, use btrfstune to enable the feature, in the future it will be
possible to turn it on within mkfs by -O option.

Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agobtrfs-progs: revert skinny extents changes from mkfs
David Sterba [Tue, 9 Apr 2013 17:11:36 +0000 (19:11 +0200)]
btrfs-progs: revert skinny extents changes from mkfs

We are going to unify enabling filesystem features via option -O.
For now, use btrfstune to enable the features.

Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agoBtrfs-progs: add skinny metadata support to progs V3
Josef Bacik [Fri, 15 Mar 2013 19:32:16 +0000 (15:32 -0400)]
Btrfs-progs: add skinny metadata support to progs V3

This fixes up the progs to properly deal with skinny metadata.  This adds the -x
option to mkfs and btrfstune for enabling the skinny metadata option.  This also
makes changes to fsck so it can properly deal with the skinny metadata entries.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agobtrfs-progs: re-add send-test
Mark Fasheh [Sat, 6 Apr 2013 18:30:04 +0000 (13:30 -0500)]
btrfs-progs: re-add send-test

send-test.c links against libbtrfs and uses the send functionality provided
to decode and print a send stream to the console.

66819df "btrfs-progs: add send-test" contained this file when
submitted, but somehow got lost on commit.

[sandeen@redhat.com: Resurrect lost send-test.c from original commit]

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: btrfs-select-super output is confusing when it fails
Anand Jain [Fri, 5 Apr 2013 05:55:02 +0000 (13:55 +0800)]
btrfs-progs: btrfs-select-super output is confusing when it fails

Trivial patch:
./btrfs-progs/btrfs-select-super -s 0 /dev/sdc
using SB copy 0, bytenr 65536
No valid Btrfs found on /dev/sdc
Open ctree failed

The line 'using..' is confusing which gives an
indication that command is successful

This patch will avoid that when command fails

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agobtrfs-progs: mkfs should first check all disks before writing to a disk
Anand Jain [Mon, 15 Apr 2013 06:38:09 +0000 (14:38 +0800)]
btrfs-progs: mkfs should first check all disks before writing to a disk

In the cases where one of the disk is not suitable for
btrfs, then we would fail the mkfs, however we determine
that after we have written btrfs to the preceding disks.
At this time if user changes mind for not to use btrfs
will left with no choice.

So this patch will check if all the provided disks are
suitable for the btrfs at once before proceeding to
create btrfs on a disk.

Further this patch also removed duplicate code to check
device suitability for the btrfs.

Next, there is an existing bug about the -r mkfs option,
which this patch would carry forward most of it.
Ref:
[PATCH 2/2, RFC] btrfs-progs: overhaul mkfs.btrfs -r option

Signed-off-by: Anand Jain <anand.jain@oracle.com>
to merg prev

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agobtrfs-progs: no pending balance is not an error
Anand Jain [Tue, 16 Apr 2013 04:58:15 +0000 (12:58 +0800)]
btrfs-progs: no pending balance is not an error

Having no balance running/ paused/completed is a normal
situation, so the current output message should be positive
with return val zero.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agobtrfs-progs: fix btrfs scrub start help
Anand Jain [Mon, 8 Apr 2013 02:20:20 +0000 (10:20 +0800)]
btrfs-progs: fix btrfs scrub start help

a very trivial fix

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agobtrfs-progs: delete unused function get_mountpt
Anand Jain [Fri, 5 Apr 2013 05:54:59 +0000 (13:54 +0800)]
btrfs-progs: delete unused function get_mountpt

and get_btrfs_mount has replaced it

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agoBtrfs-progs: Use /proc/mounts instead of /etc/mtab
Stefan Behrens [Mon, 25 Mar 2013 14:21:42 +0000 (15:21 +0100)]
Btrfs-progs: Use /proc/mounts instead of /etc/mtab

/etc/mtab is not working correctly in situations where multiple
mount namespaces are used. Use /proc/mounts instead like the
rest of the code is doing it.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
11 years agoBtrfs-progs: add btrfs-crc tool
Jan Schmidt [Thu, 21 Mar 2013 16:02:40 +0000 (17:02 +0100)]
Btrfs-progs: add btrfs-crc tool

This tool can be used to compute btrfs' style crc32c checksums for filenames
as done by the kernel. Additionally, there is -c mode to do a brute force
search for file names with a given checksum.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
11 years agobtrfs-progs: add missing qgroup synopsis in btrfs
Zhi Yong Wu [Thu, 21 Mar 2013 08:33:37 +0000 (16:33 +0800)]
btrfs-progs: add missing qgroup synopsis in btrfs

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
11 years agobtrfs-progs: fix one bracket issue in mkfs.btrfs manpage
Zhi Yong Wu [Thu, 21 Mar 2013 07:17:17 +0000 (15:17 +0800)]
btrfs-progs: fix one bracket issue in mkfs.btrfs manpage

  In "[ \fB\-f\fP\fI ]", the "\fI" will result in the front half "["of
"[ -f ]" doesn't the back half "]"; When you issue the command
"man mkfs.btrfs", you will see the difference.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
11 years agoBtrfs-progs: make btrfs-image restore with a valid chunk tree V2
Josef Bacik [Wed, 27 Mar 2013 20:55:41 +0000 (16:55 -0400)]
Btrfs-progs: make btrfs-image restore with a valid chunk tree V2

Previously btrfs-image would set a METADUMP flag and would make one big system
chunk to cover the entire file system in the super in order to get around the
unpleasant business of having to adjust the chunk tree.  This meant that you
could use the progs stuff on a restored file system, which is great for testing
btrfsck and other such things.  But we want to be able to run the tree log
replay on a file system that is not able to run the tree log replay.  So in
order to do this we need to fixup the super's chunk array and the chunk tree
itself.  This is pretty easy since we restore using the logical offsets of the
metadata, so we just have to set the chunk items to have 1 stripe and have the
stripes point at the primary device and then use the logical offset of the chunk
as the physical offset.  With this patch I can restore a file system image that
had a tree log and mount the file system and have the log be replayed
successfully.  This patch also gives you the -o option in case you want the old
restore way, in the case where we want to make sure the system chunks as they
were given to us are correct.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agoBtrfs-progs: make btrfs-image grab the free space cache
Josef Bacik [Tue, 19 Mar 2013 13:43:13 +0000 (09:43 -0400)]
Btrfs-progs: make btrfs-image grab the free space cache

A lot of tree log replay bugs are because of strange space cache setups, so make
btrfs-image scrape the free space cache as well so we can better replicate what
a user is seeing if they have a tree log bug or anything related to free space
cache.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agoBtrfs-progs: make btrfs-image copy the tree logs if they exist
Josef Bacik [Mon, 18 Mar 2013 20:03:44 +0000 (16:03 -0400)]
Btrfs-progs: make btrfs-image copy the tree logs if they exist

Currently btrfs-image doesn't copy the tree logs, which doesn't help me when
we're trying to debug log replay bugs.  Since we don't have entries in the
extent root for the blocks we have to walk down all of the trees in order to
copy them.  With this patch I can image a file system with a tree log and it
works fine.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agoBtrfs-progs: cleanup error handling in btrfs-image
Josef Bacik [Mon, 18 Mar 2013 18:50:45 +0000 (14:50 -0400)]
Btrfs-progs: cleanup error handling in btrfs-image

We use BUG_ON() everywhere in btrfs-image.  When users are going to use this
command things are pretty dire, so I'd rather have really good error messages so
I know what happened rather than figure out which one of the 20 BUG_ON()'s made
the stupid thing exit early.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agoBtrfs-progs: tool to visualize fragmentation
Arne Jansen [Mon, 28 Nov 2011 16:12:30 +0000 (17:12 +0100)]
Btrfs-progs: tool to visualize fragmentation

This tool draws per-chunk pngs representing the allocation map. A black
or colored dot means the block is allocated.
The output is written to a subdirectory, together with an index.html to be
viewed in a browser.
There are options to control whether color should be used and which block
group types should be printed.
To build, you need to have libpng and libgd installed. It is not part of
the 'all' target, so please build it explicitely with make btrfs-fragments.

A (rather untypical) example can be seen at

http://sensille.com/fragments

Please regard this as a first scratch version and feel free to improve it :)

Signed-off-by: Arne Jansen <sensille@gmx.net>
11 years agoBtrfs-progs: make scrub IO priority configurable
Stefan Behrens [Wed, 16 May 2012 16:51:28 +0000 (18:51 +0200)]
Btrfs-progs: make scrub IO priority configurable

The btrfs tool is changed in order to support command line parameters
to configure the IO priority of the scrub tasks. Also the default is
changed. The default IO priority for scrub is the idle class now.

The behavior is the same as when one would type
'ionice ... btrfs scrub start ...' or 'ionice ... btrfs scrub resume ...'
(without this patch applied).
The only reason for adding this to the btrfs tool is that it was not
documented and not obvious that it worked like this, that all internal
scrub tasks inherited the IO priority values of the btrfs tool that is
starting or resuming the scrub operation.

Note that after applying the patch it is no longer possible to set
the IO priority using ionice since the btrfs tool always configures
the priority in order to run in the idle class by default.

Some basic performance measurements have been done with the goal to
measure which IO priority for scrub gives the best overall disk data
throughput. The kernel was configured to use the CFQ IO scheduler
with default configuration and without support for throttling. The
summary is, that the more the disk head movements are avoided, the
faster the overall disk transfer capacity is, which is not really a
big surprise. Therefore it makes sense that the best data throughput
was measured setting the scrub IO priority and the scrub readahead
IO priority to the idle class priority. Running with idle class IO
priority means that scrub and scrub readahead IO is paused while
other tasks access the disk. Doing the tasks one after the other
instead of concurrently avoids many disk head movements. The
overall data throughput of rotating disks is improved this way.

However, if it is desired to have the scrub task done within a
reasonable time, and if at the same time the filesystem is heavily
loaded, the idle IO priority should be avoided. Otherwise the scrub
operation will never take place and thus never terminate.

The best effort IO priority class with the subclass 7 (the lowest
one in the best effort class) is recommended in the case of always
heavily loaded hard disks. If the filesystem is not loaded all the
time and leaves some idle slots for scrub, the idle class IO priority
is recommended. The idle class now is the default if the scrub
operation is started with the btrfs-progs tools.

Note that the patch that sets the scrub readahead IO priority to the
idle class is a seperate patch, this needs to be done in the kernel.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
11 years agobtrfs-progs: makefile: clean static targets
David Sterba [Tue, 19 Mar 2013 17:12:05 +0000 (18:12 +0100)]
btrfs-progs: makefile: clean static targets

* create .static.o version from the library objects as well and use them
  for building static targets
* remove build dependencies on libbtrfs.*
* other minor cleanups

Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agoRemoving btrfsctl, btrfs-vol, btrfs-show
Goffredo Baroncelli [Sat, 9 Jun 2012 05:52:10 +0000 (07:52 +0200)]
Removing btrfsctl, btrfs-vol, btrfs-show

With the commit 002d021c (committed October 2011)
btrfsctl, btrfs-vol, btrfs-show were declared deprecated.
The last patches related to these commands are dated December 2010.

These tools are replaced by the "btrfs" tool in all the
functionality.

This commit removes all the related code.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agoMakefile: allow user set LDFLAGS for libbtrfs.so as well
Sergei Trofimovich [Tue, 19 Mar 2013 05:33:24 +0000 (08:33 +0300)]
Makefile: allow user set LDFLAGS for libbtrfs.so as well

Detected by gentoo's QA checker:

 * QA Notice: Files built without respecting LDFLAGS have been detected
 *  Please include the following list of files in your report:
 * /usr/lib/libbtrfs.so.0.1

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
11 years agoBtrfs-progs: fix memory leaks on cleanup
Josef Bacik [Mon, 18 Mar 2013 15:07:03 +0000 (11:07 -0400)]
Btrfs-progs: fix memory leaks on cleanup

I've been working on btrfs-image and I kept seeing these leaks pop up on
valgrind so I'm just fixing them.  We don't properly cleanup the device cache,
the chunk tree mapping cache, or the space infos on close.  With this patch
valgrind doesn't complain about any memory leaks running btrfs-image.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agobtrfs-progs: defrag return zero on success
Anand Jain [Mon, 18 Mar 2013 07:29:38 +0000 (15:29 +0800)]
btrfs-progs: defrag return zero on success

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agoBtrfs-progs: fix segfault when using tools fs with tree log
Josef Bacik [Fri, 15 Mar 2013 21:13:08 +0000 (17:13 -0400)]
Btrfs-progs: fix segfault when using tools fs with tree log

We just free the log root after we set it up when we open a ctree in the tools.
This isn't nice, it makes double free's and leaks eb's, makes segfaults with
btrfs-image.  So fix this to be correct, and fix the cleanup if the buffer is
not uptodate.  With this fix I no longer segfault trying to do btrfs-image on a
file system with a log tree.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agobtrfs-progs: convert: access name_len and file_type the old way
David Sterba [Fri, 15 Mar 2013 16:10:45 +0000 (17:10 +0100)]
btrfs-progs: convert: access name_len and file_type the old way

We can't use ext2_dir_entry_2 typecast on big endian machines directly.
The bytes do not get converted during extX block read due to missing
flag EXT2_DIRBLOCK_V2_STRUCT passed down to ext2fs_read_dir_block4 from
ext2fs_process_dir_block. Fixing on the ext2 side needs updating callers
and (maybe) the library interfaces. We'll fix it on the convert side for
now.

CC: Jan Kara <jack@suse.cz>
Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agoBtrfs-progs: give restore a list roots option
Josef Bacik [Tue, 12 Mar 2013 17:38:16 +0000 (13:38 -0400)]
Btrfs-progs: give restore a list roots option

Since restore has the ability to open really really screwed up file systems, add
a list roots option to it so we can still get the contents of the tree root on a
horribly broken fs.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
11 years agobtrfs-progs: add lzo compression support to restore
Josef Bacik [Tue, 12 Mar 2013 17:38:14 +0000 (13:38 -0400)]
btrfs-progs: add lzo compression support to restore

This patch simply adds support to decompress lzo compressed extents in restore.

Signed-off-by: Josef Bacik <josef@redhat.com>
11 years agorestore: Split output directory and btrfs-local path search_dir() parameters
Peter Stuge [Tue, 12 Mar 2013 17:38:12 +0000 (13:38 -0400)]
restore: Split output directory and btrfs-local path search_dir() parameters

search_dir() recurses down the btrfs tree, and used to take the output
path for every item (i.e. in the running system, output root directory
concatenated with btrfs-local pathname) passed as the only path
parameter. Moving the output root directory to a separate parameter
and passing the btrfs-local pathname for each file and directory
separately allows easy filtering based on the btrfs-local pathname.

Signed-off-by: Peter Stuge <peter@stuge.se>
Signed-off-by: Josef Bacik <josef@redhat.com>
11 years agobtrfs-progs: Fix error handling for failed reads in restore tool when mirrors exist
David Marcin [Tue, 12 Mar 2013 17:38:11 +0000 (13:38 -0400)]
btrfs-progs: Fix error handling for failed reads in restore tool when mirrors exist

Signed-off-by: David Marcin <djmarcin@google.com>
11 years agoBtrfs-progs: try other mirrors on read failure
Josef Bacik [Tue, 12 Mar 2013 17:38:10 +0000 (13:38 -0400)]
Btrfs-progs: try other mirrors on read failure

If we hit a bad disk and the read doesn't work, try other mirrors in case we
have other disks with good copies.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
11 years agoBtrfs-progs: try other mirrors if decompression fails
Josef Bacik [Tue, 12 Mar 2013 17:38:09 +0000 (13:38 -0400)]
Btrfs-progs: try other mirrors if decompression fails

This will make the restore program fall back on other mirrors if it fails to
decompress an extent for whatever reason.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
11 years agoBtrfs-progs: add an option for specifying the root to restore
Josef Bacik [Tue, 12 Mar 2013 17:38:08 +0000 (13:38 -0400)]
Btrfs-progs: add an option for specifying the root to restore

If the normal fs tree is hosed and the user has multiple subvolumes it's handy
to be able to specify just one of the subvolumes to restore.  It's also handy if
a user only wants to restore say /home instead of his entire disk.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
11 years agobtrfs-progs: mkfs: add missing raid5/6 description
Matias Bjørling [Fri, 15 Mar 2013 14:02:57 +0000 (15:02 +0100)]
btrfs-progs: mkfs: add missing raid5/6 description

Signed-off-by: Matias Bjørling <m@bjorling.me>
11 years agobtrfs-progs: document force option in mkfs usage(); add long opt
Eric Sandeen [Wed, 13 Mar 2013 15:37:27 +0000 (10:37 -0500)]
btrfs-progs: document force option in mkfs usage(); add long opt

I missed updating the mkfs.btrfs usage() when I added the
option to force fs overwrite.

Update that, and while we're at it add a long option, since
all other commands have long counterparts.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: print errno string when /dev/btrfs-control open fails
Anand Jain [Thu, 14 Mar 2013 03:17:19 +0000 (11:17 +0800)]
btrfs-progs: print errno string when /dev/btrfs-control open fails

Of recently and intermittently I am seeing open fail
for /dev/btrfs-control (btrfs is loaded), and there are no
dmesg errors, this may not be a complete help in digging
this issue but something which is necessary.
Thanks

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agobtrfs-progs: update .gitignore file
Anand Jain [Thu, 14 Mar 2013 02:12:41 +0000 (10:12 +0800)]
btrfs-progs: update .gitignore file

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agobtrfs-progs: add Makefile rule for static build of btrfs-find-root
Hugo Mills [Tue, 12 Mar 2013 15:44:11 +0000 (15:44 +0000)]
btrfs-progs: add Makefile rule for static build of btrfs-find-root

btrfs-find-root isn't yet integrated into the main btrfs tool, and is
an important recovery tool, so it deserves to be built as a static
binary.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
11 years agobtrfs-progs: rework get_fs_info to remove side effects
Eric Sandeen [Tue, 12 Mar 2013 04:17:40 +0000 (23:17 -0500)]
btrfs-progs: rework get_fs_info to remove side effects

get_fs_info() has been silently switching from a device to a mounted
path as needed; the caller's filehandle was unexpectedly closed &
reopened outside the caller's scope.  Not so great.

The callers do want "fdmnt" to be the filehandle for the mount point
in all cases, though - the various ioctls act on this (not on an fd
for the device).  But switching it in the local scope of get_fs_info
is incorrect; it just so happens that *usually* the fd number is
unchanged.

So - use the new helpers to detect when an argument is a block
device, and open the the mounted path more obviously / explicitly
for ioctl use, storing the filehandle in fdmnt.

Then, in get_fs_info, ignore the fd completely, and use the path on
the argument to determine if the caller wanted to act on just that
device, or on all devices for the filesystem.

Affects those commands which are documented to accept either
a block device or a path:

* btrfs device stats
* btrfs replace start
* btrfs scrub start
* btrfs scrub status

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: don't open-code mountpoint discovery in scrub cancel
Eric Sandeen [Mon, 11 Mar 2013 23:13:00 +0000 (18:13 -0500)]
btrfs-progs: don't open-code mountpoint discovery in scrub cancel

cmd_scrub_cancel had its own mountpoint discovery routine;
just use open_path_or_dev_mnt() for that now.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: three new device/path helpers
Eric Sandeen [Mon, 11 Mar 2013 23:12:59 +0000 (18:12 -0500)]
btrfs-progs: three new device/path helpers

Add 3 new helpers:

* is_block_device(), to test if a path is a block device.
* get_btrfs_mount(), to get the mountpoint of a device,
  if mounted.
* open_path_or_dev_mnt(path), to open either the pathname
  or, if it's a mounted btrfs dev, the mountpoint.  Useful
  for some commands which can take either type of arg.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: close fd on return from label get/set functions
Eric Sandeen [Mon, 11 Mar 2013 23:12:58 +0000 (18:12 -0500)]
btrfs-progs: close fd on return from label get/set functions

Somehow missed these 2 in the last round.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agoBtrfs-progs: alloc our super copy in btrfs-find-root
Josef Bacik [Tue, 12 Mar 2013 14:07:39 +0000 (10:07 -0400)]
Btrfs-progs: alloc our super copy in btrfs-find-root

Dave fixed the fs_info to allocate the super copy instead of embedding it, but
he failed to notice that I open code open_ctree in btrfs-find-root so we end up
with a super that's not allocated, so we segfault whenever you try to run
btrfs-find-root.  I've fixed this up and now we don't segfault anymore.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
11 years agobtrfs-progs: Add a rule to build a static mkfs.btrfs
Antoine Sirinelli [Mon, 11 Mar 2013 21:17:17 +0000 (21:17 +0000)]
btrfs-progs: Add a rule to build a static mkfs.btrfs

Static mkfs.btrfs can be used to "bootstrap" a system from a live CD
which does not provide mkfs.btrfs.

The executable produced is named mkfs.btrfs.static and built by invoking
the "static" make rule.

Signed-off-by: Antoine Sirinelli <antoine@monte-stello.com>
11 years agobtrfs-progs: separate super_copy out of fs_info
David Sterba [Wed, 6 Mar 2013 16:32:51 +0000 (17:32 +0100)]
btrfs-progs: separate super_copy out of fs_info

Allocate fs_info::super_copy dynamically of full BTRFS_SUPER_INFO_SIZE
and use it directly for saving superblock to disk.

This fixes incorrect superblock checksum after mkfs.

Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agobtrfs-progs: update the .gitignore file
Anand Jain [Fri, 8 Mar 2013 15:25:45 +0000 (23:25 +0800)]
btrfs-progs: update the .gitignore file

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agobtrfs-progs: fix scrub error return from pthread_mutex_lock
Eric Sandeen [Mon, 4 Mar 2013 22:49:40 +0000 (16:49 -0600)]
btrfs-progs: fix scrub error return from pthread_mutex_lock

If pthread_mutex_lock() fails it returns the error in ret,
and does not set errno.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: Error handling in scrub_progress_cycle() thread
Eric Sandeen [Mon, 4 Mar 2013 22:45:37 +0000 (16:45 -0600)]
btrfs-progs: Error handling in scrub_progress_cycle() thread

consolidate error handling to ensure that peer_fd
is closed on error paths.  Add a couple comments
to the error handling after the thread is complete.

Note that scrub_progress_cycle returns negative
errnos on any error.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: better option/error handling for btrfs-vol
Eric Sandeen [Mon, 4 Mar 2013 22:40:03 +0000 (16:40 -0600)]
btrfs-progs: better option/error handling for btrfs-vol

Today wrong cmdlines give odd results:

# ./btrfs-vol /dev/sdb1
Unable to open device (null)
# ./btrfs-vol -a /dev/sdb1
usage: btrfs-vol [options] mount_point ...

Make it a bit more informative:

# ./btrfs-vol /dev/sdb1
No command specified
usage: btrfs-vol [options] mount_point ...
# ./btrfs-vol -a /dev/sdb1
No mountpoint specified
usage: btrfs-vol [options] mount_point ...

(even though it's deprecated ...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: Issue warnings if ioctls fail in sigint handlers
Eric Sandeen [Mon, 4 Mar 2013 22:35:42 +0000 (16:35 -0600)]
btrfs-progs: Issue warnings if ioctls fail in sigint handlers

The two sigint handlers issue ioctls to clean up, but if
they fail, noone would know.  I'm not sure there is
any other error handling to be done at this point, but a
notification seems wise.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: check return of posix_fadvise
Eric Sandeen [Mon, 4 Mar 2013 22:40:01 +0000 (16:40 -0600)]
btrfs-progs: check return of posix_fadvise

It seems highly unlikely that posix_fadvise could fail,
and even if it does, it was only advisory.  Still, if
it does, we could issue a notice to the user.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: Free resources when returning error from cmd_subvol_create()
Eric Sandeen [Mon, 4 Mar 2013 22:40:00 +0000 (16:40 -0600)]
btrfs-progs: Free resources when returning error from cmd_subvol_create()

cmd_subvol_create() currently returns without freeing resources
in almost every error case.  Switch to a goto arrangement
so all cleanup can be done in one place.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: tidy up cmd_subvol_create() whitespace & returns
Eric Sandeen [Mon, 4 Mar 2013 22:39:59 +0000 (16:39 -0600)]
btrfs-progs: tidy up cmd_subvol_create() whitespace & returns

Just whitespace fixes, and magical return value removal.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: Free resources when returning error from cmd_snapshot()
Eric Sandeen [Mon, 4 Mar 2013 22:39:58 +0000 (16:39 -0600)]
btrfs-progs: Free resources when returning error from cmd_snapshot()

cmd_snapshot() currently returns without freeing resources
in almost every error case.  Switch to a goto arrangement
so all cleanup can be done in one place.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: tidy up cmd_snapshot() whitespace & returns
Eric Sandeen [Mon, 4 Mar 2013 22:39:57 +0000 (16:39 -0600)]
btrfs-progs: tidy up cmd_snapshot() whitespace & returns

Just whitespace fixes, and magical return value removal.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: check for null string in parse_size
Eric Sandeen [Mon, 4 Mar 2013 22:39:56 +0000 (16:39 -0600)]
btrfs-progs: check for null string in parse_size

Because it's better than a segfault if it's called improperly,
and it makes static checkers happier.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: free allocated metadump structure on restore failure
Eric Sandeen [Mon, 4 Mar 2013 22:39:55 +0000 (16:39 -0600)]
btrfs-progs: free allocated metadump structure on restore failure

Don't return w/ "metadump" still allocated

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: free resources on do_rollback error returns
Eric Sandeen [Mon, 4 Mar 2013 22:39:53 +0000 (16:39 -0600)]
btrfs-progs: free resources on do_rollback error returns

close fd if open, and free allocated memory in buf

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: close fd on do_convert error returns
Eric Sandeen [Mon, 4 Mar 2013 22:39:52 +0000 (16:39 -0600)]
btrfs-progs: close fd on do_convert error returns

stops an fd leak that Coverity found.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: close fd on cmd_subvol_list return
Eric Sandeen [Mon, 4 Mar 2013 22:39:51 +0000 (16:39 -0600)]
btrfs-progs: close fd on cmd_subvol_list return

stops an fd leak that Coverity found.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: update mkfs.btrfs help info for raid5/6
Zhi Yong Wu [Mon, 4 Mar 2013 01:37:28 +0000 (09:37 +0800)]
btrfs-progs: update mkfs.btrfs help info for raid5/6

  Since raid5/6 support was introduced, we should update mkfs.btrfs help info.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
11 years agobtrfs-progs: usage should match what is coded
Anand Jain [Fri, 1 Mar 2013 10:10:02 +0000 (18:10 +0800)]
btrfs-progs: usage should match what is coded

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agobtrfs-progs: from troubleshooting point of view messages must be unique
Anand Jain [Fri, 1 Mar 2013 10:10:01 +0000 (18:10 +0800)]
btrfs-progs: from troubleshooting point of view messages must be unique

-----
cmds-device.c:                  fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n",
utils.c:                fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n",
-----

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agoBtrfs-progs: add correct indentation
Anand Jain [Fri, 22 Feb 2013 06:59:24 +0000 (14:59 +0800)]
Btrfs-progs: add correct indentation

A trivial fix, corrects the indentation.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agoBtrfs-progs: fix segmentation fault of "btrfs check"
Tsutomu Itoh [Wed, 27 Feb 2013 02:31:54 +0000 (11:31 +0900)]
Btrfs-progs: fix segmentation fault of "btrfs check"

Segmentation fault occurred in the following command.

 # btrfs check /dev/sdc7
 No valid Btrfs found on /dev/sdc7
 Segmentation fault (core dumped)

Fix it.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
11 years agoBtrfs-progs: output the error reason when qgroup_show fails
Wang Shilong [Wed, 27 Feb 2013 11:04:18 +0000 (19:04 +0800)]
Btrfs-progs: output the error reason when qgroup_show fails

The original code forgot to output the reason why the commands failed,
fix it.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
11 years agoBtrfs-progs: let the error message outputed only once
Wang Shilong [Wed, 27 Feb 2013 11:03:21 +0000 (19:03 +0800)]
Btrfs-progs: let the error message outputed only once

If we fail to execute the command:
btrfs qgroup show <mnt>
It will output the follow messages:
ERROR: can't perform the search - Inappropriate ioctl for device
ERROR: can't list qgroups

The error is outputed twice, this is wrong, fix it.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
11 years agobtrfs-progs: don't link binaries to a dynamic library
David Sterba [Tue, 12 Feb 2013 17:44:35 +0000 (18:44 +0100)]
btrfs-progs: don't link binaries to a dynamic library

Linking 'btrfs' and other binaries against the dynamic library makes it
tedious to use directly from the git repo. This is useful for testing
various fixes, but now it'd need to also set LD_LIBRARY_PATH or install
the library to a known path.

Add a target for static library and use it for linking, the dynamic
library is to be used by external users.

Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agobtrfs-progs: libify some parts of btrfs-progs
Mark Fasheh [Mon, 7 Jan 2013 22:24:35 +0000 (14:24 -0800)]
btrfs-progs: libify some parts of btrfs-progs

External software wanting to use the functionality provided by the btrfs
send ioctl has a hard time doing so without replicating tons of work. Of
particular interest are functions like btrfs_read_and_process_send_stream()
and subvol_uuid_search(). As that functionality requires a bit more than
just send-stream.c and send-utils.c we have to pull in some other parts of
the progs package.

This patch adds code to the Makefile and headers to create a library,
libbtrfs which the btrfs command now links to.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agobtrfs-progs: initialize save_ptr prior to strtok_r
Eric Sandeen [Tue, 26 Feb 2013 21:50:22 +0000 (15:50 -0600)]
btrfs-progs: initialize save_ptr prior to strtok_r

The coverity runs had a false positive complaining that
save_ptr is uninitialized in the call to strtok_r.

Turns out that under the covers glibc was doing enough
to confuse the checker about what was being called.

Just to keep the noise down, do a harmless initialization,
with a comment as to why.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: fix fd leak in cmd_subvol_set_default
Eric Sandeen [Mon, 25 Feb 2013 22:54:49 +0000 (16:54 -0600)]
btrfs-progs: fix fd leak in cmd_subvol_set_default

Rearrange cmd_subvol_set_default() slightly so we
don't have to close the fd on an error return.

While we're at it, fix whitespace & remove magic
return values.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: Tidy up resolve_root
Eric Sandeen [Mon, 25 Feb 2013 22:54:48 +0000 (16:54 -0600)]
btrfs-progs: Tidy up resolve_root

Whitespace fixes and fix a variable declaration after
code.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: fix mem leak in resolve_root
Eric Sandeen [Mon, 25 Feb 2013 22:54:47 +0000 (16:54 -0600)]
btrfs-progs: fix mem leak in resolve_root

If we exit with error we must free the allocated memory
to avoid a leak.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: close fd on cmd_subvol_get_default return
Eric Sandeen [Mon, 25 Feb 2013 22:54:46 +0000 (16:54 -0600)]
btrfs-progs: close fd on cmd_subvol_get_default return

Without this we leak the fd when we return from the
function.

Also, remove the senseless random return values.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: free allocated di_args in cmd_start_replace
Eric Sandeen [Mon, 25 Feb 2013 22:54:45 +0000 (16:54 -0600)]
btrfs-progs: free allocated di_args in cmd_start_replace

We only freed this allocation in error paths, and leaked
a bit when it went out of scope normally.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: provide positive errno to strerror in cmd_restore
Eric Sandeen [Mon, 25 Feb 2013 22:54:44 +0000 (16:54 -0600)]
btrfs-progs: provide positive errno to strerror in cmd_restore

check_mounted returns a negative errno, so it needs to be flipped
again before passing to strerror.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: don't call close on error fd
Eric Sandeen [Mon, 25 Feb 2013 22:54:43 +0000 (16:54 -0600)]
btrfs-progs: don't call close on error fd

In the error case where fd < 0, close(fd) is the wrong
thing to do.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: free memory before error exit in read_whole_eb
Eric Sandeen [Mon, 25 Feb 2013 22:54:42 +0000 (16:54 -0600)]
btrfs-progs: free memory before error exit in read_whole_eb

Free the memory allocated to "multi" before the error
exit in read_whole_eb().  Set it to NULL after we free
it in the loop to avoid any potential double-free.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: more scrub cancel error handling
Eric Sandeen [Mon, 25 Feb 2013 22:54:41 +0000 (16:54 -0600)]
btrfs-progs: more scrub cancel error handling

If we request scrub cancel on an unmounted or
non-btrfs device, we still get a "scrub canceled"
success message:

# btrfs scrub cancel /dev/loop1
scrub cancelled
# blkid /dev/loop1
/dev/loop1: UUID="7f586941-1d5e-4ba7-9caa-b35934849957" TYPE="xfs"

Fix this so that if check_mounted_where returns 0
we don't report success.

While we're at it, use perror to report the reason for an open
failure, if we get one.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: fix close of error fd in scrub cancel
Eric Sandeen [Mon, 25 Feb 2013 22:54:40 +0000 (16:54 -0600)]
btrfs-progs: fix close of error fd in scrub cancel

If we retry opening the mountpoint and fail, we'll call
close on a filehandle w/ value -1.  Rearrange so the
retry uses the same open and same error handling.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: fix open error test in cmd_start_replace
Eric Sandeen [Mon, 25 Feb 2013 22:54:39 +0000 (16:54 -0600)]
btrfs-progs: fix open error test in cmd_start_replace

open() returns a negative fd on failure, not 0.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: avoid double-free in __btrfs_map_block
Eric Sandeen [Mon, 25 Feb 2013 22:54:38 +0000 (16:54 -0600)]
btrfs-progs: avoid double-free in __btrfs_map_block

__btrfs_map_block() can possibly do the goto again: loop after
having allocated & freed the "multi" pointer.  There are then
a couple error conditions where it will attempt to again kfree
the now non-NULL multi pointer.  So before retrying, reset
multi to NULL after we free it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: btrfs_list_get_path_rootid error handling
Eric Sandeen [Mon, 25 Feb 2013 22:54:37 +0000 (16:54 -0600)]
btrfs-progs: btrfs_list_get_path_rootid error handling

btrfs_list_get_path_rootid() tries to return a negative
number on error, but it's a u64 function.  Callers which test
for a return < 0 will never see an error.

Change the function to fill in the rootid via a pointer,
and then return a simple int as error.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: Remove write-only var fdres in cmd_dev_stats()
Eric Sandeen [Mon, 25 Feb 2013 22:54:36 +0000 (16:54 -0600)]
btrfs-progs: Remove write-only var fdres in cmd_dev_stats()

fdres is initialized to -1, then later tested, but never
set.  Just remove it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: fix btrfs_get_subvol cut/paste error
Eric Sandeen [Mon, 25 Feb 2013 22:54:35 +0000 (16:54 -0600)]
btrfs-progs: fix btrfs_get_subvol cut/paste error

in btrfs_get_subvol(), there is a cut and paste error:

       if (ri->full_path)
               the_ri->full_path = strdup(ri->full_path);
       else
               the_ri->name = NULL;

It should be setting the_ri->full_path to NULL here.
Do it in a function instead of the cpoy & paste to avoid future
errors.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: move btrfslabel.[c|h] stuff to utils.[c|h]
Jeff Liu [Wed, 30 Jan 2013 08:32:47 +0000 (16:32 +0800)]
btrfs-progs: move btrfslabel.[c|h] stuff to utils.[c|h]

Clean btrfslabel.[c|h] out of the source tree and move those related
functions to utils.[c|h].

CC: Gene Czarcinski <gene@czarc.net>
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
11 years agobtrfs-progs: refactor check_label()
Jeff Liu [Wed, 30 Jan 2013 08:32:43 +0000 (16:32 +0800)]
btrfs-progs: refactor check_label()

Refactor check_label().

- Make it be static at first, this is a preparation step since we'll remove
btrfslabel.[c|h] and move those functions from there to utils.[c|h], we can
do pre-checking against the input label string with it.
- Fix the label length check up from BTRFS_LABEL_SIZE to BTRFS_LABEL_SIZE - 1.
- Kill the check of label contains an invalid character, see below commits for detail:
  79e0e445fc2365e47fc7f060d5a4445d37e184b8
  btrfs-progs: kill check for /'s in labels.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
CC: David Sterba <dsterba@suse.cz>
CC: Gene Czarcinski <gene@czarc.net>
11 years agoBtrfs-progs: fix cmd_label_usage to reflect this change.
Jeff Liu [Mon, 17 Dec 2012 11:35:29 +0000 (11:35 +0000)]
Btrfs-progs: fix cmd_label_usage to reflect this change.

Fix the command usage of "btrfs filesystem label" to reflect this change. i.e. so that
we can get/set the label of a mounted filesystem against the mountpoint.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agoBtrfs-progs: Fix set_label_unmounted() with label length validation
Jeff Liu [Mon, 17 Dec 2012 11:35:27 +0000 (11:35 +0000)]
Btrfs-progs: Fix set_label_unmounted() with label length validation

Currently, we keeping silent if the label length is exceeding BTRFS_LABEL_SIZE - 1, and just
truncating the characters beyond that.

This patch make it return error and exit in this situation.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agoBtrfs-progs: Change the label of a mounted file system
Jeff Liu [Mon, 17 Dec 2012 11:35:23 +0000 (11:35 +0000)]
Btrfs-progs: Change the label of a mounted file system

With this new ioctl(2), we can set/change the label for a mounted file system.
It still does normal process for an umounted file system.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
11 years agobtrfsprogs: btrfstune support for extended inode refs
Mark Fasheh [Thu, 31 Jan 2013 18:57:53 +0000 (10:57 -0800)]
btrfsprogs: btrfstune support for extended inode refs

This patch adds an option to btrfstune, '-r' which will enable the extended
inode refs flag on the provided btrfs superblock. We don't have a disable
option at the moment as that would require far more work.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
11 years agoBtrfs-progs: fix segmentation fault of 'btrfs-debug-tree -e'
Liu Bo [Mon, 18 Feb 2013 10:05:17 +0000 (18:05 +0800)]
Btrfs-progs: fix segmentation fault of 'btrfs-debug-tree -e'

Due to some historical reasons, we remove 'printing leaf' part, which'd
lead to 'Segmentation fault' of btrfs-debug-tree -e, this patch adds it
back.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
11 years agobtrfs-progs: require mkfs -f force option to overwrite filesystem or partition table
Eric Sandeen [Thu, 14 Feb 2013 18:30:03 +0000 (12:30 -0600)]
btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table

The core of this is shamelessly stolen from xfsprogs.

Use blkid to detect an existing filesystem or partition
table on any of the target devices.  If something is found,
require the '-f' option to overwrite it, hopefully avoiding
disaster due to mistyped devicenames, etc.

# mkfs.btrfs /dev/sda1

WARNING! - Btrfs v0.20-rc1-59-gd00279c-dirty IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using

/dev/sda1 appears to contain an existing filesystem (xfs).
Use the -f option to force overwrite.
#

This does introduce a requirement on libblkid.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
11 years agobtrfs-progs: Fix pointer math in __ino_to_path_fd
Mark Fasheh [Thu, 14 Feb 2013 18:29:50 +0000 (10:29 -0800)]
btrfs-progs: Fix pointer math in __ino_to_path_fd

We are casting an array of u64 values into a char ** array so
when we dereference this array (as a char **) on a 32 bit system
we're then re-casting that back to a 32 bit value. This causes
problems when we try to print those strings.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
11 years agoBtrfs-progs: check out if the swap device
Tsutomu Itoh [Thu, 14 Feb 2013 07:53:04 +0000 (16:53 +0900)]
Btrfs-progs: check out if the swap device

Currently, the following commands succeed.

 # cat /proc/swaps
 Filename                                Type            Size    Used    Priority
 /dev/sda3                               partition       8388604 0       -1
 /dev/sdc8                               partition       9765884 0       -2
 # mkfs.btrfs /dev/sdc8

 WARNING! - Btrfs v0.20-rc1-165-g82ac345 IS EXPERIMENTAL
 WARNING! - see http://btrfs.wiki.kernel.org before using

 fs created label (null) on /dev/sdc8
         nodesize 4096 leafsize 4096 sectorsize 4096 size 9.31GB
 Btrfs v0.20-rc1-165-g82ac345
 # btrfs fi sh /dev/sdc8
 Label: none  uuid: fc0bdbd0-7eed-460f-b4e9-131273b66df2
         Total devices 1 FS bytes used 28.00KB
         devid    1 size 9.31GB used 989.62MB path /dev/sdc8

 Btrfs v0.20-rc1-165-g82ac345
 #

But we should check out the swap device. Fixed it.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Tested-by: David Sterba <dsterba@suse.cz>