linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] dump.f2fs: support to dump fsverity xattr info in print_xattr_entry()
@ 2023-07-18  4:05 Chao Yu
  2023-07-21 19:21 ` Jaegeuk Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2023-07-18  4:05 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

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

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/mount.c | 13 +++++++++++++
 fsck/xattr.h | 11 +++++++++++
 2 files changed, 24 insertions(+)

diff --git a/fsck/mount.c b/fsck/mount.c
index dbb516b..2691b2f 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: %lu\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 cddafa7..bf1dd7e 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)
 
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH] dump.f2fs: support to dump fsverity xattr info in print_xattr_entry()
  2023-07-18  4:05 [f2fs-dev] [PATCH] dump.f2fs: support to dump fsverity xattr info in print_xattr_entry() Chao Yu
@ 2023-07-21 19:21 ` Jaegeuk Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2023-07-21 19:21 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel

On 07/18, Chao Yu wrote:
> This patch adds to support dumping fsverity xattr info in print_xattr_entry().
> 
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
>  fsck/mount.c | 13 +++++++++++++
>  fsck/xattr.h | 11 +++++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/fsck/mount.c b/fsck/mount.c
> index dbb516b..2691b2f 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: %lu\n", le64_to_cpu(dloc->pos));

Fixed build error with
		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 cddafa7..bf1dd7e 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)
>  
> -- 
> 2.40.1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-21 19:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18  4:05 [f2fs-dev] [PATCH] dump.f2fs: support to dump fsverity xattr info in print_xattr_entry() Chao Yu
2023-07-21 19:21 ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).