mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-25 20:47:58 +00:00
btrfs-progs: print-tree: Print hex and human readable root flags
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
44e2b7a7e5
commit
1c202eb06d
15
print-tree.c
15
print-tree.c
@ -496,18 +496,31 @@ static int count_bytes(void *buf, int len, char b)
|
|||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Caller must ensure sizeof(*ret) >= 7 "RDONLY"
|
||||||
|
*/
|
||||||
|
static void root_flags_to_str(u64 flags, char *ret)
|
||||||
|
{
|
||||||
|
if (flags & BTRFS_ROOT_SUBVOL_RDONLY)
|
||||||
|
strcat(ret, "RDONLY");
|
||||||
|
else
|
||||||
|
strcat(ret, "none");
|
||||||
|
}
|
||||||
|
|
||||||
static void print_root(struct extent_buffer *leaf, int slot)
|
static void print_root(struct extent_buffer *leaf, int slot)
|
||||||
{
|
{
|
||||||
struct btrfs_root_item *ri;
|
struct btrfs_root_item *ri;
|
||||||
struct btrfs_root_item root_item;
|
struct btrfs_root_item root_item;
|
||||||
int len;
|
int len;
|
||||||
char uuid_str[BTRFS_UUID_UNPARSED_SIZE];
|
char uuid_str[BTRFS_UUID_UNPARSED_SIZE];
|
||||||
|
char flags_str[32] = {0};
|
||||||
|
|
||||||
ri = btrfs_item_ptr(leaf, slot, struct btrfs_root_item);
|
ri = btrfs_item_ptr(leaf, slot, struct btrfs_root_item);
|
||||||
len = btrfs_item_size_nr(leaf, slot);
|
len = btrfs_item_size_nr(leaf, slot);
|
||||||
|
|
||||||
memset(&root_item, 0, sizeof(root_item));
|
memset(&root_item, 0, sizeof(root_item));
|
||||||
read_extent_buffer(leaf, &root_item, (unsigned long)ri, len);
|
read_extent_buffer(leaf, &root_item, (unsigned long)ri, len);
|
||||||
|
root_flags_to_str(btrfs_root_flags(&root_item), flags_str);
|
||||||
|
|
||||||
printf("\t\troot data bytenr %llu level %d dirid %llu refs %u gen %llu lastsnap %llu\n",
|
printf("\t\troot data bytenr %llu level %d dirid %llu refs %u gen %llu lastsnap %llu\n",
|
||||||
(unsigned long long)btrfs_root_bytenr(&root_item),
|
(unsigned long long)btrfs_root_bytenr(&root_item),
|
||||||
@ -516,6 +529,8 @@ static void print_root(struct extent_buffer *leaf, int slot)
|
|||||||
btrfs_root_refs(&root_item),
|
btrfs_root_refs(&root_item),
|
||||||
(unsigned long long)btrfs_root_generation(&root_item),
|
(unsigned long long)btrfs_root_generation(&root_item),
|
||||||
(unsigned long long)btrfs_root_last_snapshot(&root_item));
|
(unsigned long long)btrfs_root_last_snapshot(&root_item));
|
||||||
|
printf("\t\tflags 0x%llx(%s)\n", btrfs_root_flags(&root_item),
|
||||||
|
flags_str);
|
||||||
|
|
||||||
if (root_item.generation == root_item.generation_v2) {
|
if (root_item.generation == root_item.generation_v2) {
|
||||||
uuid_unparse(root_item.uuid, uuid_str);
|
uuid_unparse(root_item.uuid, uuid_str);
|
||||||
|
Loading…
Reference in New Issue
Block a user