[CRIU] [PATCH 24/37] mount: set nsid for each mount point
Andrey Vagin
avagin at openvz.org
Fri Apr 18 07:43:02 PDT 2014
We want to look up mntns by mnt_id.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
include/proc_parse.h | 3 ++-
mount.c | 6 +++---
proc_parse.c | 4 +++-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/include/proc_parse.h b/include/proc_parse.h
index 3629455..d57ea27 100644
--- a/include/proc_parse.h
+++ b/include/proc_parse.h
@@ -121,6 +121,7 @@ struct mount_info {
int is_file;
bool is_ns_root;
struct mount_info *next;
+ struct ns_id *nsid;
/* tree linkage */
struct mount_info *parent;
@@ -144,7 +145,7 @@ extern void mnt_entry_free(struct mount_info *mi);
struct vm_area_list;
-extern struct mount_info *parse_mountinfo(pid_t pid);
+extern struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid);
extern int parse_pid_stat(pid_t pid, struct proc_pid_stat *s);
extern int parse_pid_stat_small(pid_t pid, struct proc_pid_stat_small *s);
extern int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_files);
diff --git a/mount.c b/mount.c
index a759d79..54404fe 100644
--- a/mount.c
+++ b/mount.c
@@ -85,7 +85,7 @@ int collect_mount_info(pid_t pid)
{
pr_info("Collecting mountinfo\n");
- mntinfo = parse_mountinfo(pid);
+ mntinfo = parse_mountinfo(pid, NULL);
if (!mntinfo) {
pr_err("Parsing mountinfo %d failed\n", getpid());
return -1;
@@ -839,7 +839,7 @@ struct mount_info *collect_mntinfo(struct ns_id *ns)
if (mntns_collect_root(ns->pid) < 0)
return NULL;
- pm = parse_mountinfo(ns->pid);
+ pm = parse_mountinfo(ns->pid, ns);
if (!pm) {
pr_err("Can't parse %d's mountinfo\n", ns->pid);
return NULL;
@@ -850,7 +850,6 @@ struct mount_info *collect_mntinfo(struct ns_id *ns)
goto err;
return pm;
-
err:
while (pm) {
p = pm;
@@ -1475,6 +1474,7 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
if (!pm)
goto err;
+ pm->nsid = nsid;
pm->next = *pms;
*pms = pm;
diff --git a/proc_parse.c b/proc_parse.c
index 0abacf4..26686d4 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -906,7 +906,7 @@ err:
return ret;
}
-struct mount_info *parse_mountinfo(pid_t pid)
+struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid)
{
struct mount_info *list = NULL;
FILE *f;
@@ -927,6 +927,8 @@ struct mount_info *parse_mountinfo(pid_t pid)
if (!new)
goto err;
+ new->nsid = nsid;
+
new->next = list;
list = new;
--
1.8.5.3
More information about the CRIU
mailing list