Commit 259374f6 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mnt: Add mi->mountpoint resolving helper

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d7696a42
...@@ -2363,6 +2363,31 @@ static int rst_collect_local_mntns(void) ...@@ -2363,6 +2363,31 @@ static int rst_collect_local_mntns(void)
return 0; return 0;
} }
static int get_mp_mountpoint(MntEntry *me, struct mount_info *mi, char *root, int root_len)
{
int len;
len = strlen(me->mountpoint) + root_len + 1;
mi->mountpoint = xmalloc(len);
if (!mi->mountpoint)
return -1;
/*
* For bind-mounts we would also fix the root here
* too, but bind-mounts restore merges mountpoint
* and root paths together, so there's no need in
* that.
*/
strcpy(mi->mountpoint, root);
strcpy(mi->mountpoint + root_len, me->mountpoint);
mi->ns_mountpoint = mi->mountpoint + root_len;
pr_debug("\t\tWill mount %d @ %s\n", mi->mnt_id, mi->mountpoint);
return 0;
}
static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid) static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
{ {
MntEntry *me = NULL; MntEntry *me = NULL;
...@@ -2381,7 +2406,6 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid) ...@@ -2381,7 +2406,6 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
while (1) { while (1) {
struct mount_info *pm; struct mount_info *pm;
int len;
ret = pb_read_one_eof(img, &me, PB_MNT); ret = pb_read_one_eof(img, &me, PB_MNT);
if (ret <= 0) if (ret <= 0)
...@@ -2477,22 +2501,8 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid) ...@@ -2477,22 +2501,8 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
goto err; goto err;
} }
len = strlen(me->mountpoint) + root_len + 1; if (get_mp_mountpoint(me, pm, root, root_len))
pm->mountpoint = xmalloc(len);
if (!pm->mountpoint)
goto err; goto err;
pm->ns_mountpoint = pm->mountpoint + root_len;
/*
* For bind-mounts we would also fix the root here
* too, but bind-mounts restore merges mountpoint
* and root paths together, so there's no need in
* that.
*/
strcpy(pm->mountpoint, root);
strcpy(pm->mountpoint + root_len, me->mountpoint);
pr_debug("\t\tGetting mpt for %d %s\n", pm->mnt_id, pm->mountpoint);
pr_debug("\t\tGetting opts for %d\n", pm->mnt_id); pr_debug("\t\tGetting opts for %d\n", pm->mnt_id);
pm->options = xstrdup(me->options); pm->options = xstrdup(me->options);
......
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