aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@openvz.org>2012-12-17 19:05:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-17 20:15:27 -0500
commit138d22b58696c506799f8de759804083ff9effae (patch)
tree4c2af24ab90ececcfd30693cb6e17ab60e30bb86
parentcbac5542d48127b546a23d816380a7926eee1c25 (diff)
fs, epoll: add procfs fdinfo helper
This allows us to print out eventpoll target file descriptor, events and data, the /proc/pid/fdinfo/fd consists of | pos: 0 | flags: 02 | tfd: 5 events: 1d data: ffffffffffffffff enabled: 1 [avagin@: fix for unitialized ret variable] Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Pavel Emelyanov <xemul@parallels.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andrey Vagin <avagin@openvz.org> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: James Bottomley <jbottomley@parallels.com> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Matthew Helsley <matt.helsley@gmail.com> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@onelan.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/eventpoll.c28
-rw-r--r--fs/proc/array.c2
-rw-r--r--fs/signalfd.c18
-rw-r--r--include/linux/proc_fs.h3
4 files changed, 50 insertions, 1 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index cd96649bfe6..be56b21435f 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -38,6 +38,8 @@
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/mman.h> 39#include <asm/mman.h>
40#include <linux/atomic.h> 40#include <linux/atomic.h>
41#include <linux/proc_fs.h>
42#include <linux/seq_file.h>
41 43
42/* 44/*
43 * LOCKING: 45 * LOCKING:
@@ -783,8 +785,34 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
783 return pollflags != -1 ? pollflags : 0; 785 return pollflags != -1 ? pollflags : 0;
784} 786}
785 787
788#ifdef CONFIG_PROC_FS
789static int ep_show_fdinfo(struct seq_file *m, struct file *f)
790{
791 struct eventpoll *ep = f->private_data;
792 struct rb_node *rbp;
793 int ret = 0;
794
795 mutex_lock(&ep->mtx);
796 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
797 struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
798
799 ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
800 epi->ffd.fd, epi->event.events,
801 (long long)epi->event.data);
802 if (ret)
803 break;
804 }
805 mutex_unlock(&ep->mtx);
806
807 return ret;
808}
809#endif
810
786/* File callbacks that implement the eventpoll file behaviour */ 811/* File callbacks that implement the eventpoll file behaviour */
787static const struct file_operations eventpoll_fops = { 812static const struct file_operations eventpoll_fops = {
813#ifdef CONFIG_PROC_FS
814 .show_fdinfo = ep_show_fdinfo,
815#endif
788 .release = ep_eventpoll_release, 816 .release = ep_eventpoll_release,
789 .poll = ep_eventpoll_poll, 817 .poll = ep_eventpoll_poll,
790 .llseek = noop_llseek, 818 .llseek = noop_llseek,
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 439544fec38..060a56a9127 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -220,7 +220,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
220 seq_putc(m, '\n'); 220 seq_putc(m, '\n');
221} 221}
222 222
223static void render_sigset_t(struct seq_file *m, const char *header, 223void render_sigset_t(struct seq_file *m, const char *header,
224 sigset_t *set) 224 sigset_t *set)
225{ 225{
226 int i; 226 int i;
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 8bee4e57091..b5348696173 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -29,6 +29,7 @@
29#include <linux/anon_inodes.h> 29#include <linux/anon_inodes.h>
30#include <linux/signalfd.h> 30#include <linux/signalfd.h>
31#include <linux/syscalls.h> 31#include <linux/syscalls.h>
32#include <linux/proc_fs.h>
32 33
33void signalfd_cleanup(struct sighand_struct *sighand) 34void signalfd_cleanup(struct sighand_struct *sighand)
34{ 35{
@@ -227,7 +228,24 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
227 return total ? total: ret; 228 return total ? total: ret;
228} 229}
229 230
231#ifdef CONFIG_PROC_FS
232static int signalfd_show_fdinfo(struct seq_file *m, struct file *f)
233{
234 struct signalfd_ctx *ctx = f->private_data;
235 sigset_t sigmask;
236
237 sigmask = ctx->sigmask;
238 signotset(&sigmask);
239 render_sigset_t(m, "sigmask:\t", &sigmask);
240
241 return 0;
242}
243#endif
244
230static const struct file_operations signalfd_fops = { 245static const struct file_operations signalfd_fops = {
246#ifdef CONFIG_PROC_FS
247 .show_fdinfo = signalfd_show_fdinfo,
248#endif
231 .release = signalfd_release, 249 .release = signalfd_release,
232 .poll = signalfd_poll, 250 .poll = signalfd_poll,
233 .read = signalfd_read, 251 .read = signalfd_read,
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 3fd2e871ff1..b4f70f0a9a4 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -290,4 +290,7 @@ static inline struct net *PDE_NET(struct proc_dir_entry *pde)
290 return pde->parent->data; 290 return pde->parent->data;
291} 291}
292 292
293#include <linux/signal.h>
294
295void render_sigset_t(struct seq_file *m, const char *header, sigset_t *set);
293#endif /* _LINUX_PROC_FS_H */ 296#endif /* _LINUX_PROC_FS_H */