Commit c5bca38d authored by Eric Biggers's avatar Eric Biggers Committed by Jaegeuk Kim
Browse files

f2fs: use the updated test_dummy_encryption helper functions



Switch f2fs over to the functions that are replacing
fscrypt_set_test_dummy_encryption().  Since f2fs hasn't been converted
to the new mount API yet, this doesn't really provide a benefit for
f2fs.  But it allows fscrypt_set_test_dummy_encryption() to be removed.

Also take the opportunity to eliminate an #ifdef.

Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 0840a791
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/fs_context.h>
#include <linux/sched/mm.h>
#include <linux/statfs.h>
#include <linux/buffer_head.h>
@@ -492,9 +493,19 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb,
					  bool is_remount)
{
	struct f2fs_sb_info *sbi = F2FS_SB(sb);
#ifdef CONFIG_FS_ENCRYPTION
	struct fs_parameter param = {
		.type = fs_value_is_string,
		.string = arg->from ? arg->from : "",
	};
	struct fscrypt_dummy_policy *policy =
		&F2FS_OPTION(sbi).dummy_enc_policy;
	int err;

	if (!IS_ENABLED(CONFIG_FS_ENCRYPTION)) {
		f2fs_warn(sbi, "test_dummy_encryption option not supported");
		return -EINVAL;
	}

	if (!f2fs_sb_has_encrypt(sbi)) {
		f2fs_err(sbi, "Encrypt feature is off");
		return -EINVAL;
@@ -506,12 +517,12 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb,
	 * needed to allow it to be set or changed during remount.  We do allow
	 * it to be specified during remount, but only if there is no change.
	 */
	if (is_remount && !F2FS_OPTION(sbi).dummy_enc_policy.policy) {
	if (is_remount && !fscrypt_is_dummy_policy_set(policy)) {
		f2fs_warn(sbi, "Can't set test_dummy_encryption on remount");
		return -EINVAL;
	}
	err = fscrypt_set_test_dummy_encryption(
		sb, arg->from, &F2FS_OPTION(sbi).dummy_enc_policy);

	err = fscrypt_parse_test_dummy_encryption(&param, policy);
	if (err) {
		if (err == -EEXIST)
			f2fs_warn(sbi,
@@ -524,12 +535,14 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb,
				  opt, err);
		return -EINVAL;
	}
	err = fscrypt_add_test_dummy_key(sb, policy);
	if (err) {
		f2fs_warn(sbi, "Error adding test dummy encryption key [%d]",
			  err);
		return err;
	}
	f2fs_warn(sbi, "Test dummy encryption mode enabled");
	return 0;
#else
	f2fs_warn(sbi, "test_dummy_encryption option not supported");
	return -EINVAL;
#endif
}

#ifdef CONFIG_F2FS_FS_COMPRESSION