Blame view

fs/reiserfs/procfs.c 13.3 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
  /* -*- linux-c -*- */
  
  /* fs/reiserfs/procfs.c */
  
  /*
   * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
   */
  
  /* proc info support a la one created by Sizif@Botik.RU for PGC */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
12
  #include <linux/module.h>
  #include <linux/time.h>
  #include <linux/seq_file.h>
17093991a   Fabian Frederick   fs/reiserfs: use ...
13
  #include <linux/uaccess.h>
f466c6fdb   Al Viro   move private bits...
14
  #include "reiserfs.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
16
  #include <linux/init.h>
  #include <linux/proc_fs.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
19
  /*
   * LOCKING:
   *
672fe15d0   Al Viro   reiserfs: fix dea...
20
   * These guys are evicted from procfs as the very first step in ->kill_sb().
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
   *
   */
672fe15d0   Al Viro   reiserfs: fix dea...
23
  static int show_version(struct seq_file *m, void *unused)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
  {
672fe15d0   Al Viro   reiserfs: fix dea...
25
  	struct super_block *sb = m->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
  	char *format;
bd4c625c0   Linus Torvalds   reiserfs: run scr...
27
28
  
  	if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
  		format = "3.6";
bd4c625c0   Linus Torvalds   reiserfs: run scr...
30
  	} else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
  		format = "3.5";
  	} else {
  		format = "unknown";
  	}
bd4c625c0   Linus Torvalds   reiserfs: run scr...
35
36
  	seq_printf(m, "%s format\twith checks %s
  ", format,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
  #if defined( CONFIG_REISERFS_CHECK )
bd4c625c0   Linus Torvalds   reiserfs: run scr...
38
  		   "on"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
  #else
bd4c625c0   Linus Torvalds   reiserfs: run scr...
40
  		   "off"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
  #endif
bd4c625c0   Linus Torvalds   reiserfs: run scr...
42
  	    );
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
44
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
46
47
48
49
50
51
52
53
54
55
56
  #define SF( x ) ( r -> x )
  #define SFP( x ) SF( s_proc_info_data.x )
  #define SFPL( x ) SFP( x[ level ] )
  #define SFPF( x ) SFP( scan_bitmap.x )
  #define SFPJ( x ) SFP( journal.x )
  
  #define D2C( x ) le16_to_cpu( x )
  #define D4C( x ) le32_to_cpu( x )
  #define DF( x ) D2C( rs -> s_v1.x )
  #define DFL( x ) D4C( rs -> s_v1.x )
  
  #define objectid_map( s, rs ) (old_format_only (s) ?				\
3e8962be9   Al Viro   [PATCH] reiserfs ...
57
58
                           (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) :	\
  			 (__le32 *)(rs + 1))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
61
62
  #define MAP( i ) D4C( objectid_map( sb, rs )[ i ] )
  
  #define DJF( x ) le32_to_cpu( rs -> x )
  #define DJV( x ) le32_to_cpu( s_v1 -> x )
bd4c625c0   Linus Torvalds   reiserfs: run scr...
63
  #define DJP( x ) le32_to_cpu( jp -> x )
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
  #define JF( x ) ( r -> s_journal -> x )
