diff options
author | Anand Jain <anand.jain@oracle.com> | 2013-12-18 12:07:55 +0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-01-31 08:22:21 -0800 |
commit | d89437893266332cce295c06c9d00b79aa5b4dd6 (patch) | |
tree | 415b50a673c6c6e49c5bc3403f654ddd5631b9ab /mkfs.c | |
parent | b5a09775c6e3dd6c842764b026e1764a057b7dfd (diff) |
btrfs-progs: handle error in the btrfs_prepare_device
this patch will handle the strerror reporting of the error instead of
printing errno, and also replaced the BUG_ON with the error handling
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'mkfs.c')
-rw-r--r-- | mkfs.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1445,6 +1445,10 @@ int main(int ac, char **av) first_file = file; ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count, block_count, &mixed, discard); + if (ret) { + close(fd); + exit(1); + } if (block_count && block_count > dev_block_count) { fprintf(stderr, "%s is smaller than requested size\n", file); exit(1); @@ -1552,8 +1556,11 @@ int main(int ac, char **av) } ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count, block_count, &mixed, discard); + if (ret) { + close(fd); + exit(1); + } mixed = old_mixed; - BUG_ON(ret); ret = btrfs_add_to_fsid(trans, root, fd, file, dev_block_count, sectorsize, sectorsize, sectorsize); |