mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-26 19:51:32 +00:00
mkfs.f2fs: support multiple features with one "-O"
Now one "-O" option can support multiple features separated by a comma or blank, such as: feature1,feature2,... or "feature1 feature2 ..." Signed-off-by: Junling Zheng <zhengjunling@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
4c55d62ced
commit
28c3b13e7d
@ -112,7 +112,8 @@ is hidden to users, and utilized by F2FS cleaner. If not specified, the best
|
||||
number will be assigned automatically accoring to the partition size.
|
||||
.TP
|
||||
.BI \-O " feature-list"
|
||||
Specify a feature list in order f2fs filesystem will supports.
|
||||
Specify a feature list like feature1[feature2,feature3,...] in order f2fs
|
||||
filesystem will supports.
|
||||
e.g "encrypt" and so on.
|
||||
.TP
|
||||
.BI \-q
|
||||
|
@ -51,7 +51,7 @@ static void mkfs_usage()
|
||||
MSG(0, " -l label\n");
|
||||
MSG(0, " -m support zoned block device [default:0]\n");
|
||||
MSG(0, " -o overprovision ratio [default:5]\n");
|
||||
MSG(0, " -O [feature list] e.g. \"encrypt\"\n");
|
||||
MSG(0, " -O feature1[feature2,feature3,...] e.g. \"encrypt\"\n");
|
||||
MSG(0, " -q quiet mode\n");
|
||||
MSG(0, " -s # of segments per section [default:1]\n");
|
||||
MSG(0, " -S sparse mode\n");
|
||||
@ -81,10 +81,8 @@ static void f2fs_show_info()
|
||||
MSG(0, "Info: Trim is %s\n", c.trim ? "enabled": "disabled");
|
||||
}
|
||||
|
||||
static void parse_feature(const char *features)
|
||||
static void set_feature_bits(char *features)
|
||||
{
|
||||
while (*features == ' ')
|
||||
features++;
|
||||
if (!strcmp(features, "encrypt")) {
|
||||
c.feature |= cpu_to_le32(F2FS_FEATURE_ENCRYPT);
|
||||
} else if (!strcmp(features, "verity")) {
|
||||
@ -109,6 +107,33 @@ static void parse_feature(const char *features)
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_feature(const char *features)
|
||||
{
|
||||
char *buf, *sub, *next;
|
||||
|
||||
buf = calloc(strlen(features) + 1, sizeof(char));
|
||||
ASSERT(buf);
|
||||
strncpy(buf, features, strlen(features) + 1);
|
||||
|
||||
for (sub = buf; sub && *sub; sub = next ? next + 1 : NULL) {
|
||||
/* Skip the beginning blanks */
|
||||
while (*sub && *sub == ' ')
|
||||
sub++;
|
||||
next = sub;
|
||||
/* Skip a feature word */
|
||||
while (*next && *next != ' ' && *next != ',')
|
||||
next++;
|
||||
|
||||
if (*next == 0)
|
||||
next = NULL;
|
||||
else
|
||||
*next = 0;
|
||||
|
||||
set_feature_bits(sub);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
|
||||
static void f2fs_parse_options(int argc, char *argv[])
|
||||
{
|
||||
static const char *option_string = "qa:c:d:e:E:il:mo:O:s:S:z:t:fw:";
|
||||
|
Loading…
Reference in New Issue
Block a user