Commit 9bbf81e4830db873300c1d0503b371b4f8a932ce

Authored by Alexey Dobriyan
Committed by Linus Torvalds
1 parent 85cc9b1144

[PATCH] seq_file conversion: coda

Compile-tested.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: <jaharkes@cs.cmu.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 39 additions and 37 deletions Side-by-side Diff

... ... @@ -15,6 +15,7 @@
15 15 #include <linux/mm.h>
16 16 #include <linux/sysctl.h>
17 17 #include <linux/proc_fs.h>
  18 +#include <linux/seq_file.h>
18 19 #include <linux/slab.h>
19 20 #include <linux/stat.h>
20 21 #include <linux/ctype.h>
21 22  
22 23  
... ... @@ -84,15 +85,11 @@
84 85 return 0;
85 86 }
86 87  
87   -static int coda_vfs_stats_get_info( char * buffer, char ** start,
88   - off_t offset, int length)
  88 +static int proc_vfs_stats_show(struct seq_file *m, void *v)
89 89 {
90   - int len=0;
91   - off_t begin;
92 90 struct coda_vfs_stats * ps = & coda_vfs_stat;
93 91  
94   - /* this works as long as we are below 1024 characters! */
95   - len += sprintf( buffer,
  92 + seq_printf(m,
96 93 "Coda VFS statistics\n"
97 94 "===================\n\n"
98 95 "File Operations:\n"
99 96  
100 97  
101 98  
... ... @@ -132,28 +129,14 @@
132 129 ps->rmdir,
133 130 ps->rename,
134 131 ps->permission);
135   -
136   - begin = offset;
137   - *start = buffer + begin;
138   - len -= begin;
139   -
140   - if ( len > length )
141   - len = length;
142   - if ( len < 0 )
143   - len = 0;
144   -
145   - return len;
  132 + return 0;
146 133 }
147 134  
148   -static int coda_cache_inv_stats_get_info( char * buffer, char ** start,
149   - off_t offset, int length)
  135 +static int proc_cache_inv_stats_show(struct seq_file *m, void *v)
150 136 {
151   - int len=0;
152   - off_t begin;
153 137 struct coda_cache_inv_stats * ps = & coda_cache_inv_stat;
154 138  
155   - /* this works as long as we are below 1024 characters! */
156   - len += sprintf( buffer,
  139 + seq_printf(m,
157 140 "Coda cache invalidation statistics\n"
158 141 "==================================\n\n"
159 142 "flush\t\t%9d\n"
160 143  
161 144  
162 145  
... ... @@ -170,19 +153,35 @@
170 153 ps->zap_vnode,
171 154 ps->purge_fid,
172 155 ps->replace );
173   -
174   - begin = offset;
175   - *start = buffer + begin;
176   - len -= begin;
  156 + return 0;
  157 +}
177 158  
178   - if ( len > length )
179   - len = length;
180   - if ( len < 0 )
181   - len = 0;
  159 +static int proc_vfs_stats_open(struct inode *inode, struct file *file)
  160 +{
  161 + return single_open(file, proc_vfs_stats_show, NULL);
  162 +}
182 163  
183   - return len;
  164 +static int proc_cache_inv_stats_open(struct inode *inode, struct file *file)
  165 +{
  166 + return single_open(file, proc_cache_inv_stats_show, NULL);
184 167 }
185 168  
  169 +static const struct file_operations proc_vfs_stats_fops = {
  170 + .owner = THIS_MODULE,
  171 + .open = proc_vfs_stats_open,
  172 + .read = seq_read,
  173 + .llseek = seq_lseek,
  174 + .release = single_release,
  175 +};
  176 +
  177 +static const struct file_operations proc_cache_inv_stats_fops = {
  178 + .owner = THIS_MODULE,
  179 + .open = proc_cache_inv_stats_open,
  180 + .read = seq_read,
  181 + .llseek = seq_lseek,
  182 + .release = single_release,
  183 +};
  184 +
186 185 static ctl_table coda_table[] = {
187 186 {CODA_TIMEOUT, "timeout", &coda_timeout, sizeof(int), 0644, NULL, &proc_dointvec},
188 187 {CODA_HARD, "hard", &coda_hard, sizeof(int), 0644, NULL, &proc_dointvec},
... ... @@ -212,9 +211,6 @@
212 211  
213 212 #endif
214 213  
215   -#define coda_proc_create(name,get_info) \
216   - create_proc_info_entry(name, 0, proc_fs_coda, get_info)
217   -
218 214 void coda_sysctl_init(void)
219 215 {
220 216 reset_coda_vfs_stats();
221 217  
... ... @@ -223,9 +219,15 @@
223 219 #ifdef CONFIG_PROC_FS
224 220 proc_fs_coda = proc_mkdir("coda", proc_root_fs);
225 221 if (proc_fs_coda) {
  222 + struct proc_dir_entry *pde;
  223 +
226 224 proc_fs_coda->owner = THIS_MODULE;
227   - coda_proc_create("vfs_stats", coda_vfs_stats_get_info);
228   - coda_proc_create("cache_inv_stats", coda_cache_inv_stats_get_info);
  225 + pde = create_proc_entry("vfs_stats", 0, proc_fs_coda);
  226 + if (pde)
  227 + pde->proc_fops = &proc_vfs_stats_fops;
  228 + pde = create_proc_entry("cache_inv_stats", 0, proc_fs_coda);
  229 + if (pde)
  230 + pde->proc_fops = &proc_cache_inv_stats_fops;
229 231 }
230 232 #endif
231 233