mkfs.f2fs: set encryption feature

This patch add to support encryption feature.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2015-04-21 20:03:40 -07:00
parent 65950fc736
commit 6e6c713240
3 changed files with 24 additions and 1 deletions

View File

@ -251,6 +251,7 @@ struct f2fs_configuration {
int fix_on;
int bug_on;
int auto_fix;
__le32 feature; /* defined features */
} __attribute__((packed));
#ifdef CONFIG_64BIT
@ -315,6 +316,8 @@ enum {
#define MAX_ACTIVE_NODE_LOGS 8
#define MAX_ACTIVE_DATA_LOGS 8
#define F2FS_FEATURE_ENCRYPT 0x0001
/*
* For superblock
*/
@ -353,6 +356,10 @@ struct f2fs_super_block {
__le32 cp_payload;
__u8 version[VERSION_LEN]; /* the kernel version */
__u8 init_version[VERSION_LEN]; /* the initial kernel version */
__le32 feature; /* defined features */
__u8 encryption_level; /* versioning level for encryption */
__u8 encrypt_pw_salt[16]; /* Salt used for string2key algorithm */
__u8 reserved[871]; /* valid reserved region */
} __attribute__((packed));
/*

View File

@ -364,6 +364,8 @@ static int f2fs_prepare_super_block(void)
memcpy(sb.version, config.version, VERSION_LEN);
memcpy(sb.init_version, config.version, VERSION_LEN);
sb.feature = config.feature;
return 0;
}

View File

@ -33,6 +33,7 @@ static void mkfs_usage()
MSG(0, " -e [extension list] e.g. \"mp3,gif,mov\"\n");
MSG(0, " -l label\n");
MSG(0, " -o overprovision ratio [default:5]\n");
MSG(0, " -O set feature\n");
MSG(0, " -q quiet mode\n");
MSG(0, " -s # of segments per section [default:1]\n");
MSG(0, " -z # of sections per zone [default:1]\n");
@ -61,9 +62,19 @@ static void f2fs_show_info()
MSG(0, "Info: Trim is %s\n", config.trim ? "enabled": "disabled");
}
static void parse_feature(char *features)
{
if (!strcmp(features, "encrypt")) {
config.feature |= cpu_to_le32(F2FS_FEATURE_ENCRYPT);
} else {
MSG(0, "Error: Wrong features\n");
mkfs_usage();
}
}
static void f2fs_parse_options(int argc, char *argv[])
{
static const char *option_string = "qa:d:e:l:o:s:z:t:";
static const char *option_string = "qa:d:e:l:o:O:s:z:t:";
int32_t option=0;
while ((option = getopt(argc,argv,option_string)) != EOF) {
@ -91,6 +102,9 @@ static void f2fs_parse_options(int argc, char *argv[])
case 'o':
config.overprovision = atoi(optarg);
break;
case 'O':
parse_feature(strdup(optarg));
break;
case 's':
config.segs_per_sec = atoi(optarg);
break;