diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-05-13 09:22:10 -0400 |
---|---|---|
committer | Dave Kleikamp <shaggy@linux.vnet.ibm.com> | 2008-05-13 09:22:10 -0400 |
commit | b2e03ca7485cac033a0667d9e45e28d32fdee9a5 (patch) | |
tree | c439fb22c543027143cebe17512b77964bd0ec20 /fs/jfs/jfs_debug.c | |
parent | 88f85a55c0645c2b7e03bf34d2a90eddf6de34fa (diff) |
JFS: switch to seq_files
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Diffstat (limited to 'fs/jfs/jfs_debug.c')
-rw-r--r-- | fs/jfs/jfs_debug.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c index bf6ab19b86ee..6a73de84bcef 100644 --- a/fs/jfs/jfs_debug.c +++ b/fs/jfs/jfs_debug.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/ctype.h> | 21 | #include <linux/ctype.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/proc_fs.h> | 23 | #include <linux/proc_fs.h> |
24 | #include <linux/seq_file.h> | ||
24 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
25 | #include "jfs_incore.h" | 26 | #include "jfs_incore.h" |
26 | #include "jfs_filsys.h" | 27 | #include "jfs_filsys.h" |
@@ -30,29 +31,19 @@ | |||
30 | 31 | ||
31 | static struct proc_dir_entry *base; | 32 | static struct proc_dir_entry *base; |
32 | #ifdef CONFIG_JFS_DEBUG | 33 | #ifdef CONFIG_JFS_DEBUG |
33 | static int loglevel_read(char *page, char **start, off_t off, | 34 | static int jfs_loglevel_proc_show(struct seq_file *m, void *v) |
34 | int count, int *eof, void *data) | ||
35 | { | 35 | { |
36 | int len; | 36 | seq_printf(m, "%d\n", jfsloglevel); |
37 | 37 | return 0; | |
38 | len = sprintf(page, "%d\n", jfsloglevel); | 38 | } |
39 | |||
40 | len -= off; | ||
41 | *start = page + off; | ||
42 | |||
43 | if (len > count) | ||
44 | len = count; | ||
45 | else | ||
46 | *eof = 1; | ||
47 | |||
48 | if (len < 0) | ||
49 | len = 0; | ||
50 | 39 | ||
51 | return len; | 40 | static int jfs_loglevel_proc_open(struct inode *inode, struct file *file) |
41 | { | ||
42 | return single_open(file, jfs_loglevel_proc_show, NULL); | ||
52 | } | 43 | } |
53 | 44 | ||
54 | static int loglevel_write(struct file *file, const char __user *buffer, | 45 | static ssize_t jfs_loglevel_proc_write(struct file *file, |
55 | unsigned long count, void *data) | 46 | const char __user *buffer, size_t count, loff_t *ppos) |
56 | { | 47 | { |
57 | char c; | 48 | char c; |
58 | 49 | ||
@@ -65,22 +56,30 @@ static int loglevel_write(struct file *file, const char __user *buffer, | |||
65 | jfsloglevel = c - '0'; | 56 | jfsloglevel = c - '0'; |
66 | return count; | 57 | return count; |
67 | } | 58 | } |
59 | |||
60 | static 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 | 68 | #endif |
69 | 69 | ||
70 | static struct { | 70 | static struct { |
71 | const char *name; | 71 | const char *name; |
72 | read_proc_t *read_fn; | 72 | const struct file_operations *proc_fops; |
73 | write_proc_t *write_fn; | ||
74 | } Entries[] = { | 73 | } Entries[] = { |
75 | #ifdef CONFIG_JFS_STATISTICS | 74 | #ifdef CONFIG_JFS_STATISTICS |
76 | { "lmstats", jfs_lmstats_read, }, | 75 | { "lmstats", &jfs_lmstats_proc_fops, }, |
77 | { "txstats", jfs_txstats_read, }, | 76 | { "txstats", &jfs_txstats_proc_fops, }, |
78 | { "xtstat", jfs_xtstat_read, }, | 77 | { "xtstat", &jfs_xtstat_proc_fops, }, |
79 | { "mpstat", jfs_mpstat_read, }, | 78 | { "mpstat", &jfs_mpstat_proc_fops, }, |
80 | #endif | 79 | #endif |
81 | #ifdef CONFIG_JFS_DEBUG | 80 | #ifdef CONFIG_JFS_DEBUG |
82 | { "TxAnchor", jfs_txanchor_read, }, | 81 | { "TxAnchor", &jfs_txanchor_proc_fops, }, |
83 | { "loglevel", loglevel_read, loglevel_write } | 82 | { "loglevel", &jfs_loglevel_proc_fops } |
84 | #endif | 83 | #endif |
85 | }; | 84 | }; |
86 | #define NPROCENT ARRAY_SIZE(Entries) | 85 | #define NPROCENT ARRAY_SIZE(Entries) |
@@ -93,13 +92,8 @@ void jfs_proc_init(void) | |||
93 | return; | 92 | return; |
94 | base->owner = THIS_MODULE; | 93 | base->owner = THIS_MODULE; |
95 | 94 | ||
96 | for (i = 0; i < NPROCENT; i++) { | 95 | for (i = 0; i < NPROCENT; i++) |
97 | struct proc_dir_entry *p; | 96 | proc_create(Entries[i].name, 0, base, Entries[i].proc_fops); |
98 | if ((p = create_proc_entry(Entries[i].name, 0, base))) { | ||
99 | p->read_proc = Entries[i].read_fn; | ||
100 | p->write_proc = Entries[i].write_fn; | ||
101 | } | ||
102 | } | ||
103 | } | 97 | } |
104 | 98 | ||
105 | void jfs_proc_clean(void) | 99 | void jfs_proc_clean(void) |