btrfs-progs: mkfs: fix regression preventing --rootdir to create file
authorQu Wenruo <wqu@suse.com>
Wed, 29 Nov 2017 08:07:34 +0000 (16:07 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jan 2018 17:15:16 +0000 (18:15 +0100)
commit0855a8cd43006c38441729ce950a086745deab16
tree4659850ff060c851446889e770b3f282c97a3321
parent1c9c5f7fb3f6a2182d230d469b22b3b1329f24d8
btrfs-progs: mkfs: fix regression preventing --rootdir to create file

Commit 460e93f25754 ("btrfs-progs: mkfs: check the status of file at mkfs")
will try to check the file state before creating fs on it.

The check is mostly fine for normal mkfs case, while for --rootdir
option, it's allowed to create a new file if the destination file
doesn't exist.

Fix it by allowing non-existent file if --rootdir is specified.

Fixes: 460e93f25754 ("btrfs-progs: mkfs: check the status of file at mkfs")
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
mkfs/main.c
utils.c
utils.h