[CRIU] [PATCH 11/14] mount: use per-ns list of mount-points in clean_mnt_ns and free_mnt_ns
Andrey Vagin
avagin at openvz.org
Thu Apr 17 12:24:05 PDT 2014
We are going to dump nested mount namespaces, so we move the mountinfo
list on the namespace structure.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
mount.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/mount.c b/mount.c
index 8a4d909..840d721 100644
--- a/mount.c
+++ b/mount.c
@@ -1299,7 +1299,7 @@ static int do_umount_one(struct mount_info *mi)
return 0;
}
-static int clean_mnt_ns(void)
+static int clean_mnt_ns(struct mount_info *mntinfo_tree)
{
pr_info("Cleaning mount namespace\n");
@@ -1385,16 +1385,14 @@ void mnt_entry_free(struct mount_info *mi)
xfree(mi);
}
-static void free_mounts(void)
+static void free_mntinfo(struct mount_info *pms)
{
- mntinfo_tree = NULL;
-
- while (mntinfo) {
+ while (pms) {
struct mount_info *pm;
- pm = mntinfo->next;
- mnt_entry_free(mntinfo);
- mntinfo = pm;
+ pm = pms->next;
+ mnt_entry_free(pms);
+ pms = pm;
}
}
@@ -1718,10 +1716,15 @@ int fini_mnt_ns()
int prepare_mnt_ns(int ns_pid)
{
int ret = -1;
- struct mount_info *mis;
+ struct mount_info *mis, *old;
+ struct ns_id ns = { .pid = getpid(), .nd = &mnt_ns_desc };
pr_info("Restoring mount namespace\n");
+ old = collect_mntinfo(&ns);
+ if (old == NULL)
+ return -1;
+
close_proc();
mis = read_mnt_ns_img(ns_pid);
@@ -1739,7 +1742,7 @@ int prepare_mnt_ns(int ns_pid)
* prior to recreating new ones.
*/
if (!opts.root) {
- if (clean_mnt_ns())
+ if (clean_mnt_ns(ns.mnt.mntinfo_tree))
return -1;
} else {
struct mount_info *mi;
@@ -1767,7 +1770,7 @@ int prepare_mnt_ns(int ns_pid)
}
}
- free_mounts();
+ free_mntinfo(old);
ret = populate_mnt_ns(ns_pid, mis);
if (ret)
--
1.8.5.3
More information about the CRIU
mailing list