From: Daniel Vacek <neelx@suse.com>
To: David Sterba <dsterba@suse.com>
Cc: Daniel Vacek <neelx@suse.com>,
linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org,
Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Subject: [PATCH v2 6/8] btrfs-progs: handle fscrypt context items
Date: Wed, 24 Jun 2026 18:51:42 +0200 [thread overview]
Message-ID: <20260624165144.556908-7-neelx@suse.com> (raw)
In-Reply-To: <20260624165144.556908-1-neelx@suse.com>
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
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: Daniel Vacek <neelx@suse.com>
---
check/main.c | 2 ++
kernel-shared/print-tree.c | 20 ++++++++++++++++++++
kernel-shared/uapi/btrfs_tree.h | 3 ++-
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/check/main.c b/check/main.c
index a32247b3..2df55edc 100644
--- a/check/main.c
+++ b/check/main.c
@@ -1896,6 +1896,8 @@ static int process_one_leaf(struct btrfs_root *root, struct extent_buffer *eb,
break;
case BTRFS_VERITY_DESC_ITEM_KEY:
case BTRFS_VERITY_MERKLE_ITEM_KEY:
+ case BTRFS_FSCRYPT_INODE_CTX_KEY:
+ case BTRFS_FSCRYPT_CTX_KEY:
break;
default:
error("unknown key (%llu %u %llu) found in leaf %llu",
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 159f0825..d68398e9 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -117,6 +117,20 @@ static void print_dir_item(struct extent_buffer *eb, u32 size,
}
}
+static void print_fscrypt_context(struct extent_buffer *eb, int slot)
+{
+ int i;
+ unsigned long ptr = btrfs_item_ptr_offset(eb, slot);
+ u32 item_size = btrfs_item_size(eb, slot);
+ u8 ctx_buf[item_size];
+
+ read_extent_buffer(eb, ctx_buf, ptr, item_size);
+ printf("\t\tvalue: ");
+ for(i = 0; i < item_size; i++)
+ printf("%02x", ctx_buf[i]);
+ printf("\n");
+}
+
static void print_inode_extref_item(struct extent_buffer *eb, u32 size,
struct btrfs_inode_extref *extref)
{
@@ -740,6 +754,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_FSCRYPT_INODE_CTX_KEY] = "FSCRYPT_INODE_CTX",
+ [BTRFS_FSCRYPT_CTX_KEY] = "FSCRYPT_CTX",
[BTRFS_VERITY_DESC_ITEM_KEY] = "VERITY_DESC_ITEM",
[BTRFS_VERITY_MERKLE_ITEM_KEY] = "VERITY_MERKLE_ITEM",
[BTRFS_ORPHAN_ITEM_KEY] = "ORPHAN_ITEM",
@@ -1556,6 +1572,10 @@ void __btrfs_print_leaf(struct extent_buffer *eb, unsigned int mode)
case BTRFS_XATTR_ITEM_KEY:
print_dir_item(eb, item_size, ptr);
break;
+ case BTRFS_FSCRYPT_INODE_CTX_KEY:
+ case BTRFS_FSCRYPT_CTX_KEY:
+ print_fscrypt_context(eb, i);
+ break;
case BTRFS_DIR_LOG_INDEX_KEY:
case BTRFS_DIR_LOG_ITEM_KEY: {
struct btrfs_dir_log_item *dlog;
diff --git a/kernel-shared/uapi/btrfs_tree.h b/kernel-shared/uapi/btrfs_tree.h
index 45675dae..b4532237 100644
--- a/kernel-shared/uapi/btrfs_tree.h
+++ b/kernel-shared/uapi/btrfs_tree.h
@@ -168,7 +168,8 @@
#define BTRFS_VERITY_DESC_ITEM_KEY 36
#define BTRFS_VERITY_MERKLE_ITEM_KEY 37
-#define BTRFS_FSCRYPT_CTXT_ITEM_KEY 41
+#define BTRFS_FSCRYPT_INODE_CTX_KEY 41
+#define BTRFS_FSCRYPT_CTX_KEY 42
#define BTRFS_ORPHAN_ITEM_KEY 48
/* reserve 2-15 close to the inode for later flexibility */
--
2.53.0
next prev parent reply other threads:[~2026-06-24 16:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 16:51 [PATCH v2 0/8] btrfs-progs: fscrypt updates Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 1/8] btrfs-progs: check: fix max inline extent size Daniel Vacek
2026-06-25 23:40 ` Qu Wenruo
2026-07-01 15:47 ` Daniel Vacek
2026-07-01 22:22 ` Qu Wenruo
2026-07-02 5:34 ` Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 2/8] btrfs-progs: add new FEATURE_INCOMPAT_ENCRYPT flag Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 3/8] btrfs-progs: start tracking extent encryption context info Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 4/8] btrfs-progs: add inode encryption contexts Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 5/8] btrfs-progs: print encryptin type field of file extents Daniel Vacek
2026-06-25 23:50 ` Qu Wenruo
2026-07-01 15:59 ` Daniel Vacek
2026-07-01 22:26 ` Qu Wenruo
2026-07-02 5:40 ` Daniel Vacek
2026-07-02 6:19 ` Qu Wenruo
2026-07-02 6:48 ` Daniel Vacek
2026-07-02 6:56 ` Qu Wenruo
2026-07-02 7:05 ` Daniel Vacek
2026-07-02 7:11 ` Qu Wenruo
2026-07-02 7:18 ` Daniel Vacek
2026-06-24 16:51 ` Daniel Vacek [this message]
2026-06-24 16:51 ` [PATCH v2 7/8] btrfs-progs: check: update inline extent length checking Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 8/8] btrfs-progs: recognize ENCRYPT inode item flag Daniel Vacek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260624165144.556908-7-neelx@suse.com \
--to=neelx@suse.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sweettea-kernel@dorminy.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox