2 * Basic program to add ext4 encryption to a file system
4 * Copyright 2015, Google, Inc.
7 * This file may be redistributed under the terms of the GNU Public
17 #include <sys/types.h>
20 #include <ext2fs/ext2_fs.h>
21 #include <ext2fs/ext2fs.h>
23 int main (int argc, char *argv[])
30 initialize_ext2_error_table();
33 fprintf(stderr, "%s: Usage <device|filesystem>\n", argv[0]);
37 retval = ext2fs_open(argv[1], EXT2_FLAG_RW, 0, 0,
38 unix_io_manager, &fs);
41 com_err(argv[0], retval, "while trying to open '%s'",
45 if (!ext2fs_has_feature_encrypt(fs->super)) {
46 ext2fs_set_feature_encrypt(fs->super);
47 fs->super->s_encrypt_algos[0] =
48 EXT4_ENCRYPTION_MODE_AES_256_XTS;
49 fs->super->s_encrypt_algos[1] =
50 EXT4_ENCRYPTION_MODE_AES_256_CTS;
51 ext2fs_mark_super_dirty(fs);
52 printf("Ext4 encryption enabled on %s\n", argv[1]);
54 printf("Ext4 encryption already enabled on %s\n", argv[1]);
56 retval = ext2fs_close(fs);
58 com_err(argv[0], retval, "while trying to close '%s'",