blob: 9229e5514a4e13eef0fbaaef47f547bc90989a10 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/module.h>
12#include <linux/time.h>
13#include <linux/seq_file.h>
14#include <asm/uaccess.h>
15#include <linux/reiserfs_fs.h>
16#include <linux/reiserfs_fs_sb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/init.h>
18#include <linux/proc_fs.h>
19
Robert P. J. Dayf87367a2007-05-08 00:25:01 -070020#ifdef CONFIG_REISERFS_PROC_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22/*
23 * LOCKING:
24 *
25 * We rely on new Alexander Viro's super-block locking.
26 *
27 */
28
29static int show_version(struct seq_file *m, struct super_block *sb)
30{
31 char *format;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070032
33 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 format = "3.6";
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070035 } else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 format = "3.5";
37 } else {
38 format = "unknown";
39 }
40
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070041 seq_printf(m, "%s format\twith checks %s\n", format,
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#if defined( CONFIG_REISERFS_CHECK )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070043 "on"
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#else
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070045 "off"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070047 );
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 return 0;
49}
50
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070051int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
52 int count, int *eof, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
54 *start = buffer;
55 *eof = 1;
56 return 0;
57}
58
59#define SF( x ) ( r -> x )
60#define SFP( x ) SF( s_proc_info_data.x )
61#define SFPL( x ) SFP( x[ level ] )
62#define SFPF( x ) SFP( scan_bitmap.x )
63#define SFPJ( x ) SFP( journal.x )
64
65#define D2C( x ) le16_to_cpu( x )
66#define D4C( x ) le32_to_cpu( x )
67#define DF( x ) D2C( rs -> s_v1.x )
68#define DFL( x ) D4C( rs -> s_v1.x )
69
70#define objectid_map( s, rs ) (old_format_only (s) ? \
Al Viro3e8962b2005-05-01 08:59:18 -070071 (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \
72 (__le32 *)(rs + 1))
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#define MAP( i ) D4C( objectid_map( sb, rs )[ i ] )
74
75#define DJF( x ) le32_to_cpu( rs -> x )
76#define DJV( x ) le32_to_cpu( s_v1 -> x )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070077#define DJP( x ) le32_to_cpu( jp -> x )
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#define JF( x ) ( r -> s_journal -> x )
79
80static int show_super(struct seq_file *m, struct super_block *sb)
81{
82 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070084 seq_printf(m, "state: \t%s\n"
85 "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"
86 "gen. counter: \t%i\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070087 "s_disk_reads: \t%i\n"
88 "s_disk_writes: \t%i\n"
89 "s_fix_nodes: \t%i\n"
90 "s_do_balance: \t%i\n"
91 "s_unneeded_left_neighbor: \t%i\n"
92 "s_good_search_by_key_reada: \t%i\n"
93 "s_bmaps: \t%i\n"
94 "s_bmaps_without_search: \t%i\n"
95 "s_direct2indirect: \t%i\n"
96 "s_indirect2direct: \t%i\n"
97 "\n"
98 "max_hash_collisions: \t%i\n"
99 "breads: \t%lu\n"
100 "bread_misses: \t%lu\n"
101 "search_by_key: \t%lu\n"
102 "search_by_key_fs_changed: \t%lu\n"
103 "search_by_key_restarted: \t%lu\n"
104 "insert_item_restarted: \t%lu\n"
105 "paste_into_item_restarted: \t%lu\n"
106 "cut_from_item_restarted: \t%lu\n"
107 "delete_solid_item_restarted: \t%lu\n"
108 "delete_item_restarted: \t%lu\n"
109 "leaked_oid: \t%lu\n"
110 "leaves_removable: \t%lu\n",
111 SF(s_mount_state) == REISERFS_VALID_FS ?
112 "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
113 reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",
114 reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "",
115 reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",
116 reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",
117 reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",
118 reiserfs_no_unhashed_relocation(sb) ?
119 "NO_UNHASHED_RELOCATION " : "",
120 reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",
121 reiserfs_test4(sb) ? "TEST4 " : "",
122 have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?
123 "SMALL_TAILS " : "NO_TAILS ",
124 replay_only(sb) ? "REPLAY_ONLY " : "",
125 convert_reiserfs(sb) ? "CONV " : "",
Pekka Enbergd739b422006-02-01 03:06:43 -0800126 atomic_read(&r->s_generation_counter),
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700127 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
128 SF(s_do_balance), SF(s_unneeded_left_neighbor),
129 SF(s_good_search_by_key_reada), SF(s_bmaps),
130 SF(s_bmaps_without_search), SF(s_direct2indirect),
131 SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),
132 SFP(bread_miss), SFP(search_by_key),
133 SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),
134 SFP(insert_item_restarted), SFP(paste_into_item_restarted),
135 SFP(cut_from_item_restarted),
136 SFP(delete_solid_item_restarted), SFP(delete_item_restarted),
137 SFP(leaked_oid), SFP(leaves_removable));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139 return 0;
140}
141
142static int show_per_level(struct seq_file *m, struct super_block *sb)
143{
144 struct reiserfs_sb_info *r = REISERFS_SB(sb);
145 int level;
146
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700147 seq_printf(m, "level\t"
148 " balances"
149 " [sbk: reads"
150 " fs_changed"
151 " restarted]"
152 " free space"
153 " items"
154 " can_remove"
155 " lnum"
156 " rnum"
157 " lbytes"
158 " rbytes"
159 " get_neig"
160 " get_neig_res" " need_l_neig" " need_r_neig" "\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700162 for (level = 0; level < MAX_HEIGHT; ++level) {
163 seq_printf(m, "%i\t"
164 " %12lu"
165 " %12lu"
166 " %12lu"
167 " %12lu"
168 " %12lu"
169 " %12lu"
170 " %12lu"
171 " %12li"
172 " %12li"
173 " %12li"
174 " %12li"
175 " %12lu"
176 " %12lu"
177 " %12lu"
178 " %12lu"
179 "\n",
180 level,
181 SFPL(balance_at),
182 SFPL(sbk_read_at),
183 SFPL(sbk_fs_changed),
184 SFPL(sbk_restarted),
185 SFPL(free_at),
186 SFPL(items_at),
187 SFPL(can_node_be_removed),
188 SFPL(lnum),
189 SFPL(rnum),
190 SFPL(lbytes),
191 SFPL(rbytes),
192 SFPL(get_neighbors),
193 SFPL(get_neighbors_restart),
194 SFPL(need_l_neighbor), SFPL(need_r_neighbor)
195 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 }
197 return 0;
198}
199
200static int show_bitmap(struct seq_file *m, struct super_block *sb)
201{
202 struct reiserfs_sb_info *r = REISERFS_SB(sb);
203
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700204 seq_printf(m, "free_block: %lu\n"
205 " scan_bitmap:"
206 " wait"
207 " bmap"
208 " retry"
209 " stolen"
210 " journal_hint"
211 "journal_nohint"
212 "\n"
213 " %14lu"
214 " %14lu"
215 " %14lu"
216 " %14lu"
217 " %14lu"
218 " %14lu"
219 " %14lu"
220 "\n",
221 SFP(free_block),
222 SFPF(call),
223 SFPF(wait),
224 SFPF(bmap),
225 SFPF(retry),
226 SFPF(stolen),
227 SFPF(in_journal_hint), SFPF(in_journal_nohint));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229 return 0;
230}
231
232static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
233{
234 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700235 struct reiserfs_super_block *rs = sb_info->s_rs;
236 int hash_code = DFL(s_hash_function_code);
237 __u32 flags = DJF(s_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700239 seq_printf(m, "block_count: \t%i\n"
240 "free_blocks: \t%i\n"
241 "root_block: \t%i\n"
242 "blocksize: \t%i\n"
243 "oid_maxsize: \t%i\n"
244 "oid_cursize: \t%i\n"
245 "umount_state: \t%i\n"
246 "magic: \t%10.10s\n"
247 "fs_state: \t%i\n"
248 "hash: \t%s\n"
249 "tree_height: \t%i\n"
250 "bmap_nr: \t%i\n"
251 "version: \t%i\n"
252 "flags: \t%x[%s]\n"
253 "reserved_for_journal: \t%i\n",
254 DFL(s_block_count),
255 DFL(s_free_blocks),
256 DFL(s_root_block),
257 DF(s_blocksize),
258 DF(s_oid_maxsize),
259 DF(s_oid_cursize),
260 DF(s_umount_state),
261 rs->s_v1.s_magic,
262 DF(s_fs_state),
263 hash_code == TEA_HASH ? "tea" :
264 (hash_code == YURA_HASH) ? "rupasov" :
265 (hash_code == R5_HASH) ? "r5" :
266 (hash_code == UNSET_HASH) ? "unset" : "unknown",
267 DF(s_tree_height),
268 DF(s_bmap_nr),
269 DF(s_version), flags, (flags & reiserfs_attrs_cleared)
270 ? "attrs_cleared" : "", DF(s_reserved_for_journal));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272 return 0;
273}
274
275static int show_oidmap(struct seq_file *m, struct super_block *sb)
276{
277 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700278 struct reiserfs_super_block *rs = sb_info->s_rs;
279 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 unsigned long total_used = 0;
281 int i;
282
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700283 for (i = 0; i < mapsize; ++i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 __u32 right;
285
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700286 right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 seq_printf(m, "%s: [ %x .. %x )\n",
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700288 (i & 1) ? "free" : "used", MAP(i), right);
289 if (!(i & 1)) {
290 total_used += right - MAP(i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 }
292 }
293#if defined( REISERFS_USE_OIDMAPF )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700294 if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
Josef Sipek1fc5adb2006-12-08 02:37:33 -0800295 loff_t size = sb_info->oidmap.mapf->f_path.dentry->d_inode->i_size;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700296 total_used += size / sizeof(reiserfs_oidinterval_d_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 }
298#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700299 seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
300 mapsize,
301 mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 return 0;
303}
304
305static int show_journal(struct seq_file *m, struct super_block *sb)
306{
307 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700308 struct reiserfs_super_block *rs = r->s_rs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 struct journal_params *jp = &rs->s_v1.s_journal;
310 char b[BDEVNAME_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700312 seq_printf(m, /* on-disk fields */
313 "jp_journal_1st_block: \t%i\n"
314 "jp_journal_dev: \t%s[%x]\n"
315 "jp_journal_size: \t%i\n"
316 "jp_journal_trans_max: \t%i\n"
317 "jp_journal_magic: \t%i\n"
318 "jp_journal_max_batch: \t%i\n"
319 "jp_journal_max_commit_age: \t%i\n"
320 "jp_journal_max_trans_age: \t%i\n"
321 /* incore fields */
322 "j_1st_reserved_block: \t%i\n"
323 "j_state: \t%li\n"
Jeff Mahoney600ed412009-03-30 14:02:17 -0400324 "j_trans_id: \t%u\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700325 "j_mount_id: \t%lu\n"
326 "j_start: \t%lu\n"
327 "j_len: \t%lu\n"
328 "j_len_alloc: \t%lu\n"
329 "j_wcount: \t%i\n"
330 "j_bcount: \t%lu\n"
331 "j_first_unflushed_offset: \t%lu\n"
Jeff Mahoney600ed412009-03-30 14:02:17 -0400332 "j_last_flush_trans_id: \t%u\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700333 "j_trans_start_time: \t%li\n"
334 "j_list_bitmap_index: \t%i\n"
335 "j_must_wait: \t%i\n"
336 "j_next_full_flush: \t%i\n"
337 "j_next_async_flush: \t%i\n"
338 "j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n"
339 /* reiserfs_proc_info_data_t.journal fields */
340 "in_journal: \t%12lu\n"
341 "in_journal_bitmap: \t%12lu\n"
342 "in_journal_reusable: \t%12lu\n"
343 "lock_journal: \t%12lu\n"
344 "lock_journal_wait: \t%12lu\n"
345 "journal_begin: \t%12lu\n"
346 "journal_relock_writers: \t%12lu\n"
347 "journal_relock_wcount: \t%12lu\n"
348 "mark_dirty: \t%12lu\n"
349 "mark_dirty_already: \t%12lu\n"
350 "mark_dirty_notjournal: \t%12lu\n"
351 "restore_prepared: \t%12lu\n"
352 "prepare: \t%12lu\n"
353 "prepare_retry: \t%12lu\n",
354 DJP(jp_journal_1st_block),
355 bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
356 DJP(jp_journal_dev),
357 DJP(jp_journal_size),
358 DJP(jp_journal_trans_max),
359 DJP(jp_journal_magic),
360 DJP(jp_journal_max_batch),
361 SB_JOURNAL(sb)->j_max_commit_age,
362 DJP(jp_journal_max_trans_age),
363 JF(j_1st_reserved_block),
364 JF(j_state),
365 JF(j_trans_id),
366 JF(j_mount_id),
367 JF(j_start),
368 JF(j_len),
369 JF(j_len_alloc),
370 atomic_read(&r->s_journal->j_wcount),
371 JF(j_bcount),
372 JF(j_first_unflushed_offset),
373 JF(j_last_flush_trans_id),
374 JF(j_trans_start_time),
375 JF(j_list_bitmap_index),
376 JF(j_must_wait),
377 JF(j_next_full_flush),
378 JF(j_next_async_flush),
379 JF(j_cnode_used),
380 JF(j_cnode_free),
381 SFPJ(in_journal),
382 SFPJ(in_journal_bitmap),
383 SFPJ(in_journal_reusable),
384 SFPJ(lock_journal),
385 SFPJ(lock_journal_wait),
386 SFPJ(journal_being),
387 SFPJ(journal_relock_writers),
388 SFPJ(journal_relock_wcount),
389 SFPJ(mark_dirty),
390 SFPJ(mark_dirty_already),
391 SFPJ(mark_dirty_notjournal),
392 SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry)
393 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 return 0;
395}
396
397/* iterator */
398static int test_sb(struct super_block *sb, void *data)
399{
400 return data == sb;
401}
402
403static int set_sb(struct super_block *sb, void *data)
404{
405 return -ENOENT;
406}
407
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700408static void *r_start(struct seq_file *m, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409{
410 struct proc_dir_entry *de = m->private;
411 struct super_block *s = de->parent->data;
412 loff_t l = *pos;
413
414 if (l)
415 return NULL;
416
417 if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, s)))
418 return NULL;
419
420 up_write(&s->s_umount);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 return s;
422}
423
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700424static void *r_next(struct seq_file *m, void *v, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425{
426 ++*pos;
427 if (v)
428 deactivate_super(v);
429 return NULL;
430}
431
432static void r_stop(struct seq_file *m, void *v)
433{
434 if (v)
435 deactivate_super(v);
436}
437
438static int r_show(struct seq_file *m, void *v)
439{
440 struct proc_dir_entry *de = m->private;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700441 int (*show) (struct seq_file *, struct super_block *) = de->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 return show(m, v);
443}
444
Jan Engelhardtec26e112008-02-08 04:21:18 -0800445static const struct seq_operations r_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 .start = r_start,
447 .next = r_next,
448 .stop = r_stop,
449 .show = r_show,
450};
451
452static int r_open(struct inode *inode, struct file *file)
453{
454 int ret = seq_open(file, &r_ops);
455
456 if (!ret) {
457 struct seq_file *m = file->private_data;
458 m->private = PDE(inode);
459 }
460 return ret;
461}
462
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800463static const struct file_operations r_file_operations = {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700464 .open = r_open,
465 .read = seq_read,
466 .llseek = seq_lseek,
467 .release = seq_release,
Denis V. Lunev19b4fc52008-04-29 01:02:09 -0700468 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469};
470
471static struct proc_dir_entry *proc_info_root = NULL;
472static const char proc_info_root_name[] = "fs/reiserfs";
473
474static void add_file(struct super_block *sb, char *name,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700475 int (*func) (struct seq_file *, struct super_block *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476{
Denis V. Lunev19b4fc52008-04-29 01:02:09 -0700477 proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
478 &r_file_operations, func);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700481int reiserfs_proc_info_init(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482{
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700483 char b[BDEVNAME_SIZE];
484 char *s;
485
486 /* Some block devices use /'s */
487 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
488 s = strchr(b, '/');
489 if (s)
490 *s = '!';
491
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700492 spin_lock_init(&__PINFO(sb).lock);
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700493 REISERFS_SB(sb)->procdir = proc_mkdir(b, proc_info_root);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700494 if (REISERFS_SB(sb)->procdir) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 REISERFS_SB(sb)->procdir->data = sb;
496 add_file(sb, "version", show_version);
497 add_file(sb, "super", show_super);
498 add_file(sb, "per-level", show_per_level);
499 add_file(sb, "bitmap", show_bitmap);
500 add_file(sb, "on-disk-super", show_on_disk_super);
501 add_file(sb, "oidmap", show_oidmap);
502 add_file(sb, "journal", show_journal);
503 return 0;
504 }
Jeff Mahoney45b03d52009-03-30 14:02:21 -0400505 reiserfs_warning(sb, "cannot create /proc/%s/%s",
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700506 proc_info_root_name, b);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 return 1;
508}
509
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700510int reiserfs_proc_info_done(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511{
512 struct proc_dir_entry *de = REISERFS_SB(sb)->procdir;
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700513 char b[BDEVNAME_SIZE];
514 char *s;
515
516 /* Some block devices use /'s */
517 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
518 s = strchr(b, '/');
519 if (s)
520 *s = '!';
521
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 if (de) {
523 remove_proc_entry("journal", de);
524 remove_proc_entry("oidmap", de);
525 remove_proc_entry("on-disk-super", de);
526 remove_proc_entry("bitmap", de);
527 remove_proc_entry("per-level", de);
528 remove_proc_entry("super", de);
529 remove_proc_entry("version", de);
530 }
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700531 spin_lock(&__PINFO(sb).lock);
532 __PINFO(sb).exiting = 1;
533 spin_unlock(&__PINFO(sb).lock);
534 if (proc_info_root) {
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700535 remove_proc_entry(b, proc_info_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 REISERFS_SB(sb)->procdir = NULL;
537 }
538 return 0;
539}
540
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700541struct proc_dir_entry *reiserfs_proc_register_global(char *name,
542 read_proc_t * func)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700544 return (proc_info_root) ? create_proc_read_entry(name, 0,
545 proc_info_root,
546 func, NULL) : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547}
548
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700549void reiserfs_proc_unregister_global(const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700551 remove_proc_entry(name, proc_info_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552}
553
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700554int reiserfs_proc_info_global_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700556 if (proc_info_root == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 proc_info_root = proc_mkdir(proc_info_root_name, NULL);
Alexey Dobriyan99b76232009-03-25 22:48:06 +0300558 if (!proc_info_root) {
Jeff Mahoney45b03d52009-03-30 14:02:21 -0400559 reiserfs_warning(NULL, "cannot create /proc/%s",
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700560 proc_info_root_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 return 1;
562 }
563 }
564 return 0;
565}
566
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700567int reiserfs_proc_info_global_done(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 = NULL;
571 remove_proc_entry(proc_info_root_name, NULL);
572 }
573 return 0;
574}
575
576/* REISERFS_PROC_INFO */
577#else
578
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700579int reiserfs_proc_info_init(struct super_block *sb)
580{
581 return 0;
582}
583int reiserfs_proc_info_done(struct super_block *sb)
584{
585 return 0;
586}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700588struct proc_dir_entry *reiserfs_proc_register_global(char *name,
589 read_proc_t * func)
590{
591 return NULL;
592}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700594void reiserfs_proc_unregister_global(const char *name)
595{;
596}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700598int reiserfs_proc_info_global_init(void)
599{
600 return 0;
601}
602int reiserfs_proc_info_global_done(void)
603{
604 return 0;
605}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700607int reiserfs_global_version_in_proc(char *buffer, char **start,
608 off_t offset,
609 int count, int *eof, void *data)
610{
611 return 0;
612}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613
614/* REISERFS_PROC_INFO */
615#endif
616
617/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 * Revision 1.1.8.2 2001/07/15 17:08:42 god
619 * . use get_super() in procfs.c
620 * . remove remove_save_link() from reiserfs_do_truncate()
621 *
622 * I accept terms and conditions stated in the Legal Agreement
623 * (available at http://www.namesys.com/legalese.html)
624 *
625 * Revision 1.1.8.1 2001/07/11 16:48:50 god
626 * proc info support
627 *
628 * I accept terms and conditions stated in the Legal Agreement
629 * (available at http://www.namesys.com/legalese.html)
630 *
631 */
632
Jeff Mahoney0222e652009-03-30 14:02:44 -0400633/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 * Make Linus happy.
635 * Local variables:
636 * c-indentation-style: "K&R"
637 * mode-name: "LC"
638 * c-basic-offset: 8
639 * tab-width: 8
640 * End:
641 */