mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 05:48:05 +00:00
mnt: Helper for getting mntns root path
Acked-by: Andrew Vagin <avagin@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
169dada873
commit
02f7c5c624
23
mount.c
23
mount.c
@ -1395,6 +1395,15 @@ static void free_mntinfo(struct mount_info *pms)
|
||||
*/
|
||||
static char *mnt_roots;
|
||||
|
||||
/*
|
||||
* Helper for getting a path to where the namespace's root
|
||||
* is re-constructed.
|
||||
*/
|
||||
static inline int print_ns_root(struct ns_id *ns, char *buf, int bs)
|
||||
{
|
||||
return snprintf(buf, bs, "%s/%d/", mnt_roots, ns->id);
|
||||
}
|
||||
|
||||
static int create_mnt_roots(void)
|
||||
{
|
||||
if (mnt_roots)
|
||||
@ -1491,8 +1500,7 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
|
||||
goto err;
|
||||
|
||||
if (nsid->id != root_item->ids->mnt_ns_id)
|
||||
root_len = snprintf(root, sizeof(root), "%s/%d/",
|
||||
mnt_roots, nsid->id);
|
||||
root_len = print_ns_root(nsid, root, sizeof(root));
|
||||
len = strlen(me->mountpoint) + root_len + 1;
|
||||
pm->mountpoint = xmalloc(len);
|
||||
if (!pm->mountpoint)
|
||||
@ -1573,9 +1581,7 @@ char *rst_get_mnt_root(int mnt_id)
|
||||
if (m->nsid->pid == getpid())
|
||||
return path;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%d/",
|
||||
mnt_roots, m->nsid->id);
|
||||
|
||||
print_ns_root(m->nsid, path, sizeof(path));
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -1606,8 +1612,7 @@ int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid)
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%d/", mnt_roots, nsid->id);
|
||||
|
||||
print_ns_root(nsid, path, sizeof(path));
|
||||
if (cr_pivot_root(path))
|
||||
return -1;
|
||||
|
||||
@ -1641,9 +1646,7 @@ static int prepare_roots_yard(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%d",
|
||||
mnt_roots, nsid->id);
|
||||
|
||||
print_ns_root(nsid, path, sizeof(path));
|
||||
if (mkdir(path, 0600)) {
|
||||
pr_perror("Unable to create %s", path);
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user