btrfs-progs: mkfs: check for sane sectorsize earlier

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2016-08-31 20:16:35 +02:00
parent 976f6adfb5
commit b318553f33
2 changed files with 6 additions and 1 deletions

6
mkfs.c
View File

@ -1636,6 +1636,12 @@ int main(int argc, char **argv)
features))
exit(1);
if (sectorsize < sizeof(struct btrfs_super_block)) {
error("sectorsize smaller than superblock: %u < %zu",
sectorsize, sizeof(struct btrfs_super_block));
exit(1);
}
/* Check device/block_count after the nodesize is determined */
if (block_count && block_count < btrfs_min_dev_size(nodesize)) {
error("size %llu is too small to make a usable filesystem",

View File

@ -1420,7 +1420,6 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg,
}
/* and write out the super block */
BUG_ON(sizeof(super) > cfg->sectorsize);
memset(buf->data, 0, BTRFS_SUPER_INFO_SIZE);
memcpy(buf->data, &super, sizeof(super));
buf->len = BTRFS_SUPER_INFO_SIZE;