btrfs-progs: mkfs: Use the whole file or block device to mkfs for rootdir
authorQu Wenruo <wqu@suse.com>
Wed, 29 Nov 2017 08:42:05 +0000 (16:42 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jan 2018 17:15:20 +0000 (18:15 +0100)
commit1733989352244572a0a53862c9377d21cbbcecf7
tree1db0d547adbcb257a1bf6b82b407c35b9ac8418d
parent0ca2f5a7241373c660946802b0d7f8305234c286
btrfs-progs: mkfs: Use the whole file or block device to mkfs for rootdir

For --rootdir, even for large existing file or block device, it will
always shrink the resulting filesystem.

The problem is, mkfs.btrfs will try to calculate the dir size, and use
it as @block_count to mkfs, which makes the filesystem shrunk.

Fix it by trying to get the original block device or file size as
@block_count, so mkfs.btrfs can use the full file/block device for
--rootdir option.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
mkfs/main.c
utils.c
utils.h