summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-11-19 15:55:05 +0100
committerDavid Sterba <dsterba@suse.com>2015-11-19 16:00:31 +0100
commitbf1ac8305ab3f191d9345793b88c4f5ec691cb9b (patch)
treedfcb8551a6a5f080cc5323f98e7daeefbda59e7a /utils.c
parent37a3f647569eb7f944a8ac65dc8763bbb877628d (diff)
btrfs-progs: mkfs: use correct size for superblock csum and writeout
If sectorsize is not BTRFS_SUPER_INFO_SIZE (4k), the superblock checksum is wrong and mkfs fails. This has been reported on ppc64 where we pick sectorisize from page size (64k). This has been broken since ages (2008) and discovered by the recently added superblock checks. Reported-by: Dinar Valeev <dvaleev@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/utils.c b/utils.c
index 60235d84..13835051 100644
--- a/utils.c
+++ b/utils.c
@@ -552,12 +552,12 @@ 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, cfg->sectorsize);
+ memset(buf->data, 0, BTRFS_SUPER_INFO_SIZE);
memcpy(buf->data, &super, sizeof(super));
- buf->len = cfg->sectorsize;
+ buf->len = BTRFS_SUPER_INFO_SIZE;
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
- ret = pwrite(fd, buf->data, cfg->sectorsize, cfg->blocks[0]);
- if (ret != cfg->sectorsize) {
+ ret = pwrite(fd, buf->data, BTRFS_SUPER_INFO_SIZE, cfg->blocks[0]);
+ if (ret != BTRFS_SUPER_INFO_SIZE) {
ret = (ret < 0 ? -errno : -EIO);
goto out;
}