]> Pileus Git - ~andy/linux/blobdiff - fs/eventfd.c
Merge tag 'usb-3.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[~andy/linux] / fs / eventfd.c
index d81b9f654086d1cdb3899767cf6e1e5bf05e9f6e..d6a88e7812f3e68a84888ce104cce4285ea50538 100644 (file)
@@ -19,6 +19,8 @@
 #include <linux/export.h>
 #include <linux/kref.h>
 #include <linux/eventfd.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 
 struct eventfd_ctx {
        struct kref kref;
@@ -284,7 +286,25 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
        return res;
 }
 
+#ifdef CONFIG_PROC_FS
+static int eventfd_show_fdinfo(struct seq_file *m, struct file *f)
+{
+       struct eventfd_ctx *ctx = f->private_data;
+       int ret;
+
+       spin_lock_irq(&ctx->wqh.lock);
+       ret = seq_printf(m, "eventfd-count: %16llx\n",
+                        (unsigned long long)ctx->count);
+       spin_unlock_irq(&ctx->wqh.lock);
+
+       return ret;
+}
+#endif
+
 static const struct file_operations eventfd_fops = {
+#ifdef CONFIG_PROC_FS
+       .show_fdinfo    = eventfd_show_fdinfo,
+#endif
        .release        = eventfd_release,
        .poll           = eventfd_poll,
        .read           = eventfd_read,
@@ -329,15 +349,12 @@ EXPORT_SYMBOL_GPL(eventfd_fget);
  */
 struct eventfd_ctx *eventfd_ctx_fdget(int fd)
 {
-       struct file *file;
        struct eventfd_ctx *ctx;
-
-       file = eventfd_fget(fd);
-       if (IS_ERR(file))
-               return (struct eventfd_ctx *) file;
-       ctx = eventfd_ctx_get(file->private_data);
-       fput(file);
-
+       struct fd f = fdget(fd);
+       if (!f.file)
+               return ERR_PTR(-EBADF);
+       ctx = eventfd_ctx_fileget(f.file);
+       fdput(f);
        return ctx;
 }
 EXPORT_SYMBOL_GPL(eventfd_ctx_fdget);