lkml.org 
[lkml]   [2012]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 6/7] fs, epoll: Add procfs fdinfo helper v2
    This allow 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>
    CC: Pavel Emelyanov <xemul@parallels.com>
    CC: Al Viro <viro@ZenIV.linux.org.uk>
    CC: Alexey Dobriyan <adobriyan@gmail.com>
    CC: Andrew Morton <akpm@linux-foundation.org>
    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: Andrey Vagin <avagin@openvz.org>
    ---
    fs/eventpoll.c | 29 +++++++++++++++++++++++++++++
    1 file changed, 29 insertions(+)

    Index: linux-2.6.git/fs/eventpoll.c
    ===================================================================
    --- linux-2.6.git.orig/fs/eventpoll.c
    +++ linux-2.6.git/fs/eventpoll.c
    @@ -38,6 +38,8 @@
    #include <asm/io.h>
    #include <asm/mman.h>
    #include <linux/atomic.h>
    +#include <linux/proc_fs.h>
    +#include <linux/seq_file.h>

    /*
    * LOCKING:
    @@ -783,8 +785,35 @@ static unsigned int ep_eventpoll_poll(st
    return pollflags != -1 ? pollflags : 0;
    }

    +#ifdef CONFIG_PROC_FS
    +static int ep_show_fdinfo(struct seq_file *m, struct file *f)
    +{
    + struct eventpoll *ep = f->private_data;
    + struct rb_node *rbp;
    + int ret = 0;
    +
    + mutex_lock(&ep->mtx);
    + for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
    + struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
    +
    + ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx enabled: %d\n",
    + epi->ffd.fd, epi->event.events,
    + (long long)epi->event.data,
    + ep_is_linked(&epi->rdllink));
    + if (ret)
    + break;
    + }
    + mutex_unlock(&ep->mtx);
    +
    + return ret;
    +}
    +#endif
    +
    /* File callbacks that implement the eventpoll file behaviour */
    static const struct file_operations eventpoll_fops = {
    +#ifdef CONFIG_PROC_FS
    + .show_fdinfo = ep_show_fdinfo,
    +#endif
    .release = ep_eventpoll_release,
    .poll = ep_eventpoll_poll,
    .llseek = noop_llseek,


    \
     
     \ /
      Last update: 2012-11-12 12:01    [W:4.095 / U:0.232 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site