[CRIU] [PATCH 07/10] mounts: handle non-root bind-mounts

Andrey Vagin avagin at openvz.org
Tue Aug 13 09:02:50 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 | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/mount.c b/mount.c
index cbe1f33..7cd4e98 100644
--- a/mount.c
+++ b/mount.c
@@ -256,6 +256,18 @@ static int collect_shared(struct mount_info *info)
 				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;
@@ -799,6 +811,19 @@ static int propagate_mount(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