linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Rosenberg <drosen@google.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	kernel-team@android.com, Daniel Rosenberg <drosen@google.com>
Subject: [PATCH] tune2fs: Support casefolded encryption
Date: Mon,  2 Dec 2019 21:29:23 -0800	[thread overview]
Message-ID: <20191203052923.65477-1-drosen@google.com> (raw)

This allows enabling casefold and encryption at the same
time. Fsck still needs to be adjusted to deal wtih this.

Change-Id: Ic9ed63180ef28c36e083cee85ade432e4bfcc654
Signed-off-by: Daniel Rosenberg <drosen@google.com>
---
 misc/mke2fs.c  |  9 ---------
 misc/tune2fs.c | 37 ++++++++++++++++++++++++++++++-------
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index da29ab39..879e3914 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -2460,15 +2460,6 @@ profile_error:
 		}
 	}
 
-	if (ext2fs_has_feature_casefold(&fs_param) &&
-	    ext2fs_has_feature_encrypt(&fs_param)) {
-		com_err(program_name, 0, "%s",
-			_("The encrypt and casefold features are not "
-			  "compatible.\nThey can not be both enabled "
-			  "simultaneously.\n"));
-		      exit (1);
-	}
-
 	/* Don't allow user to set both metadata_csum and uninit_bg bits. */
 	if (ext2fs_has_feature_metadata_csum(&fs_param) &&
 	    ext2fs_has_feature_gdt_csum(&fs_param))
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index c31c9a7c..b19ee5ca 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -101,6 +101,8 @@ static int rewrite_checksums;
 static int feature_64bit;
 static int fsck_requested;
 static char *undo_file;
+static int encoding = 0;
+static char encoding_flags = 0;
 
 int journal_size, journal_flags;
 char *journal_device;
@@ -160,7 +162,8 @@ static __u32 ok_features[3] = {
 		EXT4_FEATURE_INCOMPAT_64BIT |
 		EXT4_FEATURE_INCOMPAT_ENCRYPT |
 		EXT4_FEATURE_INCOMPAT_CSUM_SEED |
-		EXT4_FEATURE_INCOMPAT_LARGEDIR,
+		EXT4_FEATURE_INCOMPAT_LARGEDIR |
+		EXT4_FEATURE_INCOMPAT_CASEFOLD,
 	/* R/O compat */
 	EXT2_FEATURE_RO_COMPAT_LARGE_FILE |
 		EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
@@ -1403,12 +1406,6 @@ mmp_error:
 	}
 
 	if (FEATURE_ON(E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_ENCRYPT)) {
-		if (ext2fs_has_feature_casefold(sb)) {
-			fputs(_("Cannot enable encrypt feature on filesystems "
-				"with the encoding feature enabled.\n"),
-			      stderr);
-			return 1;
-		}
 		fs->super->s_encrypt_algos[0] =
 			EXT4_ENCRYPTION_MODE_AES_256_XTS;
 		fs->super->s_encrypt_algos[1] =
@@ -2146,6 +2143,24 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
 				continue;
 			}
 			ext_mount_opts = strdup(arg);
+		} else if (!strcmp(token, "encoding")) {
+			if (!arg) {
+				r_usage++;
+				continue;
+			}
+
+			encoding = e2p_str2encoding(arg);
+			if (encoding < 0) {
+				fprintf(stderr, _("Invalid encoding: %s"), arg);
+				r_usage++;
+				continue;
+			}
+		} else if (!strcmp(token, "encoding_flags")) {
+			if (!arg) {
+				r_usage++;
+				continue;
+			}
+			encoding_flags = *arg;
 		} else
 			r_usage++;
 	}
@@ -3325,6 +3340,14 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
 		       ext_mount_opts);
 		free(ext_mount_opts);
 	}
+	if (encoding > 0) {
+		sb->s_encoding = encoding;
+		ext2fs_mark_super_dirty(fs);
+	}
+	if (encoding_flags) {
+		sb->s_encoding_flags = encoding_flags;
+		ext2fs_mark_super_dirty(fs);
+	}
 
 	free(device_name);
 	remove_error_table(&et_ext2_error_table);
-- 
2.24.0.393.g34dc348eaf-goog


                 reply	other threads:[~2019-12-03  5:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191203052923.65477-1-drosen@google.com \
    --to=drosen@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).