diff --git a/crtools.c b/crtools.c index aeddab1cf..fc0e010ed 100644 --- a/crtools.c +++ b/crtools.c @@ -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; diff --git a/include/crtools.h b/include/crtools.h index 458ec2d8c..fdfb59b81 100644 --- a/include/crtools.h +++ b/include/crtools.h @@ -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, diff --git a/include/image.h b/include/image.h index e311821ab..3e5f36d45 100644 --- a/include/image.h +++ b/include/image.h @@ -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, diff --git a/include/mount.h b/include/mount.h index c3c758fe8..22f89c2a7 100644 --- a/include/mount.h +++ b/include/mount.h @@ -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__ */ diff --git a/include/syscall-types.h b/include/syscall-types.h index 332fa220e..918c0fc6f 100644 --- a/include/syscall-types.h +++ b/include/syscall-types.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 diff --git a/mount.c b/mount.c index 246f28e1e..a5cc74f8b 100644 --- a/mount.c +++ b/mount.c @@ -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); +} diff --git a/namespaces.c b/namespaces.c index 7a89a299e..43f044c3b 100644 --- a/namespaces.c +++ b/namespaces.c @@ -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;