Blame view

fs/jfs/jfs_debug.c 2.76 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
  /*
   *   Copyright (C) International Business Machines Corp., 2000-2004
   *   Portions Copyright (C) Christoph Hellwig, 2001-2002
   *
   *   This program is free software;  you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License as published by
63f83c9fc   Dave Kleikamp   JFS: White space ...
7
   *   the Free Software Foundation; either version 2 of the License, or
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
   *   (at your option) any later version.
63f83c9fc   Dave Kleikamp   JFS: White space ...
9
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
12
13
14
15
   *   This program is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
   *   the GNU General Public License for more details.
   *
   *   You should have received a copy of the GNU General Public License
63f83c9fc   Dave Kleikamp   JFS: White space ...
16
   *   along with this program;  if not, write to the Free Software
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
19
20
21
22
23
   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   */
  
  #include <linux/fs.h>
  #include <linux/ctype.h>
  #include <linux/module.h>
  #include <linux/proc_fs.h>
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
24
  #include <linux/seq_file.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
28
  #include <asm/uaccess.h>
  #include "jfs_incore.h"
  #include "jfs_filsys.h"
  #include "jfs_debug.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
30
31
32
  #ifdef PROC_FS_JFS /* see jfs_debug.h */
  
  static struct proc_dir_entry *base;
  #ifdef CONFIG_JFS_DEBUG
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
33
  static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
  {
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
35
36
37
38
  	seq_printf(m, "%d
  ", jfsloglevel);
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39

b2e03ca74   Alexey Dobriyan   JFS: switch to se...
40
41
42
  static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
  {
  	return single_open(file, jfs_loglevel_proc_show, NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
  }
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
44
45
  static ssize_t jfs_loglevel_proc_write(struct file *file,
  		const char __user *buffer, size_t count, loff_t *ppos)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
49
50
51
52
53
54
55
56
57
  {
  	char c;
  
  	if (get_user(c, buffer))
  		return -EFAULT;
  
  	/* yes, I know this is an ASCIIism.  --hch */
  	if (c < '0' || c > '9')
  		return -EINVAL;
  	jfsloglevel = c - '0';
  	return count;
  }
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
58
59
60
61
62
63
64
65
66
  
  static const struct file_operations jfs_loglevel_proc_fops = {
  	.owner		= THIS_MODULE,
  	.open		= jfs_loglevel_proc_open,
  	.read		= seq_read,
  	.llseek		= seq_lseek,
  	.release	= single_release,
  	.write		= jfs_loglevel_proc_write,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
  static struct {
  	const char	*name;
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
70
  	const struct file_operations *proc_fops;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
  } Entries[] = {
  #ifdef CONFIG_JFS_STATISTICS
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
73
74
75
76
  	{ "lmstats",	&jfs_lmstats_proc_fops, },
  	{ "txstats",	&jfs_txstats_proc_fops, },
  	{ "xtstat",	&jfs_xtstat_proc_fops, },
  	{ "mpstat",	&jfs_mpstat_proc_fops, },
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
  #endif
  #ifdef CONFIG_JFS_DEBUG
b2e03ca74   Alexey Dobriyan   JFS: switch to se...
79
80
  	{ "TxAnchor",	&jfs_txanchor_proc_fops, },
  	{ "loglevel",	&jfs_loglevel_proc_fops }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
82
  #endif
  };
e8c96f8c2   Tobias Klauser   [PATCH] fs: Use A...
83
  #define NPROCENT	ARRAY_SIZE(Entries)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
84
85
86
87
  
  void jfs_proc_init(void)
  {
  	int i;
36a5aeb87   Alexey Dobriyan   proc: remove proc...
88
  	if (!(base = proc_mkdir("fs/jfs", NULL)))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
  		return;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90

b2e03ca74   Alexey Dobriyan   JFS: switch to se...
91
92
  	for (i = 0; i < NPROCENT; i++)
  		proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
93
94
95
96
97
98
99
100
101
  }
  
  void jfs_proc_clean(void)
  {
  	int i;
  
  	if (base) {
  		for (i = 0; i < NPROCENT; i++)
  			remove_proc_entry(Entries[i].name, base);
36a5aeb87   Alexey Dobriyan   proc: remove proc...
102
  		remove_proc_entry("fs/jfs", NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
103
104
105
106
  	}
  }
  
  #endif /* PROC_FS_JFS */