From 6a0440391da7a99ffab94ccc66264af9b5f3ce34 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Mon, 31 Jul 2017 14:54:24 +0100 Subject: New upstream release. --- cmds-inspect-dump-super.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'cmds-inspect-dump-super.c') diff --git a/cmds-inspect-dump-super.c b/cmds-inspect-dump-super.c index ba0d708e..98e0270a 100644 --- a/cmds-inspect-dump-super.c +++ b/cmds-inspect-dump-super.c @@ -34,13 +34,14 @@ #include "commands.h" #include "crc32c.h" #include "cmds-inspect-dump-super.h" +#include "help.h" static int check_csum_sblock(void *sb, int csum_size) { u8 result[BTRFS_CSUM_SIZE]; u32 crc = ~(u32)0; - crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE, + crc = btrfs_csum_data((char *)sb + BTRFS_CSUM_SIZE, crc, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); btrfs_csum_final(crc, result); @@ -64,13 +65,21 @@ static void print_sys_chunk_array(struct btrfs_super_block *sb) buf = malloc(sizeof(*buf) + sizeof(*sb)); if (!buf) { error("not enough memory"); - goto out; + return; } write_extent_buffer(buf, sb, 0, sizeof(*sb)); + buf->len = sizeof(*sb); array_size = btrfs_super_sys_array_size(sb); array_ptr = sb->sys_chunk_array; sb_array_offset = offsetof(struct btrfs_super_block, sys_chunk_array); + + if (array_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) { + error("sys_array_size %u shouldn't exceed %u bytes", + array_size, BTRFS_SYSTEM_CHUNK_ARRAY_SIZE); + goto out; + } + cur_offset = 0; item = 0; @@ -123,8 +132,8 @@ static void print_sys_chunk_array(struct btrfs_super_block *sb) item++; } - free(buf); out: + free(buf); return; out_short_read: @@ -388,8 +397,8 @@ static void dump_superblock(struct btrfs_super_block *sb, int full) (unsigned long long)btrfs_super_sectorsize(sb)); printf("nodesize\t\t%llu\n", (unsigned long long)btrfs_super_nodesize(sb)); - printf("leafsize\t\t%llu\n", - (unsigned long long)btrfs_super_leafsize(sb)); + printf("leafsize (deprecated)\t\t%u\n", + le32_to_cpu(sb->__unused_leafsize)); printf("stripesize\t\t%llu\n", (unsigned long long)btrfs_super_stripesize(sb)); printf("root_dir\t\t%llu\n", -- cgit v1.2.3