aboutsummaryrefslogtreecommitdiffstats
path: root/fs/eventpoll.c
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 /fs/eventpoll.c
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>
Diffstat (limited to 'fs/eventpoll.c')
-rw-r--r--fs/eventpoll.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index cd96649bfe62..be56b21435f8 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,