Commit Graph

11 Commits

Author SHA1 Message Date
Nicholas D Steeves bd2cc320af btrfs-progs: typo review of strings and comments
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba 9971f00edd btrfs-progs: fi du: switch to negative error codes
We're using the kernel-style negative error numbers.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:53:15 +02:00
Austin S. Hemmelgarn 1c36022fe7 btrfs-progs: fix fi du so it works in more cases
Currently, btrfs fi du uses open_file_or_dir(), which tries to open
it's argument with O_RDWR.  Because of POSIX semantics, this fails for
non-root users when the file is read-only or is an executable that
is being run currently, or for all users (including root) when the
filesystem is read-only.  This results in a somewhat confusing 'Unknown
error -1' message when trying to check such files.  Switch to using
open_file_or_dir3() with O_RDONLY passed in the flags, as this avoids
the limitations listed above, and we have no need to write to the files
anyway (and thus shouldn't be opening them writable).

Signed-off-by: Austin S. Hemmelgarn <ahferroin7@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-30 16:22:53 +02:00
Alexander Fougner f7fb93d558 btrfs-progs: fi du: fix incorrect column order
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-18 14:29:26 +01:00
David Sterba 4685a56081 btrfs-progs: fi du: make the output more aligned
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-15 19:00:57 +01:00
David Sterba b44d130828 btrfs-progs: fi du: update help text
Move the command-specific options to the beginning, add missing long
option.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-15 18:25:05 +01:00
David Sterba d66d44eacb btrfs-progs: switch more error messages to common helpers
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
David Sterba aad4b1f081 btrfs-progs: fi du: add long options for units
Drop -h, add just the common long options for now.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
David Sterba 54dea513c6 btrfs-progs: fi du: switch to u64
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
Mark Fasheh bc23667bd2 btrfs-progs: fi du: Calculate space shared by each directory arguments file set
Here we define each file set as those found by a recursive search of a
single directory argument to btrfs fi du.

This isn't as simple as adding up shared extents - they may be shared with
each other, and may also overlap. This patch uses an interval tree to store
shared extents we find while fiemapping files. After collecting them, a 'set
shared' count is calculated by summing (without overlap) each shared region
discovered. This is then displayed to the user as 'set shared'.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
Mark Fasheh a2e7ff1eae btrfs-progs: filesystem: add 'du' command
'btrfs du' differs from regular du in that it will work to resolve which
blocks are shared between files in its list. This gives the user a more
accurate bytecount from which they can make decisions regarding management
of their file space.

We still print a total number of bytes counted (like regular du), but also
print the number of bytes which were found to have been shared amongst the
file set provided. From there it becomes trivial to calculate how much space
is exclusively owned.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
[ rename files to reflect the filesystem command group, add GPL v2
  file headers ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00