[CRIU] [PATCH 2/2] mount: Introduce generic FSs parsing callback

Pavel Emelyanov xemul at parallels.com
Wed Dec 4 07:51:25 PST 2013


And make use of it in for btrfs.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 include/proc_parse.h |  2 +-
 mount-btrfs.c        |  2 --
 mount.c              |  5 ++++-
 proc_parse.c         | 21 +++++++++------------
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/include/proc_parse.h b/include/proc_parse.h
index a313d30..857357e 100644
--- a/include/proc_parse.h
+++ b/include/proc_parse.h
@@ -96,6 +96,7 @@ struct fstype {
 	int code;
 	int (*dump)(struct mount_info *pm);
 	int (*restore)(struct mount_info *pm);
+	int (*parse)(struct mount_info *pm);
 };
 
 struct mount_info {
@@ -108,7 +109,6 @@ struct mount_info {
 	int		master_id;
 	int		shared_id;
 	struct fstype	*fstype;
-	char		*kfstype;
 	char		*source;
 	char		*options;
 	bool		mounted;
diff --git a/mount-btrfs.c b/mount-btrfs.c
index fffbdb8..eab065a 100644
--- a/mount-btrfs.c
+++ b/mount-btrfs.c
@@ -487,8 +487,6 @@ err:
 
 int btrfs_parse_mountinfo(struct mount_info *m)
 {
-	if (strcmp(m->kfstype, "btrfs"))
-		return 0;
 	return btrfs_parse_volume(m) ? 0 : -1;
 }
 
diff --git a/mount.c b/mount.c
index ebc5656..3c85cb0 100644
--- a/mount.c
+++ b/mount.c
@@ -603,6 +603,10 @@ static struct fstype fstypes[] = {
 	}, {
 		.name = "simfs",
 		.code = FSTYPE__SIMFS,
+	}, {
+		.name = "btrfs",
+		.code = FSTYPE__UNSUPPORTED,
+		.parse = btrfs_parse_mountinfo,
 	}
 };
 
@@ -1143,7 +1147,6 @@ void mnt_entry_free(struct mount_info *mi)
 
 	xfree(mi->root);
 	xfree(mi->mountpoint);
-	xfree(mi->kfstype);
 	xfree(mi->source);
 	xfree(mi->options);
 	xfree(mi);
diff --git a/proc_parse.c b/proc_parse.c
index 485bd7a..fd27220 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -761,9 +761,6 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new)
 		return -1;
 
 	ret = -1;
-	new->kfstype = xstrdup(fstype);
-	if (!new->kfstype)
-		goto err;
 	new->fstype = find_fstype_by_name(fstype);
 
 	new->options = xmalloc(strlen(opt) + 1);
@@ -810,18 +807,18 @@ struct mount_info *parse_mountinfo(pid_t pid)
 			goto err;
 		}
 
-		pr_info("\ttype %s (%s) source %s %x %s @ %s flags %x options %s\n",
-				new->fstype->name, new->kfstype, new->source,
+		pr_info("\ttype %s source %s %x %s @ %s flags %x options %s\n",
+				new->fstype->name, new->source,
 				new->s_dev, new->root, new->mountpoint,
 				new->flags, new->options);
 
-		/*
-		 * BTRFS requires subvolumes parsing.
-		 */
-		if (btrfs_parse_mountinfo(new)) {
-			pr_err("Failed to parse FS specific data on %s\n",
-			       new->mountpoint);
-			goto err;
+		if (new->fstype->parse) {
+			ret = new->fstype->parse(new);
+			if (ret) {
+				pr_err("Failed to parse FS specific data on %s\n",
+						new->mountpoint);
+				goto err;
+			}
 		}
 	}
 out:
-- 
1.8.3.1


More information about the CRIU mailing list