672fe15d0   Al Viro   reiserfs: fix dea...
65
  static int show_super(struct seq_file *m, void *unused)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
  {
672fe15d0   Al Viro   reiserfs: fix dea...
67
  	struct super_block *sb = m->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
  	struct reiserfs_sb_info *r = REISERFS_SB(sb);
bd4c625c0   Linus Torvalds   reiserfs: run scr...
69
70
71
72
73
74
75
  
  	seq_printf(m, "state: \t%s
  "
  		   "mount options: \t%s%s%s%s%s%s%s%s%s%s%s
  "
  		   "gen. counter: \t%i
  "
bd4c625c0   Linus Torvalds   reiserfs: run scr...
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  		   "s_disk_reads: \t%i
  "
  		   "s_disk_writes: \t%i
  "
  		   "s_fix_nodes: \t%i
  "
  		   "s_do_balance: \t%i
  "
  		   "s_unneeded_left_neighbor: \t%i
  "
  		   "s_good_search_by_key_reada: \t%i
  "
  		   "s_bmaps: \t%i
  "
  		   "s_bmaps_without_search: \t%i
  "
  		   "s_direct2indirect: \t%i
  "
  		   "s_indirect2direct: \t%i
  "
  		   "
  "
  		   "max_hash_collisions: \t%i
  "
  		   "breads: \t%lu
  "
  		   "bread_misses: \t%lu
  "
  		   "search_by_key: \t%lu
  "
  		   "search_by_key_fs_changed: \t%lu
  "
  		   "search_by_key_restarted: \t%lu
  "
  		   "insert_item_restarted: \t%lu
  "
  		   "paste_into_item_restarted: \t%lu
  "
  		   "cut_from_item_restarted: \t%lu
  "
  		   "delete_solid_item_restarted: \t%lu
  "
  		   "delete_item_restarted: \t%lu
  "
  		   "leaked_oid: \t%lu
  "
  		   "leaves_removable: \t%lu
  ",
  		   SF(s_mount_state) == REISERFS_VALID_FS ?
  		   "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
  		   reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",
  		   reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "",
  		   reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",
  		   reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",
  		   reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",
  		   reiserfs_no_unhashed_relocation(sb) ?
  		   "NO_UNHASHED_RELOCATION " : "",
  		   reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",
  		   reiserfs_test4(sb) ? "TEST4 " : "",
  		   have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?
  		   "SMALL_TAILS " : "NO_TAILS ",
  		   replay_only(sb) ? "REPLAY_ONLY " : "",
  		   convert_reiserfs(sb) ? "CONV " : "",
d739b42b8   Pekka Enberg   [PATCH] reiserfs:...
139
  		   atomic_read(&r->s_generation_counter),
bd4c625c0   Linus Torvalds   reiserfs: run scr...
140
141
142
143
144
145
146
147
148
149
150
  		   SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
  		   SF(s_do_balance), SF(s_unneeded_left_neighbor),
  		   SF(s_good_search_by_key_reada), SF(s_bmaps),
  		   SF(s_bmaps_without_search), SF(s_direct2indirect),
  		   SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),
  		   SFP(bread_miss), SFP(search_by_key),
  		   SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),
  		   SFP(insert_item_restarted), SFP(paste_into_item_restarted),
  		   SFP(cut_from_item_restarted),
  		   SFP(delete_solid_item_restarted), SFP(delete_item_restarted),
  		   SFP(leaked_oid), SFP(leaves_removable));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
151
152
153
  
  	return 0;
  }
