From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
To: linux-btrfs@vger.kernel.org, ebiggers@google.com, kernel-team@meta.com
Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Subject: [PATCH v2 6/8] btrfs-progs: handle fscrypt context items
Date: Tue, 8 Aug 2023 13:22:25 -0400 [thread overview]
Message-ID: <0d7c3a8f8584b9f5609da43abb20c434c390b85e.1691520000.git.sweettea-kernel@dorminy.me> (raw)
In-Reply-To: <cover.1691520000.git.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>
---
kernel-shared/print-tree.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 9f332f811..19a0e8ac8 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -100,6 +100,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)
{
@@ -675,6 +689,7 @@ 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_CTXT_ITEM_KEY] = "FSCRYPT_CTXT_ITEM",
[BTRFS_VERITY_DESC_ITEM_KEY] = "VERITY_DESC_ITEM",
[BTRFS_VERITY_MERKLE_ITEM_KEY] = "VERITY_MERKLE_ITEM",
[BTRFS_ORPHAN_ITEM_KEY] = "ORPHAN_ITEM",
@@ -1395,6 +1410,9 @@ 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_CTXT_ITEM_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;
--
2.41.0
next prev parent reply other threads:[~2023-08-08 18:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 17:22 [PATCH v2 0/8] btrfs-progs: add encryption support Sweet Tea Dorminy
2023-08-08 17:22 ` [PATCH v2 1/8] btrfs-progs: add new FEATURE_INCOMPAT_ENCRYPT flag Sweet Tea Dorminy
2023-08-08 17:22 ` [PATCH v2 2/8] btrfs-progs: start tracking extent encryption context info Sweet Tea Dorminy
2023-08-08 17:22 ` [PATCH v2 3/8] btrfs-progs: add inode encryption contexts Sweet Tea Dorminy
2023-08-08 17:22 ` [PATCH v2 4/8] btrfs-progs: save and load fscrypt extent contexts Sweet Tea Dorminy
2023-08-08 17:22 ` [PATCH v2 5/8] btrfs-progs: interpret encrypted file extents Sweet Tea Dorminy
2023-08-08 17:22 ` Sweet Tea Dorminy [this message]
2023-08-08 17:22 ` [PATCH v2 7/8] btrfs-progs: escape unprintable characters in names Sweet Tea Dorminy
2023-08-08 17:22 ` [PATCH v2 8/8] btrfs-progs: check: update inline extent length checking Sweet Tea Dorminy
2023-08-09 20:41 ` [PATCH v2 0/8] btrfs-progs: add encryption support Josef Bacik
2023-08-10 12:23 ` Neal Gompa
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=0d7c3a8f8584b9f5609da43abb20c434c390b85e.1691520000.git.sweettea-kernel@dorminy.me \
--to=sweettea-kernel@dorminy.me \
--cc=ebiggers@google.com \
--cc=kernel-team@meta.com \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).