[Devel] [PATCH 12/28] [PREP 12/14] Add proc vfsmount on struct pid_namespace

Pavel Emelianov xemul at openvz.org
Fri Jun 15 09:10:28 PDT 2007


Each namespace is supposed to have its own proc mount. So add the
struct vfsmount pointer to struct pid_namespace and introduce the
helpers to initialize it properly.

Signed-off-by: Pavel Emelianov <xemul at openvz.org>

---

 fs/proc/root.c                |   20 ++++++++++++++++++++
 include/linux/pid_namespace.h |    3 +++
 include/linux/proc_fs.h       |   12 ++++++++++++
 3 files changed, 35 insertions(+)

--- ./fs/proc/root.c.pidnswithproc	2007-06-15 15:05:16.000000000 +0400
+++ ./fs/proc/root.c	2007-06-15 15:12:25.000000000 +0400
@@ -107,6 +107,9 @@ void __init proc_root_init(void)
 		unregister_filesystem(&proc_fs_type);
 		return;
 	}
+#ifdef CONFIG_PID_NS
+	init_pid_ns.proc_mnt = proc_mnt;
+#endif
 	proc_misc_init();
 	proc_net = proc_mkdir("net", NULL);
 	proc_net_stat = proc_mkdir("net/stat", NULL);
@@ -222,6 +225,23 @@ struct proc_dir_entry * create_proc_root
 	return de;
 }
 
+int pid_ns_prepare_proc(struct pid_namespace *ns)
+{
+	struct vfsmount *mnt;
+
+	mnt = kern_mount(&proc_fs_type);
+	if (IS_ERR(mnt))
+		return PTR_ERR(mnt);
+
+	ns->proc_mnt = mnt;
+	return 0;
+}
+
+void pid_ns_release_proc(struct pid_namespace *ns)
+{
+	mntput(ns->proc_mnt);
+}
+
 EXPORT_SYMBOL(proc_symlink);
 EXPORT_SYMBOL(proc_mkdir);
 EXPORT_SYMBOL(create_proc_entry);
--- ./include/linux/pid_namespace.h.pidnswithproc	2007-06-15 15:00:32.000000000 +0400
+++ ./include/linux/pid_namespace.h	2007-06-15 15:12:25.000000000 +0400
@@ -20,6 +20,9 @@ struct pid_namespace {
 	struct pidmap pidmap[PIDMAP_ENTRIES];
 	int last_pid;
 	struct task_struct *child_reaper;
+#ifdef CONFIG_PROC_FS
+	struct vfsmount *proc_mnt;
+#endif
 };
 
 extern struct pid_namespace init_pid_ns;
--- ./include/linux/proc_fs.h.pidnswithproc	2007-06-15 15:04:52.000000000 +0400
+++ ./include/linux/proc_fs.h	2007-06-15 15:12:25.000000000 +0400
@@ -144,6 +144,9 @@ extern const struct file_operations proc
 extern const struct file_operations proc_kmsg_operations;
 extern const struct file_operations ppc_htab_operations;
 
+extern int pid_ns_prepare_proc(struct pid_namespace *ns);
+extern void pid_ns_release_proc(struct pid_namespace *ns);
+
 /*
  * proc_tty.c
  */
@@ -251,6 +254,15 @@ static inline void proc_tty_unregister_d
 
 extern struct proc_dir_entry proc_root;
 
+static inline int pid_ns_prepare_proc(struct pid_namespace *ns)
+{
+	return 0;
+}
+
+static inline void pid_ns_release_proc(struct pid_namespace *ns)
+{
+}
+
 #endif /* CONFIG_PROC_FS */
 
 #if !defined(CONFIG_PROC_KCORE)
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list