mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-09 14:17:03 +00:00
Btrfs-progs: add option to btrfs-debug-tree to print uuid tree only
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
parent
1ff26009b3
commit
6634da9c9a
@ -30,13 +30,14 @@
|
|||||||
|
|
||||||
static int print_usage(void)
|
static int print_usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: btrfs-debug-tree [ -e ] [ -d ] [ -r ] [ -R ]\n");
|
fprintf(stderr, "usage: btrfs-debug-tree [-e] [-d] [-r] [-R] [-u]\n");
|
||||||
fprintf(stderr, " [-b block_num ] device\n");
|
fprintf(stderr, " [-b block_num ] device\n");
|
||||||
fprintf(stderr, "\t-e : print detailed extents info\n");
|
fprintf(stderr, "\t-e : print detailed extents info\n");
|
||||||
fprintf(stderr, "\t-d : print info of btrfs device and root tree dirs"
|
fprintf(stderr, "\t-d : print info of btrfs device and root tree dirs"
|
||||||
" only\n");
|
" only\n");
|
||||||
fprintf(stderr, "\t-r : print info of roots only\n");
|
fprintf(stderr, "\t-r : print info of roots only\n");
|
||||||
fprintf(stderr, "\t-R : print info of roots and root backups\n");
|
fprintf(stderr, "\t-R : print info of roots and root backups\n");
|
||||||
|
fprintf(stderr, "\t-u : print info of uuid tree only\n");
|
||||||
fprintf(stderr, "\t-b block_num : print info of the specified block"
|
fprintf(stderr, "\t-b block_num : print info of the specified block"
|
||||||
" only\n");
|
" only\n");
|
||||||
fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
|
fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
|
||||||
@ -129,6 +130,7 @@ int main(int ac, char **av)
|
|||||||
int slot;
|
int slot;
|
||||||
int extent_only = 0;
|
int extent_only = 0;
|
||||||
int device_only = 0;
|
int device_only = 0;
|
||||||
|
int uuid_tree_only = 0;
|
||||||
int roots_only = 0;
|
int roots_only = 0;
|
||||||
int root_backups = 0;
|
int root_backups = 0;
|
||||||
u64 block_only = 0;
|
u64 block_only = 0;
|
||||||
@ -138,7 +140,7 @@ int main(int ac, char **av)
|
|||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int c;
|
int c;
|
||||||
c = getopt(ac, av, "deb:rR");
|
c = getopt(ac, av, "deb:rRu");
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
switch(c) {
|
switch(c) {
|
||||||
@ -151,6 +153,9 @@ int main(int ac, char **av)
|
|||||||
case 'r':
|
case 'r':
|
||||||
roots_only = 1;
|
roots_only = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
uuid_tree_only = 1;
|
||||||
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
roots_only = 1;
|
roots_only = 1;
|
||||||
root_backups = 1;
|
root_backups = 1;
|
||||||
@ -201,7 +206,7 @@ int main(int ac, char **av)
|
|||||||
goto close_root;
|
goto close_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extent_only) {
|
if (!(extent_only || uuid_tree_only)) {
|
||||||
if (roots_only) {
|
if (roots_only) {
|
||||||
printf("root tree: %llu level %d\n",
|
printf("root tree: %llu level %d\n",
|
||||||
(unsigned long long)info->tree_root->node->start,
|
(unsigned long long)info->tree_root->node->start,
|
||||||
@ -250,7 +255,7 @@ again:
|
|||||||
if (btrfs_key_type(&found_key) == BTRFS_ROOT_ITEM_KEY) {
|
if (btrfs_key_type(&found_key) == BTRFS_ROOT_ITEM_KEY) {
|
||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
struct extent_buffer *buf;
|
struct extent_buffer *buf;
|
||||||
int skip = extent_only | device_only;
|
int skip = extent_only | device_only | uuid_tree_only;
|
||||||
|
|
||||||
offset = btrfs_item_ptr_offset(leaf, slot);
|
offset = btrfs_item_ptr_offset(leaf, slot);
|
||||||
read_extent_buffer(leaf, &ri, offset, sizeof(ri));
|
read_extent_buffer(leaf, &ri, offset, sizeof(ri));
|
||||||
@ -268,9 +273,9 @@ again:
|
|||||||
printf("root");
|
printf("root");
|
||||||
break;
|
break;
|
||||||
case BTRFS_EXTENT_TREE_OBJECTID:
|
case BTRFS_EXTENT_TREE_OBJECTID:
|
||||||
if (!device_only)
|
if (!device_only && !uuid_tree_only)
|
||||||
skip = 0;
|
skip = 0;
|
||||||
if (!extent_only && !device_only)
|
if (!skip)
|
||||||
printf("extent");
|
printf("extent");
|
||||||
break;
|
break;
|
||||||
case BTRFS_CHUNK_TREE_OBJECTID:
|
case BTRFS_CHUNK_TREE_OBJECTID:
|
||||||
@ -279,7 +284,9 @@ again:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BTRFS_DEV_TREE_OBJECTID:
|
case BTRFS_DEV_TREE_OBJECTID:
|
||||||
|
if (!uuid_tree_only)
|
||||||
skip = 0;
|
skip = 0;
|
||||||
|
if (!skip)
|
||||||
printf("device");
|
printf("device");
|
||||||
break;
|
break;
|
||||||
case BTRFS_FS_TREE_OBJECTID:
|
case BTRFS_FS_TREE_OBJECTID:
|
||||||
@ -331,6 +338,12 @@ again:
|
|||||||
printf("quota");
|
printf("quota");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case BTRFS_UUID_TREE_OBJECTID:
|
||||||
|
if (!extent_only && !device_only)
|
||||||
|
skip = 0;
|
||||||
|
if (!skip)
|
||||||
|
printf("uuid");
|
||||||
|
break;
|
||||||
case BTRFS_MULTIPLE_OBJECTIDS:
|
case BTRFS_MULTIPLE_OBJECTIDS:
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
printf("multiple");
|
printf("multiple");
|
||||||
@ -369,7 +382,7 @@ no_node:
|
|||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extent_only || device_only)
|
if (extent_only || device_only || uuid_tree_only)
|
||||||
goto close_root;
|
goto close_root;
|
||||||
|
|
||||||
if (root_backups)
|
if (root_backups)
|
||||||
|
Loading…
Reference in New Issue
Block a user