Commit 26a0dc91 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mount: add a function to get a temporary root for mntns

On restore all mount namespaces are restored in the root mntns and
sub-namecpeaces are restored in temorary places.

This function allows to get paths to these places.

It will be used in open_remap_ghost(), because it's called in the root
task, when other tasks are not forked yet.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4e6e60a8
......@@ -30,5 +30,6 @@ extern int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid);
extern int fini_mnt_ns(void);
int rst_collect_local_mntns();
char *rst_get_mnt_root(int mnt_id);
#endif /* __CR_MOUNT_H__ */
......@@ -1572,6 +1572,27 @@ err:
return NULL;
}
char *rst_get_mnt_root(int mnt_id)
{
struct mount_info *m;
static char path[PATH_MAX] = "/";
if (!(root_ns_mask & CLONE_NEWNS))
return path;
m = lookup_mnt_id(mnt_id);
if (m == NULL)
return NULL;
if (m->nsid->pid == getpid())
return path;
snprintf(path, sizeof(path), "%s/%d/",
mnt_roots, m->nsid->id);
return path;
}
int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid)
{
char path[PATH_MAX];
......
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