2 * Copyright (C) International Business Machines Corp., 2000-2004
3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/ctype.h>
22 #include <linux/module.h>
23 #include <linux/proc_fs.h>
24 #include <linux/seq_file.h>
25 #include <asm/uaccess.h>
26 #include "jfs_incore.h"
27 #include "jfs_filsys.h"
28 #include "jfs_debug.h"
30 #ifdef PROC_FS_JFS /* see jfs_debug.h */
32 static struct proc_dir_entry
*base
;
33 #ifdef CONFIG_JFS_DEBUG
34 static int jfs_loglevel_proc_show(struct seq_file
*m
, void *v
)
36 seq_printf(m
, "%d\n", jfsloglevel
);
40 static int jfs_loglevel_proc_open(struct inode
*inode
, struct file
*file
)
42 return single_open(file
, jfs_loglevel_proc_show
, NULL
);
45 static ssize_t
jfs_loglevel_proc_write(struct file
*file
,
46 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
50 if (get_user(c
, buffer
))
53 /* yes, I know this is an ASCIIism. --hch */
54 if (c
< '0' || c
> '9')
56 jfsloglevel
= c
- '0';
60 static const struct file_operations jfs_loglevel_proc_fops
= {
62 .open
= jfs_loglevel_proc_open
,
65 .release
= single_release
,
66 .write
= jfs_loglevel_proc_write
,
72 const struct file_operations
*proc_fops
;
74 #ifdef CONFIG_JFS_STATISTICS
75 { "lmstats", &jfs_lmstats_proc_fops
, },
76 { "txstats", &jfs_txstats_proc_fops
, },
77 { "xtstat", &jfs_xtstat_proc_fops
, },
78 { "mpstat", &jfs_mpstat_proc_fops
, },
80 #ifdef CONFIG_JFS_DEBUG
81 { "TxAnchor", &jfs_txanchor_proc_fops
, },
82 { "loglevel", &jfs_loglevel_proc_fops
}
85 #define NPROCENT ARRAY_SIZE(Entries)
87 void jfs_proc_init(void)
91 if (!(base
= proc_mkdir("fs/jfs", NULL
)))
93 base
->owner
= THIS_MODULE
;
95 for (i
= 0; i
< NPROCENT
; i
++)
96 proc_create(Entries
[i
].name
, 0, base
, Entries
[i
].proc_fops
);
99 void jfs_proc_clean(void)
104 for (i
= 0; i
< NPROCENT
; i
++)
105 remove_proc_entry(Entries
[i
].name
, base
);
106 remove_proc_entry("fs/jfs", NULL
);
110 #endif /* PROC_FS_JFS */