672fe15d0   Al Viro   reiserfs: fix dea...
154
  static int show_per_level(struct seq_file *m, void *unused)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155
  {
672fe15d0   Al Viro   reiserfs: fix dea...
156
  	struct super_block *sb = m->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
158
  	struct reiserfs_sb_info *r = REISERFS_SB(sb);
  	int level;
bd4c625c0   Linus Torvalds   reiserfs: run scr...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  	seq_printf(m, "level\t"
  		   "     balances"
  		   " [sbk:  reads"
  		   "   fs_changed"
  		   "   restarted]"
  		   "   free space"
  		   "        items"
  		   "   can_remove"
  		   "         lnum"
  		   "         rnum"
  		   "       lbytes"
  		   "       rbytes"
  		   "     get_neig"
  		   " get_neig_res" "  need_l_neig" "  need_r_neig" "
  ");
  
  	for (level = 0; level < MAX_HEIGHT; ++level) {
  		seq_printf(m, "%i\t"
  			   " %12lu"
  			   " %12lu"
  			   " %12lu"
  			   " %12lu"
  			   " %12lu"
  			   " %12lu"
  			   " %12lu"
  			   " %12li"
  			   " %12li"
  			   " %12li"
  			   " %12li"
  			   " %12lu"
  			   " %12lu"
  			   " %12lu"
  			   " %12lu"
  			   "
  ",
  			   level,
  			   SFPL(balance_at),
  			   SFPL(sbk_read_at),
  			   SFPL(sbk_fs_changed),
  			   SFPL(sbk_restarted),
  			   SFPL(free_at),
  			   SFPL(items_at),
  			   SFPL(can_node_be_removed),
  			   SFPL(lnum),
  			   SFPL(rnum),
  			   SFPL(lbytes),
  			   SFPL(rbytes),
  			   SFPL(get_neighbors),
  			   SFPL(get_neighbors_restart),
  			   SFPL(need_l_neighbor), SFPL(need_r_neighbor)
  		    );
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
211
212
  	}
  	return 0;
  }
672fe15d0   Al Viro   reiserfs: fix dea...
213
  static int show_bitmap(struct seq_file *m, void *unused)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
214
  {
672fe15d0   Al Viro   reiserfs: fix dea...
215
  	struct super_block *sb = m->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
216
  	struct reiserfs_sb_info *r = REISERFS_SB(sb);
bd4c625c0   Linus Torvalds   reiserfs: run scr...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
  	seq_printf(m, "free_block: %lu
  "
  		   "  scan_bitmap:"
  		   "          wait"
  		   "          bmap"
  		   "         retry"
  		   "        stolen"
  		   "  journal_hint"
  		   "journal_nohint"
  		   "
  "
  		   " %14lu"
  		   " %14lu"
  		   " %14lu"
  		   " %14lu"
  		   " %14lu"
  		   " %14lu"
  		   " %14lu"
  		   "
  ",
  		   SFP(free_block),
  		   SFPF(call),
  		   SFPF(wait),
  		   SFPF(bmap),
  		   SFPF(retry),
  		   SFPF(stolen),
  		   SFPF(in_journal_hint), SFPF(in_journal_nohint));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
244
245
246
  
  	return 0;
  }
672fe15d0   Al Viro   reiserfs: fix dea...
247
  static int show_on_disk_super(struct seq_file *m, void *unused)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
248
  {
672fe15d0   Al Viro   reiserfs: fix dea...
249
  	struct super_block *sb = m->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
250
  	struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
bd4c625c0   Linus Torvalds   reiserfs: run scr...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
  	struct reiserfs_super_block *rs = sb_info->s_rs;
  	int hash_code = DFL(s_hash_function_code);
  	__u32 flags = DJF(s_flags);
  
  	seq_printf(m, "block_count: \t%i
  "
  		   "free_blocks: \t%i
  "
  		   "root_block: \t%i
  "
  		   "blocksize: \t%i
  "
  		   "oid_maxsize: \t%i
  "
  		   "oid_cursize: \t%i
  "
  		   "umount_state: \t%i
  "
  		   "magic: \t%10.10s
  "
  		   "fs_state: \t%i
  "
  		   "hash: \t%s
  "
  		   "tree_height: \t%i
  "
  		   "bmap_nr: \t%i
  "
  		   "version: \t%i
  "
  		   "flags: \t%x[%s]
  "
  		   "reserved_for_journal: \t%i
  ",
  		   DFL(s_block_count),
  		   DFL(s_free_blocks),
  		   DFL(s_root_block),
  		   DF(s_blocksize),
  		   DF(s_oid_maxsize),
  		   DF(s_oid_cursize),
  		   DF(s_umount_state),
  		   rs->s_v1.s_magic,
  		   DF(s_fs_state),
  		   hash_code == TEA_HASH ? "tea" :
  		   (hash_code == YURA_HASH) ? "rupasov" :
  		   (hash_code == R5_HASH) ? "r5" :
  		   (hash_code == UNSET_HASH) ? "unset" : "unknown",
  		   DF(s_tree_height),
  		   DF(s_bmap_nr),
  		   DF(s_version), flags, (flags & reiserfs_attrs_cleared)
  		   ? "attrs_cleared" : "", DF(s_reserved_for_journal));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
302
303
304
  
  	return 0;
  }
672fe15d0   Al Viro   reiserfs: fix dea...
305
  static int show_oidmap(struct seq_file *m, void *unused)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
306
  {
672fe15d0   Al Viro   reiserfs: fix dea...
307
  	struct super_block *sb = m->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
308
  	struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
bd4c625c0   Linus Torvalds   reiserfs: run scr...
309
310
  	struct reiserfs_super_block *rs = sb_info->s_rs;
  	unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
311
312
  	unsigned long total_used = 0;
  	int i;
bd4c625c0   Linus Torvalds   reiserfs: run scr...
313
  	for (i = 0; i < mapsize; ++i) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
314
  		__u32 right;
bd4c625c0   Linus Torvalds   reiserfs: run scr...
315
  		right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
316
317
  		seq_printf(m, "%s: [ %x .. %x )
  ",
bd4c625c0   Linus Torvalds   reiserfs: run scr...
318
319
320
  			   (i & 1) ? "free" : "used", MAP(i), right);
  		if (!(i & 1)) {
  			total_used += right - MAP(i);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
321
322
323
  		}
  	}
  #if defined( REISERFS_USE_OIDMAPF )
bd4c625c0   Linus Torvalds   reiserfs: run scr...
324
  	if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
496ad9aa8   Al Viro   new helper: file_...
325
  		loff_t size = file_inode(sb_info->oidmap.mapf)->i_size;
bd4c625c0   Linus Torvalds   reiserfs: run scr...
326
  		total_used += size / sizeof(reiserfs_oidinterval_d_t);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
327
328
  	}
  #endif
