Skip to contentSkip to conversation

mkfs.f2fs: avoid dumplicate extensions

PATCH In review Sheng Yong 2 participants 4 messages Nov 30, 2015 – Dec 1, 2015

lore
Share & tools
lore

Sheng Yong

author
#0 lore raw

PATCH v3 1/2 mkfs.f2fs: avoid dumplicate extensions

Before copying an user specified extension to extension_list, check if it is already in the list. User specified extensions are delimitted by token either ',' or ' '.

---
 mkfs/f2fs_format.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
mkfs/f2fs_format.c +17 -3
index 176bdea..a29d7ef 100644
@@ -118,6 +118,19 @@ const char *media_ext_lists[] = {
 	NULL
 };
 
+static bool is_extension_exist(const char *name)
+{
+	int i;
+
+	for (i = 0; i < F2FS_MAX_EXTENSION; i++) {
+		char *ext = (char *)sb.extension_list[i];
+		if (!strcmp(ext, name))
+			return 1;
+	}
+
+	return 0;
+}
+
 static void configure_extension_list(void)
 {
 	const char **extlist = media_ext_lists;
@@ -141,11 +154,12 @@ static void configure_extension_list(void)
 		return;
 
 	/* add user ext list */
-	ue = strtok(ext_str, ",");
+	ue = strtok(ext_str, ", ");
 	while (ue != NULL) {
 		name_len = strlen(ue);
-		memcpy(sb.extension_list[i++], ue, name_len);
-		ue = strtok(NULL, ",");
+		if (!is_extension_exist(ue))
+			memcpy(sb.extension_list[i++], ue, name_len);
+		ue = strtok(NULL, ", ");
 		if (i >= F2FS_MAX_EXTENSION)
 			break;
 	}
Signature · 9 lines
1.9.1


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
author
#1 lore raw

PATCH v3 2/2 mkfs.f2fs: skip extension name that is too long

From: Chao Yu <[email protected]>

The length of extension name has a limit of 8 bytes. If an extension exceeds the limitation, it will not be added to the extension_list.

---
 mkfs/f2fs_format.c | 5 +++++
 1 file changed, 5 insertions(+)
mkfs/f2fs_format.c +5 -0
index a29d7ef..212df60 100644
@@ -157,8 +157,13 @@ static void configure_extension_list(void)
 	ue = strtok(ext_str, ", ");
 	while (ue != NULL) {
 		name_len = strlen(ue);
+		if (name_len >= 8) {
+			MSG(0, "\tWarn: Extension name (%s) is too long\n", ue);
+			goto next;
+		}
 		if (!is_extension_exist(ue))
 			memcpy(sb.extension_list[i++], ue, name_len);
+next:
 		ue = strtok(NULL, ", ");
 		if (i >= F2FS_MAX_EXTENSION)
 			break;
Signature · 9 lines
1.9.1


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
author
#2 lore raw

Re: [PATCH V3 2/2] mkfs.f2fs: skip extension name that is too long

Hi, Chao Yu, Jaegeuk

I'm not sure if it is ok to send this patch out by me. If I did it the wrong way, please ignore this patch.

thanks,
Sheng

Quoted 20 lines · Sheng Yong

From: Chao Yu <[email protected]>

The length of extension name has a limit of 8 bytes. If an extension exceeds the limitation, it will not be added to the extension_list.

---
 mkfs/f2fs_format.c | 5 +++++
 1 file changed, 5 insertions(+)
mkfs/f2fs_format.c +0 -0
index a29d7ef..212df60 100644
@@ -157,8 +157,13 @@ static void configure_extension_list(void)
 	ue = strtok(ext_str, ", ");
 	while (ue != NULL) {
 		name_len = strlen(ue);

mkfs/f2fs_format.c static void configure_extension_list(void) · line 169

Quoted 10 lines
mkfs/f2fs_format.c +5 -0
+		if (name_len >= 8) {
+			MSG(0, "\tWarn: Extension name (%s) is too long\n", ue);
+			goto next;
+		}
 		if (!is_extension_exist(ue))
 			memcpy(sb.extension_list[i++], ue, name_len);
+next:
 		ue = strtok(NULL, ", ");
 		if (i >= F2FS_MAX_EXTENSION)
 			break;

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140

#3 lore raw

Re: [PATCH V3 2/2] mkfs.f2fs: skip extension name that is too long

Hi Sheng,

Quoted 4 lines · Sheng Yong

Hi, Chao Yu, Jaegeuk

I'm not sure if it is ok to send this patch out by me. If I did it the wrong way, please ignore this patch.

It's OK to me, thanks for your reediting. :)

Regards,

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140