[CRIU] [PATCH 27/37] mount: add a function to get a temporary root for mntns
Andrey Vagin
avagin at openvz.org
Fri Apr 18 07:43:05 PDT 2014
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: Andrey Vagin <avagin at openvz.org>
---
include/mount.h | 1 +
mount.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/include/mount.h b/include/mount.h
index 8dc7a2e..0e7a73c 100644
--- a/include/mount.h
+++ b/include/mount.h
@@ -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__ */
diff --git a/mount.c b/mount.c
index 623cdf5..599f50c 100644
--- a/mount.c
+++ b/mount.c
@@ -1566,6 +1566,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];
--
1.8.5.3
More information about the CRIU
mailing list