Linux Container Development
 help / color / mirror / Atom feed
* [PATCH 25/28] proc: Supply an accessor to get the process ID associated with some proc files [RFC]
       [not found] ` <20130416182550.27773.89310.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
@ 2013-04-16 18:27   ` David Howells
       [not found]     ` <20130416182730.27773.88726.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2013-04-16 18:27 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn, Tejun Heo,
	cgroups-u79uwXL29TY76Z2rM5mHXA

Supply an accessor to get the process ID associated with some proc files and
directories (get_proc_pid()).

Signed-off-by: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
cc: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---

 fs/proc/base.c          |    5 +++++
 include/linux/proc_fs.h |    2 ++
 kernel/cgroup.c         |    3 +--
 kernel/cpuset.c         |    3 +--
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index f2637c9..9ea16c8 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -157,6 +157,11 @@ static unsigned int pid_entry_count_dirs(const struct pid_entry *entries,
 	return count;
 }
 
+struct pid *get_proc_pid(const struct inode *inode)
+{
+	return PROC_I(inode)->pid;
+}
+
 static int get_task_root(struct task_struct *task, struct path *root)
 {
 	int result = -ENOENT;
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 718e966..7abc72a 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -88,6 +88,7 @@ extern void proc_set_size(struct proc_dir_entry *, loff_t);
 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
 extern void *proc_get_parent_data(const struct inode *);
 extern const char *get_proc_name(const struct proc_dir_entry *);
+extern struct pid *get_proc_pid(const struct inode *);
 #else
 
 static inline void proc_flush_task(struct task_struct *task)
@@ -113,6 +114,7 @@ static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
 	umode_t mode, struct proc_dir_entry *parent) { return NULL; }
 static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
 static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
+static inline struct pid *get_proc_pid(const struct inode *inode) { return NULL; }
 
 #endif /* CONFIG_PROC_FS */
 
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a32f943..021548a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4823,8 +4823,7 @@ out:
 
 static int cgroup_open(struct inode *inode, struct file *file)
 {
-	struct pid *pid = PROC_I(inode)->pid;
-	return single_open(file, proc_cgroup_show, pid);
+	return single_open(file, proc_cgroup_show, get_proc_pid(inode));
 }
 
 const struct file_operations proc_cgroup_operations = {
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 4f9dfe4..0ec6edd 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2703,8 +2703,7 @@ out:
 
 static int cpuset_open(struct inode *inode, struct file *file)
 {
-	struct pid *pid = PROC_I(inode)->pid;
-	return single_open(file, proc_cpuset_show, pid);
+	return single_open(file, proc_cpuset_show, get_proc_pid(inode));
 }
 
 const struct file_operations proc_cpuset_operations = {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 25/28] proc: Supply an accessor to get the process ID associated with some proc files [RFC]
       [not found]     ` <20130416182730.27773.88726.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
@ 2013-04-17  1:53       ` Li Zefan
  2013-04-18 18:39       ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Li Zefan @ 2013-04-17  1:53 UTC (permalink / raw)
  To: David Howells
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn, Tejun Heo,
	cgroups-u79uwXL29TY76Z2rM5mHXA

On 2013/4/17 2:27, David Howells wrote:
> Supply an accessor to get the process ID associated with some proc files and
> directories (get_proc_pid()).
> 
> Signed-off-by: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> cc: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

Acked-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 25/28] proc: Supply an accessor to get the process ID associated with some proc files [RFC]
       [not found]     ` <20130416182730.27773.88726.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
  2013-04-17  1:53       ` Li Zefan
@ 2013-04-18 18:39       ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2013-04-18 18:39 UTC (permalink / raw)
  To: David Howells
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	cgroups-u79uwXL29TY76Z2rM5mHXA

Hello, David.

On Tue, Apr 16, 2013 at 07:27:30PM +0100, David Howells wrote:
> +struct pid *get_proc_pid(const struct inode *inode)
> +{
> +	return PROC_I(inode)->pid;
> +}

Maybe we can add /** comment explaining what this is about?  Other
than that, it looks fine to me.  It probably would be best to route
this through -mm given it touches /proc too, so cc Andrew on the next
posting?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-18 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20130416182550.27773.89310.stgit@warthog.procyon.org.uk>
     [not found] ` <20130416182550.27773.89310.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2013-04-16 18:27   ` [PATCH 25/28] proc: Supply an accessor to get the process ID associated with some proc files [RFC] David Howells
     [not found]     ` <20130416182730.27773.88726.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2013-04-17  1:53       ` Li Zefan
2013-04-18 18:39       ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox