aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2023-07-18 12:05:00 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2023-07-21 12:19:29 -0700
commit6ebf6f2967d0a5731af1767d5735f46e30fea0fc (patch)
tree2bfe793ff05dd2b1f131219328a7bf58809106de
parentbc444aeddbcd1e5fb1081fc7d6eeb1f742fd7ee1 (diff)
downloadf2fs-tools-6ebf6f2967d0a5731af1767d5735f46e30fea0fc.tar.gz
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>
-rw-r--r--fsck/mount.c13
-rw-r--r--fsck/xattr.h11
2 files changed, 24 insertions, 0 deletions
diff --git a/fsck/mount.c b/fsck/mount.c
index b0f4eab..5e687a8 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -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]);
diff --git a/fsck/xattr.h b/fsck/xattr.h
index 2527350..867349c 100644
--- a/fsck/xattr.h
+++ b/fsck/xattr.h
@@ -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)