[CRIU] [PATCH 1/6] mnt: add a function to check whether a mount overmounts something

Andrei Vagin avagin at openvz.org
Mon Sep 12 21:19:43 PDT 2016


From: Andrei Vagin <avagin at virtuozzo.com>

This function is going to be used more than once.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/mount.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/criu/mount.c b/criu/mount.c
index fe120a1..797edd7 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -637,6 +637,23 @@ static struct mount_info *find_fsroot_mount_for(struct mount_info *bm)
 	return NULL;
 }
 
+static bool does_mnt_overmount(struct mount_info *m)
+{
+	struct mount_info *t;
+
+	if (!m->parent)
+		return false;
+
+	list_for_each_entry(t, &m->parent->children, siblings) {
+		if (m == t)
+			continue;
+		if (issubpath(t->mountpoint, m->mountpoint))
+			return true;
+	}
+
+	return false;
+}
+
 static int validate_mounts(struct mount_info *info, bool for_dump)
 {
 	struct mount_info *m, *t;
@@ -701,13 +718,10 @@ static int validate_mounts(struct mount_info *info, bool for_dump)
 			}
 		}
 skip_fstype:
-		list_for_each_entry(t, &m->parent->children, siblings) {
-			if (m == t)
-				continue;
-			if (!issubpath(m->mountpoint, t->mountpoint))
-				continue;
-
-			pr_err("%d:%s is overmounted\n", m->mnt_id, m->mountpoint);
+		if (does_mnt_overmount(m) &&
+		    !list_empty(&m->parent->mnt_share)) {
+			pr_err("Unable to handle mounts under %d:%s\n",
+					m->mnt_id, m->mountpoint);
 			return -1;
 		}
 	}
-- 
2.7.4



More information about the CRIU mailing list