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

Andrei Vagin avagin at openvz.org
Wed Sep 21 23:16:36 PDT 2016


From: Andrei Vagin <avagin at virtuozzo.com>

This function is going to be used more than once.

v2: don't change logic in this patch
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/mount.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/criu/mount.c b/criu/mount.c
index f402f6f..9613122 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -648,6 +648,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;
@@ -712,13 +729,9 @@ 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)) {
+			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