summaryrefslogtreecommitdiff
path: root/cmds-inspect-dump-super.c
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2017-07-31 14:54:24 +0100
committerDimitri John Ledkov <xnox@ubuntu.com>2017-07-31 14:54:24 +0100
commit6a0440391da7a99ffab94ccc66264af9b5f3ce34 (patch)
tree1c7cf4f07b08c4965ab19819ebce367be16fb980 /cmds-inspect-dump-super.c
parent5f2e2384443a09e3f1fec71940e9e32b70789102 (diff)
New upstream release.
Diffstat (limited to 'cmds-inspect-dump-super.c')
-rw-r--r--cmds-inspect-dump-super.c19
1 files changed, 14 insertions, 5 deletions
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",