From 473197834610c538467d599a12419e046109ef73 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 29 Nov 2012 14:19:18 +1100 Subject: [PATCH] fdinfo: show sigmask for signalfd fd The sigmask is read in lockless manner for a sake of code simplicity, thus if precise data needed here the tasks which refer to the signalfd should be stopped before read. Signed-off-by: Cyrill Gorcunov Acked-by: Pavel Emelyanov Cc: Oleg Nesterov Cc: Andrey Vagin Cc: Al Viro Cc: Alexey Dobriyan Cc: James Bottomley Cc: "Aneesh Kumar K.V" Cc: Alexey Dobriyan Cc: Matthew Helsley Cc: "J. Bruce Fields" Cc: "Aneesh Kumar K.V" Cc: Tvrtko Ursulin Signed-off-by: Andrew Morton --- fs/proc/array.c | 2 +- fs/signalfd.c | 18 ++++++++++++++++++ include/linux/proc_fs.h | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index 7f7111796ea2..6a91e6ffbcbd 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, seq_putc(m, '\n'); } -static void render_sigset_t(struct seq_file *m, const char *header, +void render_sigset_t(struct seq_file *m, const char *header, sigset_t *set) { int i; diff --git a/fs/signalfd.c b/fs/signalfd.c index 8bee4e570911..b53486961735 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c @@ -29,6 +29,7 @@ #include #include #include +#include void signalfd_cleanup(struct sighand_struct *sighand) { @@ -227,7 +228,24 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count, return total ? total: ret; } +#ifdef CONFIG_PROC_FS +static int signalfd_show_fdinfo(struct seq_file *m, struct file *f) +{ + struct signalfd_ctx *ctx = f->private_data; + sigset_t sigmask; + + sigmask = ctx->sigmask; + signotset(&sigmask); + render_sigset_t(m, "sigmask:\t", &sigmask); + + return 0; +} +#endif + static const struct file_operations signalfd_fops = { +#ifdef CONFIG_PROC_FS + .show_fdinfo = signalfd_show_fdinfo, +#endif .release = signalfd_release, .poll = signalfd_poll, .read = signalfd_read, diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 2e24018b7cec..32676b35d2f5 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -314,4 +314,7 @@ static inline struct net *PDE_NET(struct proc_dir_entry *pde) return pde->parent->data; } +#include + +void render_sigset_t(struct seq_file *m, const char *header, sigset_t *set); #endif /* _LINUX_PROC_FS_H */ -- 2.39.5