From: Sheng Yong <shengyong1@huawei.com>
To: chao2.yu@samsung.com, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [RFC PATCH] mkfs.f2fs: avoid dumplicate extension
Date: Fri, 27 Nov 2015 16:55:12 +0000 [thread overview]
Message-ID: <1448643312-28861-1-git-send-email-shengyong1@huawei.com> (raw)
Before copying user specified extension to extension_list, check if it is
already in the list.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
mkfs/f2fs_format.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 176bdea..b7ea19f 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -118,6 +118,26 @@ const char *media_ext_lists[] = {
NULL
};
+static int extension_exist(const char *name, const int len)
+{
+ const char **extlist = media_ext_lists;
+ int name_len, min_len;
+ int ret;
+
+
+ while (*extlist) {
+ name_len = strlen(*extlist);
+ min_len = name_len < len ? name_len : len;
+ ret = strncmp(*extlist, name, min_len);
+
+ if (ret == 0 && name_len == len)
+ return 1;
+ extlist++;
+ }
+
+ return 0;
+}
+
static void configure_extension_list(void)
{
const char **extlist = media_ext_lists;
@@ -144,7 +164,8 @@ static void configure_extension_list(void)
ue = strtok(ext_str, ",");
while (ue != NULL) {
name_len = strlen(ue);
- memcpy(sb.extension_list[i++], ue, name_len);
+ if (!extension_exist(ue, name_len))
+ memcpy(sb.extension_list[i++], ue, name_len);
ue = strtok(NULL, ",");
if (i >= F2FS_MAX_EXTENSION)
break;
--
1.9.1
------------------------------------------------------------------------------
next reply other threads:[~2015-11-27 9:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 16:55 Sheng Yong [this message]
2015-11-27 13:09 ` [RFC PATCH] mkfs.f2fs: avoid dumplicate extension Chao Yu
2015-11-28 0:39 ` Sheng Yong
2015-11-28 2:31 ` Chao Yu
2015-11-28 2:45 ` Sheng Yong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448643312-28861-1-git-send-email-shengyong1@huawei.com \
--to=shengyong1@huawei.com \
--cc=chao2.yu@samsung.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).