Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1780138imi; Sat, 23 Jul 2022 17:56:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIy1un+z3ZFZZ82z1afYSJCbOpVFak+Prgsf05fe6vaCd+L6UgFXwAhCh1fBKl2Y7hk1Je X-Received: by 2002:a17:90a:bd90:b0:1f2:2538:1761 with SMTP id z16-20020a17090abd9000b001f225381761mr7346289pjr.107.1658624171565; Sat, 23 Jul 2022 17:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658624171; cv=none; d=google.com; s=arc-20160816; b=dSwudNwMs6fVWvdZ+wiPQVHcuWmCYrtTIfXeXDue+SZR7hshr+MzhUDUfK0cVb08NL ozo0mTDEpA7huIwmDZm+S4rpfxsx5USuvYzvE8k+t7w7eeMFLbPZcCYJFZoPfXjxl7Pm e3EzedC92KrH+f41Q516SWsca2ZrmME8kEjDQ7r8nGtQgrmYmDd2Qin0SlHIGLpVR7y5 tNW6NhUjivtLEGam64z5aNRW2LLdj7BakYFBEuoV85EST9ZbgBWqe0j4RVnhnRVnAQFx +180HIknHqdTtnFOeQsP7UDeTX6rdbF35+QO9tEVRPXfsxBJboj3faKpW+U2vn0sdxos F+pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2OM81YG39wnsgbeJ2SVX+PJhaYhKHxRqlfhjzfDAhvs=; b=eWWESsVSuCV/Fc6ADZDF+/sl8r4B33Tq2ypffp03e6efp3SfP9wd0YlYVIu6sq+2qh xhKQFXXKhcJhaNOvZZI0QaRn4XgwxMzinCNOLvSHS7oFxfMTY6Ny/BYWFg6O6ycb1iuJ CE7ZmsuRZvdCwatbgXsK/XC77+xmTtbYSXU3+KNH4PVHgXq4h9QtYO+zCCr0l7VNqDD0 VPZIAmpjFqo//aSudUTgtoGI2QdoO489aA3BK0IMJsbDXg99GZO/DsmYBIS8bfpZyjnq viY9Fuqiw16oVFc4McNURBjlnrV+d+sKOfzAxqT2RGoRxVEDpDr+UVzCXtY8XqQ3qHah 24aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=jo9PimxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170903120900b001622a77631esi11683716plh.594.2022.07.23.17.55.57; Sat, 23 Jul 2022 17:56:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=jo9PimxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239487AbiGXAzF (ORCPT + 99 others); Sat, 23 Jul 2022 20:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239331AbiGXAyn (ORCPT ); Sat, 23 Jul 2022 20:54:43 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03EAB15A20; Sat, 23 Jul 2022 17:54:42 -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 3D29E80BB8; Sat, 23 Jul 2022 20:54:42 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1658624082; bh=AgDYp0BiOtfI423w4RuFeYp4IwenEY64iE6iTJOoayc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jo9PimxW1WAvkkJJz/rgxg7uH3nmtl6rKZVegJYJ55yvfxSoqqSzlOUFHPn61xoSY 5YJtxfTPh8cFdAbHmVs6Xlj3sYyeYJZR9D1s0YBsJcv3eeglVK6hCxT8I/k4tVBnij 9ZsdYTcygIgzoe4W5AlFKJR06bevJCBpm11fYqS9b4Mmvl2z+wTAkYVeWYynch7tTK hAtX3X9lDZSLBhydnLXMu/YIzGhzCVt9jZY6TPykcN1xwfXHm98DinwijddqHMBpS0 1pZvH7KSyeH9HCKC1VtxK5fvxbxpklrdSKV6KVOCSX7MUmxo9GcwCRs/dSb3zxLYFp 4vFsMGB25JZWg== From: Sweet Tea Dorminy To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, osandov@osandov.com, kernel-team@fb.com Cc: Sweet Tea Dorminy Subject: [PATCH RFC v2 09/16] btrfs: translate btrfs encryption flags and encrypted inode flag. Date: Sat, 23 Jul 2022 20:53:54 -0400 Message-Id: <3f8eaa2ac5226dba403197398ebbd5208ccd9cc0.1658623319.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Omar Sandoval In btrfs, a file can be encrypted either if its directory is encrypted or its root subvolume is encrypted, so translate both to the standard flags. Signed-off-by: Omar Sandoval Signed-off-by: Sweet Tea Dorminy --- fs/btrfs/ioctl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 8f5b65c43c8d..708e514aca25 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -147,6 +148,10 @@ static unsigned int btrfs_inode_flags_to_fsflags(struct btrfs_inode *binode) iflags |= FS_NOCOW_FL; if (ro_flags & BTRFS_INODE_RO_VERITY) iflags |= FS_VERITY_FL; + if ((binode->flags & BTRFS_INODE_FSCRYPT_CONTEXT) || + (btrfs_root_flags(&binode->root->root_item) & + BTRFS_ROOT_SUBVOL_FSCRYPT)) + iflags |= FS_ENCRYPT_FL; if (flags & BTRFS_INODE_NOCOMPRESS) iflags |= FS_NOCOMP_FL; @@ -176,10 +181,14 @@ void btrfs_sync_inode_flags_to_i_flags(struct inode *inode) new_fl |= S_DIRSYNC; if (binode->ro_flags & BTRFS_INODE_RO_VERITY) new_fl |= S_VERITY; + if ((binode->flags & BTRFS_INODE_FSCRYPT_CONTEXT) || + (btrfs_root_flags(&binode->root->root_item) & + BTRFS_ROOT_SUBVOL_FSCRYPT)) + new_fl |= S_ENCRYPTED; set_mask_bits(&inode->i_flags, S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | S_DIRSYNC | - S_VERITY, new_fl); + S_VERITY | S_ENCRYPTED, new_fl); } /* @@ -192,7 +201,7 @@ static int check_fsflags(unsigned int old_flags, unsigned int flags) FS_NOATIME_FL | FS_NODUMP_FL | \ FS_SYNC_FL | FS_DIRSYNC_FL | \ FS_NOCOMP_FL | FS_COMPR_FL | - FS_NOCOW_FL)) + FS_NOCOW_FL | FS_ENCRYPT_FL)) return -EOPNOTSUPP; /* COMPR and NOCOMP on new/old are valid */ -- 2.35.1