[CRIU] [PATCH 05/10] mount: restore shared, slave, private properties.

Andrey Vagin avagin at openvz.org
Tue Aug 13 09:02:48 EDT 2013


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

diff --git a/mount.c b/mount.c
index b2bc9f5..f14f1ca 100644
--- a/mount.c
+++ b/mount.c
@@ -704,6 +704,27 @@ static char *resolve_source(struct mount_info *mi)
 	return NULL;
 }
 
+static int restore_shared_options(struct mount_info *mi, bool private, bool shared, bool slave)
+{
+	pr_debug("%d:%s private %d shared %d slave %d\n",
+			mi->mnt_id, mi->mountpoint, private, shared, slave);
+
+	if (private && mount(NULL, mi->mountpoint, NULL, MS_PRIVATE, NULL)) {
+		pr_perror("Unable to make %s private", mi->mountpoint);
+		return -1;
+	}
+	if (shared && mount(NULL, mi->mountpoint, NULL, MS_SHARED, NULL)) {
+		pr_perror("Unable to make %s shared", mi->mountpoint);
+		return -1;
+	}
+	if (slave && mount(NULL, mi->mountpoint, NULL, MS_SLAVE, NULL)) {
+		pr_perror("Unable to make %s slave", mi->mountpoint);
+		return -1;
+	}
+
+	return 0;
+}
+
 /*
  * Umount points, which are propagated in slave parents, because
  * we can't be sure, that they were inherited in a real life.
@@ -793,6 +814,9 @@ static int do_new_mount(struct mount_info *mi)
 		return -1;
 	}
 
+	if (restore_shared_options(mi, 0, mi->shared_id, 0))
+		return -1;
+
 	if (tp->restore && tp->restore(mi))
 		return -1;
 
-- 
1.8.3.1



More information about the CRIU mailing list