bd4c625c0   Linus Torvalds   reiserfs: run scr...
329
330
331
332
  	seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]
  ",
  		   mapsize,
  		   mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
333
334
  	return 0;
  }
672fe15d0   Al Viro   reiserfs: fix dea...
335
  static int show_journal(struct seq_file *m, void *unused)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
336
  {
672fe15d0   Al Viro   reiserfs: fix dea...
337
  	struct super_block *sb = m->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
338
  	struct reiserfs_sb_info *r = REISERFS_SB(sb);
bd4c625c0   Linus Torvalds   reiserfs: run scr...
339
  	struct reiserfs_super_block *rs = r->s_rs;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
340
  	struct journal_params *jp = &rs->s_v1.s_journal;
bd4c625c0   Linus Torvalds   reiserfs: run scr...
341
342
343
344
  
  	seq_printf(m,		/* on-disk fields */
  		   "jp_journal_1st_block: \t%i
  "
a1c6f0573   Dmitry Monakhov   fs: use block_dev...
345
346
  		   "jp_journal_dev: \t%pg[%x]
  "
bd4c625c0   Linus Torvalds   reiserfs: run scr...
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
  		   "jp_journal_size: \t%i
  "
  		   "jp_journal_trans_max: \t%i
  "
  		   "jp_journal_magic: \t%i
  "
  		   "jp_journal_max_batch: \t%i
  "
  		   "jp_journal_max_commit_age: \t%i
  "
  		   "jp_journal_max_trans_age: \t%i
  "
  		   /* incore fields */
  		   "j_1st_reserved_block: \t%i
  "
  		   "j_state: \t%li
  "
600ed4167   Jeff Mahoney   reiserfs: audit t...
364
365
  		   "j_trans_id: \t%u
  "
bd4c625c0   Linus Torvalds   reiserfs: run scr...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
  		   "j_mount_id: \t%lu
  "
  		   "j_start: \t%lu
  "
  		   "j_len: \t%lu
  "
  		   "j_len_alloc: \t%lu
  "
  		   "j_wcount: \t%i
  "
  		   "j_bcount: \t%lu
  "
  		   "j_first_unflushed_offset: \t%lu
  "
600ed4167   Jeff Mahoney   reiserfs: audit t...
380
381
  		   "j_last_flush_trans_id: \t%u
  "
bd4c625c0   Linus Torvalds   reiserfs: run scr...
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
  		   "j_trans_start_time: \t%li
  "
  		   "j_list_bitmap_index: \t%i
  "
  		   "j_must_wait: \t%i
  "
  		   "j_next_full_flush: \t%i
  "
  		   "j_next_async_flush: \t%i
  "
  		   "j_cnode_used: \t%i
  " "j_cnode_free: \t%i
  " "
  "
  		   /* reiserfs_proc_info_data_t.journal fields */
  		   "in_journal: \t%12lu
  "
  		   "in_journal_bitmap: \t%12lu
  "
  		   "in_journal_reusable: \t%12lu
  "
  		   "lock_journal: \t%12lu
  "
  		   "lock_journal_wait: \t%12lu
  "
  		   "journal_begin: \t%12lu
  "
  		   "journal_relock_writers: \t%12lu
  "
  		   "journal_relock_wcount: \t%12lu
  "
  		   "mark_dirty: \t%12lu
  "
  		   "mark_dirty_already: \t%12lu
  "
  		   "mark_dirty_notjournal: \t%12lu
  "
  		   "restore_prepared: \t%12lu
  "
  		   "prepare: \t%12lu
  "
  		   "prepare_retry: \t%12lu
  ",
  		   DJP(jp_journal_1st_block),
a1c6f0573   Dmitry Monakhov   fs: use block_dev...
426
  		   SB_JOURNAL(sb)->j_dev_bd,
bd4c625c0   Linus Torvalds   reiserfs: run scr...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
  		   DJP(jp_journal_dev),
  		   DJP(jp_journal_size),
  		   DJP(jp_journal_trans_max),
  		   DJP(jp_journal_magic),
  		   DJP(jp_journal_max_batch),
  		   SB_JOURNAL(sb)->j_max_commit_age,
  		   DJP(jp_journal_max_trans_age),
  		   JF(j_1st_reserved_block),
  		   JF(j_state),
  		   JF(j_trans_id),
  		   JF(j_mount_id),
  		   JF(j_start),
  		   JF(j_len),
  		   JF(j_len_alloc),
  		   atomic_read(&r->s_journal->j_wcount),
  		   JF(j_bcount),
  		   JF(j_first_unflushed_offset),
  		   JF(j_last_flush_trans_id),
  		   JF(j_trans_start_time),
  		   JF(j_list_bitmap_index),
  		   JF(j_must_wait),
  		   JF(j_next_full_flush),
  		   JF(j_next_async_flush),
  		   JF(j_cnode_used),
  		   JF(j_cnode_free),
  		   SFPJ(in_journal),
  		   SFPJ(in_journal_bitmap),
  		   SFPJ(in_journal_reusable),
  		   SFPJ(lock_journal),
  		   SFPJ(lock_journal_wait),
  		   SFPJ(journal_being),
  		   SFPJ(journal_relock_writers),
  		   SFPJ(journal_relock_wcount),
  		   SFPJ(mark_dirty),
  		   SFPJ(mark_dirty_already),
  		   SFPJ(mark_dirty_notjournal),
  		   SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry)
  	    );
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
465
466
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
467
468
  static int r_open(struct inode *inode, struct file *file)
  {
672fe15d0   Al Viro   reiserfs: fix dea...
469
470
  	return single_open(file, PDE_DATA(inode), 
  				proc_get_parent_data(inode));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
471
  }
