Skip to content

Commit cc7ad82

Browse files
sweetteakdave
authored andcommitted
btrfs-progs: print-tree: handle fscrypt context items
Encrypted inodes have a new associated item, the fscrypt context, which can be printed as a pure hex string in dump-tree. Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent bb05653 commit cc7ad82

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

kernel-shared/print-tree.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ static void print_dir_item(struct extent_buffer *eb, u32 size,
117117
}
118118
}
119119

120+
static void print_fscrypt_context(struct extent_buffer *eb, int slot)
121+
{
122+
unsigned long ptr = btrfs_item_ptr_offset(eb, slot);
123+
u32 item_size = btrfs_item_size(eb, slot);
124+
u8 ctx_buf[item_size];
125+
126+
read_extent_buffer(eb, ctx_buf, ptr, item_size);
127+
printf("\t\tvalue: ");
128+
for(int i = 0; i < item_size; i++)
129+
printf("%02x", ctx_buf[i]);
130+
printf("\n");
131+
}
132+
120133
static void print_inode_extref_item(struct extent_buffer *eb, u32 size,
121134
struct btrfs_inode_extref *extref)
122135
{
@@ -756,6 +769,7 @@ void print_key_type(FILE *stream, u64 objectid, u8 type)
756769
[BTRFS_DIR_LOG_ITEM_KEY] = "DIR_LOG_ITEM",
757770
[BTRFS_DIR_LOG_INDEX_KEY] = "DIR_LOG_INDEX",
758771
[BTRFS_XATTR_ITEM_KEY] = "XATTR_ITEM",
772+
[BTRFS_FSCRYPT_CTXT_ITEM_KEY] = "FSCRYPT_CTXT_ITEM",
759773
[BTRFS_VERITY_DESC_ITEM_KEY] = "VERITY_DESC_ITEM",
760774
[BTRFS_VERITY_MERKLE_ITEM_KEY] = "VERITY_MERKLE_ITEM",
761775
[BTRFS_ORPHAN_ITEM_KEY] = "ORPHAN_ITEM",
@@ -1566,6 +1580,9 @@ void __btrfs_print_leaf(struct extent_buffer *eb, unsigned int mode)
15661580
case BTRFS_XATTR_ITEM_KEY:
15671581
print_dir_item(eb, item_size, ptr);
15681582
break;
1583+
case BTRFS_FSCRYPT_CTXT_ITEM_KEY:
1584+
print_fscrypt_context(eb, i);
1585+
break;
15691586
case BTRFS_DIR_LOG_INDEX_KEY:
15701587
case BTRFS_DIR_LOG_ITEM_KEY: {
15711588
struct btrfs_dir_log_item *dlog;

0 commit comments

Comments
 (0)