Commit c1a25fc1 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mnt: Add mi->root resolving helper

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 259374f6
...@@ -2363,6 +2363,56 @@ static int rst_collect_local_mntns(void) ...@@ -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) ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment