summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2017-11-29 16:07:34 +0800
committerDavid Sterba <dsterba@suse.com>2018-01-08 18:15:16 +0100
commit0855a8cd43006c38441729ce950a086745deab16 (patch)
tree4659850ff060c851446889e770b3f282c97a3321 /mkfs
parent1c9c5f7fb3f6a2182d230d469b22b3b1329f24d8 (diff)
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>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mkfs/main.c b/mkfs/main.c
index 16254ee9..94d9ef03 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -720,7 +720,7 @@ int main(int argc, char **argv)
u32 stripesize = 4096;
int zero_end = 1;
int fd = -1;
- int ret;
+ int ret = 0;
int close_ret;
int i;
int mixed = 0;
@@ -888,7 +888,9 @@ int main(int argc, char **argv)
while (dev_cnt-- > 0) {
file = argv[optind++];
- if (is_block_device(file) == 1)
+ if (source_dir_set && is_path_exist(file) == 0)
+ ret = 0;
+ else if (is_block_device(file) == 1)
ret = test_dev_for_mkfs(file, force_overwrite);
else
ret = test_status_for_mkfs(file, force_overwrite);