projects
/
platform
/
upstream
/
btrfs-progs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
btrfs-progs: check: introduce traversal function for fsck
[platform/upstream/btrfs-progs.git]
/
cmds-inspect.c
diff --git
a/cmds-inspect.c
b/cmds-inspect.c
index
04e1ae8
..
4b7cea0
100644
(file)
--- a/
cmds-inspect.c
+++ b/
cmds-inspect.c
@@
-33,6
+33,7
@@
#include "btrfs-list.h"
#include "cmds-inspect-dump-tree.h"
#include "cmds-inspect-dump-super.h"
#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>",
static const char * const inspect_cmd_group_usage[] = {
"btrfs inspect-internal <command> <args>",
@@
-95,7
+96,6
@@
static int cmd_inspect_inode_resolve(int argc, char **argv)
int ret;
DIR *dirstream = NULL;
int ret;
DIR *dirstream = NULL;
- optind = 1;
while (1) {
int c = getopt(argc, argv, "v");
if (c < 0)
while (1) {
int c = getopt(argc, argv, "v");
if (c < 0)
@@
-150,7
+150,6
@@
static int cmd_inspect_logical_resolve(int argc, char **argv)
char *path_ptr;
DIR *dirstream = NULL;
char *path_ptr;
DIR *dirstream = NULL;
- optind = 1;
while (1) {
int c = getopt(argc, argv, "Pvs:");
if (c < 0)
while (1) {
int c = getopt(argc, argv, "Pvs:");
if (c < 0)
@@
-273,7
+272,7
@@
static int cmd_inspect_subvolid_resolve(int argc, char **argv)
if (check_argc_exact(argc - optind, 2))
usage(cmd_inspect_subvolid_resolve_usage);
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;
if (fd < 0) {
ret = -ENOENT;
goto out;
@@
-293,7
+292,7
@@
static int cmd_inspect_subvolid_resolve(int argc, char **argv)
out:
close_file_or_dir(fd, dirstream);
out:
close_file_or_dir(fd, dirstream);
- return
ret ? 1 : 0
;
+ return
!!ret
;
}
static const char* const cmd_inspect_rootid_usage[] = {
}
static const char* const cmd_inspect_rootid_usage[] = {
@@
-322,7
+321,7
@@
static int cmd_inspect_rootid(int argc, char **argv)
ret = lookup_ino_rootid(fd, &rootid);
if (ret) {
ret = lookup_ino_rootid(fd, &rootid);
if (ret) {
- error("
rootid failed with ret=%d", ret
);
+ error("
failed to lookup root id: %s", strerror(-ret)
);
goto out;
}
goto out;
}
@@
-414,7
+413,7
@@
static void adjust_dev_min_size(struct list_head *extents,
/*
* List of device extents is sorted by descending order of the extent's
* end offset. If some extent goes beyond the computed minimum size,
/*
* 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 leng
ht
s of all extents,
+ * which initially matches the sum of the leng
th
s 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).
*/
* 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).
*/
@@
-536,32
+535,33
@@
static int print_min_dev_size(int fd, u64 devid)
off);
off += sizeof(*sh);
extent = (struct btrfs_dev_extent *)(args.buf + off);
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;
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 &&
if (!ret && last_pos != (u64)-1 &&
- last_pos !=
sh->offset
)
+ last_pos !=
btrfs_search_header_offset(sh)
)
ret = add_dev_extent(&holes, last_pos,
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;
}
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 ||
}
if (sk->min_type != BTRFS_DEV_EXTENT_KEY ||
@@
-640,6
+640,8
@@
const struct cmd_group inspect_cmd_group = {
cmd_inspect_dump_tree_usage, NULL, 0 },
{ "dump-super", cmd_inspect_dump_super,
cmd_inspect_dump_super_usage, NULL, 0 },
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
}
};
NULL_CMD_STRUCT
}
};