From patchwork Fri Jan 22 15:15:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 1430409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=2SvWZsPU; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DMjY96MYdz9sSC for ; Sat, 23 Jan 2021 02:17:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=O6hxRqaNttNu7svmi91ErhWqJncGRw80ryVniFp70tw=; b=2SvWZsPU5jqva/3SoErMloTaI 5xUXYPrfOICb5+mWsyX701CndoKSIF3Y7v0riUJcoPlCHXQZxfdst1aWhRIVJ5OOab13rIKOIY+Of t+WZO+xjj4eQcKa6YTfXYCzxiFIWQqYeiWeZi5FGod1Q6Oc2+uJrtTJNDiDhUIUneIQYDH2RpRRxW yuz4G66mmixlveWOnMJD0d40BK8Hg1WEU6TteX2ExLHv+v3WWsZTayo4wWf9CBAyhuXpf2J1hZX8Q k5yM2vJpusNCxoveV6HHhExnJM9SVmzdWcPGKst5TxLGWMNZHBWBTri7JT6tPdwudlyxXdwP2Wo+n NvsgHIP9Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2yAX-0006vE-W5; Fri, 22 Jan 2021 15:16:14 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2yAR-0006sg-5W for linux-mtd@lists.infradead.org; Fri, 22 Jan 2021 15:16:08 +0000 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2yA1-0004Bw-H9; Fri, 22 Jan 2021 16:15:41 +0100 Received: from sha by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1l2yA0-0003qx-TQ; Fri, 22 Jan 2021 16:15:40 +0100 From: Sascha Hauer To: linux-fsdevel@vger.kernel.org Subject: [PATCH 5/8] ubifs: Factor out ubifs_set_feature_flag() Date: Fri, 22 Jan 2021 16:15:33 +0100 Message-Id: <20210122151536.7982-6-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210122151536.7982-1-s.hauer@pengutronix.de> References: <20210122151536.7982-1-s.hauer@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210122_101607_286718_D3A68C4C X-CRM114-Status: GOOD ( 14.64 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Sascha Hauer , linux-mtd@lists.infradead.org, kernel@pengutronix.de, Jan Kara Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The code setting a feature flag can be reused for upcoming projid support. Factor out a function to share the code. Signed-off-by: Sascha Hauer --- fs/ubifs/sb.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index c160f718c288..87466836fcfc 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c @@ -924,28 +924,34 @@ int ubifs_fixup_free_space(struct ubifs_info *c) return err; } -int ubifs_enable_encryption(struct ubifs_info *c) +static int ubifs_set_feature_flag(struct ubifs_info *c, unsigned int flag) { - int err; struct ubifs_sb_node *sup = c->sup_node; - if (!IS_ENABLED(CONFIG_FS_ENCRYPTION)) - return -EOPNOTSUPP; - - if (c->encrypted) + if ((sup->flags & cpu_to_le32(flag)) == cpu_to_le32(flag)) return 0; if (c->ro_mount || c->ro_media) return -EROFS; if (c->fmt_version < 5) { - ubifs_err(c, "on-flash format version 5 is needed for encryption"); + ubifs_err(c, "on-flash format version 5 is needed for feature flags"); return -EINVAL; } - sup->flags |= cpu_to_le32(UBIFS_FLG_ENCRYPTION); + sup->flags |= cpu_to_le32(flag); + + return ubifs_write_sb_node(c, sup); +} + +int ubifs_enable_encryption(struct ubifs_info *c) +{ + int err; + + if (!IS_ENABLED(CONFIG_FS_ENCRYPTION)) + return -EOPNOTSUPP; - err = ubifs_write_sb_node(c, sup); + err = ubifs_set_feature_flag(c, UBIFS_FLG_ENCRYPTION); if (!err) c->encrypted = 1;