1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/fs.h>
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"
29
30#ifdef PROC_FS_JFS
31
32static struct proc_dir_entry *base;
33#ifdef CONFIG_JFS_DEBUG
34static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
35{
36 seq_printf(m, "%d\n", jfsloglevel);
37 return 0;
38}
39
40static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
41{
42 return single_open(file, jfs_loglevel_proc_show, NULL);
43}
44
45static ssize_t jfs_loglevel_proc_write(struct file *file,
46 const char __user *buffer, size_t count, loff_t *ppos)
47{
48 char c;
49
50 if (get_user(c, buffer))
51 return -EFAULT;
52
53
54 if (c < '0' || c > '9')
55 return -EINVAL;
56 jfsloglevel = c - '0';
57 return count;
58}
59
60static const struct file_operations jfs_loglevel_proc_fops = {
61 .owner = THIS_MODULE,
62 .open = jfs_loglevel_proc_open,
63 .read = seq_read,
64 .llseek = seq_lseek,
65 .release = single_release,
66 .write = jfs_loglevel_proc_write,
67};
68#endif
69
70static struct {
71 const char *name;
72 const struct file_operations *proc_fops;
73} Entries[] = {
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, },
79#endif
80#ifdef CONFIG_JFS_DEBUG
81 { "TxAnchor", &jfs_txanchor_proc_fops, },
82 { "loglevel", &jfs_loglevel_proc_fops }
83#endif
84};
85#define NPROCENT ARRAY_SIZE(Entries)
86
87void jfs_proc_init(void)
88{
89 int i;
90
91 if (!(base = proc_mkdir("fs/jfs", NULL)))
92 return;
93
94 for (i = 0; i < NPROCENT; i++)
95 proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
96}
97
98void jfs_proc_clean(void)
99{
100 int i;
101
102 if (base) {
103 for (i = 0; i < NPROCENT; i++)
104 remove_proc_entry(Entries[i].name, base);
105 remove_proc_entry("fs/jfs", NULL);
106 }
107}
108
109#endif
110