Commit Graph

23 Commits (master)

Author SHA1 Message Date
David Sterba 94fced6353 btrfs-progs: build: drop kernel-lib from -I and update paths
Include the files by full path to avoid any confusion in case of
potentially duplicate names.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
David Sterba c07960c8be btrfs-progs: move utils.[ch] to common/
Update include paths and remove some duplicates.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
David Sterba f93b471143 btrfs-progs: move help.[ch] to common/
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:03 +02:00
David Sterba 4ac63ccbd8 btrfs-progs: help: don't print usage on wrong argument counts
The error message about the unsatisfied argument count is scrolled away
by the full usage string dump. This is not considered a good usability
practice.

This commit switches all direct usage -> return patterns, where the
argument check has no other constraint, eg. dependency on an option.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-03-05 12:57:56 +01:00
Josh Soref 2cd4a76ea9 btrfs-progs: fix typos in user-visible strings
* error messages
* help strings

Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 18:24:49 +01:00
David Sterba e578b59bf6 btrfs-progs: convert strerror to implicit %m
Similar to the changes where strerror(errno) was converted, continue
with the remaining cases where the argument was stored in another
variable.

The savings in object size are about 4500 bytes:

 $ size btrfs.old btrfs.new
   text    data     bss     dec     hex filename
 805055   24248   19748  849051   cf49b btrfs.old
 804527   24248   19748  848523   cf28b btrfs.new

Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo a0d9de4e40 btrfs-progs: Refactor write_all_supers and its callers to use btrfs_fs_info
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-12 17:53:28 +02:00
David Sterba 1c880f34f1 btrfs-progs: move help defines to own header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:45 +01:00
David Sterba 57d1cbd867 btrfs-progs: print help test to stdout
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 3bb71d27ac btrfs-progs: utils: switch more error messages to common helpers
Functions relatd to device changes/status/open, mount checks.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 14:38:16 +01:00
David Sterba 358807cc33 btrfs-progs: unify argc min/max checking
We don't want to modify argc.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
David Sterba 6398ed78f9 btrfs-progs: unify naming of argc and argv
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
Zhao Lei 2b4000c551 btrfs-progs: Add missing close_ctree to btrfs-select-super.c
Add missing close_ctree() to btrfs-select-super.c to avoid memory leak.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
Zhao Lei e72cb5de12 btrfs-progs: Add all missing btrfs_close_all_devices to standalone tools
This patch add all missing btrfs_close_all_devices() to standalone
tools in btrfs progs, to avoid memory leak.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
Karel Zak 33f2d6b84d btrfs-progs: autoconf: use standard PACKAGE_* macros
- use standard PACKAGE_{NAME,VERSION,STRING,URL,...} autoconf macros
  rather than homemade BTRFS_BUILD_VERSION

- don't #include version.h, now the file is necessary for library API only

Note that "btrfs version" returns "btrfs-progs <version>" instead of
the original confusing "btrfs <version>".

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:00:58 +01:00
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
Gui Hecheng f1672e50c7 btrfs-progs: use check_argc_* to check arg number for all tools
Since this patch:
	btrfs-progs: move the check_argc_* functions into utils.c

All tools including the independent tools(e.g. btrfs-image, btrfs-convert)
can share the convenience of the check_argc_* functions, so this patch
adopt the argc check functions globally.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Christian Hesse e2a157f380 btrfs-progs: fix compiler warning
gcc 4.9.0 gives a warning: format ‘%d’ expects argument of type ‘int’,
but argument 2 has type ‘u64’

Using %llu and casting to unsigned long long (same as bytenr) fixes this.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:32 +02:00
Wang Shilong 64fddab8ac Btrfs-progs: switch to arg_strtou64() part3
Switch to new helper arg_strtou64(), also check if user assign
a valid super copy.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-03-21 06:23:20 -07:00
Anand Jain 555ae67390 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>
2013-04-23 18:56:20 +02:00
Danny Kukawka c88c2f52fe btrfs-progs: Handle errors returned from open_ctree
Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2013-01-21 18:27:54 +01:00
Sergei Trofimovich 3d7c94cfec btrfsck: decode error properly
check_mounted() returns kernel-style negative errors.
Patch drops sign for strerror().

Before the patch:
check_mounted(): Could not open /dev/sdb2
Could not check mount status: Unknown error 18446744073709551603

After the patch:
check_mounted(): Could not open /dev/sdb2
Could not check mount status: Permission denied

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2011-10-25 09:18:59 -04:00
Chris Mason b4382217f1 Btrfs-progs: add a btrfs-select-super command to overwrite the super
Btrfs stores multiple copies of the superblock, and for common power-failure
crashes where barriers were not in use, one of the super copies is often
valid while the first copy is not.

This adds a btrfs-select-super -s N /dev/xxx command, which can
overwrite all the super blocks with a copy that you have already
determined is valid with btrfsck -s

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-25 09:18:31 -04:00