From patchwork Tue Sep 6 00:01:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 12966637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31199C54EE9 for ; Tue, 6 Sep 2022 00:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232575AbiIFABd (ORCPT ); Mon, 5 Sep 2022 20:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232455AbiIFAB3 (ORCPT ); Mon, 5 Sep 2022 20:01:29 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3E4652E47 for ; Mon, 5 Sep 2022 17:01:28 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 3BBEE80C62; Mon, 5 Sep 2022 20:01:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1662422488; bh=2Vz/3GvrxiKaPAr5G7cYeDJPqNrHRDLmOcXksq3eZ+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgwQpacZqtuGg/gicyZ0YO2hXO8GzTjccKdBC71wCDQJ+CZO9uE7W3lSTefPMMjHt 8eOsRaCidYdVcrXR8zfvGjYepCQ+J2hj8t4fwMdc+J36bCrSTSLwxqCWJZj/MAeWw5 tvR6loeDOagK9euV7LMoJ2OKdPuSYj7mM3W327LeHYu7TXGgbP4JmIDHm/VovdtsgD t8F6gd0SApnxSyducz3cgxAQ0v6v9gVvl8zQ/vPOx037fQbIxT+c6OkDqH9epf9E2E zqt6TtmzZ7SrRptlet5gHKcI3arRlII6CKrT1s1auQsL8I25LlmUWzNOiW6PsJu434 duEBWt03d0xqQ== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Cc: Sweet Tea Dorminy Subject: [PATCH 4/6] btrfs-progs: handle fscrypt context items Date: Mon, 5 Sep 2022 20:01:05 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 --- kernel-shared/ctree.h | 2 ++ kernel-shared/print-tree.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index 4392393d..2541a102 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -1397,6 +1397,8 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info) #define BTRFS_VERITY_DESC_ITEM_KEY 36 #define BTRFS_VERITY_MERKLE_ITEM_KEY 37 +#define BTRFS_FSCRYPT_CTXT_ITEM_KEY 41 + #define BTRFS_ORPHAN_ITEM_KEY 48 #define BTRFS_DIR_LOG_ITEM_KEY 60 diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index bb8db45c..2163f833 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -97,6 +97,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) { @@ -671,6 +685,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", @@ -1378,6 +1393,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;