Whamcloud - gitweb
misc: teach mke2fs to create encrypted file systems
authorIldar Muslukhov <muslukhovi@gmail.com>
Mon, 2 Mar 2015 16:54:19 +0000 (11:54 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 9 Mar 2015 03:29:04 +0000 (23:29 -0400)
Also enable support for encryption in e2fsprogs.

Signed-off-by: Ildar Muslukhov <muslukhovi@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ext2fs.h
misc/mke2fs.c

index 0f83efc..d75dd76 100644 (file)
@@ -598,7 +598,8 @@ typedef struct ext2_icount *ext2_icount_t;
                                         EXT4_FEATURE_INCOMPAT_FLEX_BG|\
                                         EXT4_LIB_INCOMPAT_MMP|\
                                         EXT4_FEATURE_INCOMPAT_64BIT|\
-                                        EXT4_FEATURE_INCOMPAT_INLINE_DATA)
+                                        EXT4_FEATURE_INCOMPAT_INLINE_DATA|\
+                                        EXT4_FEATURE_INCOMPAT_ENCRYPT)
 
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP        (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
                                         EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
@@ -615,7 +616,7 @@ typedef struct ext2_icount *ext2_icount_t;
  * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
  * to ext2fs_openfs()
  */
-#define EXT2_LIB_SOFTSUPP_INCOMPAT     (EXT4_FEATURE_INCOMPAT_ENCRYPT)
+#define EXT2_LIB_SOFTSUPP_INCOMPAT     (0)
 #define EXT2_LIB_SOFTSUPP_RO_COMPAT    (EXT4_FEATURE_RO_COMPAT_REPLICA)
 
 
index aeb852f..ec450ad 100644 (file)
@@ -1076,7 +1076,8 @@ static __u32 ok_features[3] = {
                EXT4_FEATURE_INCOMPAT_FLEX_BG|
                EXT4_FEATURE_INCOMPAT_MMP |
                EXT4_FEATURE_INCOMPAT_64BIT|
-               EXT4_FEATURE_INCOMPAT_INLINE_DATA,
+               EXT4_FEATURE_INCOMPAT_INLINE_DATA|
+               EXT4_FEATURE_INCOMPAT_ENCRYPT,
        /* R/O compat */
        EXT2_FEATURE_RO_COMPAT_LARGE_FILE|
                EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
@@ -2910,6 +2911,15 @@ int main (int argc, char *argv[])
                        sizeof(fs->super->s_last_mounted));
        }
 
+       /* Set current default encryption algorithms for data and
+        * filename encryption */
+       if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_ENCRYPT) {
+               fs->super->s_encrypt_algos[0] =
+                       EXT4_ENCRYPTION_MODE_AES_256_XTS;
+               fs->super->s_encrypt_algos[1] =
+                       EXT4_ENCRYPTION_MODE_AES_256_CBC;
+       }
+
        if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                       EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
                fs->super->s_checksum_type = EXT2_CRC32C_CHKSUM;