Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1476107

[PATCH 2/2] f2fs: fix to detect temporary name of multimedia file

From Chao Yu <yuchao0@huawei.com>
Newsgroups linux.kernel
Subject [PATCH 2/2] f2fs: fix to detect temporary name of multimedia file
Date 2016-09-05 06:30 +0200
Message-ID <sdTHI-7dc-1@gated-at.bofh.it> (permalink)
References <sdTHI-7dc-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Some applications may create multimeida file with temporary name like
'*.jpg.tmp' or '*.mp4.tmp', then rename to '*.jpg' or '*.mp4'.

Now, f2fs can only detect multimedia filename with specified format:
"filename + '.' + extension", so it will make f2fs missing to detect
multimedia file with special temporary name, result in failing to set
cold flag on file.

This patch enhances detection flow for enabling lookup extension in the
middle of temporary filename.

Reported-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/namei.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 73fa356..bfcd9da 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -91,18 +91,23 @@ static int is_multimedia_file(const unsigned char *s, const char *sub)
 {
 	size_t slen = strlen(s);
 	size_t sublen = strlen(sub);
+	int i;
 
 	/*
 	 * filename format of multimedia file should be defined as:
-	 * "filename + '.' + extension".
+	 * "filename + '.' + extension + (optional: '.' + temp extension)".
 	 */
 	if (slen < sublen + 2)
 		return 0;
 
-	if (s[slen - sublen - 1] != '.')
-		return 0;
+	for (i = 1; i < slen - sublen; i++) {
+		if (s[i] != '.')
+			continue;
+		if (!strncasecmp(s + i + 1, sub, sublen))
+			return 1;
+	}
 
-	return !strncasecmp(s + slen - sublen, sub, sublen);
+	return 0;
 }
 
 /*
-- 
2.8.2.311.gee88674

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 2/2] f2fs: fix to detect temporary name of multimedia file Chao Yu <yuchao0@huawei.com> - 2016-09-05 06:30 +0200

csiph-web