summaryrefslogtreecommitdiff
path: root/mkfs.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-08-22 16:31:11 +0200
committerDavid Sterba <dsterba@suse.com>2016-08-24 14:36:58 +0200
commit974cfeeebb42b4911737876241c13dd12685b412 (patch)
tree540eedd541d86d90937e31d1c4bea22b6ed2117b /mkfs.c
parent3c350dec06da272fed7ef1ea0eb5031131c77671 (diff)
btrfs-progs: mkfs: do not scan partially initialized devices
We call scan ioctl on the devices too early, when most of the filesystem structures are not yet created. Move the registration to the end, after the filesystem gets closed. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'mkfs.c')
-rw-r--r--mkfs.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/mkfs.c b/mkfs.c
index 1f209b54..0b081dd4 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1748,9 +1748,6 @@ int main(int argc, char **argv)
exit(1);
}
- if (is_block_device(file) == 1)
- btrfs_register_one_device(file);
-
if (dev_cnt == 0)
goto raid_groups;
@@ -1796,9 +1793,6 @@ int main(int argc, char **argv)
printf("adding device %s id %llu\n", file,
(unsigned long long)device->devid);
}
-
- if (is_block_device(file) == 1)
- btrfs_register_one_device(file);
}
raid_groups:
@@ -1867,6 +1861,15 @@ raid_groups:
out:
ret = close_ctree(root);
BUG_ON(ret);
+
+ optind = saved_optind;
+ dev_cnt = argc - optind;
+ while (dev_cnt-- > 0) {
+ file = argv[optind++];
+ if (is_block_device(file) == 1)
+ btrfs_register_one_device(file);
+ }
+
btrfs_close_all_devices();
free(label);
return 0;