dump.f2fs: support to dump fsverity xattr info in print_xattr_entry()

This patch adds to support dumping fsverity xattr info in print_xattr_entry().

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Chao Yu 2023-07-18 12:05:00 +08:00 committed by Jaegeuk Kim
parent bc444aeddb
commit 6ebf6f2967
2 changed files with 24 additions and 0 deletions

View File

@ -199,6 +199,7 @@ static void print_xattr_entry(const struct f2fs_xattr_entry *ent)
char *enc_name = F2FS_XATTR_NAME_ENCRYPTION_CONTEXT;
u32 enc_name_len = strlen(enc_name);
const union fscrypt_context *ctx;
const struct fsverity_descriptor_location *dloc;
int i;
MSG(0, "\nxattr: e_name_index:%d e_name:", ent->e_name_index);
@ -250,6 +251,18 @@ static void print_xattr_entry(const struct f2fs_xattr_entry *ent)
return;
}
break;
case F2FS_XATTR_INDEX_VERITY:
dloc = (const struct fsverity_descriptor_location *)value;
if (ent->e_name_len != strlen(F2FS_XATTR_NAME_VERITY) ||
memcmp(ent->e_name, F2FS_XATTR_NAME_VERITY,
ent->e_name_len))
break;
if (size != sizeof(*dloc))
break;
MSG(0, "version: %u\n", le32_to_cpu(dloc->version));
MSG(0, "size: %u\n", le32_to_cpu(dloc->size));
MSG(0, "pos: %"PRIu64"\n", le64_to_cpu(dloc->pos));
return;
}
for (i = 0; i < size; i++)
MSG(0, "%02X", value[i]);

View File

@ -90,6 +90,14 @@ static inline int fscrypt_context_size(const union fscrypt_context *ctx)
return 0;
}
struct fsverity_descriptor_location {
__le32 version;
__le32 size;
__le64 pos;
};
static_assert(sizeof(struct fsverity_descriptor_location) == 16, "");
#define F2FS_ACL_VERSION 0x0001
struct f2fs_acl_entry {
@ -150,6 +158,9 @@ static inline int f2fs_acl_count(int size)
#define F2FS_XATTR_INDEX_LUSTRE 5
#define F2FS_XATTR_INDEX_SECURITY 6
#define F2FS_XATTR_INDEX_ENCRYPTION 9
#define F2FS_XATTR_INDEX_VERITY 11
#define F2FS_XATTR_NAME_VERITY "v"
#define IS_XATTR_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)