0001
0002
0003
0004
0005
0006
0007 #include <linux/fs.h>
0008 #include <linux/ctype.h>
0009 #include <linux/module.h>
0010 #include <linux/proc_fs.h>
0011 #include <linux/seq_file.h>
0012 #include <linux/uaccess.h>
0013 #include "jfs_incore.h"
0014 #include "jfs_filsys.h"
0015 #include "jfs_debug.h"
0016
0017 #ifdef PROC_FS_JFS
0018
0019 #ifdef CONFIG_JFS_DEBUG
0020 static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
0021 {
0022 seq_printf(m, "%d\n", jfsloglevel);
0023 return 0;
0024 }
0025
0026 static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
0027 {
0028 return single_open(file, jfs_loglevel_proc_show, NULL);
0029 }
0030
0031 static ssize_t jfs_loglevel_proc_write(struct file *file,
0032 const char __user *buffer, size_t count, loff_t *ppos)
0033 {
0034 char c;
0035
0036 if (get_user(c, buffer))
0037 return -EFAULT;
0038
0039
0040 if (c < '0' || c > '9')
0041 return -EINVAL;
0042 jfsloglevel = c - '0';
0043 return count;
0044 }
0045
0046 static const struct proc_ops jfs_loglevel_proc_ops = {
0047 .proc_open = jfs_loglevel_proc_open,
0048 .proc_read = seq_read,
0049 .proc_lseek = seq_lseek,
0050 .proc_release = single_release,
0051 .proc_write = jfs_loglevel_proc_write,
0052 };
0053 #endif
0054
0055 void jfs_proc_init(void)
0056 {
0057 struct proc_dir_entry *base;
0058
0059 base = proc_mkdir("fs/jfs", NULL);
0060 if (!base)
0061 return;
0062
0063 #ifdef CONFIG_JFS_STATISTICS
0064 proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show);
0065 proc_create_single("txstats", 0, base, jfs_txstats_proc_show);
0066 proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show);
0067 proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show);
0068 #endif
0069 #ifdef CONFIG_JFS_DEBUG
0070 proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show);
0071 proc_create("loglevel", 0, base, &jfs_loglevel_proc_ops);
0072 #endif
0073 }
0074
0075 void jfs_proc_clean(void)
0076 {
0077 remove_proc_subtree("fs/jfs", NULL);
0078 }
0079
0080 #endif