[CRIU] [PATCH 1/1] simplify the "ignore filesystem-subtype" logic

Oleg Nesterov oleg at redhat.com
Fri Apr 10 09:24:50 PDT 2015


We can simply overwrite the dot symbol right after the kernel reports
it to us.

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---
 mount.c      |   17 +----------------
 proc_parse.c |   10 +++++++++-
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/mount.c b/mount.c
index b370627..8b57729 100644
--- a/mount.c
+++ b/mount.c
@@ -1344,7 +1344,7 @@ bool add_fsname_auto(const char *names)
 	return fsauto_names != NULL;
 }
 
-static struct fstype *__find_fstype_by_name(char *_fst, bool force_auto)
+static struct fstype *__find_fstype_by_name(char *fst, bool force_auto)
 {
 	int i;
 
@@ -1354,22 +1354,7 @@ static struct fstype *__find_fstype_by_name(char *_fst, bool force_auto)
 	 * anything is wrong, almost every fs has its own features)
 	 * 2nd -- save some space in the image (since we scan all
 	 * names anyway)
-	 *
-	 * The kernel reports "subtypes" sometimes and the valid
-	 * type-vs-subtype delimiter is the dot symbol. We disregard any
-	 * subtypes for the purpose of finding the fstype.
 	 */
-	char fst[1024];
-
-	for (i = 0; _fst[i] && i < sizeof(fst) - 1; i++) {
-		if (_fst[i] == '.')
-			break;
-
-		fst[i] = _fst[i];
-	}
-
-	fst[i] = 0;
-
 	for (i = 1; i < ARRAY_SIZE(fstypes); i++) {
 		struct fstype *fstype = fstypes + i;
 
diff --git a/proc_parse.c b/proc_parse.c
index 2f05699..5d50979 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -947,7 +947,7 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
 {
 	unsigned int kmaj, kmin;
 	int ret, n;
-	char *opt = NULL;
+	char *sub, *opt = NULL;
 
 	new->mountpoint = xmalloc(PATH_MAX);
 	if (new->mountpoint == NULL)
@@ -981,6 +981,14 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
 	ret = sscanf(str, "%ms %ms %ms", fsname, &new->source, &opt);
 	if (ret != 3)
 		goto err;
+	/*
+	 * The kernel reports "subtypes" sometimes and the valid
+	 * type-vs-subtype delimiter is the dot symbol. We disregard
+	 * any subtypes for the purpose of finding the fstype.
+	 */
+	sub = strchr(*fsname, '.');
+	if (sub)
+		*sub = 0;
 
 	new->fstype = find_fstype_by_name(*fsname);
 
-- 
1.5.5.1




More information about the CRIU mailing list