[CRIU] [PATCH 1/3] tmpfs: use device number instead of mnt_id in image names

Andrey Vagin avagin at openvz.org
Mon Jun 16 07:40:03 PDT 2014


One file system can be mounted a few times, so mnt_id isn't unique for it.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 image-desc.c         | 1 +
 include/image-desc.h | 1 +
 include/magic.h      | 1 +
 mount.c              | 6 ++++--
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/image-desc.c b/image-desc.c
index 8145f15..64c6964 100644
--- a/image-desc.c
+++ b/image-desc.c
@@ -66,6 +66,7 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
 	FD_ENTRY(ROUTE,		"route-%d"),
 	FD_ENTRY(IPTABLES,	"iptables-%d"),
 	FD_ENTRY(TMPFS_IMG,	"tmpfs-%d.tar.gz"),
+	FD_ENTRY(TMPFS_DEV,	"tmpfs-dev-%d.tar.gz"),
 	FD_ENTRY(TTY_FILES,	"tty"),
 	FD_ENTRY(TTY_INFO,	"tty-info"),
 	FD_ENTRY(FILE_LOCKS,	"filelocks-%d"),
diff --git a/include/image-desc.h b/include/image-desc.h
index 76644c8..aa2fb37 100644
--- a/include/image-desc.h
+++ b/include/image-desc.h
@@ -78,6 +78,7 @@ enum {
 	_CR_FD_GLOB_TO,
 
 	CR_FD_TMPFS_IMG,
+	CR_FD_TMPFS_DEV,
 	CR_FD_PAGES,
 	CR_FD_PSIGNAL,
 
diff --git a/include/magic.h b/include/magic.h
index 09fa85d..2e1243d 100644
--- a/include/magic.h
+++ b/include/magic.h
@@ -77,6 +77,7 @@
 #define IFADDR_MAGIC		RAW_IMAGE_MAGIC
 #define ROUTE_MAGIC		RAW_IMAGE_MAGIC
 #define TMPFS_IMG_MAGIC		RAW_IMAGE_MAGIC
+#define TMPFS_DEV_MAGIC		RAW_IMAGE_MAGIC
 #define IPTABLES_MAGIC		RAW_IMAGE_MAGIC
 
 #define PAGES_OLD_MAGIC		PAGEMAP_MAGIC
diff --git a/mount.c b/mount.c
index 4e92be8..b449502 100644
--- a/mount.c
+++ b/mount.c
@@ -646,7 +646,7 @@ static int tmpfs_dump(struct mount_info *pm)
 		goto out;
 	}
 
-	fd_img = open_image(CR_FD_TMPFS_IMG, O_DUMP, pm->mnt_id);
+	fd_img = open_image(CR_FD_TMPFS_DEV, O_DUMP, pm->s_dev);
 	if (fd_img < 0)
 		goto out;
 
@@ -676,7 +676,9 @@ static int tmpfs_restore(struct mount_info *pm)
 	int ret;
 	int fd_img;
 
-	fd_img = open_image(CR_FD_TMPFS_IMG, O_RSTR, pm->mnt_id);
+	fd_img = open_image(CR_FD_TMPFS_DEV, O_RSTR, pm->s_dev);
+	if (fd_img < 0 && errno == ENOENT)
+		fd_img = open_image(CR_FD_TMPFS_IMG, O_RSTR, pm->mnt_id);
 	if (fd_img < 0)
 		return -1;
 
-- 
1.8.5.3



More information about the CRIU mailing list