check: collect mounts of the current mntns

They are used for collecting unix sockets

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2014-04-21 18:23:41 +04:00 committed by Pavel Emelyanov
parent f1b4c5ea9f
commit b6d3314c54
5 changed files with 22 additions and 5 deletions

View file

@ -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");

View file

@ -998,7 +998,7 @@ err_close:
return -1;
}
static int collect_pstree_ids(void)
int collect_pstree_ids(void)
{
struct pstree_item *item;

View file

@ -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;

View file

@ -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__ */

View file

@ -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