[CRIU] [PATCH 08/39] mount: read information about all mount namespaces
Andrey Vagin
avagin at openvz.org
Mon Apr 21 07:23:18 PDT 2014
read_mnt_ns_img() is splited on two parts. The first part enumirates all
namespaces and call the second part, which read a proper image file.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
mount.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/mount.c b/mount.c
index 758cc34..c0561bb 100644
--- a/mount.c
+++ b/mount.c
@@ -1384,17 +1384,14 @@ static void free_mounts(void)
}
}
-static struct mount_info *read_mnt_ns_img(int ns_pid)
+static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
{
MntEntry *me = NULL;
int img, ret;
- struct mount_info *pms = NULL;
-
- pr_info("Populating mount namespace\n");
- img = open_image(CR_FD_MNTS, O_RSTR, ns_pid);
+ img = open_image(CR_FD_MNTS, O_RSTR, nsid->id);
if (img < 0)
- return NULL;
+ return -1;
pr_debug("Reading mountpoint images\n");
@@ -1410,8 +1407,8 @@ static struct mount_info *read_mnt_ns_img(int ns_pid)
if (!pm)
goto err;
- pm->next = pms;
- pms = pm;
+ pm->next = *pms;
+ *pms = pm;
pm->mnt_id = me->mnt_id;
pm->parent_mnt_id = me->parent_mnt_id;
@@ -1462,15 +1459,32 @@ static struct mount_info *read_mnt_ns_img(int ns_pid)
mnt_entry__free_unpacked(me, NULL);
close(img);
- return pms;
+ return 0;
err:
- while (pms) {
- struct mount_info *pm = pms;
- pms = pm->next;
- mnt_entry_free(pm);
- }
close_safe(&img);
+ return -1;
+}
+
+static struct mount_info *read_mnt_ns_img()
+{
+ struct mount_info *pms = NULL;
+ struct ns_id *nsid;
+
+ nsid = ns_ids;
+ while (nsid) {
+ if (nsid->nd != &mnt_ns_desc) {
+ nsid = nsid->next;
+ continue;
+ }
+
+ if (collect_mnt_from_image(&pms, nsid))
+ goto err;
+
+ nsid = nsid->next;
+ }
+ return pms;
+err:
return NULL;
}
--
1.8.5.3
More information about the CRIU
mailing list