[PATCH 4/7] ubifs: Factor out ubifs_set_feature_flag()
Sascha Hauer
s.hauer at pengutronix.de
Tue Mar 30 11:43:48 BST 2021
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 <s.hauer at pengutronix.de>
---
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;
--
2.29.2
More information about the linux-mtd
mailing list