diff options
author | Cyrill Gorcunov <gorcunov@openvz.org> | 2012-12-17 19:04:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:27 -0500 |
commit | cbac5542d48127b546a23d816380a7926eee1c25 (patch) | |
tree | 08ae343d94b427ed971bffc507edaaade053c294 /fs/eventfd.c | |
parent | 55985dd72ab27b47530dcc8bdddd28b69f4abe8b (diff) |
fs, eventfd: add procfs fdinfo helper
This allows us to print out raw counter value. The /proc/pid/fdinfo/fd
output is
| pos: 0
| flags: 04002
| eventfd-count: 5a
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/eventfd.c')
-rw-r--r-- | fs/eventfd.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/eventfd.c b/fs/eventfd.c index d81b9f654086..35470d9b96e6 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/export.h> | 19 | #include <linux/export.h> |
20 | #include <linux/kref.h> | 20 | #include <linux/kref.h> |
21 | #include <linux/eventfd.h> | 21 | #include <linux/eventfd.h> |
22 | #include <linux/proc_fs.h> | ||
23 | #include <linux/seq_file.h> | ||
22 | 24 | ||
23 | struct eventfd_ctx { | 25 | struct eventfd_ctx { |
24 | struct kref kref; | 26 | struct kref kref; |
@@ -284,7 +286,25 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c | |||
284 | return res; | 286 | return res; |
285 | } | 287 | } |
286 | 288 | ||
289 | #ifdef CONFIG_PROC_FS | ||
290 | static int eventfd_show_fdinfo(struct seq_file *m, struct file *f) | ||
291 | { | ||
292 | struct eventfd_ctx *ctx = f->private_data; | ||
293 | int ret; | ||
294 | |||
295 | spin_lock_irq(&ctx->wqh.lock); | ||
296 | ret = seq_printf(m, "eventfd-count: %16llx\n", | ||
297 | (unsigned long long)ctx->count); | ||
298 | spin_unlock_irq(&ctx->wqh.lock); | ||
299 | |||
300 | return ret; | ||
301 | } | ||
302 | #endif | ||
303 | |||
287 | static const struct file_operations eventfd_fops = { | 304 | static const struct file_operations eventfd_fops = { |
305 | #ifdef CONFIG_PROC_FS | ||
306 | .show_fdinfo = eventfd_show_fdinfo, | ||
307 | #endif | ||
288 | .release = eventfd_release, | 308 | .release = eventfd_release, |
289 | .poll = eventfd_poll, | 309 | .poll = eventfd_poll, |
290 | .read = eventfd_read, | 310 | .read = eventfd_read, |