[CRIU] [PATCH 09/11] mounts: handle non-root bind-mounts

Andrey Vagin avagin at openvz.org
Tue Jul 30 12:25:34 EDT 2013


A non-root mount is bind-mounted from a proper root mount.

Non-root mount without root mount is not supported yet

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 mount.c | 37 +++++++++++++++++++++++++++++++------
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/mount.c b/mount.c
index af250c8..6f7fc71 100644
--- a/mount.c
+++ b/mount.c
@@ -239,13 +239,25 @@ static int collect_shared(struct mount_info *info)
 				list_add(&t->mnt_share, &m->mnt_share);
 			}
 		}
-		if (!need_master)
-			continue;
 
-		pr_err("Mount %d (master_id: %d shared_id: %d) "
-		       "has unreachable sharing\n", m->mnt_id,
-			m->master_id, m->shared_id);
-		return -1;
+		if (need_master) {
+			pr_err("Mount %d (master_id: %d shared_id: %d) "
+			       "has unreachable sharing\n", m->mnt_id,
+				m->master_id, m->shared_id);
+			return -1;
+		}
+
+		/* Search bind-mounts */
+		if (list_empty(&m->mnt_bind)) {
+			/*
+			 * A first mounted point will be set up as a source point
+			 * for others. Look at propagate_mount()
+			 */
+			for (t = m->next; t; t = t->next) {
+				if (mounts_equal(m, t, true))
+					list_add(&t->mnt_bind, &m->mnt_bind);
+			}
+		}
 	}
 
 	return 0;
@@ -772,6 +784,19 @@ static int umount_from_slaves(struct mount_info *mi)
 		}
 	}
 
+	/*
+	 * FIXME Currently non-root mounts can be restored
+	 * only if a proper root mount exists
+	 */
+	if (fsroot_mounted(mi))
+		list_for_each_entry(t, &mi->mnt_bind, mnt_bind) {
+			if (t->bind)
+				continue;
+			if (t->master_id)
+				continue;
+			t->bind = mi;
+		}
+
 	return 0;
 }
 
-- 
1.8.3.1



More information about the CRIU mailing list