[CRIU] [PATCH 2/2] mount: Dump/restore devtmpfs if it's virtualized

Cyrill Gorcunov gorcunov at openvz.org
Mon Oct 20 10:01:03 PDT 2014


In case if we meet virtualized devtmpfs on dump
(which means its s_dev is different from one obtained
 during mountpoints dump procedure) we should dump it
with tar help. Thus on restore it get filled from the
image.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 mount.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/mount.c b/mount.c
index 108ab07bd8b6..3e30bc3ffa20 100644
--- a/mount.c
+++ b/mount.c
@@ -729,6 +729,26 @@ out:
 	return ret;
 }
 
+static bool rt_detmpfs_match(struct mount_info *pm)
+{
+	struct stat *host_st;
+
+	host_st = kerndat_get_fs_stat(KERNDAT_FS_STAT_DEVTMPFS);
+	if (host_st) {
+		if (host_st->st_dev == kdev_to_odev(pm->s_dev))
+			return true;
+	}
+
+	return false;
+}
+
+static int devtmpfs_dump(struct mount_info *pm)
+{
+	if (!rt_detmpfs_match(pm))
+		return tmpfs_dump(pm);
+	return 0;
+}
+
 static int tmpfs_restore(struct mount_info *pm)
 {
 	int ret;
@@ -753,6 +773,13 @@ static int tmpfs_restore(struct mount_info *pm)
 	return 0;
 }
 
+static int devtmpfs_restore(struct mount_info *pm)
+{
+	if (!rt_detmpfs_match(pm))
+		return tmpfs_restore(pm);
+	return 0;
+}
+
 static int binfmt_misc_dump(struct mount_info *pm)
 {
 	int fd, ret = -1;
@@ -831,6 +858,8 @@ static struct fstype fstypes[] = {
 	}, {
 		.name = "devtmpfs",
 		.code = FSTYPE__DEVTMPFS,
+		.dump = devtmpfs_dump,
+		.restore = devtmpfs_restore,
 	}, {
 		.name = "binfmt_misc",
 		.code = FSTYPE__BINFMT_MISC,
-- 
1.9.3



More information about the CRIU mailing list