aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-09-29 19:08:25 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-11-05 14:13:23 -0500
commita3816ab0e8fe542a89a53b82506a8ddac063fbe3 (patch)
treeffbc4ef9fe5deb6c9af3473055e0854078e1c7aa /fs
parentf365ef9b79f01d69a01134b42fdff251a510b022 (diff)
fs: Convert show_fdinfo functions to void
seq_printf functions shouldn't really check the return value. Checking seq_has_overflowed() occasionally is used instead. Update vfs documentation. Link: http://lkml.kernel.org/p/e37e6e7b76acbdcc3bb4ab2a57c8f8ca1ae11b9a.1412031505.git.joe@perches.com Cc: David S. Miller <davem@davemloft.net> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Joe Perches <joe@perches.com> [ did a few clean ups ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/eventfd.c9
-rw-r--r--fs/eventpoll.c13
-rw-r--r--fs/notify/fdinfo.c78
-rw-r--r--fs/notify/fdinfo.h4
-rw-r--r--fs/proc/fd.c3
-rw-r--r--fs/signalfd.c4
-rw-r--r--fs/timerfd.c27
7 files changed, 59 insertions, 79 deletions
diff --git a/fs/eventfd.c b/fs/eventfd.c
index d6a88e7812f3..4b0a226024fa 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -287,17 +287,14 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
287} 287}
288 288
289#ifdef CONFIG_PROC_FS 289#ifdef CONFIG_PROC_FS
290static int eventfd_show_fdinfo(struct seq_file *m, struct file *f) 290static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)
291{ 291{
292 struct eventfd_ctx *ctx = f->private_data; 292 struct eventfd_ctx *ctx = f->private_data;
293 int ret;
294 293
295 spin_lock_irq(&ctx->wqh.lock); 294 spin_lock_irq(&ctx->wqh.lock);
296 ret = seq_printf(m, "eventfd-count: %16llx\n", 295 seq_printf(m, "eventfd-count: %16llx\n",
297 (unsigned long long)ctx->count); 296 (unsigned long long)ctx->count);
298 spin_unlock_irq(&ctx->wqh.lock); 297 spin_unlock_irq(&ctx->wqh.lock);
299
300 return ret;
301} 298}
302#endif 299#endif
303 300
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7bcfff900f05..d77f94491352 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -870,25 +870,22 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
870} 870}
871 871
872#ifdef CONFIG_PROC_FS 872#ifdef CONFIG_PROC_FS
873static int ep_show_fdinfo(struct seq_file *m, struct file *f) 873static void ep_show_fdinfo(struct seq_file *m, struct file *f)
874{ 874{
875 struct eventpoll *ep = f->private_data; 875 struct eventpoll *ep = f->private_data;
876 struct rb_node *rbp; 876 struct rb_node *rbp;
877 int ret = 0;
878 877
879 mutex_lock(&ep->mtx); 878 mutex_lock(&ep->mtx);
880 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 879 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
881 struct epitem *epi = rb_entry(rbp, struct epitem, rbn); 880 struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
882 881
883 ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n", 882 seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
884 epi->ffd.fd, epi->event.events, 883 epi->ffd.fd, epi->event.events,
885 (long long)epi->event.data); 884 (long long)epi->event.data);
886 if (ret) 885 if (seq_has_overflowed(m))
887 break; 886 break;
888 } 887 }
889 mutex_unlock(&ep->mtx); 888 mutex_unlock(&ep->mtx);
890
891 return ret;
892} 889}
893#endif 890#endif
894 891
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index 9d7e2b9659cb..6ffd220eb14d 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -20,25 +20,24 @@
20 20
21#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY) 21#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY)
22 22
23static int show_fdinfo(struct seq_file *m, struct file *f, 23static void show_fdinfo(struct seq_file *m, struct file *f,
24 int (*show)(struct seq_file *m, struct fsnotify_mark *mark)) 24 void (*show)(struct seq_file *m,
25 struct fsnotify_mark *mark))
25{ 26{
26 struct fsnotify_group *group = f->private_data; 27 struct fsnotify_group *group = f->private_data;
27 struct fsnotify_mark *mark; 28 struct fsnotify_mark *mark;
28 int ret = 0;
29 29
30 mutex_lock(&group->mark_mutex); 30 mutex_lock(&group->mark_mutex);
31 list_for_each_entry(mark, &group->marks_list, g_list) { 31 list_for_each_entry(mark, &group->marks_list, g_list) {
32 ret = show(m, mark); 32 show(m, mark);
33 if (ret) 33 if (seq_has_overflowed(m))
34 break; 34 break;
35 } 35 }
36 mutex_unlock(&group->mark_mutex); 36 mutex_unlock(&group->mark_mutex);
37 return ret;
38} 37}
39 38
40#if defined(CONFIG_EXPORTFS) 39#if defined(CONFIG_EXPORTFS)
41static int show_mark_fhandle(struct seq_file *m, struct inode *inode) 40static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
42{ 41{
43 struct { 42 struct {
44 struct file_handle handle; 43 struct file_handle handle;
@@ -52,71 +51,62 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
52 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); 51 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
53 if ((ret == FILEID_INVALID) || (ret < 0)) { 52 if ((ret == FILEID_INVALID) || (ret < 0)) {
54 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); 53 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
55 return 0; 54 return;
56 } 55 }
57 56
58 f.handle.handle_type = ret; 57 f.handle.handle_type = ret;
59 f.handle.handle_bytes = size * sizeof(u32); 58 f.handle.handle_bytes = size * sizeof(u32);
60 59
61 ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", 60 seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
62 f.handle.handle_bytes, f.handle.handle_type); 61 f.handle.handle_bytes, f.handle.handle_type);
63 62
64 for (i = 0; i < f.handle.handle_bytes; i++) 63 for (i = 0; i < f.handle.handle_bytes; i++)
65 ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]); 64 seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
66
67 return ret;
68} 65}
69#else 66#else
70static int show_mark_fhandle(struct seq_file *m, struct inode *inode) 67static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
71{ 68{
72 return 0;
73} 69}
74#endif 70#endif
75 71
76#ifdef CONFIG_INOTIFY_USER 72#ifdef CONFIG_INOTIFY_USER
77 73
78static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 74static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
79{ 75{
80 struct inotify_inode_mark *inode_mark; 76 struct inotify_inode_mark *inode_mark;
81 struct inode *inode; 77 struct inode *inode;
82 int ret = 0;
83 78
84 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) 79 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE)))
85 return 0; 80 return;
86 81
87 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); 82 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
88 inode = igrab(mark->i.inode); 83 inode = igrab(mark->i.inode);
89 if (inode) { 84 if (inode) {
90 ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x " 85 seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
91 "mask:%x ignored_mask:%x ", 86 inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
92 inode_mark->wd, inode->i_ino, 87 mark->mask, mark->ignored_mask);
93 inode->i_sb->s_dev, 88 show_mark_fhandle(m, inode);
94 mark->mask, mark->ignored_mask); 89 seq_putc(m, '\n');
95 ret |= show_mark_fhandle(m, inode);
96 ret |= seq_putc(m, '\n');
97 iput(inode); 90 iput(inode);
98 } 91 }
99
100 return ret;
101} 92}
102 93
103int inotify_show_fdinfo(struct seq_file *m, struct file *f) 94void inotify_show_fdinfo(struct seq_file *m, struct file *f)
104{ 95{
105 return show_fdinfo(m, f, inotify_fdinfo); 96 show_fdinfo(m, f, inotify_fdinfo);
106} 97}
107 98
108#endif /* CONFIG_INOTIFY_USER */ 99#endif /* CONFIG_INOTIFY_USER */
109 100
110#ifdef CONFIG_FANOTIFY 101#ifdef CONFIG_FANOTIFY
111 102
112static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 103static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
113{ 104{
114 unsigned int mflags = 0; 105 unsigned int mflags = 0;
115 struct inode *inode; 106 struct inode *inode;
116 int ret = 0;
117 107
118 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) 108 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
119 return 0; 109 return;
120 110
121 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) 111 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
122 mflags |= FAN_MARK_IGNORED_SURV_MODIFY; 112 mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
@@ -124,26 +114,22 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
124 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { 114 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
125 inode = igrab(mark->i.inode); 115 inode = igrab(mark->i.inode);
126 if (!inode) 116 if (!inode)
127 goto out; 117 return;
128 ret = seq_printf(m, "fanotify ino:%lx sdev:%x " 118 seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
129 "mflags:%x mask:%x ignored_mask:%x ", 119 inode->i_ino, inode->i_sb->s_dev,
130 inode->i_ino, inode->i_sb->s_dev, 120 mflags, mark->mask, mark->ignored_mask);
131 mflags, mark->mask, mark->ignored_mask); 121 show_mark_fhandle(m, inode);
132 ret |= show_mark_fhandle(m, inode); 122 seq_putc(m, '\n');
133 ret |= seq_putc(m, '\n');
134 iput(inode); 123 iput(inode);
135 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { 124 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
136 struct mount *mnt = real_mount(mark->m.mnt); 125 struct mount *mnt = real_mount(mark->m.mnt);
137 126
138 ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x " 127 seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n",
139 "ignored_mask:%x\n", mnt->mnt_id, mflags, 128 mnt->mnt_id, mflags, mark->mask, mark->ignored_mask);
140 mark->mask, mark->ignored_mask);
141 } 129 }
142out:
143 return ret;
144} 130}
145 131
146int fanotify_show_fdinfo(struct seq_file *m, struct file *f) 132void fanotify_show_fdinfo(struct seq_file *m, struct file *f)
147{ 133{
148 struct fsnotify_group *group = f->private_data; 134 struct fsnotify_group *group = f->private_data;
149 unsigned int flags = 0; 135 unsigned int flags = 0;
@@ -169,7 +155,7 @@ int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
169 seq_printf(m, "fanotify flags:%x event-flags:%x\n", 155 seq_printf(m, "fanotify flags:%x event-flags:%x\n",
170 flags, group->fanotify_data.f_flags); 156 flags, group->fanotify_data.f_flags);
171 157
172 return show_fdinfo(m, f, fanotify_fdinfo); 158 show_fdinfo(m, f, fanotify_fdinfo);
173} 159}
174 160
175#endif /* CONFIG_FANOTIFY */ 161#endif /* CONFIG_FANOTIFY */
diff --git a/fs/notify/fdinfo.h b/fs/notify/fdinfo.h
index 556afda990e9..9664c4904d6b 100644
--- a/fs/notify/fdinfo.h
+++ b/fs/notify/fdinfo.h
@@ -10,11 +10,11 @@ struct file;
10#ifdef CONFIG_PROC_FS 10#ifdef CONFIG_PROC_FS
11 11
12#ifdef CONFIG_INOTIFY_USER 12#ifdef CONFIG_INOTIFY_USER
13extern int inotify_show_fdinfo(struct seq_file *m, struct file *f); 13void inotify_show_fdinfo(struct seq_file *m, struct file *f);
14#endif 14#endif
15 15
16#ifdef CONFIG_FANOTIFY 16#ifdef CONFIG_FANOTIFY
17extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f); 17void fanotify_show_fdinfo(struct seq_file *m, struct file *f);
18#endif 18#endif
19 19
20#else /* CONFIG_PROC_FS */ 20#else /* CONFIG_PROC_FS */
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index e11d7c590bb0..8e5ad83b629a 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -53,7 +53,8 @@ static int seq_show(struct seq_file *m, void *v)
53 (long long)file->f_pos, f_flags, 53 (long long)file->f_pos, f_flags,
54 real_mount(file->f_path.mnt)->mnt_id); 54 real_mount(file->f_path.mnt)->mnt_id);
55 if (file->f_op->show_fdinfo) 55 if (file->f_op->show_fdinfo)
56 ret = file->f_op->show_fdinfo(m, file); 56 file->f_op->show_fdinfo(m, file);
57 ret = seq_has_overflowed(m);
57 fput(file); 58 fput(file);
58 } 59 }
59 60
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 424b7b65321f..7e412ad74836 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -230,7 +230,7 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
230} 230}
231 231
232#ifdef CONFIG_PROC_FS 232#ifdef CONFIG_PROC_FS
233static int signalfd_show_fdinfo(struct seq_file *m, struct file *f) 233static void signalfd_show_fdinfo(struct seq_file *m, struct file *f)
234{ 234{
235 struct signalfd_ctx *ctx = f->private_data; 235 struct signalfd_ctx *ctx = f->private_data;
236 sigset_t sigmask; 236 sigset_t sigmask;
@@ -238,8 +238,6 @@ static int signalfd_show_fdinfo(struct seq_file *m, struct file *f)
238 sigmask = ctx->sigmask; 238 sigmask = ctx->sigmask;
239 signotset(&sigmask); 239 signotset(&sigmask);
240 render_sigset_t(m, "sigmask:\t", &sigmask); 240 render_sigset_t(m, "sigmask:\t", &sigmask);
241
242 return 0;
243} 241}
244#endif 242#endif
245 243
diff --git a/fs/timerfd.c b/fs/timerfd.c
index b46ffa94372a..b94fa6c3c6eb 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -288,7 +288,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
288} 288}
289 289
290#ifdef CONFIG_PROC_FS 290#ifdef CONFIG_PROC_FS
291static int timerfd_show(struct seq_file *m, struct file *file) 291static void timerfd_show(struct seq_file *m, struct file *file)
292{ 292{
293 struct timerfd_ctx *ctx = file->private_data; 293 struct timerfd_ctx *ctx = file->private_data;
294 struct itimerspec t; 294 struct itimerspec t;
@@ -298,18 +298,19 @@ static int timerfd_show(struct seq_file *m, struct file *file)
298 t.it_interval = ktime_to_timespec(ctx->tintv); 298 t.it_interval = ktime_to_timespec(ctx->tintv);
299 spin_unlock_irq(&ctx->wqh.lock); 299 spin_unlock_irq(&ctx->wqh.lock);
300 300
301 return seq_printf(m, 301 seq_printf(m,
302 "clockid: %d\n" 302 "clockid: %d\n"
303 "ticks: %llu\n" 303 "ticks: %llu\n"
304 "settime flags: 0%o\n" 304 "settime flags: 0%o\n"
305 "it_value: (%llu, %llu)\n" 305 "it_value: (%llu, %llu)\n"
306 "it_interval: (%llu, %llu)\n", 306 "it_interval: (%llu, %llu)\n",
307 ctx->clockid, (unsigned long long)ctx->ticks, 307 ctx->clockid,
308 ctx->settime_flags, 308 (unsigned long long)ctx->ticks,
309 (unsigned long long)t.it_value.tv_sec, 309 ctx->settime_flags,
310 (unsigned long long)t.it_value.tv_nsec, 310 (unsigned long long)t.it_value.tv_sec,
311 (unsigned long long)t.it_interval.tv_sec, 311 (unsigned long long)t.it_value.tv_nsec,
312 (unsigned long long)t.it_interval.tv_nsec); 312 (unsigned long long)t.it_interval.tv_sec,
313 (unsigned long long)t.it_interval.tv_nsec);
313} 314}
314#else 315#else
315#define timerfd_show NULL 316#define timerfd_show NULL