diff options
Diffstat (limited to 'fs/coda')
-rw-r--r-- | fs/coda/sysctl.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c index 1c82e9a7d7c8..db3b1a9c9a5b 100644 --- a/fs/coda/sysctl.c +++ b/fs/coda/sysctl.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/sysctl.h> | 16 | #include <linux/sysctl.h> |
17 | #include <linux/proc_fs.h> | 17 | #include <linux/proc_fs.h> |
18 | #include <linux/seq_file.h> | ||
18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
19 | #include <linux/stat.h> | 20 | #include <linux/stat.h> |
20 | #include <linux/ctype.h> | 21 | #include <linux/ctype.h> |
@@ -84,15 +85,11 @@ static int do_reset_coda_cache_inv_stats( ctl_table * table, int write, | |||
84 | return 0; | 85 | return 0; |
85 | } | 86 | } |
86 | 87 | ||
87 | static int coda_vfs_stats_get_info( char * buffer, char ** start, | 88 | static int proc_vfs_stats_show(struct seq_file *m, void *v) |
88 | off_t offset, int length) | ||
89 | { | 89 | { |
90 | int len=0; | ||
91 | off_t begin; | ||
92 | struct coda_vfs_stats * ps = & coda_vfs_stat; | 90 | struct coda_vfs_stats * ps = & coda_vfs_stat; |
93 | 91 | ||
94 | /* this works as long as we are below 1024 characters! */ | 92 | seq_printf(m, |
95 | len += sprintf( buffer, | ||
96 | "Coda VFS statistics\n" | 93 | "Coda VFS statistics\n" |
97 | "===================\n\n" | 94 | "===================\n\n" |
98 | "File Operations:\n" | 95 | "File Operations:\n" |
@@ -132,28 +129,14 @@ static int coda_vfs_stats_get_info( char * buffer, char ** start, | |||
132 | ps->rmdir, | 129 | ps->rmdir, |
133 | ps->rename, | 130 | ps->rename, |
134 | ps->permission); | 131 | ps->permission); |
135 | 132 | return 0; | |
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; | ||
146 | } | 133 | } |
147 | 134 | ||
148 | static int coda_cache_inv_stats_get_info( char * buffer, char ** start, | 135 | static int proc_cache_inv_stats_show(struct seq_file *m, void *v) |
149 | off_t offset, int length) | ||
150 | { | 136 | { |
151 | int len=0; | ||
152 | off_t begin; | ||
153 | struct coda_cache_inv_stats * ps = & coda_cache_inv_stat; | 137 | struct coda_cache_inv_stats * ps = & coda_cache_inv_stat; |
154 | 138 | ||
155 | /* this works as long as we are below 1024 characters! */ | 139 | seq_printf(m, |
156 | len += sprintf( buffer, | ||
157 | "Coda cache invalidation statistics\n" | 140 | "Coda cache invalidation statistics\n" |
158 | "==================================\n\n" | 141 | "==================================\n\n" |
159 | "flush\t\t%9d\n" | 142 | "flush\t\t%9d\n" |
@@ -170,19 +153,35 @@ static int coda_cache_inv_stats_get_info( char * buffer, char ** start, | |||
170 | ps->zap_vnode, | 153 | ps->zap_vnode, |
171 | ps->purge_fid, | 154 | ps->purge_fid, |
172 | ps->replace ); | 155 | ps->replace ); |
173 | 156 | return 0; | |
174 | begin = offset; | 157 | } |
175 | *start = buffer + begin; | ||
176 | len -= begin; | ||
177 | 158 | ||
178 | if ( len > length ) | 159 | static int proc_vfs_stats_open(struct inode *inode, struct file *file) |
179 | len = length; | 160 | { |
180 | if ( len < 0 ) | 161 | return single_open(file, proc_vfs_stats_show, NULL); |
181 | len = 0; | 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 | static ctl_table coda_table[] = { | 185 | static ctl_table coda_table[] = { |
187 | {CODA_TIMEOUT, "timeout", &coda_timeout, sizeof(int), 0644, NULL, &proc_dointvec}, | 186 | {CODA_TIMEOUT, "timeout", &coda_timeout, sizeof(int), 0644, NULL, &proc_dointvec}, |
188 | {CODA_HARD, "hard", &coda_hard, sizeof(int), 0644, NULL, &proc_dointvec}, | 187 | {CODA_HARD, "hard", &coda_hard, sizeof(int), 0644, NULL, &proc_dointvec}, |
@@ -212,9 +211,6 @@ static struct proc_dir_entry* proc_fs_coda; | |||
212 | 211 | ||
213 | #endif | 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 | void coda_sysctl_init(void) | 214 | void coda_sysctl_init(void) |
219 | { | 215 | { |
220 | reset_coda_vfs_stats(); | 216 | reset_coda_vfs_stats(); |
@@ -223,9 +219,15 @@ void coda_sysctl_init(void) | |||
223 | #ifdef CONFIG_PROC_FS | 219 | #ifdef CONFIG_PROC_FS |
224 | proc_fs_coda = proc_mkdir("coda", proc_root_fs); | 220 | proc_fs_coda = proc_mkdir("coda", proc_root_fs); |
225 | if (proc_fs_coda) { | 221 | if (proc_fs_coda) { |
222 | struct proc_dir_entry *pde; | ||
223 | |||
226 | proc_fs_coda->owner = THIS_MODULE; | 224 | proc_fs_coda->owner = THIS_MODULE; |
227 | coda_proc_create("vfs_stats", coda_vfs_stats_get_info); | 225 | pde = create_proc_entry("vfs_stats", 0, proc_fs_coda); |
228 | coda_proc_create("cache_inv_stats", coda_cache_inv_stats_get_info); | 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 | #endif | 232 | #endif |
231 | 233 | ||