mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 07:15:31 +00:00
mnt: Add mi->root resolving helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
97
mount.c
97
mount.c
@@ -2363,6 +2363,56 @@ static int rst_collect_local_mntns(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_mp_root(MntEntry *me, struct mount_info *mi)
|
||||||
|
{
|
||||||
|
struct ext_mount *em = NULL;
|
||||||
|
|
||||||
|
if (!me->ext_mount) {
|
||||||
|
mi->root = xstrdup(me->root);
|
||||||
|
if (!mi->root)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* External mount point -- get the reverse mapping
|
||||||
|
* from the command line and put into root's place
|
||||||
|
*/
|
||||||
|
|
||||||
|
em = ext_mount_lookup(me->root);
|
||||||
|
if (!em) {
|
||||||
|
if (!opts.autodetect_ext_mounts) {
|
||||||
|
pr_err("No mapping for %s mountpoint\n", me->mountpoint);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make up an external mount entry for this
|
||||||
|
* mount point, since we couldn't find a user
|
||||||
|
* supplied one.
|
||||||
|
*/
|
||||||
|
em = xmalloc(sizeof(struct ext_mount));
|
||||||
|
if (!em)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Put a : in here since those are invalid on
|
||||||
|
* the cli, so we know it's autogenerated in
|
||||||
|
* debugging.
|
||||||
|
*/
|
||||||
|
em->key = AUTODETECTED_MOUNT;
|
||||||
|
em->val = mi->source;
|
||||||
|
}
|
||||||
|
|
||||||
|
mi->external = em;
|
||||||
|
mi->root = em->val;
|
||||||
|
out:
|
||||||
|
pr_debug("\t\tWill mount %d from %s%s\n",
|
||||||
|
mi->mnt_id, mi->root, em ? " (E)" : "");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int get_mp_mountpoint(MntEntry *me, struct mount_info *mi, char *root, int root_len)
|
static int get_mp_mountpoint(MntEntry *me, struct mount_info *mi, char *root, int root_len)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
@@ -2455,51 +2505,8 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
|
|||||||
/* FIXME: abort unsupported early */
|
/* FIXME: abort unsupported early */
|
||||||
pm->fstype = decode_fstype(me->fstype, me->fsname);
|
pm->fstype = decode_fstype(me->fstype, me->fsname);
|
||||||
|
|
||||||
if (me->ext_mount) {
|
if (get_mp_root(me, pm))
|
||||||
struct ext_mount *em;
|
goto err;
|
||||||
|
|
||||||
/*
|
|
||||||
* External mount point -- get the reverse mapping
|
|
||||||
* from the command line and put into root's place
|
|
||||||
*/
|
|
||||||
|
|
||||||
em = ext_mount_lookup(me->root);
|
|
||||||
if (!em) {
|
|
||||||
if (!opts.autodetect_ext_mounts) {
|
|
||||||
pr_err("No mapping for %s mountpoint\n", me->mountpoint);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make up an external mount entry for this
|
|
||||||
* mount point, since we couldn't find a user
|
|
||||||
* supplied one.
|
|
||||||
*/
|
|
||||||
em = xmalloc(sizeof(struct ext_mount));
|
|
||||||
if (!em)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
em->val = pm->source;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Put a : in here since those are invalid on
|
|
||||||
* the cli, so we know it's autogenerated in
|
|
||||||
* debugging.
|
|
||||||
*/
|
|
||||||
em->key = AUTODETECTED_MOUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
pm->external = em;
|
|
||||||
pm->root = em->val;
|
|
||||||
pr_debug("Mountpoint %s will have root from %s\n",
|
|
||||||
me->mountpoint, pm->root);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
pr_debug("\t\tGetting root for %d\n", pm->mnt_id);
|
|
||||||
pm->root = xstrdup(me->root);
|
|
||||||
if (!pm->root)
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_mp_mountpoint(me, pm, root, root_len))
|
if (get_mp_mountpoint(me, pm, root, root_len))
|
||||||
goto err;
|
goto err;
|
||||||
|
Reference in New Issue
Block a user