Skip to contentSkip to conversation

btrfs-progs: add print support for verity items.

PATCH In review Sweet Tea Dorminy 3 participants 4 messages Mar 23, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: add print support for verity items.

'btrfs inspect-internals dump-tree' doesn't currently know about the two types of verity items and prints them as 'UNKNOWN.36' or 'UNKNOWN.37'. So add them to the known item types.

---

Inspired by Boris' recent patchset noting that these items were not yet properly printed:
https://lore.kernel.org/linux-btrfs/5579a70597cd660ffb265db9e97840a1faca8812.1647382272.git.boris@bur.io/T/#u

---

 kernel-shared/ctree.h      | 4 ++++
 kernel-shared/print-tree.c | 2 ++
 2 files changed, 6 insertions(+)
kernel-shared/ctree.h +4 -0
index bf71fc85..b8d7e5a8 100644
@@ -1350,6 +1350,10 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
 #define BTRFS_INODE_REF_KEY		12
 #define BTRFS_INODE_EXTREF_KEY		13
 #define BTRFS_XATTR_ITEM_KEY		24
+
+#define BTRFS_VERITY_DESC_ITEM_KEY	36
+#define BTRFS_VERITY_MERKLE_ITEM_KEY	37
+
 #define BTRFS_ORPHAN_ITEM_KEY		48
 
 #define BTRFS_DIR_LOG_ITEM_KEY  60
kernel-shared/print-tree.c +2 -0
index 73f969c3..ee7f679c 100644
@@ -647,6 +647,8 @@ void print_key_type(FILE *stream, u64 objectid, u8 type)
 		[BTRFS_DIR_LOG_ITEM_KEY]	= "DIR_LOG_ITEM",
 		[BTRFS_DIR_LOG_INDEX_KEY]	= "DIR_LOG_INDEX",
 		[BTRFS_XATTR_ITEM_KEY]		= "XATTR_ITEM",
+		[BTRFS_VERITY_DESC_ITEM_KEY]	= "VERITY_DESC_ITEM",
+		[BTRFS_VERITY_MERKLE_ITEM_KEY	= "VERITY_MERKLE_ITEM",
 		[BTRFS_ORPHAN_ITEM_KEY]		= "ORPHAN_ITEM",
 		[BTRFS_ROOT_ITEM_KEY]		= "ROOT_ITEM",
 		[BTRFS_ROOT_REF_KEY]		= "ROOT_REF",
Signature · 1 line
2.35.1
#3 lore raw
In reply to Sweet Tea Dorminy
Quoted 39 lines · Sweet Tea Dorminy

'btrfs inspect-internals dump-tree' doesn't currently know about the two types of verity items and prints them as 'UNKNOWN.36' or 'UNKNOWN.37'. So add them to the known item types.

---

Inspired by Boris' recent patchset noting that these items were not yet properly printed:
https://lore.kernel.org/linux-btrfs/5579a70597cd660ffb265db9e97840a1faca8812.1647382272.git.boris@bur.io/T/#u

---

 kernel-shared/ctree.h      | 4 ++++
 kernel-shared/print-tree.c | 2 ++
 2 files changed, 6 insertions(+)
kernel-shared/ctree.h +4 -0
index bf71fc85..b8d7e5a8 100644
@@ -1350,6 +1350,10 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
 #define BTRFS_INODE_REF_KEY		12
 #define BTRFS_INODE_EXTREF_KEY		13
 #define BTRFS_XATTR_ITEM_KEY		24
+
+#define BTRFS_VERITY_DESC_ITEM_KEY	36
+#define BTRFS_VERITY_MERKLE_ITEM_KEY	37
+
 #define BTRFS_ORPHAN_ITEM_KEY		48
 
 #define BTRFS_DIR_LOG_ITEM_KEY  60
kernel-shared/print-tree.c +0 -0
index 73f969c3..ee7f679c 100644

kernel-shared/print-tree.c void print_key_type(FILE *stream, u64 objectid, u8 type) · line 651

Quoted 5 lines
kernel-shared/print-tree.c +2 -0
@@ -647,6 +647,8 @@ void print_key_type(FILE *stream, u64 objectid, u8 type)
 		[BTRFS_DIR_LOG_ITEM_KEY]	= "DIR_LOG_ITEM",
 		[BTRFS_DIR_LOG_INDEX_KEY]	= "DIR_LOG_INDEX",
 		[BTRFS_XATTR_ITEM_KEY]		= "XATTR_ITEM",
+		[BTRFS_VERITY_DESC_ITEM_KEY]	= "VERITY_DESC_ITEM",
+		[BTRFS_VERITY_MERKLE_ITEM_KEY	= "VERITY_MERKLE_ITEM",

[CC] kernel-shared/print-tree.o
kernel-shared/print-tree.c: In function ‘print_key_type’:
kernel-shared/print-tree.c:650:49: error: lvalue required as left operand of assignment

  650 |                 [BTRFS_VERITY_MERKLE_ITEM_KEY   = "VERITY_MERKLE_ITEM",
      |                                                 ^
kernel-shared/print-tree.c:650:71: error: expected ‘]’ before ‘,’ token
  650 |                 [BTRFS_VERITY_MERKLE_ITEM_KEY   = "VERITY_MERKLE_ITEM",
      |                                                                       ^
      |                                                                       ]
kernel-shared/print-tree.c:682:9: error: expected expression before ‘}’ token
  682 |         };
      |         ^

make: *** [Makefile:414: kernel-shared/print-tree.o] Error 1