blob: 9aa7a06e093f0a8bd6b48016387ef41128d4b92a [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/init.h>
20#include <linux/proc_fs.h>
21
Robert P. J. Dayf87367a2007-05-08 00:25:01 -070022#ifdef CONFIG_REISERFS_PROC_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24/*
25 * LOCKING:
26 *
27 * We rely on new Alexander Viro's super-block locking.
28 *
29 */
30
31static int show_version(struct seq_file *m, struct super_block *sb)
32{
33 char *format;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070034
35 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 format = "3.6";
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070037 } else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 format = "3.5";
39 } else {
40 format = "unknown";
41 }
42
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070043 seq_printf(m, "%s format\twith checks %s\n", format,
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#if defined( CONFIG_REISERFS_CHECK )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070045 "on"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#else
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070047 "off"
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070049 );
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 return 0;
51}
52
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070053int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
54 int count, int *eof, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055{
56 *start = buffer;
57 *eof = 1;
58 return 0;
59}
60
61#define SF( x ) ( r -> x )
62#define SFP( x ) SF( s_proc_info_data.x )
63#define SFPL( x ) SFP( x[ level ] )
64#define SFPF( x ) SFP( scan_bitmap.x )
65#define SFPJ( x ) SFP( journal.x )
66
67#define D2C( x ) le16_to_cpu( x )
68#define D4C( x ) le32_to_cpu( x )
69#define DF( x ) D2C( rs -> s_v1.x )
70#define DFL( x ) D4C( rs -> s_v1.x )
71
72#define objectid_map( s, rs ) (old_format_only (s) ? \
Al Viro3e8962b2005-05-01 08:59:18 -070073 (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \
74 (__le32 *)(rs + 1))
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#define MAP( i ) D4C( objectid_map( sb, rs )[ i ] )
76
77#define DJF( x ) le32_to_cpu( rs -> x )
78#define DJV( x ) le32_to_cpu( s_v1 -> x )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070079#define DJP( x ) le32_to_cpu( jp -> x )
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define JF( x ) ( r -> s_journal -> x )
81
82static int show_super(struct seq_file *m, struct super_block *sb)
83{
84 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070086 seq_printf(m, "state: \t%s\n"
87 "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"
88 "gen. counter: \t%i\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070089 "s_disk_reads: \t%i\n"
90 "s_disk_writes: \t%i\n"
91 "s_fix_nodes: \t%i\n"
92 "s_do_balance: \t%i\n"
93 "s_unneeded_left_neighbor: \t%i\n"
94 "s_good_search_by_key_reada: \t%i\n"
95 "s_bmaps: \t%i\n"
96 "s_bmaps_without_search: \t%i\n"
97 "s_direct2indirect: \t%i\n"
98 "s_indirect2direct: \t%i\n"
99 "\n"
100 "max_hash_collisions: \t%i\n"
101 "breads: \t%lu\n"
102 "bread_misses: \t%lu\n"
103 "search_by_key: \t%lu\n"
104 "search_by_key_fs_changed: \t%lu\n"
105 "search_by_key_restarted: \t%lu\n"
106 "insert_item_restarted: \t%lu\n"
107 "paste_into_item_restarted: \t%lu\n"
108 "cut_from_item_restarted: \t%lu\n"
109 "delete_solid_item_restarted: \t%lu\n"
110 "delete_item_restarted: \t%lu\n"
111 "leaked_oid: \t%lu\n"
112 "leaves_removable: \t%lu\n",
113 SF(s_mount_state) == REISERFS_VALID_FS ?
114 "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
115 reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",
116 reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "",
117 reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",
118 reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",
119 reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",
120 reiserfs_no_unhashed_relocation(sb) ?
121 "NO_UNHASHED_RELOCATION " : "",
122 reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",
123 reiserfs_test4(sb) ? "TEST4 " : "",
124 have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?
125 "SMALL_TAILS " : "NO_TAILS ",
126 replay_only(sb) ? "REPLAY_ONLY " : "",
127 convert_reiserfs(sb) ? "CONV " : "",
Pekka Enbergd739b422006-02-01 03:06:43 -0800128 atomic_read(&r->s_generation_counter),
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700129 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
130 SF(s_do_balance), SF(s_unneeded_left_neighbor),
131 SF(s_good_search_by_key_reada), SF(s_bmaps),
132 SF(s_bmaps_without_search), SF(s_direct2indirect),
133 SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),
134 SFP(bread_miss), SFP(search_by_key),
135 SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),
136 SFP(insert_item_restarted), SFP(paste_into_item_restarted),
137 SFP(cut_from_item_restarted),
138 SFP(delete_solid_item_restarted), SFP(delete_item_restarted),
139 SFP(leaked_oid), SFP(leaves_removable));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141 return 0;
142}
143
144static int show_per_level(struct seq_file *m, struct super_block *sb)
145{
146 struct reiserfs_sb_info *r = REISERFS_SB(sb);
147 int level;
148
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700149 seq_printf(m, "level\t"
150 " balances"
151 " [sbk: reads"
152 " fs_changed"
153 " restarted]"
154 " free space"
155 " items"
156 " can_remove"
157 " lnum"
158 " rnum"
159 " lbytes"
160 " rbytes"
161 " get_neig"
162 " get_neig_res" " need_l_neig" " need_r_neig" "\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700164 for (level = 0; level < MAX_HEIGHT; ++level) {
165 seq_printf(m, "%i\t"
166 " %12lu"
167 " %12lu"
168 " %12lu"
169 " %12lu"
170 " %12lu"
171 " %12lu"
172 " %12lu"
173 " %12li"
174 " %12li"
175 " %12li"
176 " %12li"
177 " %12lu"
178 " %12lu"
179 " %12lu"
180 " %12lu"
181 "\n",
182 level,
183 SFPL(balance_at),
184 SFPL(sbk_read_at),
185 SFPL(sbk_fs_changed),
186 SFPL(sbk_restarted),
187 SFPL(free_at),
188 SFPL(items_at),
189 SFPL(can_node_be_removed),
190 SFPL(lnum),
191 SFPL(rnum),
192 SFPL(lbytes),
193 SFPL(rbytes),
194 SFPL(get_neighbors),
195 SFPL(get_neighbors_restart),
196 SFPL(need_l_neighbor), SFPL(need_r_neighbor)
197 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 }
199 return 0;
200}
201
202static int show_bitmap(struct seq_file *m, struct super_block *sb)
203{
204 struct reiserfs_sb_info *r = REISERFS_SB(sb);
205
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700206 seq_printf(m, "free_block: %lu\n"
207 " scan_bitmap:"
208 " wait"
209 " bmap"
210 " retry"
211 " stolen"
212 " journal_hint"
213 "journal_nohint"
214 "\n"
215 " %14lu"
216 " %14lu"
217 " %14lu"
218 " %14lu"
219 " %14lu"
220 " %14lu"
221 " %14lu"
222 "\n",
223 SFP(free_block),
224 SFPF(call),
225 SFPF(wait),
226 SFPF(bmap),
227 SFPF(retry),
228 SFPF(stolen),
229 SFPF(in_journal_hint), SFPF(in_journal_nohint));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
231 return 0;
232}
233
234static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
235{
236 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700237 struct reiserfs_super_block *rs = sb_info->s_rs;
238 int hash_code = DFL(s_hash_function_code);
239 __u32 flags = DJF(s_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700241 seq_printf(m, "block_count: \t%i\n"
242 "free_blocks: \t%i\n"
243 "root_block: \t%i\n"
244 "blocksize: \t%i\n"
245 "oid_maxsize: \t%i\n"
246 "oid_cursize: \t%i\n"
247 "umount_state: \t%i\n"
248 "magic: \t%10.10s\n"
249 "fs_state: \t%i\n"
250 "hash: \t%s\n"
251 "tree_height: \t%i\n"
252 "bmap_nr: \t%i\n"
253 "version: \t%i\n"
254 "flags: \t%x[%s]\n"
255 "reserved_for_journal: \t%i\n",
256 DFL(s_block_count),
257 DFL(s_free_blocks),
258 DFL(s_root_block),
259 DF(s_blocksize),
260 DF(s_oid_maxsize),
261 DF(s_oid_cursize),
262 DF(s_umount_state),
263 rs->s_v1.s_magic,
264 DF(s_fs_state),
265 hash_code == TEA_HASH ? "tea" :
266 (hash_code == YURA_HASH) ? "rupasov" :
267 (hash_code == R5_HASH) ? "r5" :
268 (hash_code == UNSET_HASH) ? "unset" : "unknown",
269 DF(s_tree_height),
270 DF(s_bmap_nr),
271 DF(s_version), flags, (flags & reiserfs_attrs_cleared)
272 ? "attrs_cleared" : "", DF(s_reserved_for_journal));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274 return 0;
275}
276
277static int show_oidmap(struct seq_file *m, struct super_block *sb)
278{
279 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700280 struct reiserfs_super_block *rs = sb_info->s_rs;
281 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 unsigned long total_used = 0;
283 int i;
284
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700285 for (i = 0; i < mapsize; ++i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 __u32 right;
287
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700288 right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 seq_printf(m, "%s: [ %x .. %x )\n",
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700290 (i & 1) ? "free" : "used", MAP(i), right);
291 if (!(i & 1)) {
292 total_used += right - MAP(i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 }
294 }
295#if defined( REISERFS_USE_OIDMAPF )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700296 if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
Josef Sipek1fc5adb2006-12-08 02:37:33 -0800297 loff_t size = sb_info->oidmap.mapf->f_path.dentry->d_inode->i_size;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700298 total_used += size / sizeof(reiserfs_oidinterval_d_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 }
300#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700301 seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
302 mapsize,
303 mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 return 0;
305}
306
307static int show_journal(struct seq_file *m, struct super_block *sb)
308{
309 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700310 struct reiserfs_super_block *rs = r->s_rs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 struct journal_params *jp = &rs->s_v1.s_journal;
312 char b[BDEVNAME_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700314 seq_printf(m, /* on-disk fields */
315 "jp_journal_1st_block: \t%i\n"
316 "jp_journal_dev: \t%s[%x]\n"
317 "jp_journal_size: \t%i\n"
318 "jp_journal_trans_max: \t%i\n"
319 "jp_journal_magic: \t%i\n"
320 "jp_journal_max_batch: \t%i\n"
321 "jp_journal_max_commit_age: \t%i\n"
322 "jp_journal_max_trans_age: \t%i\n"
323 /* incore fields */
324 "j_1st_reserved_block: \t%i\n"
325 "j_state: \t%li\n"
326 "j_trans_id: \t%lu\n"
327 "j_mount_id: \t%lu\n"
328 "j_start: \t%lu\n"
329 "j_len: \t%lu\n"
330 "j_len_alloc: \t%lu\n"
331 "j_wcount: \t%i\n"
332 "j_bcount: \t%lu\n"
333 "j_first_unflushed_offset: \t%lu\n"
334 "j_last_flush_trans_id: \t%lu\n"
335 "j_trans_start_time: \t%li\n"
336 "j_list_bitmap_index: \t%i\n"
337 "j_must_wait: \t%i\n"
338 "j_next_full_flush: \t%i\n"
339 "j_next_async_flush: \t%i\n"
340 "j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n"
341 /* reiserfs_proc_info_data_t.journal fields */
342 "in_journal: \t%12lu\n"
343 "in_journal_bitmap: \t%12lu\n"
344 "in_journal_reusable: \t%12lu\n"
345 "lock_journal: \t%12lu\n"
346 "lock_journal_wait: \t%12lu\n"
347 "journal_begin: \t%12lu\n"
348 "journal_relock_writers: \t%12lu\n"
349 "journal_relock_wcount: \t%12lu\n"
350 "mark_dirty: \t%12lu\n"
351 "mark_dirty_already: \t%12lu\n"
352 "mark_dirty_notjournal: \t%12lu\n"
353 "restore_prepared: \t%12lu\n"
354 "prepare: \t%12lu\n"
355 "prepare_retry: \t%12lu\n",
356 DJP(jp_journal_1st_block),
357 bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
358 DJP(jp_journal_dev),
359 DJP(jp_journal_size),
360 DJP(jp_journal_trans_max),
361 DJP(jp_journal_magic),
362 DJP(jp_journal_max_batch),
363 SB_JOURNAL(sb)->j_max_commit_age,
364 DJP(jp_journal_max_trans_age),
365 JF(j_1st_reserved_block),
366 JF(j_state),
367 JF(j_trans_id),
368 JF(j_mount_id),
369 JF(j_start),
370 JF(j_len),
371 JF(j_len_alloc),
372 atomic_read(&r->s_journal->j_wcount),
373 JF(j_bcount),
374 JF(j_first_unflushed_offset),
375 JF(j_last_flush_trans_id),
376 JF(j_trans_start_time),
377 JF(j_list_bitmap_index),
378 JF(j_must_wait),
379 JF(j_next_full_flush),
380 JF(j_next_async_flush),
381 JF(j_cnode_used),
382 JF(j_cnode_free),
383 SFPJ(in_journal),
384 SFPJ(in_journal_bitmap),
385 SFPJ(in_journal_reusable),
386 SFPJ(lock_journal),
387 SFPJ(lock_journal_wait),
388 SFPJ(journal_being),
389 SFPJ(journal_relock_writers),
390 SFPJ(journal_relock_wcount),
391 SFPJ(mark_dirty),
392 SFPJ(mark_dirty_already),
393 SFPJ(mark_dirty_notjournal),
394 SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry)
395 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 return 0;
397}
398
399/* iterator */
400static int test_sb(struct super_block *sb, void *data)
401{
402 return data == sb;
403}
404
405static int set_sb(struct super_block *sb, void *data)
406{
407 return -ENOENT;
408}
409
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700410static void *r_start(struct seq_file *m, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
412 struct proc_dir_entry *de = m->private;
413 struct super_block *s = de->parent->data;
414 loff_t l = *pos;
415
416 if (l)
417 return NULL;
418
419 if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, s)))
420 return NULL;
421
422 up_write(&s->s_umount);
423
424 if (de->deleted) {
425 deactivate_super(s);
426 return NULL;
427 }
428
429 return s;
430}
431
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700432static void *r_next(struct seq_file *m, void *v, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433{
434 ++*pos;
435 if (v)
436 deactivate_super(v);
437 return NULL;
438}
439
440static void r_stop(struct seq_file *m, void *v)
441{
442 if (v)
443 deactivate_super(v);
444}
445
446static int r_show(struct seq_file *m, void *v)
447{
448 struct proc_dir_entry *de = m->private;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700449 int (*show) (struct seq_file *, struct super_block *) = de->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 return show(m, v);
451}
452
453static struct seq_operations r_ops = {
454 .start = r_start,
455 .next = r_next,
456 .stop = r_stop,
457 .show = r_show,
458};
459
460static int r_open(struct inode *inode, struct file *file)
461{
462 int ret = seq_open(file, &r_ops);
463
464 if (!ret) {
465 struct seq_file *m = file->private_data;
466 m->private = PDE(inode);
467 }
468 return ret;
469}
470
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800471static const struct file_operations r_file_operations = {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700472 .open = r_open,
473 .read = seq_read,
474 .llseek = seq_lseek,
475 .release = seq_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476};
477
478static struct proc_dir_entry *proc_info_root = NULL;
479static const char proc_info_root_name[] = "fs/reiserfs";
480
481static void add_file(struct super_block *sb, char *name,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700482 int (*func) (struct seq_file *, struct super_block *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483{
484 struct proc_dir_entry *de;
485 de = create_proc_entry(name, 0, REISERFS_SB(sb)->procdir);
486 if (de) {
487 de->data = func;
488 de->proc_fops = &r_file_operations;
489 }
490}
491
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700492int reiserfs_proc_info_init(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493{
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700494 char b[BDEVNAME_SIZE];
495 char *s;
496
497 /* Some block devices use /'s */
498 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
499 s = strchr(b, '/');
500 if (s)
501 *s = '!';
502
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700503 spin_lock_init(&__PINFO(sb).lock);
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700504 REISERFS_SB(sb)->procdir = proc_mkdir(b, proc_info_root);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700505 if (REISERFS_SB(sb)->procdir) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 REISERFS_SB(sb)->procdir->owner = THIS_MODULE;
507 REISERFS_SB(sb)->procdir->data = sb;
508 add_file(sb, "version", show_version);
509 add_file(sb, "super", show_super);
510 add_file(sb, "per-level", show_per_level);
511 add_file(sb, "bitmap", show_bitmap);
512 add_file(sb, "on-disk-super", show_on_disk_super);
513 add_file(sb, "oidmap", show_oidmap);
514 add_file(sb, "journal", show_journal);
515 return 0;
516 }
517 reiserfs_warning(sb, "reiserfs: cannot create /proc/%s/%s",
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700518 proc_info_root_name, b);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 return 1;
520}
521
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700522int reiserfs_proc_info_done(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523{
524 struct proc_dir_entry *de = REISERFS_SB(sb)->procdir;
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700525 char b[BDEVNAME_SIZE];
526 char *s;
527
528 /* Some block devices use /'s */
529 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
530 s = strchr(b, '/');
531 if (s)
532 *s = '!';
533
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 if (de) {
535 remove_proc_entry("journal", de);
536 remove_proc_entry("oidmap", de);
537 remove_proc_entry("on-disk-super", de);
538 remove_proc_entry("bitmap", de);
539 remove_proc_entry("per-level", de);
540 remove_proc_entry("super", de);
541 remove_proc_entry("version", de);
542 }
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700543 spin_lock(&__PINFO(sb).lock);
544 __PINFO(sb).exiting = 1;
545 spin_unlock(&__PINFO(sb).lock);
546 if (proc_info_root) {
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700547 remove_proc_entry(b, proc_info_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 REISERFS_SB(sb)->procdir = NULL;
549 }
550 return 0;
551}
552
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700553struct proc_dir_entry *reiserfs_proc_register_global(char *name,
554 read_proc_t * func)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700556 return (proc_info_root) ? create_proc_read_entry(name, 0,
557 proc_info_root,
558 func, NULL) : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559}
560
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700561void reiserfs_proc_unregister_global(const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700563 remove_proc_entry(name, proc_info_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564}
565
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700566int reiserfs_proc_info_global_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700568 if (proc_info_root == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 proc_info_root = proc_mkdir(proc_info_root_name, NULL);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700570 if (proc_info_root) {
571 proc_info_root->owner = THIS_MODULE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 } else {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700573 reiserfs_warning(NULL,
574 "reiserfs: cannot create /proc/%s",
575 proc_info_root_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 return 1;
577 }
578 }
579 return 0;
580}
581
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700582int reiserfs_proc_info_global_done(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700584 if (proc_info_root != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 proc_info_root = NULL;
586 remove_proc_entry(proc_info_root_name, NULL);
587 }
588 return 0;
589}
590
591/* REISERFS_PROC_INFO */
592#else
593
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700594int reiserfs_proc_info_init(struct super_block *sb)
595{
596 return 0;
597}
598int reiserfs_proc_info_done(struct super_block *sb)
599{
600 return 0;
601}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700603struct proc_dir_entry *reiserfs_proc_register_global(char *name,
604 read_proc_t * func)
605{
606 return NULL;
607}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700609void reiserfs_proc_unregister_global(const char *name)
610{;
611}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700613int reiserfs_proc_info_global_init(void)
614{
615 return 0;
616}
617int reiserfs_proc_info_global_done(void)
618{
619 return 0;
620}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700622int reiserfs_global_version_in_proc(char *buffer, char **start,
623 off_t offset,
624 int count, int *eof, void *data)
625{
626 return 0;
627}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628
629/* REISERFS_PROC_INFO */
630#endif
631
632/*
633 * $Log: procfs.c,v $
634 * Revision 1.1.8.2 2001/07/15 17:08:42 god
635 * . use get_super() in procfs.c
636 * . remove remove_save_link() from reiserfs_do_truncate()
637 *
638 * I accept terms and conditions stated in the Legal Agreement
639 * (available at http://www.namesys.com/legalese.html)
640 *
641 * Revision 1.1.8.1 2001/07/11 16:48:50 god
642 * proc info support
643 *
644 * I accept terms and conditions stated in the Legal Agreement
645 * (available at http://www.namesys.com/legalese.html)
646 *
647 */
648
649/*
650 * Make Linus happy.
651 * Local variables:
652 * c-indentation-style: "K&R"
653 * mode-name: "LC"
654 * c-basic-offset: 8
655 * tab-width: 8
656 * End:
657 */