blob: 83b9135a411af94f15522f0281adefe6d7ef9501 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* -*- linux-c -*- */
2
3/* fs/reiserfs/procfs.c */
4
5/*
6 * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
7 */
8
9/* proc info support a la one created by Sizif@Botik.RU for PGC */
10
11/* $Id: procfs.c,v 1.1.8.2 2001/07/15 17:08:42 god Exp $ */
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/module.h>
14#include <linux/time.h>
15#include <linux/seq_file.h>
16#include <asm/uaccess.h>
17#include <linux/reiserfs_fs.h>
18#include <linux/reiserfs_fs_sb.h>
19#include <linux/smp_lock.h>
20#include <linux/init.h>
21#include <linux/proc_fs.h>
22
Robert P. J. Dayf87367a2007-05-08 00:25:01 -070023#ifdef CONFIG_REISERFS_PROC_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25/*
26 * LOCKING:
27 *
28 * We rely on new Alexander Viro's super-block locking.
29 *
30 */
31
32static int show_version(struct seq_file *m, struct super_block *sb)
33{
34 char *format;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070035
36 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 format = "3.6";
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070038 } else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 format = "3.5";
40 } else {
41 format = "unknown";
42 }
43
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070044 seq_printf(m, "%s format\twith checks %s\n", format,
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#if defined( CONFIG_REISERFS_CHECK )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070046 "on"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#else
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070048 "off"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070050 );
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 return 0;
52}
53
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070054int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
55 int count, int *eof, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
57 *start = buffer;
58 *eof = 1;
59 return 0;
60}
61
62#define SF( x ) ( r -> x )
63#define SFP( x ) SF( s_proc_info_data.x )
64#define SFPL( x ) SFP( x[ level ] )
65#define SFPF( x ) SFP( scan_bitmap.x )
66#define SFPJ( x ) SFP( journal.x )
67
68#define D2C( x ) le16_to_cpu( x )
69#define D4C( x ) le32_to_cpu( x )
70#define DF( x ) D2C( rs -> s_v1.x )
71#define DFL( x ) D4C( rs -> s_v1.x )
72
73#define objectid_map( s, rs ) (old_format_only (s) ? \
Al Viro3e8962b2005-05-01 08:59:18 -070074 (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \
75 (__le32 *)(rs + 1))
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#define MAP( i ) D4C( objectid_map( sb, rs )[ i ] )
77
78#define DJF( x ) le32_to_cpu( rs -> x )
79#define DJV( x ) le32_to_cpu( s_v1 -> x )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070080#define DJP( x ) le32_to_cpu( jp -> x )
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#define JF( x ) ( r -> s_journal -> x )
82
83static int show_super(struct seq_file *m, struct super_block *sb)
84{
85 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070087 seq_printf(m, "state: \t%s\n"
88 "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"
89 "gen. counter: \t%i\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070090 "s_disk_reads: \t%i\n"
91 "s_disk_writes: \t%i\n"
92 "s_fix_nodes: \t%i\n"
93 "s_do_balance: \t%i\n"
94 "s_unneeded_left_neighbor: \t%i\n"
95 "s_good_search_by_key_reada: \t%i\n"
96 "s_bmaps: \t%i\n"
97 "s_bmaps_without_search: \t%i\n"
98 "s_direct2indirect: \t%i\n"
99 "s_indirect2direct: \t%i\n"
100 "\n"
101 "max_hash_collisions: \t%i\n"
102 "breads: \t%lu\n"
103 "bread_misses: \t%lu\n"
104 "search_by_key: \t%lu\n"
105 "search_by_key_fs_changed: \t%lu\n"
106 "search_by_key_restarted: \t%lu\n"
107 "insert_item_restarted: \t%lu\n"
108 "paste_into_item_restarted: \t%lu\n"
109 "cut_from_item_restarted: \t%lu\n"
110 "delete_solid_item_restarted: \t%lu\n"
111 "delete_item_restarted: \t%lu\n"
112 "leaked_oid: \t%lu\n"
113 "leaves_removable: \t%lu\n",
114 SF(s_mount_state) == REISERFS_VALID_FS ?
115 "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
116 reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",
117 reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "",
118 reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",
119 reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",
120 reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",
121 reiserfs_no_unhashed_relocation(sb) ?
122 "NO_UNHASHED_RELOCATION " : "",
123 reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",
124 reiserfs_test4(sb) ? "TEST4 " : "",
125 have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?
126 "SMALL_TAILS " : "NO_TAILS ",
127 replay_only(sb) ? "REPLAY_ONLY " : "",
128 convert_reiserfs(sb) ? "CONV " : "",
Pekka Enbergd739b422006-02-01 03:06:43 -0800129 atomic_read(&r->s_generation_counter),
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700130 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
131 SF(s_do_balance), SF(s_unneeded_left_neighbor),
132 SF(s_good_search_by_key_reada), SF(s_bmaps),
133 SF(s_bmaps_without_search), SF(s_direct2indirect),
134 SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),
135 SFP(bread_miss), SFP(search_by_key),
136 SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),
137 SFP(insert_item_restarted), SFP(paste_into_item_restarted),
138 SFP(cut_from_item_restarted),
139 SFP(delete_solid_item_restarted), SFP(delete_item_restarted),
140 SFP(leaked_oid), SFP(leaves_removable));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142 return 0;
143}
144
145static int show_per_level(struct seq_file *m, struct super_block *sb)
146{
147 struct reiserfs_sb_info *r = REISERFS_SB(sb);
148 int level;
149
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700150 seq_printf(m, "level\t"
151 " balances"
152 " [sbk: reads"
153 " fs_changed"
154 " restarted]"
155 " free space"
156 " items"
157 " can_remove"
158 " lnum"
159 " rnum"
160 " lbytes"
161 " rbytes"
162 " get_neig"
163 " get_neig_res" " need_l_neig" " need_r_neig" "\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700165 for (level = 0; level < MAX_HEIGHT; ++level) {
166 seq_printf(m, "%i\t"
167 " %12lu"
168 " %12lu"
169 " %12lu"
170 " %12lu"
171 " %12lu"
172 " %12lu"
173 " %12lu"
174 " %12li"
175 " %12li"
176 " %12li"
177 " %12li"
178 " %12lu"
179 " %12lu"
180 " %12lu"
181 " %12lu"
182 "\n",
183 level,
184 SFPL(balance_at),
185 SFPL(sbk_read_at),
186 SFPL(sbk_fs_changed),
187 SFPL(sbk_restarted),
188 SFPL(free_at),
189 SFPL(items_at),
190 SFPL(can_node_be_removed),
191 SFPL(lnum),
192 SFPL(rnum),
193 SFPL(lbytes),
194 SFPL(rbytes),
195 SFPL(get_neighbors),
196 SFPL(get_neighbors_restart),
197 SFPL(need_l_neighbor), SFPL(need_r_neighbor)
198 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 }
200 return 0;
201}
202
203static int show_bitmap(struct seq_file *m, struct super_block *sb)
204{
205 struct reiserfs_sb_info *r = REISERFS_SB(sb);
206
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700207 seq_printf(m, "free_block: %lu\n"
208 " scan_bitmap:"
209 " wait"
210 " bmap"
211 " retry"
212 " stolen"
213 " journal_hint"
214 "journal_nohint"
215 "\n"
216 " %14lu"
217 " %14lu"
218 " %14lu"
219 " %14lu"
220 " %14lu"
221 " %14lu"
222 " %14lu"
223 "\n",
224 SFP(free_block),
225 SFPF(call),
226 SFPF(wait),
227 SFPF(bmap),
228 SFPF(retry),
229 SFPF(stolen),
230 SFPF(in_journal_hint), SFPF(in_journal_nohint));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232 return 0;
233}
234
235static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
236{
237 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700238 struct reiserfs_super_block *rs = sb_info->s_rs;
239 int hash_code = DFL(s_hash_function_code);
240 __u32 flags = DJF(s_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700242 seq_printf(m, "block_count: \t%i\n"
243 "free_blocks: \t%i\n"
244 "root_block: \t%i\n"
245 "blocksize: \t%i\n"
246 "oid_maxsize: \t%i\n"
247 "oid_cursize: \t%i\n"
248 "umount_state: \t%i\n"
249 "magic: \t%10.10s\n"
250 "fs_state: \t%i\n"
251 "hash: \t%s\n"
252 "tree_height: \t%i\n"
253 "bmap_nr: \t%i\n"
254 "version: \t%i\n"
255 "flags: \t%x[%s]\n"
256 "reserved_for_journal: \t%i\n",
257 DFL(s_block_count),
258 DFL(s_free_blocks),
259 DFL(s_root_block),
260 DF(s_blocksize),
261 DF(s_oid_maxsize),
262 DF(s_oid_cursize),
263 DF(s_umount_state),
264 rs->s_v1.s_magic,
265 DF(s_fs_state),
266 hash_code == TEA_HASH ? "tea" :
267 (hash_code == YURA_HASH) ? "rupasov" :
268 (hash_code == R5_HASH) ? "r5" :
269 (hash_code == UNSET_HASH) ? "unset" : "unknown",
270 DF(s_tree_height),
271 DF(s_bmap_nr),
272 DF(s_version), flags, (flags & reiserfs_attrs_cleared)
273 ? "attrs_cleared" : "", DF(s_reserved_for_journal));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
275 return 0;
276}
277
278static int show_oidmap(struct seq_file *m, struct super_block *sb)
279{
280 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700281 struct reiserfs_super_block *rs = sb_info->s_rs;
282 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 unsigned long total_used = 0;
284 int i;
285
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700286 for (i = 0; i < mapsize; ++i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 __u32 right;
288
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700289 right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 seq_printf(m, "%s: [ %x .. %x )\n",
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700291 (i & 1) ? "free" : "used", MAP(i), right);
292 if (!(i & 1)) {
293 total_used += right - MAP(i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 }
295 }
296#if defined( REISERFS_USE_OIDMAPF )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700297 if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
Josef Sipek1fc5adb2006-12-08 02:37:33 -0800298 loff_t size = sb_info->oidmap.mapf->f_path.dentry->d_inode->i_size;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700299 total_used += size / sizeof(reiserfs_oidinterval_d_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 }
301#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700302 seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
303 mapsize,
304 mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 return 0;
306}
307
308static int show_journal(struct seq_file *m, struct super_block *sb)
309{
310 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700311 struct reiserfs_super_block *rs = r->s_rs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 struct journal_params *jp = &rs->s_v1.s_journal;
313 char b[BDEVNAME_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700315 seq_printf(m, /* on-disk fields */
316 "jp_journal_1st_block: \t%i\n"
317 "jp_journal_dev: \t%s[%x]\n"
318 "jp_journal_size: \t%i\n"
319 "jp_journal_trans_max: \t%i\n"
320 "jp_journal_magic: \t%i\n"
321 "jp_journal_max_batch: \t%i\n"
322 "jp_journal_max_commit_age: \t%i\n"
323 "jp_journal_max_trans_age: \t%i\n"
324 /* incore fields */
325 "j_1st_reserved_block: \t%i\n"
326 "j_state: \t%li\n"
327 "j_trans_id: \t%lu\n"
328 "j_mount_id: \t%lu\n"
329 "j_start: \t%lu\n"
330 "j_len: \t%lu\n"
331 "j_len_alloc: \t%lu\n"
332 "j_wcount: \t%i\n"
333 "j_bcount: \t%lu\n"
334 "j_first_unflushed_offset: \t%lu\n"
335 "j_last_flush_trans_id: \t%lu\n"
336 "j_trans_start_time: \t%li\n"
337 "j_list_bitmap_index: \t%i\n"
338 "j_must_wait: \t%i\n"
339 "j_next_full_flush: \t%i\n"
340 "j_next_async_flush: \t%i\n"
341 "j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n"
342 /* reiserfs_proc_info_data_t.journal fields */
343 "in_journal: \t%12lu\n"
344 "in_journal_bitmap: \t%12lu\n"
345 "in_journal_reusable: \t%12lu\n"
346 "lock_journal: \t%12lu\n"
347 "lock_journal_wait: \t%12lu\n"
348 "journal_begin: \t%12lu\n"
349 "journal_relock_writers: \t%12lu\n"
350 "journal_relock_wcount: \t%12lu\n"
351 "mark_dirty: \t%12lu\n"
352 "mark_dirty_already: \t%12lu\n"
353 "mark_dirty_notjournal: \t%12lu\n"
354 "restore_prepared: \t%12lu\n"
355 "prepare: \t%12lu\n"
356 "prepare_retry: \t%12lu\n",
357 DJP(jp_journal_1st_block),
358 bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
359 DJP(jp_journal_dev),
360 DJP(jp_journal_size),
361 DJP(jp_journal_trans_max),
362 DJP(jp_journal_magic),
363 DJP(jp_journal_max_batch),
364 SB_JOURNAL(sb)->j_max_commit_age,
365 DJP(jp_journal_max_trans_age),
366 JF(j_1st_reserved_block),
367 JF(j_state),
368 JF(j_trans_id),
369 JF(j_mount_id),
370 JF(j_start),
371 JF(j_len),
372 JF(j_len_alloc),
373 atomic_read(&r->s_journal->j_wcount),
374 JF(j_bcount),
375 JF(j_first_unflushed_offset),
376 JF(j_last_flush_trans_id),
377 JF(j_trans_start_time),
378 JF(j_list_bitmap_index),
379 JF(j_must_wait),
380 JF(j_next_full_flush),
381 JF(j_next_async_flush),
382 JF(j_cnode_used),
383 JF(j_cnode_free),
384 SFPJ(in_journal),
385 SFPJ(in_journal_bitmap),
386 SFPJ(in_journal_reusable),
387 SFPJ(lock_journal),
388 SFPJ(lock_journal_wait),
389 SFPJ(journal_being),
390 SFPJ(journal_relock_writers),
391 SFPJ(journal_relock_wcount),
392 SFPJ(mark_dirty),
393 SFPJ(mark_dirty_already),
394 SFPJ(mark_dirty_notjournal),
395 SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry)
396 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 return 0;
398}
399
400/* iterator */
401static int test_sb(struct super_block *sb, void *data)
402{
403 return data == sb;
404}
405
406static int set_sb(struct super_block *sb, void *data)
407{
408 return -ENOENT;
409}
410
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700411static void *r_start(struct seq_file *m, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412{
413 struct proc_dir_entry *de = m->private;
414 struct super_block *s = de->parent->data;
415 loff_t l = *pos;
416
417 if (l)
418 return NULL;
419
420 if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, s)))
421 return NULL;
422
423 up_write(&s->s_umount);
424
425 if (de->deleted) {
426 deactivate_super(s);
427 return NULL;
428 }
429
430 return s;
431}
432
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700433static void *r_next(struct seq_file *m, void *v, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
435 ++*pos;
436 if (v)
437 deactivate_super(v);
438 return NULL;
439}
440
441static void r_stop(struct seq_file *m, void *v)
442{
443 if (v)
444 deactivate_super(v);
445}
446
447static int r_show(struct seq_file *m, void *v)
448{
449 struct proc_dir_entry *de = m->private;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700450 int (*show) (struct seq_file *, struct super_block *) = de->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 return show(m, v);
452}
453
454static struct seq_operations r_ops = {
455 .start = r_start,
456 .next = r_next,
457 .stop = r_stop,
458 .show = r_show,
459};
460
461static int r_open(struct inode *inode, struct file *file)
462{
463 int ret = seq_open(file, &r_ops);
464
465 if (!ret) {
466 struct seq_file *m = file->private_data;
467 m->private = PDE(inode);
468 }
469 return ret;
470}
471
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800472static const struct file_operations r_file_operations = {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700473 .open = r_open,
474 .read = seq_read,
475 .llseek = seq_lseek,
476 .release = seq_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477};
478
479static struct proc_dir_entry *proc_info_root = NULL;
480static const char proc_info_root_name[] = "fs/reiserfs";
481
482static void add_file(struct super_block *sb, char *name,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700483 int (*func) (struct seq_file *, struct super_block *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484{
485 struct proc_dir_entry *de;
486 de = create_proc_entry(name, 0, REISERFS_SB(sb)->procdir);
487 if (de) {
488 de->data = func;
489 de->proc_fops = &r_file_operations;
490 }
491}
492
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700493int reiserfs_proc_info_init(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494{
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700495 char b[BDEVNAME_SIZE];
496 char *s;
497
498 /* Some block devices use /'s */
499 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
500 s = strchr(b, '/');
501 if (s)
502 *s = '!';
503
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700504 spin_lock_init(&__PINFO(sb).lock);
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700505 REISERFS_SB(sb)->procdir = proc_mkdir(b, proc_info_root);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700506 if (REISERFS_SB(sb)->procdir) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 REISERFS_SB(sb)->procdir->owner = THIS_MODULE;
508 REISERFS_SB(sb)->procdir->data = sb;
509 add_file(sb, "version", show_version);
510 add_file(sb, "super", show_super);
511 add_file(sb, "per-level", show_per_level);
512 add_file(sb, "bitmap", show_bitmap);
513 add_file(sb, "on-disk-super", show_on_disk_super);
514 add_file(sb, "oidmap", show_oidmap);
515 add_file(sb, "journal", show_journal);
516 return 0;
517 }
518 reiserfs_warning(sb, "reiserfs: cannot create /proc/%s/%s",
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700519 proc_info_root_name, b);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 return 1;
521}
522
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700523int reiserfs_proc_info_done(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524{
525 struct proc_dir_entry *de = REISERFS_SB(sb)->procdir;
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700526 char b[BDEVNAME_SIZE];
527 char *s;
528
529 /* Some block devices use /'s */
530 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
531 s = strchr(b, '/');
532 if (s)
533 *s = '!';
534
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 if (de) {
536 remove_proc_entry("journal", de);
537 remove_proc_entry("oidmap", de);
538 remove_proc_entry("on-disk-super", de);
539 remove_proc_entry("bitmap", de);
540 remove_proc_entry("per-level", de);
541 remove_proc_entry("super", de);
542 remove_proc_entry("version", de);
543 }
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700544 spin_lock(&__PINFO(sb).lock);
545 __PINFO(sb).exiting = 1;
546 spin_unlock(&__PINFO(sb).lock);
547 if (proc_info_root) {
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700548 remove_proc_entry(b, proc_info_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 REISERFS_SB(sb)->procdir = NULL;
550 }
551 return 0;
552}
553
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700554struct proc_dir_entry *reiserfs_proc_register_global(char *name,
555 read_proc_t * func)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700557 return (proc_info_root) ? create_proc_read_entry(name, 0,
558 proc_info_root,
559 func, NULL) : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560}
561
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700562void reiserfs_proc_unregister_global(const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700564 remove_proc_entry(name, proc_info_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565}
566
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700567int reiserfs_proc_info_global_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700569 if (proc_info_root == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 proc_info_root = proc_mkdir(proc_info_root_name, NULL);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700571 if (proc_info_root) {
572 proc_info_root->owner = THIS_MODULE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 } else {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700574 reiserfs_warning(NULL,
575 "reiserfs: cannot create /proc/%s",
576 proc_info_root_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 return 1;
578 }
579 }
580 return 0;
581}
582
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700583int reiserfs_proc_info_global_done(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700585 if (proc_info_root != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 proc_info_root = NULL;
587 remove_proc_entry(proc_info_root_name, NULL);
588 }
589 return 0;
590}
591
592/* REISERFS_PROC_INFO */
593#else
594
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700595int reiserfs_proc_info_init(struct super_block *sb)
596{
597 return 0;
598}
599int reiserfs_proc_info_done(struct super_block *sb)
600{
601 return 0;
602}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700604struct proc_dir_entry *reiserfs_proc_register_global(char *name,
605 read_proc_t * func)
606{
607 return NULL;
608}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700610void reiserfs_proc_unregister_global(const char *name)
611{;
612}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700614int reiserfs_proc_info_global_init(void)
615{
616 return 0;
617}
618int reiserfs_proc_info_global_done(void)
619{
620 return 0;
621}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700623int reiserfs_global_version_in_proc(char *buffer, char **start,
624 off_t offset,
625 int count, int *eof, void *data)
626{
627 return 0;
628}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
630/* REISERFS_PROC_INFO */
631#endif
632
633/*
634 * $Log: procfs.c,v $
635 * Revision 1.1.8.2 2001/07/15 17:08:42 god
636 * . use get_super() in procfs.c
637 * . remove remove_save_link() from reiserfs_do_truncate()
638 *
639 * I accept terms and conditions stated in the Legal Agreement
640 * (available at http://www.namesys.com/legalese.html)
641 *
642 * Revision 1.1.8.1 2001/07/11 16:48:50 god
643 * proc info support
644 *
645 * I accept terms and conditions stated in the Legal Agreement
646 * (available at http://www.namesys.com/legalese.html)
647 *
648 */
649
650/*
651 * Make Linus happy.
652 * Local variables:
653 * c-indentation-style: "K&R"
654 * mode-name: "LC"
655 * c-basic-offset: 8
656 * tab-width: 8
657 * End:
658 */