Commit db297a0f authored by Pavel Emelyanov's avatar Pavel Emelyanov

mnt: Preparations for mountpoints dumping

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 3d64f9d1
......@@ -27,6 +27,7 @@
#include "eventfd.h"
#include "eventpoll.h"
#include "inotify.h"
#include "mount.h"
struct cr_options opts;
......@@ -75,6 +76,7 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
FD_ENTRY(REMAP_FPATH, "remap-fpath", show_remap_files),
FD_ENTRY(GHOST_FILE, "ghost-file-%x", show_ghost_file),
FD_ENTRY(TCP_STREAM, "tcp-stream-%x", show_tcp_stream),
FD_ENTRY(MOUNTPOINTS, "mountpoints-%d", show_mountpoints),
};
static struct cr_fdset *alloc_cr_fdset(int nr)
......@@ -183,6 +185,8 @@ static int parse_ns_string(const char *ptr)
opts.namespaces_flags |= CLONE_NEWUTS;
else if (!strncmp(ptr, "ipc", 3))
opts.namespaces_flags |= CLONE_NEWIPC;
else if (!strncmp(ptr, "mnt", 3))
opts.namespaces_flags |= CLONE_NEWNS;
else
goto bad_ns;
ptr += 4;
......
......@@ -40,6 +40,7 @@ enum {
CR_FD_IPCNS_SHM,
CR_FD_IPCNS_MSG,
CR_FD_IPCNS_SEM,
CR_FD_MOUNTPOINTS,
_CR_FD_NS_TO,
CR_FD_PSTREE,
......
......@@ -39,6 +39,7 @@
#define EVENTPOLL_TFD_MAGIC 0x44433746 /* Novorossiysk */
#define INOTIFY_MAGIC 0x48424431 /* Volgograd */
#define INOTIFY_WD_MAGIC 0x54562009 /* Svetlogorsk (Rauschen) */
#define MOUNTPOINTS_MAGIC 0x55563928 /* Petushki */
enum fd_types {
FDINFO_UND,
......
......@@ -6,4 +6,9 @@ struct proc_mountinfo;
extern int open_mount(unsigned int s_dev);
extern int collect_mount_info(void);
struct cr_fdset;
extern int dump_mnt_ns(int pid, struct cr_fdset *);
struct cr_options;
extern void show_mountpoints(int fd, struct cr_options *);
#endif /* MOUNT_H__ */
......@@ -40,6 +40,10 @@ struct file_handle;
#define F_GETFD 1
#endif
#ifndef CLONE_NEWNS
#define CLONE_NEWNS 0x00020000
#endif
#ifndef CLONE_NEWPID
#define CLONE_NEWPID 0x20000000
#endif
......
......@@ -53,3 +53,14 @@ int collect_mount_info(void)
return 0;
}
int dump_mnt_ns(int ns_pid, struct cr_fdset *fdset)
{
return -1;
}
void show_mountpoints(int fd, struct cr_options *o)
{
pr_img_head(CR_FD_MOUNTPOINTS);
pr_img_tail(CR_FD_MOUNTPOINTS);
}
......@@ -5,6 +5,7 @@
#include "syscall.h"
#include "uts_ns.h"
#include "ipc_ns.h"
#include "mount.h"
int switch_ns(int pid, int type, char *ns)
{
......@@ -49,6 +50,12 @@ static int do_dump_namespaces(int ns_pid, unsigned int ns_flags)
if (ret < 0)
goto err;
}
if (ns_flags & CLONE_NEWNS) {
pr_info("Dump MNT namespace (mountpoints)\n");
ret = dump_mnt_ns(ns_pid, fdset);
if (ret < 0)
goto err;
}
err:
close_cr_fdset(&fdset);
return ret;
......
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