[CRIU] [PATCH] files-reg: Rework strip_deleted

Cyrill Gorcunov gorcunov at openvz.org
Tue Jul 28 01:03:53 PDT 2015


At moment here are two postfixes kernel supports,
so rework the routine to handle both.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 files-reg.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/files-reg.c b/files-reg.c
index 2a6269b2a550..1a89e45a89bd 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -647,16 +647,32 @@ static inline bool nfs_silly_rename(char *rpath, const struct fd_parms *parms)
 
 static void strip_deleted(struct fd_link *link)
 {
-	const char postfix[] = " (deleted)";
-	const size_t plen = strlen(postfix);
+	struct dcache_prepends {
+		const char	*str;
+		size_t		len;
+	} static const prepends[] = {
+		{
+			.str	= " (deleted)",
+			.len	= 10,
+		}, {
+			.str	= "//deleted",
+			.len	= 10,
+		}
+	};
+	size_t i;
+
+	for (i = 0; i < ARRAY_SIZE(prepends); i++) {
+		size_t at;
+
+		if (link->len <= prepends[i].len)
+			continue;
 
-	if (link->len > plen) {
-		size_t at = link->len - plen;
-		if (!strcmp(&link->name[at], postfix)) {
+		at = link->len - prepends[i].len;
+		if (!strcmp(&link->name[at], prepends[i].str)) {
 			pr_debug("Stip %s' tag from '%s'\n",
-				 postfix, link->name);
+				 prepends[i].str, link->name);
 			link->name[at] = '\0';
-			link->len -= plen;
+			link->len -= prepends[i].len;
 		}
 	}
 }
-- 
2.4.3



More information about the CRIU mailing list