Commit Graph

83 Commits (e69e015634a28d15ec651a17f900016b7b18df8f)

Author SHA1 Message Date
Dimitri John Ledkov e69e015634 btrfs-progs: drop feature defines from C files, in favour of CFLAGS defines
glibc 2.10+ (5+ years old) enables all the desired features:
_XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a
single _GNU_SOURCE define in the makefile alone. For portability to
other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also
defined.

This also resolves Debian bug report filed by Michael Tautschnig -
"Inconsistent use of _XOPEN_SOURCE results in conflicting
declarations". Whilst I was not able to reproduce the results, the
reported fact is that _XOPEN_SOURCE set to 500 in one set of files
(e.g. cmds-filesystem.c) generates/defines different struct stat from
other files (cmds-replace.c).

This patch thus cleans up all feature defines, and sets them at a
consistent level.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-27 14:45:59 +01:00
David Sterba 34c28896e8 btrfs-progs: unify getopt table terminators
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-21 18:56:40 +01:00
David Sterba 58a3952461 btrfs-progs: add --human-readable option where applicable
Add an alias to -h to 'filesystem usage', 'filesystem df' and
'device usage' commands, same as the traditional 'df'.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-21 18:56:28 +01:00
David Sterba 2b7cdab425 btrfs-progs: make getopt tables static const
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-19 13:44:49 +01:00
Qu Wenruo e015a83e6d btrfs-progs: Fix wrong return value when executing 'fi show' on umounted device.
When executing 'btrfs fi show' on unmounted device, even no problem
happens, the return value is still 1 not 0.

The problem lies in search_umounted_fs_uuids(), where when it finds the
given uuid, it should return 1, but later uuid copy overwrites the return
value, causing it always return 0 under that case.

Fix it by pass found as pointer, and return value only indicates
whether anything wrong happens, whether found or not is stored in the
new parameter.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-14 15:15:06 +01:00
David Sterba f8a24717b1 btrfs-progs: fix minor leak of dev_info in btrfs_scan_kernel
Resolves-coverity-id: 1127098
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-30 15:48:55 +01:00
David Sterba 8499af3484 btrfs-progs: fi show, don't leak canonical path
Resolves-coverity-id: 1260252
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-30 15:48:54 +01:00
Gui Hecheng 280434ebde btrfs-progs: move check_arg_type() to util.c
The check_arg_type() function does quite generic thing, move it to
utils.c.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-29 18:10:58 +01:00
Justin Maggard 7d83db5bae btrfs-progs: Fix btrfs fi show by uuid and label
Commit 8be2fff (btrfs-progs: apply realpath for btrfs fi
show when mount point is given) changed the behavior of
btrfs fi show to return an error if the call to realpath()
failed.  This broke the ability to specify a filesystem by
uuid or label.

So let's not consider a failed call to realpath() as an
error.  If the user really specified a bad device, just
return nothing like we did before.

Signed-off-by: Justin Maggard <jmaggard10@gmail.com>
Reviewed-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-29 17:13:58 +01:00
Satoru Takeuchi 0e4e1b1ed9 btrfs-progs: cleanup: avoid to use literal for getopt val
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-19 15:07:02 +01:00
Gui Hecheng 0c13451796 btrfs-progs: skip fs with no seed when build seed/sprout mapping for fi show
There is no need to try to build seed/sprout mapping for those btrfs
without seed devices, so just skip such fs.
We could get the total number of devices from the disk super block, if it
equals the number of items in list @fs_devices->devices, then there shouldn't
be any seed devices.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:13 +01:00
Gui Hecheng e7c4e700ff btrfs-progs: make the search target device routine more clear for fi show
Extract the procedure of searching for a target device for fi show
from the @map_seed_devices() function to make it more clear.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:12 +01:00
David Sterba 84bd55c9cf btrfs-progs: add original 'df' and rename 'disk_usage' to 'usage'
Add back the original output of the 'btrfs fi df' command for backward
compatibility. The rich output is moved from 'disk_usage' to 'usage'.