4b6f5d20b   Arjan van de Ven   [PATCH] Make most...
472
  static const struct file_operations r_file_operations = {
bd4c625c0   Linus Torvalds   reiserfs: run scr...
473
474
475
  	.open = r_open,
  	.read = seq_read,
  	.llseek = seq_lseek,
672fe15d0   Al Viro   reiserfs: fix dea...
476
  	.release = single_release,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
477
478
479
480
481
482
  };
  
  static struct proc_dir_entry *proc_info_root = NULL;
  static const char proc_info_root_name[] = "fs/reiserfs";
  
  static void add_file(struct super_block *sb, char *name,
672fe15d0   Al Viro   reiserfs: fix dea...
483
  		     int (*func) (struct seq_file *, void *))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
484
  {
19b4fc52d   Denis V. Lunev   reiserfs: use non...
485
486
  	proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
  			 &r_file_operations, func);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
487
  }
bd4c625c0   Linus Torvalds   reiserfs: run scr...
488
  int reiserfs_proc_info_init(struct super_block *sb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
489
  {
6fbe82a95   Jeff Mahoney   [PATCH] reiserfs:...
490
491
492
493
  	char b[BDEVNAME_SIZE];
  	char *s;
  
  	/* Some block devices use /'s */
2ccdc4131   Al Viro   kill reiserfs_bde...
494
  	strlcpy(b, sb->s_id, BDEVNAME_SIZE);
6fbe82a95   Jeff Mahoney   [PATCH] reiserfs:...
495
496
497
  	s = strchr(b, '/');
  	if (s)
  		*s = '!';
bd4c625c0   Linus Torvalds   reiserfs: run scr...
498
  	spin_lock_init(&__PINFO(sb).lock);
270b5ac21   David Howells   proc: Add proc_mk...
499
  	REISERFS_SB(sb)->procdir = proc_mkdir_data(b, 0, proc_info_root, sb);
bd4c625c0   Linus Torvalds   reiserfs: run scr...
500
  	if (REISERFS_SB(sb)->procdir) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
501
502
503
504
505
506
507
508
509
  		add_file(sb, "version", show_version);
  		add_file(sb, "super", show_super);
  		add_file(sb, "per-level", show_per_level);
  		add_file(sb, "bitmap", show_bitmap);
  		add_file(sb, "on-disk-super", show_on_disk_super);
  		add_file(sb, "oidmap", show_oidmap);
  		add_file(sb, "journal", show_journal);
  		return 0;
  	}
45b03d5e8   Jeff Mahoney   reiserfs: rework ...
510
  	reiserfs_warning(sb, "cannot create /proc/%s/%s",
6fbe82a95   Jeff Mahoney   [PATCH] reiserfs:...
511
  			 proc_info_root_name, b);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
512
513
  	return 1;
  }
