{
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);
}
case BTRFS_UUID_KEY_RECEIVED_SUBVOL:
printf(" 0x%016llx)", (unsigned long long)offset);
break;
+
+ /*
+ * Key offsets of ROOT_ITEM point to tree root, print them in human
+ * readable format. Especially useful for trees like data/tree reloc
+ * tree, whose tree id can be negative.
+ */
+ case BTRFS_ROOT_ITEM_KEY:
+ printf(" ");
+ print_objectid(stdout, offset, type);
+ printf(")");
+ break;
default:
if (offset == (u64)-1)
printf(" -1)");
break;
case BTRFS_EXTENT_CSUM_KEY:
print_extent_csum(eb, root->fs_info, item_size,
- disk_key.offset);
+ offset);
break;
case BTRFS_EXTENT_DATA_KEY:
print_file_extent_item(eb, item, i, ptr);