Agreed in http://www.spinics.net/lists/linux-btrfs/msg31698.html

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:10 +01:00
Goffredo Baroncelli 9002666a2b btrfs-progs: Add command btrfs filesystem disk-usage
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:09 +01:00
Goffredo Baroncelli e12e91e859 btrfs-progs: Enhance the command btrfs filesystem df
Enhance the command "btrfs filesystem df" to show space usage information
for a mount point(s). It shows also an estimation of the space available,
on the basis of the current one used.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
[code moved under #if 0 instead of deletion]
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:09 +01:00
David Sterba 3d1ed6d152 btrfs-progs: move group type and profile pretty printers to utils
Move and add the btrfs_ prefix.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:09 +01:00
Gui Hecheng 8be2fff129 btrfs-progs: apply realpath for btrfs fi show when mount point is given
For now,
	# btrfs fi show /mnt/btrfs
gives info correctly, while
	# btrfs fi show /mnt/btrfs/
gives nothing.

This implies that the @realpath() function should be applied to
unify the behavior.

Made a more clear comment right above the call as well.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-27 18:37:00 +01:00
Gui Hecheng a1c3bcf1c2 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>
2014-11-14 11:02:33 +01:00
David Sterba 0287f03a8c btrfs-progs: use the correct SI prefixes
The SI standard defines lowercase 'k' and uppercase for the rest.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-04 18:22:51 +01:00
Anand Jain 2f55fd7019 btrfs-progs: optimize btrfs_scan_lblkid() for multiple calls
btrfs_scan_lblikd() is called by most the device related command functions.
And btrfs_scan_lblkid() is most expensive function and it becomes more expensive
as number of devices in the system increase. Further some threads call this
function more than once for absolutely no extra benefit and the real waste of
resources. Below list of threads and number of times btrfs_scan_lblkid()
is called in that thread.

  btrfs-find-root            1
  btrfs rescue super-recover 2
  btrfs-debug-tree           1
  btrfs-image -r             2
  btrfs check                2
  btrfs restore              2
  calc-size                  NC
  btrfs-corrupt-block        NC
  btrfs-image                NC
  btrfs-map-logical          1
  btrfs-select-super         NC
  btrfstune                  2
  btrfs-zero-log             NC
  tester                     NC
  quick-test.c               NC
  btrfs-convert              0
  mkfs                       #number of devices to be mkfs
  btrfs label set unmounted  2
  btrfs get label unmounted  2

This patch will:
  move out calling register_one_device with in btrfs_scan_lblkid()
  and so function setting the BTRFS_UPDATE_KERNEL to yes will
  call btrfs_register_all_devices() separately.

  introduce a global variable scan_done, which is set when scan is
  done succssfully per thread. So that following calls to this function
  will just return success.

  Further if any function needs to force scan after scan_done is set,
  then it can be done when there is such a requirement, but as of now there
  isn't any such requirement.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-03 19:17:11 +01:00
Gui Hecheng 8a26f850cd btrfs-progs: skip mounted fs when deal with umounted ones for fi show
Stalling problems may happen when exec balance & fi show cmds concurrently.

With the following commit:
        commit 915902c500
        btrfs-progs: fix device missing of btrfs fi show with seed devices

The fi show cmd will bother the mounted fs when only umounted fs should
be handled after @btrfs_can_kernel() has finished showing all mounted ones.

We could skip the mounted fs after @btrfs_can_kernel() is done, then tasks
keeps going on mounted fs while fi show continues on umounted ones separately.

Reported-by: Petr Janecek <janecek@ucw.cz>
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-03 18:35:31 +01:00
Qu Wenruo ae8f7f687f btrfs-progs: Fix number of arguments check of 'btrfs fi df'
'btrfs fi df' needs exactly one arguments as mount option,
but as 3.17 we can run 'btrfs fi df' without any argument,
and it will error as "ERROR: can't access '%s'" which means
the argument number does not do what it should.

The bug is caused by manually modify the optind and use check_argc_max()
instead of the original check_argc_exact().

This patch fixes it by not modifying the optind and use check_argc_exact()
again.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-03 18:35:30 +01:00
David Sterba 0b90a24e11 btrfs-progs: add options to tune units for fi df output
The size unit format is a longstanding annoyance. This patch is based on
the work of Nils and Alexandre and enhances the options. It's possible
to select raw bytes, SI-based or IEC-based compact units (human
frientdly) or a fixed base from kilobytes to terabytes. The default is
compact human readable IEC-based, no change to current version.

CC: Nils Steinger <nst@voidptr.de>
CC: Alexandre Oliva <oliva@gnu.org>
Reviewed-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-10 18:58:28 +02:00
Gui Hecheng 2513077f2f btrfs-progs: fix device missing of btrfs fi show with seed devices
*Note*
this handles the problem under umounted state, the similar problem
under mounted state is already fixed by Anand.

Steps to reproduce:
        # mkfs.btrfs -f /dev/sda1
        # btrfstune -S 1 /dev/sda1
        # mount /dev/sda1 /mnt
        # btrfs dev add /dev/sda2 /mnt
        # umount /mnt                   <== (umounted)
        # btrfs fi show /dev/sda2
result:
        Label: none  uuid: XXXXXXXXXXXXXXXXXX
        Total devices 2 FS bytes used 368.00KiB
        devid    2 size 9.31GiB used 1.25GiB path /dev/sda2
        *** Some devices missing
        Btrfs v3.16-67-g69f54ea-dirty

It is because @btrfs_scan_lblkid() won't establish mappinig
between the seed and sprout devices. So seeding devices are missing.
We could use @open_ctree_* to detect all seed/sprout mappings
for each fs scanned after @btrfs_scan_lblkid().

sth worthes mention:
o If there are multi-level of seeds, all devices in them will be shown
  in the ascending order of @devid
o If device replace is execed on a sprout fs with a device in a seed fs,
  the replaced device still exist in the seed fs together with
  the replacing device in the sprout fs, so we only keep the latest device
  with the newest generation

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-10 10:52:41 +02:00
Anand Jain 5444864e56 btrfs-progs: remove BTRFS_SCAN_PROC scan method
The libblkid scan method which was introduced later, will also
scan devices under /proc/partitions. So we don't have to do
the explicit scan of the same.

Remove the scan method BTRFS_SCAN_PROC.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-10 10:38:34 +02:00
Eric Sandeen 4e85e48188 btrfs-progs: scan /proc/partitions not all of /dev with "-d"
We can scan for btrfs devices in a few ways.  By default
libblkid is used for "device scan" and "filesystem show";
with the -m option only mounted filesystems are scanned,
and with -d we physically read every system device.

But there's no reason for the complexity of a descent through
/dev; /proc/partitions has every device known to the kernel, so
just use that when -d is specified.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-10 09:32:11 +02:00
David Sterba da5db5596c btrfs-progs: read global reserve size from space infos
Kernels >= 3.15 export the global block reserve as a space info presented
by 'btrfs fi df' but would display 'unknown' instead of some meaningful
string.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-28 02:03:33 +02:00
Satoru Takeuchi cfee4bc139 btrfs-progs: avoid to use numeric literal for the size of uuid buffer
Replace a numeric literal to more descriptive macro for
the size of uuid buffer.

Signed-of-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:55 +02:00
Satoru Takeuchi acf2652649 btrfs-progs: remove unnecessary NULL check after get_df()
If get_df() returns 0, "sargs" surely points to malloc'ed region.
So NULL check of sargs is not necessary.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Qu Wenruo 23d7f6d9dc btrfs-progs: Allow btrfs_read_dev_super() to read all 3 super for super_recover.
Btrfs-progs superblock checksum check is somewhat too restricted for
super-recover, since current btrfs-progs will only read the 1st
superblock and if you need super-recover the 1st superblock is
possibly already damaged.

The fix is introducing super_recover parameter for
btrfs_read_dev_super() and callers to allow scan backup superblocks if
needed.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:04:50 +02:00
Satoru Takeuchi 99ac0d5732 btrfs-progs: Avoid double-free of fs_devices->list
I found the following patch is insufficient.

===============================================================================
commit 6e6b32ddf58db54f714d0f263c2589f4859e8b5e
Author: Adam Buchbinder <abuchbinder@google.com>
Date:   Fri Jun 13 16:43:56 2014 -0700

    btrfs-progs: Fix a use-after-free in the volumes code.
===============================================================================

"btrfs filesystem show <dev>" with this patch causes segmentation fault
if "<dev>" is a not-mounted Btrfs filesystem.

===============================================================================
Label: none  uuid: <cut here>
        Total devices 1 FS bytes used 112.00KiB
        devid    1 size 59.12GiB used 2.04GiB path /dev/sdd1

Segmentation fault (core dumped)
===============================================================================

It's due to double-free of fs_devices->list as follows.

===============================================================================
cmd_show
  -> list_del(&fs_devices->list)     # 1st one.
  -> btrfs_close_devices(fs_devices)
    -> list_del(&fs_devices->list)   # <- 2nd one introduced at 6e6b32dd.
                                          Double-free happens here.
===============================================================================

First list_del() can safely be removed because fs_devices->list will be
deleted by second one, soon.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:43:11 +02:00
Gui Hecheng 3a3e609541 btrfs-progs: update manpage for btrfs resize support size unit t/p/e
btrfs resize now support size unit parse of k/m/g/t/p/e in kernel space,
adopt the changes in userspace manpage.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:34 +02:00
Qu Wenruo ccd14cbf62 btrfs-progs: Fix the return value of btrfs_scan_kernel()
btrfs_scan_kernel() is only used in 'btrfs fi show' but returns wrong
return value.  When search parameter is passed, it will never return 0
even the search can be matched.

This patch will change the whatever strange logic to a more easy to
understand one using 'found' var.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-04-22 14:34:27 +02:00
Rakesh Pandit 40af8f4ae7 Btrfs-progs: return with -ENOMEM if malloc fails
Prevent segfault if memory allocation fails for sargs in get_df
(cmds-filesystem.c).

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-03-21 09:51:31 -07:00
Qu Wenruo 9d57509e99 btrfs-progs: Fix a memleak in btrfs_scan_one_device.
Valgrind reports memleak in btrfs_scan_one_device() about allocating
btrfs_device but on btrfs_close_devices() they are not reclaimed.

Although not a bug since after btrfs_close_devices() btrfs will exit so
memory will be reclaimed by system anyway, it's better to fix it anyway.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-03-21 09:51:31 -07:00
Chris Mason d1fffb0221 btrfs-progs: fix uninit variable in btrfs_scan_kernel
Signed-off-by: Chris Mason <clm@fb.com>
2014-03-21 09:50:47 -07:00
Qu Wenruo 93f4f126ec btrfs-progs: Fix check_arg_type() which doesn't use realpath() result.
Fix a problem that does not use the result of realpath(), which caused
check_arg_type() can't handle mount point which ends with a final '/'.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-03-21 06:23:14 -07:00
Qu Wenruo 206efb60cb btrfs-progs: Add missing devices check for mounted btrfs.
In btrfs/003 of xfstest, it will check whether btrfs fi show can find
missing devices.

But before the patch, btrfs-progs will not check whether device missing
if given a mounted btrfs mountpoint/block device.
This patch fixes the bug and will pass btrfs/003.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-03-21 06:23:10 -07:00
Anand Jain 31f30c9975 btrfs-progs: return non zero when label is not found
btrfs filesystem show <not-found-label> should return non zero

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:34 -08:00
Anand Jain 94abeb46b7 btrfs-progs: lblkid wouldn't find non mapper path input
A new test case when disk is unmounted and if the non mapper
disk path is given as the argument to the btrfs filesystem show <arg>
we still need this to work but lblkid will pull only mapper disks,
it won't match. So this will normalize the input to find btrfs
by fsid and pass it to the search.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:33 -08:00
Mitchel Humpherys ef3f6124f0 btrfs-progs: fix minor grammar issues
Remove the extraneous `to' from `Can't access to X'.

Signed-off-by: Mitchel Humpherys <mitch.special@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:28 -08:00
Pascal VITOUX a2bd44cbc6 btrfs-progs: skip non-regular files while defragmenting
Skip non-regular files to avoid ioctl errors while defragmenting.

They are silently ignored in recursive mode but reported as errors when
used as command-line arguments.

Signed-off-by: Pascal VITOUX <vitoux.pascal@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:23 -08:00
Gui Hecheng d9d9704510 btrfs-progs: fix improper error prompt for defragment
The error msg:
	"ERROR: defrag range ioctl not supported in this kernel,
	 please try without any options."
should only show up when failing to do a range defraging,
not upon non-range defraging.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:13 -08:00
David Sterba 37cd29521a btrfs-progs: call endmntent in btrfs_scan_kernel
btrfs_scan_kernel() does a getmntent() but never releases the
filedescriptor it gets back from that.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64711

Reported-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:07 -08:00
Anand Jain 1ecefced86 btrfs-progs: define BTRFS_UUID_UNPARSE_SIZE for uuid unparse buf size
we use 37 as the allocation size to hold the uuid_unparse, here
it defines BTRFS_UUID_UNPARSE_SIZE for the same.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:03 -08:00
Filipe David Borba Manana 457b1286dd Btrfs-progs: let get_label return the label instead of printing it
get_label prints the label at the moment. Change this so that
the label is returned and printing is done by the caller.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:02 -08:00
Anand Jain a156b967ed btrfs-progs: make filesystem show by label work
with design revamp around filesystem show the fsid filter
by label wasn't planned. but apparently that seemed to be
necessary. this patch will fix it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:21:58 -08:00
Chris Mason 5aff090a39 btrfs filesystem show: skip duplicate fsids
If a given filesystem is mounted more than once, btrfs fi show will
print dups.  This adds a quick and dirty hash table of fsids it
has already printed and makes sure we don't print any fsid more than
once.

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-18 14:27:21 -05:00
Eric Sandeen b68477aee1 btrfs-progs: check for fstat failure in cmd_defrag
Resolves-Coverity-CID: 1125924
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 7e29db9e49 btrfs-progs: pass positive errno to strerror in cmd_df()
get_df returns a negative error number, but then
we pass it to strerror, which wants a positive value...

Resolves-Coverity-CID: 1125929
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00