[CRIU] [PATCH] mount: resolve parent mount of symbolic link correctly

Katerina Koukiou k.koukiou at googlemail.com
Mon Jul 25 07:26:01 PDT 2016


When using --root option in criu dump, when the mountpoint passed
contains a symbolic link, criu does not resolve its parent correctly.
e.g when passing --root /run/rootfs, dump finishes successfully;
but when /var/run/rootfs is passed, where /var/run is symbolic link to
/run it exits with error "New root and old root are the same".

Signed-off-by: Katerina Koukiou <k.koukiou at gmail.com>
---
 criu/mount.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/criu/mount.c b/criu/mount.c
index 7c280c0..0cd83af 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -3420,6 +3420,8 @@ int prepare_mnt_ns(void)
 			return -1;
 	} else {
 		struct mount_info *mi;
+		char *ret;
+		char path[PATH_MAX + 1];
 
 		/*
 		 * The whole tree of mountpoints is to be moved into one
@@ -3428,8 +3430,14 @@ int prepare_mnt_ns(void)
 		 * with a single umount call later.
 		 */
 
+		ret = realpath(opts.root, path);
+		if (!ret) {
+			pr_err("Unable to find real path for %s\n", opts.root);
+			return -1;
+		}
+
 		/* moving a mount residing under a shared mount is invalid. */
-		mi = mount_resolve_path(ns.mnt.mntinfo_tree, opts.root);
+		mi = mount_resolve_path(ns.mnt.mntinfo_tree, path);
 		if (mi == NULL) {
 			pr_err("Unable to find mount point for %s\n", opts.root);
 			return -1;
-- 
2.7.3



More information about the CRIU mailing list