#include "btrfs-list.h"
#include "cmds-inspect-dump-tree.h"
#include "cmds-inspect-dump-super.h"
+#include "cmds-inspect-tree-stats.h"
static const char * const inspect_cmd_group_usage[] = {
"btrfs inspect-internal <command> <args>",
if (check_argc_exact(argc - optind, 2))
usage(cmd_inspect_subvolid_resolve_usage);
- fd = btrfs_open_dir(argv[optind], &dirstream, 1);
+ fd = btrfs_open_dir(argv[optind + 1], &dirstream, 1);
if (fd < 0) {
ret = -ENOENT;
goto out;
out:
close_file_or_dir(fd, dirstream);
- return ret ? 1 : 0;
+ return !!ret;
}
static const char* const cmd_inspect_rootid_usage[] = {
/*
* List of device extents is sorted by descending order of the extent's
* end offset. If some extent goes beyond the computed minimum size,
- * which initially matches the sum of the lenghts of all extents,
+ * which initially matches the sum of the lengths of all extents,
* we need to check if the extent can be relocated to an hole in the
* device between [0, *min_size[ (which is what the resize ioctl does).
*/
off);
off += sizeof(*sh);
extent = (struct btrfs_dev_extent *)(args.buf + off);
- off += sh->len;
+ off += btrfs_search_header_len(sh);
- sk->min_objectid = sh->objectid;
- sk->min_type = sh->type;
- sk->min_offset = sh->offset + 1;
+ sk->min_objectid = btrfs_search_header_objectid(sh);
+ sk->min_type = btrfs_search_header_type(sh);
+ sk->min_offset = btrfs_search_header_offset(sh) + 1;
- if (sh->objectid != devid ||
- sh->type != BTRFS_DEV_EXTENT_KEY)
+ if (btrfs_search_header_objectid(sh) != devid ||
+ btrfs_search_header_type(sh) != BTRFS_DEV_EXTENT_KEY)
continue;
len = btrfs_stack_dev_extent_length(extent);
min_size += len;
- ret = add_dev_extent(&extents, sh->offset,
- sh->offset + len - 1, 0);
+ ret = add_dev_extent(&extents,
+ btrfs_search_header_offset(sh),
+ btrfs_search_header_offset(sh) + len - 1, 0);
if (!ret && last_pos != (u64)-1 &&
- last_pos != sh->offset)
+ last_pos != btrfs_search_header_offset(sh))
ret = add_dev_extent(&holes, last_pos,
- sh->offset - 1, 1);
+ btrfs_search_header_offset(sh) - 1, 1);
if (ret) {
error("add device extent: %s", strerror(-ret));
ret = 1;
goto out;
}
- last_pos = sh->offset + len;
+ last_pos = btrfs_search_header_offset(sh) + len;
}
if (sk->min_type != BTRFS_DEV_EXTENT_KEY ||
cmd_inspect_dump_tree_usage, NULL, 0 },
{ "dump-super", cmd_inspect_dump_super,
cmd_inspect_dump_super_usage, NULL, 0 },
+ { "tree-stats", cmd_inspect_tree_stats,
+ cmd_inspect_tree_stats_usage, NULL, 0 },
NULL_CMD_STRUCT
}
};