bd4c625c0   Linus Torvalds   reiserfs: run scr...
514
  int reiserfs_proc_info_done(struct super_block *sb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
515
516
  {
  	struct proc_dir_entry *de = REISERFS_SB(sb)->procdir;
121daf5f8   Al Viro   reiserfs: use pro...
517
518
519
  	if (de) {
  		char b[BDEVNAME_SIZE];
  		char *s;
6fbe82a95   Jeff Mahoney   [PATCH] reiserfs:...
520

121daf5f8   Al Viro   reiserfs: use pro...
521
  		/* Some block devices use /'s */
2ccdc4131   Al Viro   kill reiserfs_bde...
522
  		strlcpy(b, sb->s_id, BDEVNAME_SIZE);
121daf5f8   Al Viro   reiserfs: use pro...
523
524
525
  		s = strchr(b, '/');
  		if (s)
  			*s = '!';
6fbe82a95   Jeff Mahoney   [PATCH] reiserfs:...
526

121daf5f8   Al Viro   reiserfs: use pro...
527
  		remove_proc_subtree(b, proc_info_root);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
528
529
530
531
  		REISERFS_SB(sb)->procdir = NULL;
  	}
  	return 0;
  }
bd4c625c0   Linus Torvalds   reiserfs: run scr...
532
  int reiserfs_proc_info_global_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
533
  {
bd4c625c0   Linus Torvalds   reiserfs: run scr...
534
  	if (proc_info_root == NULL) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
535
  		proc_info_root = proc_mkdir(proc_info_root_name, NULL);
99b762338   Alexey Dobriyan   proc 2/2: remove ...
536
  		if (!proc_info_root) {
45b03d5e8   Jeff Mahoney   reiserfs: rework ...
537
  			reiserfs_warning(NULL, "cannot create /proc/%s",
bd4c625c0   Linus Torvalds   reiserfs: run scr...
538
  					 proc_info_root_name);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
539
540
541
542
543
  			return 1;
  		}
  	}
  	return 0;
  }
bd4c625c0   Linus Torvalds   reiserfs: run scr...
544
  int reiserfs_proc_info_global_done(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
545
  {
bd4c625c0   Linus Torvalds   reiserfs: run scr...
546
  	if (proc_info_root != NULL) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
547
548
549
550
551
  		proc_info_root = NULL;
  		remove_proc_entry(proc_info_root_name, NULL);
  	}
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
552
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
553
554
555
556
557
558
559
560
561
562
563
564
565
566
   * Revision 1.1.8.2  2001/07/15 17:08:42  god
   *  . use get_super() in procfs.c
   *  . remove remove_save_link() from reiserfs_do_truncate()
   *
   * I accept terms and conditions stated in the Legal Agreement
   * (available at http://www.namesys.com/legalese.html)
   *
   * Revision 1.1.8.1  2001/07/11 16:48:50  god
   * proc info support
   *
   * I accept terms and conditions stated in the Legal Agreement
   * (available at http://www.namesys.com/legalese.html)
   *
   */
0222e6571   Jeff Mahoney   reiserfs: strip t...
567
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
568
569
570
571
572
573
574
575
   * Make Linus happy.
   * Local variables:
   * c-indentation-style: "K&R"
   * mode-name: "LC"
   * c-basic-offset: 8
   * tab-width: 8
   * End:
   */