* [PATCH] mkfs.f2fs: support multiple features with one "-O" @ 2018-04-02 4:19 Junling Zheng 2018-04-02 13:35 ` Chao Yu 0 siblings, 1 reply; 8+ messages in thread From: Junling Zheng @ 2018-04-02 4:19 UTC (permalink / raw) To: jaegeuk, yuchao0; +Cc: linux-f2fs-devel 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> --- mkfs/f2fs_format_main.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 741600e..76ff296 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -80,10 +80,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")) { @@ -108,6 +106,32 @@ 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); + } +} + 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:f"; -- 2.16.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] mkfs.f2fs: support multiple features with one "-O" 2018-04-02 4:19 [PATCH] mkfs.f2fs: support multiple features with one "-O" Junling Zheng @ 2018-04-02 13:35 ` Chao Yu 2018-04-03 2:15 ` Junling Zheng 0 siblings, 1 reply; 8+ messages in thread From: Chao Yu @ 2018-04-02 13:35 UTC (permalink / raw) To: Junling Zheng, jaegeuk, yuchao0; +Cc: linux-f2fs-devel On 2018/4/2 12:19, Junling Zheng wrote: > Now one "-O" option can support multiple features separated > by a comma or blank, such as: > feature1,feature2,... or "feature1 feature2 ..." At a glance, can last sector number be parsed as feature name? Thanks, > > Signed-off-by: Junling Zheng <zhengjunling@huawei.com> > --- > mkfs/f2fs_format_main.c | 30 +++++++++++++++++++++++++++--- > 1 file changed, 27 insertions(+), 3 deletions(-) > > diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c > index 741600e..76ff296 100644 > --- a/mkfs/f2fs_format_main.c > +++ b/mkfs/f2fs_format_main.c > @@ -80,10 +80,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")) { > @@ -108,6 +106,32 @@ 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); > + } > +} > + > 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:f"; > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mkfs.f2fs: support multiple features with one "-O" 2018-04-02 13:35 ` Chao Yu @ 2018-04-03 2:15 ` Junling Zheng 2018-04-03 9:24 ` Chao Yu 0 siblings, 1 reply; 8+ messages in thread From: Junling Zheng @ 2018-04-03 2:15 UTC (permalink / raw) To: Chao Yu, jaegeuk, yuchao0; +Cc: linux-f2fs-devel Hi, Chao On 2018/4/2 21:35, Chao Yu wrote: > On 2018/4/2 12:19, Junling Zheng wrote: >> Now one "-O" option can support multiple features separated >> by a comma or blank, such as: >> feature1,feature2,... or "feature1 feature2 ..." > > At a glance, can last sector number be parsed as feature name? > No, we should use quotation marks to wrap whole features while separating them with blanks. Thanks, Junling > Thanks, > >> >> Signed-off-by: Junling Zheng <zhengjunling@huawei.com> >> --- >> mkfs/f2fs_format_main.c | 30 +++++++++++++++++++++++++++--- >> 1 file changed, 27 insertions(+), 3 deletions(-) >> >> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c >> index 741600e..76ff296 100644 >> --- a/mkfs/f2fs_format_main.c >> +++ b/mkfs/f2fs_format_main.c >> @@ -80,10 +80,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")) { >> @@ -108,6 +106,32 @@ 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); >> + } >> +} >> + >> 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:f"; >> > > . > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mkfs.f2fs: support multiple features with one "-O" 2018-04-03 2:15 ` Junling Zheng @ 2018-04-03 9:24 ` Chao Yu 2018-04-03 9:23 ` Junling Zheng 2018-04-03 9:38 ` [PATCH v2] " Junling Zheng 0 siblings, 2 replies; 8+ messages in thread From: Chao Yu @ 2018-04-03 9:24 UTC (permalink / raw) To: Junling Zheng, Chao Yu, jaegeuk; +Cc: linux-f2fs-devel Hi Junling, On 2018/4/3 10:15, Junling Zheng wrote: > Hi, Chao > > On 2018/4/2 21:35, Chao Yu wrote: >> On 2018/4/2 12:19, Junling Zheng wrote: >>> Now one "-O" option can support multiple features separated >>> by a comma or blank, such as: >>> feature1,feature2,... or "feature1 feature2 ..." >> >> At a glance, can last sector number be parsed as feature name? >> > > No, we should use quotation marks to wrap whole features while separating them with blanks. Sorry, that's right. > > Thanks, > Junling > >> Thanks, >> >>> >>> Signed-off-by: Junling Zheng <zhengjunling@huawei.com> >>> --- >>> mkfs/f2fs_format_main.c | 30 +++++++++++++++++++++++++++--- >>> 1 file changed, 27 insertions(+), 3 deletions(-) >>> >>> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c >>> index 741600e..76ff296 100644 >>> --- a/mkfs/f2fs_format_main.c >>> +++ b/mkfs/f2fs_format_main.c >>> @@ -80,10 +80,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")) { >>> @@ -108,6 +106,32 @@ 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);? Thanks, >>> +} >>> + >>> 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:f"; >>> >> >> . >> > > > > . > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mkfs.f2fs: support multiple features with one "-O" 2018-04-03 9:24 ` Chao Yu @ 2018-04-03 9:23 ` Junling Zheng 2018-04-03 9:38 ` [PATCH v2] " Junling Zheng 1 sibling, 0 replies; 8+ messages in thread From: Junling Zheng @ 2018-04-03 9:23 UTC (permalink / raw) To: Chao Yu, Chao Yu, jaegeuk; +Cc: linux-f2fs-devel On 2018/4/3 17:24, Chao Yu wrote: > Hi Junling, > > On 2018/4/3 10:15, Junling Zheng wrote: >> Hi, Chao >> >> On 2018/4/2 21:35, Chao Yu wrote: >>> On 2018/4/2 12:19, Junling Zheng wrote: >>>> Now one "-O" option can support multiple features separated >>>> by a comma or blank, such as: >>>> feature1,feature2,... or "feature1 feature2 ..." >>> >>> At a glance, can last sector number be parsed as feature name? >>> >> >> No, we should use quotation marks to wrap whole features while separating them with blanks. > > Sorry, that's right. > >> >> Thanks, >> Junling >> >>> Thanks, >>> >>>> >>>> Signed-off-by: Junling Zheng <zhengjunling@huawei.com> >>>> --- >>>> mkfs/f2fs_format_main.c | 30 +++++++++++++++++++++++++++--- >>>> 1 file changed, 27 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c >>>> index 741600e..76ff296 100644 >>>> --- a/mkfs/f2fs_format_main.c >>>> +++ b/mkfs/f2fs_format_main.c >>>> @@ -80,10 +80,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")) { >>>> @@ -108,6 +106,32 @@ 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);? > Sorry :( I'll send patch v2... > Thanks, > >>>> +} >>>> + >>>> 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:f"; >>>> >>> >>> . >>> >> >> >> >> . >> > > > . > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] mkfs.f2fs: support multiple features with one "-O" 2018-04-03 9:24 ` Chao Yu 2018-04-03 9:23 ` Junling Zheng @ 2018-04-03 9:38 ` Junling Zheng 2018-04-03 10:01 ` Chao Yu 2018-04-08 4:09 ` [PATCH v3] " Junling Zheng 1 sibling, 2 replies; 8+ messages in thread From: Junling Zheng @ 2018-04-03 9:38 UTC (permalink / raw) To: jaegeuk, chao, yuchao0; +Cc: linux-f2fs-devel 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> --- Changes from v1: - free buf to fix memory leak. mkfs/f2fs_format_main.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 741600e..278efff 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -80,10 +80,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")) { @@ -108,6 +106,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:f"; -- 2.16.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] mkfs.f2fs: support multiple features with one "-O" 2018-04-03 9:38 ` [PATCH v2] " Junling Zheng @ 2018-04-03 10:01 ` Chao Yu 2018-04-08 4:09 ` [PATCH v3] " Junling Zheng 1 sibling, 0 replies; 8+ messages in thread From: Chao Yu @ 2018-04-03 10:01 UTC (permalink / raw) To: Junling Zheng, jaegeuk, chao; +Cc: linux-f2fs-devel On 2018/4/3 17:38, Junling Zheng wrote: > 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> Thanks, ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3] mkfs.f2fs: support multiple features with one "-O" 2018-04-03 9:38 ` [PATCH v2] " Junling Zheng 2018-04-03 10:01 ` Chao Yu @ 2018-04-08 4:09 ` Junling Zheng 1 sibling, 0 replies; 8+ messages in thread From: Junling Zheng @ 2018-04-08 4:09 UTC (permalink / raw) To: jaegeuk, yuchao0; +Cc: linux-f2fs-devel 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> --- Changes from v1: - free buf to fix memory leak. Changes from v2: - modify usage and man page to show this feature. man/mkfs.f2fs.8 | 3 ++- mkfs/f2fs_format_main.c | 33 +++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 index 442c0ea..29dd68f 100644 --- a/man/mkfs.f2fs.8 +++ b/man/mkfs.f2fs.8 @@ -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 diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 449a0ed..a6e4474 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -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:"; -- 2.16.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-04-08 4:09 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-04-02 4:19 [PATCH] mkfs.f2fs: support multiple features with one "-O" Junling Zheng 2018-04-02 13:35 ` Chao Yu 2018-04-03 2:15 ` Junling Zheng 2018-04-03 9:24 ` Chao Yu 2018-04-03 9:23 ` Junling Zheng 2018-04-03 9:38 ` [PATCH v2] " Junling Zheng 2018-04-03 10:01 ` Chao Yu 2018-04-08 4:09 ` [PATCH v3] " Junling Zheng
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).