{
u16 num_stripes = btrfs_chunk_num_stripes(eb, chunk);
int i;
- u32 chunk_item_size = btrfs_chunk_item_size(num_stripes);
+ u32 chunk_item_size;
char chunk_flags_str[32] = {0};
+ /* The chunk must contain at least one stripe */
+ if (num_stripes < 1) {
+ printf("invalid num_stripes: %u\n", num_stripes);
+ return;
+ }
+
+ chunk_item_size = btrfs_chunk_item_size(num_stripes);
+
if ((unsigned long)chunk + chunk_item_size > eb->len) {
printf("\t\tchunk item invalid\n");
return;
case BTRFS_COMPRESS_LZO:
strcpy(ret, "lzo");
break;
+ case BTRFS_COMPRESS_ZSTD:
+ strcpy(ret, "zstd");
+ break;
default:
sprintf(ret, "UNKNOWN.%d", compress_type);
}
}
}
+static void print_temporary_item(struct extent_buffer *eb, void *ptr,
+ u64 objectid, u64 offset)
+{
+ printf("\t\ttemporary item objectid ");
+ print_objectid(stdout, objectid, BTRFS_TEMPORARY_ITEM_KEY);
+ printf(" offset %llu\n", (unsigned long long)offset);
+ switch (objectid) {
+ case BTRFS_BALANCE_OBJECTID:
+ print_balance_item(eb, ptr);
+ break;
+ default:
+ printf("\t\tunknown temporary item objectid %llu\n", objectid);
+ }
+}
+
+static void print_extent_csum(struct extent_buffer *eb,
+ struct btrfs_fs_info *fs_info, u32 item_size, u64 start)
+{
+ u32 size;
+
+ size = (item_size / btrfs_super_csum_size(fs_info->super_copy)) *
+ fs_info->sectorsize;
+ printf("\t\trange start %llu end %llu length %u\n",
+ (unsigned long long)start,
+ (unsigned long long)start + size, size);
+}
+
/* Caller must ensure sizeof(*ret) >= 14 "WRITTEN|RELOC" */
static void header_flags_to_str(u64 flags, char *ret)
{
printf("\t\tcsum item\n");
break;
case BTRFS_EXTENT_CSUM_KEY:
- printf("\t\textent csum item\n");
+ print_extent_csum(eb, root->fs_info, item_size,
+ offset);
break;
case BTRFS_EXTENT_DATA_KEY:
print_file_extent_item(eb, item, i, ptr);
offset);
break;
case BTRFS_TEMPORARY_ITEM_KEY:
- printf("\t\ttemporary item objectid ");
- print_objectid(stdout, objectid, BTRFS_TEMPORARY_ITEM_KEY);
- printf(" offset %llu\n", (unsigned long long)offset);
- switch (objectid) {
- case BTRFS_BALANCE_OBJECTID:
- print_balance_item(eb, ptr);
- break;
- default:
- printf("\t\tunknown temporary item objectid %llu\n",
- objectid);
- }
+ print_temporary_item(eb, ptr, objectid, offset);
break;
};
fflush(stdout);