Commit Graph

15 Commits (2cd4a76ea9914c35b0fb614ad68aa9aefd7e5dd7)

Author SHA1 Message Date
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 7fb70440cf btrfs-progs: Fix wrong optind re-initialization to allow mixed option and non-option
In function handle_global_options(), we reset @optind to 1.
However according to man page of getopt(3) NOTES section, if we need to
rescan options later, @optind should be reset to 0 to initialize the
internal variables correctly.

This explains the reason why in cmd_check(), getopt_long() doesn't
handle the following command correctly:
"btrfs check /dev/data/btrfs --check-data-csum"

While mkfs.btrfs handles mixed non-option and option correctly:
"mkfs.btrfs -f /dev/data/disk1 --data raid1 /dev/data/disk2"

Cc: Paul Jones <paul@pauljones.id.au>
Cc: Hugo Mills <hugo@carfax.org.uk>
Fixes: 010ceab56e ("btrfs-progs: rework option parser to use getopt for global options")
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-08-06 14:59:45 +02:00
Rosen Penev e4df433b8a btrfs-progs: treewide: Replace strerror(errno) with %m.
As btrfs is specific to Linux, %m can be used instead of strerror(errno)
in format strings. This has some size reduction benefits for embedded
systems.

glibc, musl, and uclibc-ng all support %m as a modifier to printf.
A quick glance at the BIONIC libc source indicates that it has
support for %m as well. BSDs and Windows do not but I do believe
them to be beyond the scope of btrfs-progs.

Compiled sizes on Ubuntu 16.04:

Before:
3916512 btrfs
233688  libbtrfs.so.0.1
4899    bcp
2367672 btrfs-convert
2208488 btrfs-corrupt-block
13302   btrfs-debugfs
2152160 btrfs-debug-tree
2136024 btrfs-find-root
2287592 btrfs-image
2144600 btrfs-map-logical
2130760 btrfs-select-super
2152608 btrfstune
2131760 btrfs-zero-log
2277752 mkfs.btrfs
9166    show-blocks

After:
3908744 btrfs
233256  libbtrfs.so.0.1
4899    bcp
2366560 btrfs-convert
2207432 btrfs-corrupt-block
13302   btrfs-debugfs
2151104 btrfs-debug-tree
2134968 btrfs-find-root
2281864 btrfs-image
2143536 btrfs-map-logical
2129704 btrfs-select-super
2151552 btrfstune
2130696 btrfs-zero-log
2276272 mkfs.btrfs
9166    show-blocks

Total savings: 23928 (24 kilo)bytes

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-31 15:14:03 +01:00
David Sterba 98909c21d7 btrfs-progs: drop blocksize from read_tree_block
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba a67efe4362 btrfs-progs: move command definitions to commands.h
There are some trivial helpers, we can group the command declarations in
one place.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:08:24 +02:00
Qu Wenruo 8690c887d1 btrfs-progs: Refactor read_tree_block to get rid of btrfs_root
The only reasom read_tree_block() needs a btrfs_root parameter is to get
its node/sector size.

And long ago, I have already introduced a compactible interface,
read_tree_block_fs_info() to pass btrfs_fs_info instead of btrfs_root.

Since we have cleaned up all root->sector/node/stripesize users, we
should be OK to refactor read_tree_block() function.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
2017-07-03 13:35:11 +02:00
Qu Wenruo b2615be24a btrfs-progs: Refactor nodesize users in cmds-inspect-tree-stats.c
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
2017-07-03 13:35:10 +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 951e6276e6 btrfs-progs: tree-stats: use on-stack path buffer in calc_root_size
We don't need to conserve stack space too much unlike kernel, also
remove one error condition.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:47:33 +01:00
David Sterba acf978a2d4 btrfs-progs: tree-stats: switch to common message helpers
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 11:33:14 +02:00
David Sterba 253cd12f41 btrfs-progs: tree-stats: check and report mount status
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:47:55 +02:00
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 3be6e3e7c9 btrfs-progs: deprecate and stop using btrfs_level_size
Size of a b-tree node is always nodesize, regardless of the level.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:40:23 +02:00
David Sterba 2a796d84af btrfs-progs: replace leafsize with nodesize
Nodesize is used in kernel, the values are always equal. We have to keep
leafsize in headers, similarly the tree setting functions still take and
set leafsize, but it's effectively a no-op.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:40:18 +02:00
Alexander Fougner d4abd0bfb0 btrfs-progs: copy btrfs-calc-size to inspect-internal tree-stats
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:39:53 +02:00