mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 14:55:39 +00:00
mount: Read multiple mntns images (if any) on restore
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@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
898335ba32
commit
fa14bd83f6
42
mount.c
42
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;
|
MntEntry *me = NULL;
|
||||||
int img, ret;
|
int img, ret;
|
||||||
struct mount_info *pms = NULL;
|
|
||||||
|
|
||||||
pr_info("Populating mount namespace\n");
|
img = open_image(CR_FD_MNTS, O_RSTR, nsid->id);
|
||||||
|
|
||||||
img = open_image(CR_FD_MNTS, O_RSTR, ns_pid);
|
|
||||||
if (img < 0)
|
if (img < 0)
|
||||||
return NULL;
|
return -1;
|
||||||
|
|
||||||
pr_debug("Reading mountpoint images\n");
|
pr_debug("Reading mountpoint images\n");
|
||||||
|
|
||||||
@@ -1410,8 +1407,8 @@ static struct mount_info *read_mnt_ns_img(int ns_pid)
|
|||||||
if (!pm)
|
if (!pm)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
pm->next = pms;
|
pm->next = *pms;
|
||||||
pms = pm;
|
*pms = pm;
|
||||||
|
|
||||||
pm->mnt_id = me->mnt_id;
|
pm->mnt_id = me->mnt_id;
|
||||||
pm->parent_mnt_id = me->parent_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);
|
mnt_entry__free_unpacked(me, NULL);
|
||||||
|
|
||||||
close(img);
|
close(img);
|
||||||
return pms;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
err:
|
err:
|
||||||
while (pms) {
|
|
||||||
struct mount_info *pm = pms;
|
|
||||||
pms = pm->next;
|
|
||||||
mnt_entry_free(pm);
|
|
||||||
}
|
|
||||||
close_safe(&img);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user