blob: 33532f79b4f714923ec951fa5fb75d1758fbfda3 [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>
Al Virof466c6f2012-03-17 01:16:43 -040015#include "reiserfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/init.h>
17#include <linux/proc_fs.h>
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019/*
20 * LOCKING:
21 *
22 * We rely on new Alexander Viro's super-block locking.
23 *
24 */
25
26static int show_version(struct seq_file *m, struct super_block *sb)
27{
28 char *format;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070029
30 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 format = "3.6";
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070032 } else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 format = "3.5";
34 } else {
35 format = "unknown";
36 }
37
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070038 seq_printf(m, "%s format\twith checks %s\n", format,
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#if defined( CONFIG_REISERFS_CHECK )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070040 "on"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#else
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070042 "off"
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070044 );
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 return 0;
46}
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define SF( x ) ( r -> x )
49#define SFP( x ) SF( s_proc_info_data.x )
50#define SFPL( x ) SFP( x[ level ] )
51#define SFPF( x ) SFP( scan_bitmap.x )
52#define SFPJ( x ) SFP( journal.x )
53
54#define D2C( x ) le16_to_cpu( x )
55#define D4C( x ) le32_to_cpu( x )
56#define DF( x ) D2C( rs -> s_v1.x )
57#define DFL( x ) D4C( rs -> s_v1.x )
58
59#define objectid_map( s, rs ) (old_format_only (s) ? \
Al Viro3e8962b2005-05-01 08:59:18 -070060 (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \
61 (__le32 *)(rs + 1))
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#define MAP( i ) D4C( objectid_map( sb, rs )[ i ] )
63
64#define DJF( x ) le32_to_cpu( rs -> x )
65#define DJV( x ) le32_to_cpu( s_v1 -> x )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070066#define DJP( x ) le32_to_cpu( jp -> x )
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#define JF( x ) ( r -> s_journal -> x )
68
69static int show_super(struct seq_file *m, struct super_block *sb)
70{
71 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070073 seq_printf(m, "state: \t%s\n"
74 "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"
75 "gen. counter: \t%i\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070076 "s_disk_reads: \t%i\n"
77 "s_disk_writes: \t%i\n"
78 "s_fix_nodes: \t%i\n"
79 "s_do_balance: \t%i\n"
80 "s_unneeded_left_neighbor: \t%i\n"
81 "s_good_search_by_key_reada: \t%i\n"
82 "s_bmaps: \t%i\n"
83 "s_bmaps_without_search: \t%i\n"
84 "s_direct2indirect: \t%i\n"
85 "s_indirect2direct: \t%i\n"
86 "\n"
87 "max_hash_collisions: \t%i\n"
88 "breads: \t%lu\n"
89 "bread_misses: \t%lu\n"
90 "search_by_key: \t%lu\n"
91 "search_by_key_fs_changed: \t%lu\n"
92 "search_by_key_restarted: \t%lu\n"
93 "insert_item_restarted: \t%lu\n"
94 "paste_into_item_restarted: \t%lu\n"
95 "cut_from_item_restarted: \t%lu\n"
96 "delete_solid_item_restarted: \t%lu\n"
97 "delete_item_restarted: \t%lu\n"
98 "leaked_oid: \t%lu\n"
99 "leaves_removable: \t%lu\n",
100 SF(s_mount_state) == REISERFS_VALID_FS ?
101 "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
102 reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",
103 reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "",
104 reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",
105 reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",
106 reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",
107 reiserfs_no_unhashed_relocation(sb) ?
108 "NO_UNHASHED_RELOCATION " : "",
109 reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",
110 reiserfs_test4(sb) ? "TEST4 " : "",
111 have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?
112 "SMALL_TAILS " : "NO_TAILS ",
113 replay_only(sb) ? "REPLAY_ONLY " : "",
114 convert_reiserfs(sb) ? "CONV " : "",
Pekka Enbergd739b422006-02-01 03:06:43 -0800115 atomic_read(&r->s_generation_counter),
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700116 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
117 SF(s_do_balance), SF(s_unneeded_left_neighbor),
118 SF(s_good_search_by_key_reada), SF(s_bmaps),
119 SF(s_bmaps_without_search), SF(s_direct2indirect),
120 SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),
121 SFP(bread_miss), SFP(search_by_key),
122 SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),
123 SFP(insert_item_restarted), SFP(paste_into_item_restarted),
124 SFP(cut_from_item_restarted),
125 SFP(delete_solid_item_restarted), SFP(delete_item_restarted),
126 SFP(leaked_oid), SFP(leaves_removable));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 return 0;
129}
130
131static int show_per_level(struct seq_file *m, struct super_block *sb)
132{
133 struct reiserfs_sb_info *r = REISERFS_SB(sb);
134 int level;
135
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700136 seq_printf(m, "level\t"
137 " balances"
138 " [sbk: reads"
139 " fs_changed"
140 " restarted]"
141 " free space"
142 " items"
143 " can_remove"
144 " lnum"
145 " rnum"
146 " lbytes"
147 " rbytes"
148 " get_neig"
149 " get_neig_res" " need_l_neig" " need_r_neig" "\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700151 for (level = 0; level < MAX_HEIGHT; ++level) {
152 seq_printf(m, "%i\t"
153 " %12lu"
154 " %12lu"
155 " %12lu"
156 " %12lu"
157 " %12lu"
158 " %12lu"
159 " %12lu"
160 " %12li"
161 " %12li"
162 " %12li"
163 " %12li"
164 " %12lu"
165 " %12lu"
166 " %12lu"
167 " %12lu"
168 "\n",
169 level,
170 SFPL(balance_at),
171 SFPL(sbk_read_at),
172 SFPL(sbk_fs_changed),
173 SFPL(sbk_restarted),
174 SFPL(free_at),
175 SFPL(items_at),
176 SFPL(can_node_be_removed),
177 SFPL(lnum),
178 SFPL(rnum),
179 SFPL(lbytes),
180 SFPL(rbytes),
181 SFPL(get_neighbors),
182 SFPL(get_neighbors_restart),
183 SFPL(need_l_neighbor), SFPL(need_r_neighbor)
184 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 }
186 return 0;
187}
188
189static int show_bitmap(struct seq_file *m, struct super_block *sb)
190{
191 struct reiserfs_sb_info *r = REISERFS_SB(sb);
192
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700193 seq_printf(m, "free_block: %lu\n"
194 " scan_bitmap:"
195 " wait"
196 " bmap"
197 " retry"
198 " stolen"
199 " journal_hint"
200 "journal_nohint"
201 "\n"
202 " %14lu"
203 " %14lu"
204 " %14lu"
205 " %14lu"
206 " %14lu"
207 " %14lu"
208 " %14lu"
209 "\n",
210 SFP(free_block),
211 SFPF(call),
212 SFPF(wait),
213 SFPF(bmap),
214 SFPF(retry),
215 SFPF(stolen),
216 SFPF(in_journal_hint), SFPF(in_journal_nohint));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217
218 return 0;
219}
220
221static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
222{
223 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700224 struct reiserfs_super_block *rs = sb_info->s_rs;
225 int hash_code = DFL(s_hash_function_code);
226 __u32 flags = DJF(s_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700228 seq_printf(m, "block_count: \t%i\n"
229 "free_blocks: \t%i\n"
230 "root_block: \t%i\n"
231 "blocksize: \t%i\n"
232 "oid_maxsize: \t%i\n"
233 "oid_cursize: \t%i\n"
234 "umount_state: \t%i\n"
235 "magic: \t%10.10s\n"
236 "fs_state: \t%i\n"
237 "hash: \t%s\n"
238 "tree_height: \t%i\n"
239 "bmap_nr: \t%i\n"
240 "version: \t%i\n"
241 "flags: \t%x[%s]\n"
242 "reserved_for_journal: \t%i\n",
243 DFL(s_block_count),
244 DFL(s_free_blocks),
245 DFL(s_root_block),
246 DF(s_blocksize),
247 DF(s_oid_maxsize),
248 DF(s_oid_cursize),
249 DF(s_umount_state),
250 rs->s_v1.s_magic,
251 DF(s_fs_state),
252 hash_code == TEA_HASH ? "tea" :
253 (hash_code == YURA_HASH) ? "rupasov" :
254 (hash_code == R5_HASH) ? "r5" :
255 (hash_code == UNSET_HASH) ? "unset" : "unknown",
256 DF(s_tree_height),
257 DF(s_bmap_nr),
258 DF(s_version), flags, (flags & reiserfs_attrs_cleared)
259 ? "attrs_cleared" : "", DF(s_reserved_for_journal));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 return 0;
262}
263
264static int show_oidmap(struct seq_file *m, struct super_block *sb)
265{
266 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700267 struct reiserfs_super_block *rs = sb_info->s_rs;
268 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 unsigned long total_used = 0;
270 int i;
271
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700272 for (i = 0; i < mapsize; ++i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 __u32 right;
274
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700275 right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 seq_printf(m, "%s: [ %x .. %x )\n",
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700277 (i & 1) ? "free" : "used", MAP(i), right);
278 if (!(i & 1)) {
279 total_used += right - MAP(i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 }
281 }
282#if defined( REISERFS_USE_OIDMAPF )
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700283 if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
Al Viro496ad9a2013-01-23 17:07:38 -0500284 loff_t size = file_inode(sb_info->oidmap.mapf)->i_size;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700285 total_used += size / sizeof(reiserfs_oidinterval_d_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 }
287#endif
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700288 seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
289 mapsize,
290 mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 return 0;
292}
293
294static int show_journal(struct seq_file *m, struct super_block *sb)
295{
296 struct reiserfs_sb_info *r = REISERFS_SB(sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700297 struct reiserfs_super_block *rs = r->s_rs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 struct journal_params *jp = &rs->s_v1.s_journal;
299 char b[BDEVNAME_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700301 seq_printf(m, /* on-disk fields */
302 "jp_journal_1st_block: \t%i\n"
303 "jp_journal_dev: \t%s[%x]\n"
304 "jp_journal_size: \t%i\n"
305 "jp_journal_trans_max: \t%i\n"
306 "jp_journal_magic: \t%i\n"
307 "jp_journal_max_batch: \t%i\n"
308 "jp_journal_max_commit_age: \t%i\n"
309 "jp_journal_max_trans_age: \t%i\n"
310 /* incore fields */
311 "j_1st_reserved_block: \t%i\n"
312 "j_state: \t%li\n"
Jeff Mahoney600ed412009-03-30 14:02:17 -0400313 "j_trans_id: \t%u\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700314 "j_mount_id: \t%lu\n"
315 "j_start: \t%lu\n"
316 "j_len: \t%lu\n"
317 "j_len_alloc: \t%lu\n"
318 "j_wcount: \t%i\n"
319 "j_bcount: \t%lu\n"
320 "j_first_unflushed_offset: \t%lu\n"
Jeff Mahoney600ed412009-03-30 14:02:17 -0400321 "j_last_flush_trans_id: \t%u\n"
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700322 "j_trans_start_time: \t%li\n"
323 "j_list_bitmap_index: \t%i\n"
324 "j_must_wait: \t%i\n"
325 "j_next_full_flush: \t%i\n"
326 "j_next_async_flush: \t%i\n"
327 "j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n"
328 /* reiserfs_proc_info_data_t.journal fields */
329 "in_journal: \t%12lu\n"
330 "in_journal_bitmap: \t%12lu\n"
331 "in_journal_reusable: \t%12lu\n"
332 "lock_journal: \t%12lu\n"
333 "lock_journal_wait: \t%12lu\n"
334 "journal_begin: \t%12lu\n"
335 "journal_relock_writers: \t%12lu\n"
336 "journal_relock_wcount: \t%12lu\n"
337 "mark_dirty: \t%12lu\n"
338 "mark_dirty_already: \t%12lu\n"
339 "mark_dirty_notjournal: \t%12lu\n"
340 "restore_prepared: \t%12lu\n"
341 "prepare: \t%12lu\n"
342 "prepare_retry: \t%12lu\n",
343 DJP(jp_journal_1st_block),
344 bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
345 DJP(jp_journal_dev),
346 DJP(jp_journal_size),
347 DJP(jp_journal_trans_max),
348 DJP(jp_journal_magic),
349 DJP(jp_journal_max_batch),
350 SB_JOURNAL(sb)->j_max_commit_age,
351 DJP(jp_journal_max_trans_age),
352 JF(j_1st_reserved_block),
353 JF(j_state),
354 JF(j_trans_id),
355 JF(j_mount_id),
356 JF(j_start),
357 JF(j_len),
358 JF(j_len_alloc),
359 atomic_read(&r->s_journal->j_wcount),
360 JF(j_bcount),
361 JF(j_first_unflushed_offset),
362 JF(j_last_flush_trans_id),
363 JF(j_trans_start_time),
364 JF(j_list_bitmap_index),
365 JF(j_must_wait),
366 JF(j_next_full_flush),
367 JF(j_next_async_flush),
368 JF(j_cnode_used),
369 JF(j_cnode_free),
370 SFPJ(in_journal),
371 SFPJ(in_journal_bitmap),
372 SFPJ(in_journal_reusable),
373 SFPJ(lock_journal),
374 SFPJ(lock_journal_wait),
375 SFPJ(journal_being),
376 SFPJ(journal_relock_writers),
377 SFPJ(journal_relock_wcount),
378 SFPJ(mark_dirty),
379 SFPJ(mark_dirty_already),
380 SFPJ(mark_dirty_notjournal),
381 SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry)
382 );
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 return 0;
384}
385
386/* iterator */
387static int test_sb(struct super_block *sb, void *data)
388{
389 return data == sb;
390}
391
392static int set_sb(struct super_block *sb, void *data)
393{
394 return -ENOENT;
395}
396
David Howellse42270a2013-04-12 11:17:06 +0100397struct reiserfs_seq_private {
398 struct super_block *sb;
399 int (*show) (struct seq_file *, struct super_block *);
400};
401
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700402static void *r_start(struct seq_file *m, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403{
David Howellse42270a2013-04-12 11:17:06 +0100404 struct reiserfs_seq_private *priv = m->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 loff_t l = *pos;
406
407 if (l)
408 return NULL;
409
David Howellse42270a2013-04-12 11:17:06 +0100410 if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, priv->sb)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 return NULL;
412
David Howellse42270a2013-04-12 11:17:06 +0100413 up_write(&priv->sb->s_umount);
414 return priv->sb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415}
416
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700417static void *r_next(struct seq_file *m, void *v, loff_t * pos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418{
419 ++*pos;
420 if (v)
421 deactivate_super(v);
422 return NULL;
423}
424
425static void r_stop(struct seq_file *m, void *v)
426{
427 if (v)
428 deactivate_super(v);
429}
430
431static int r_show(struct seq_file *m, void *v)
432{
David Howellse42270a2013-04-12 11:17:06 +0100433 struct reiserfs_seq_private *priv = m->private;
434 return priv->show(m, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435}
436
Jan Engelhardtec26e112008-02-08 04:21:18 -0800437static const struct seq_operations r_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 .start = r_start,
439 .next = r_next,
440 .stop = r_stop,
441 .show = r_show,
442};
443
444static int r_open(struct inode *inode, struct file *file)
445{
David Howellse42270a2013-04-12 11:17:06 +0100446 struct reiserfs_seq_private *priv;
447 int ret = seq_open_private(file, &r_ops,
448 sizeof(struct reiserfs_seq_private));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450 if (!ret) {
451 struct seq_file *m = file->private_data;
David Howellse42270a2013-04-12 11:17:06 +0100452 priv = m->private;
453 priv->sb = proc_get_parent_data(inode);
454 priv->show = PDE_DATA(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 }
456 return ret;
457}
458
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800459static const struct file_operations r_file_operations = {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700460 .open = r_open,
461 .read = seq_read,
462 .llseek = seq_lseek,
David Howellse42270a2013-04-12 11:17:06 +0100463 .release = seq_release_private,
Denis V. Lunev19b4fc52008-04-29 01:02:09 -0700464 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465};
466
467static struct proc_dir_entry *proc_info_root = NULL;
468static const char proc_info_root_name[] = "fs/reiserfs";
469
470static void add_file(struct super_block *sb, char *name,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700471 int (*func) (struct seq_file *, struct super_block *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
Denis V. Lunev19b4fc52008-04-29 01:02:09 -0700473 proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
474 &r_file_operations, func);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475}
476
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700477int reiserfs_proc_info_init(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478{
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700479 char b[BDEVNAME_SIZE];
480 char *s;
481
482 /* Some block devices use /'s */
483 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
484 s = strchr(b, '/');
485 if (s)
486 *s = '!';
487
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700488 spin_lock_init(&__PINFO(sb).lock);
David Howells270b5ac2013-04-12 02:48:30 +0100489 REISERFS_SB(sb)->procdir = proc_mkdir_data(b, 0, proc_info_root, sb);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700490 if (REISERFS_SB(sb)->procdir) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 add_file(sb, "version", show_version);
492 add_file(sb, "super", show_super);
493 add_file(sb, "per-level", show_per_level);
494 add_file(sb, "bitmap", show_bitmap);
495 add_file(sb, "on-disk-super", show_on_disk_super);
496 add_file(sb, "oidmap", show_oidmap);
497 add_file(sb, "journal", show_journal);
498 return 0;
499 }
Jeff Mahoney45b03d52009-03-30 14:02:21 -0400500 reiserfs_warning(sb, "cannot create /proc/%s/%s",
Jeff Mahoney6fbe82a2006-07-14 00:24:22 -0700501 proc_info_root_name, b);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 return 1;
503}
504
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700505int reiserfs_proc_info_done(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506{
507 struct proc_dir_entry *de = REISERFS_SB(sb)->procdir;
508 if (de) {
Al Viro121daf52013-03-30 20:16:20 -0400509 char b[BDEVNAME_SIZE];
510 char *s;
511
512 /* Some block devices use /'s */
513 strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
514 s = strchr(b, '/');
515 if (s)
516 *s = '!';
517
518 remove_proc_subtree(b, proc_info_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 REISERFS_SB(sb)->procdir = NULL;
520 }
521 return 0;
522}
523
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700524int reiserfs_proc_info_global_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700526 if (proc_info_root == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 proc_info_root = proc_mkdir(proc_info_root_name, NULL);
Alexey Dobriyan99b76232009-03-25 22:48:06 +0300528 if (!proc_info_root) {
Jeff Mahoney45b03d52009-03-30 14:02:21 -0400529 reiserfs_warning(NULL, "cannot create /proc/%s",
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700530 proc_info_root_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 return 1;
532 }
533 }
534 return 0;
535}
536
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700537int reiserfs_proc_info_global_done(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700539 if (proc_info_root != NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 proc_info_root = NULL;
541 remove_proc_entry(proc_info_root_name, NULL);
542 }
543 return 0;
544}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 * Revision 1.1.8.2 2001/07/15 17:08:42 god
547 * . use get_super() in procfs.c
548 * . remove remove_save_link() from reiserfs_do_truncate()
549 *
550 * I accept terms and conditions stated in the Legal Agreement
551 * (available at http://www.namesys.com/legalese.html)
552 *
553 * Revision 1.1.8.1 2001/07/11 16:48:50 god
554 * proc info support
555 *
556 * I accept terms and conditions stated in the Legal Agreement
557 * (available at http://www.namesys.com/legalese.html)
558 *
559 */
560
Jeff Mahoney0222e652009-03-30 14:02:44 -0400561/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 * Make Linus happy.
563 * Local variables:
564 * c-indentation-style: "K&R"
565 * mode-name: "LC"
566 * c-basic-offset: 8
567 * tab-width: 8
568 * End:
569 */