[CRIU] [PATCH] mount: Add ->collect callback

Pavel Emelyanov xemul at virtuozzo.com
Wed Jan 11 00:40:09 PST 2017


This helps cleanup cr-time mounts a little bit.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/filesystems.c         | 7 ++++---
 criu/include/filesystems.h | 1 +
 criu/mount.c               | 8 +++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/criu/filesystems.c b/criu/filesystems.c
index e640096..258eaac 100644
--- a/criu/filesystems.c
+++ b/criu/filesystems.c
@@ -39,7 +39,7 @@ struct binfmt_misc_info {
 
 LIST_HEAD(binfmt_misc_list);
 
-static int binfmt_misc_parse(struct mount_info *pm)
+static int binfmt_misc_parse_or_collect(struct mount_info *pm)
 {
 	opts.has_binfmt_misc = true;
 	return 0;
@@ -375,7 +375,7 @@ int collect_binfmt_misc(void)
 #else
 #define binfmt_misc_dump	NULL
 #define binfmt_misc_restore	NULL
-#define binfmt_misc_parse	NULL
+#define binfmt_misc_parse_or_collect NULL
 #endif
 
 static int tmpfs_dump(struct mount_info *pm)
@@ -639,7 +639,8 @@ static struct fstype fstypes[] = {
 		.restore = devtmpfs_restore,
 	}, {
 		.name = "binfmt_misc",
-		.parse = binfmt_misc_parse,
+		.parse = binfmt_misc_parse_or_collect,
+		.collect = binfmt_misc_parse_or_collect,
 		.code = FSTYPE__BINFMT_MISC,
 		.dump = binfmt_misc_dump,
 		.restore = binfmt_misc_restore,
diff --git a/criu/include/filesystems.h b/criu/include/filesystems.h
index 1e8d2aa..c9d7925 100644
--- a/criu/include/filesystems.h
+++ b/criu/include/filesystems.h
@@ -14,6 +14,7 @@ struct fstype {
 	int (*dump)(struct mount_info *pm);
 	int (*restore)(struct mount_info *pm);
 	int (*parse)(struct mount_info *pm);
+	int (*collect)(struct mount_info *pm);
 	mount_fn_t mount;
 };
 
diff --git a/criu/mount.c b/criu/mount.c
index 4749f59..9a3d0f4 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -2606,13 +2606,11 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
 			goto err;
 		}
 
-#ifdef CONFIG_BINFMT_MISC_VIRTUALIZED
-		if (me->fstype == FSTYPE__BINFMT_MISC)
-			opts.has_binfmt_misc = true;
-#endif
-
 		/* FIXME: abort unsupported early */
 		pm->fstype = decode_fstype(me->fstype);
+		if (pm->fstype->collect && (pm->fstype->collect(pm) < 0))
+			goto err;
+
 
 		if (me->fsname) {
 			pm->fsname = xstrdup(me->fsname);
-- 
2.5.0


More information about the CRIU mailing list