summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-04-07 19:09:39 +0200
committerDavid Sterba <dsterba@suse.cz>2015-04-07 19:09:39 +0200
commit445ed1f11ce3c49c6ac180e90dcff569757c56dc (patch)
tree7757488dba24fed9c1aee951cbd4d766f5083ce3
parent54d316b5ecb1be4e7ae18160bb23c139b84951be (diff)
btrfs-progs: convert: use exact size for reading superblock
We've passed blocksize to prepare_system_chunk and used it to read and write superblock. While this does not cause a bug (SUPER_INFO is blocksize ie. page size on most arches), we should really use the correct size. Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--btrfs-convert.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index d742307d..b176f7b6 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -1799,20 +1799,20 @@ static int prepare_system_chunk_sb(struct btrfs_super_block *super)
return 0;
}
-static int prepare_system_chunk(int fd, u64 sb_bytenr, u32 sectorsize)
+static int prepare_system_chunk(int fd, u64 sb_bytenr)
{
int ret;
struct extent_buffer *buf;
struct btrfs_super_block *super;
- BUG_ON(sectorsize < sizeof(*super));
- buf = malloc(sizeof(*buf) + sectorsize);
+ BUG_ON(BTRFS_SUPER_INFO_SIZE < sizeof(*super));
+ buf = malloc(sizeof(*buf) + BTRFS_SUPER_INFO_SIZE);
if (!buf)
return -ENOMEM;
- buf->len = sectorsize;
- ret = pread(fd, buf->data, sectorsize, sb_bytenr);
- if (ret != sectorsize)
+ buf->len = BTRFS_SUPER_INFO_SIZE;
+ ret = pread(fd, buf->data, BTRFS_SUPER_INFO_SIZE, sb_bytenr);
+ if (ret != BTRFS_SUPER_INFO_SIZE)
goto fail;
super = (struct btrfs_super_block *)buf->data;
@@ -1824,8 +1824,8 @@ static int prepare_system_chunk(int fd, u64 sb_bytenr, u32 sectorsize)
goto fail;
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
- ret = pwrite(fd, buf->data, sectorsize, sb_bytenr);
- if (ret != sectorsize)
+ ret = pwrite(fd, buf->data, BTRFS_SUPER_INFO_SIZE, sb_bytenr);
+ if (ret != BTRFS_SUPER_INFO_SIZE)
goto fail;
ret = 0;
@@ -2330,7 +2330,7 @@ static int do_convert(const char *devname, int datacsum, int packing, int noxatt
goto fail;
}
/* create a system chunk that maps the whole device */
- ret = prepare_system_chunk(fd, super_bytenr, blocksize);
+ ret = prepare_system_chunk(fd, super_bytenr);
if (ret) {
fprintf(stderr, "unable to update system chunk\n");
goto fail;