diff --git a/cr-check.c b/cr-check.c index 512c2d342..14f1e4db1 100644 --- a/cr-check.c +++ b/cr-check.c @@ -28,6 +28,8 @@ #include "ptrace.h" #include "kerndat.h" #include "tun.h" +#include "namespaces.h" +#include "pstree.h" static int check_tty(void) { @@ -529,6 +531,7 @@ static int check_posix_timers(void) int cr_check(void) { + struct ns_id ns = { .pid = getpid(), .nd = &mnt_ns_desc }; int ret = 0; log_set_loglevel(LOG_WARN); @@ -536,10 +539,20 @@ int cr_check(void) if (!is_root_user()) return -1; - if (mntns_collect_root(getpid()) < 0) { - pr_err("Can't collect root mount point\n"); + root_item = alloc_pstree_item(); + if (root_item == NULL) + return -1; + + root_item->pid.real = getpid(); + + if (collect_pstree_ids()) + return -1; + + ns.id = root_item->ids->mnt_ns_id; + + mntinfo = collect_mntinfo(&ns); + if (mntinfo == NULL) return -1; - } if (collect_mount_info(getpid())) { pr_err("Can't collect mount infos\n"); diff --git a/cr-dump.c b/cr-dump.c index 1087e562f..64b43108e 100644 --- a/cr-dump.c +++ b/cr-dump.c @@ -998,7 +998,7 @@ err_close: return -1; } -static int collect_pstree_ids(void) +int collect_pstree_ids(void) { struct pstree_item *item; diff --git a/include/mount.h b/include/mount.h index 0e7a73cd5..25df359ad 100644 --- a/include/mount.h +++ b/include/mount.h @@ -1,6 +1,8 @@ #ifndef __CR_MOUNT_H__ #define __CR_MOUNT_H__ +extern struct mount_info *mntinfo; + extern int mntns_collect_root(pid_t pid); struct proc_mountinfo; diff --git a/include/pstree.h b/include/pstree.h index c1f7426d8..dd0470890 100644 --- a/include/pstree.h +++ b/include/pstree.h @@ -67,4 +67,6 @@ extern CoreEntry *core_entry_alloc(int alloc_thread_info, int alloc_tc); extern int pstree_alloc_cores(struct pstree_item *item); extern void pstree_free_cores(struct pstree_item *item); +extern int collect_pstree_ids(void); + #endif /* __CR_PSTREE_H__ */ diff --git a/mount.c b/mount.c index 7baa29ecd..599539d23 100644 --- a/mount.c +++ b/mount.c @@ -32,7 +32,7 @@ /* * Single linked list of mount points get from proc/images */ -static struct mount_info *mntinfo; +struct mount_info *mntinfo; /* * Tree of mount points. When required is generated from * the mntinfo list. Tree elements are sorted, so that it