]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4 LT |
2 | /* |
3 | * Copyright (C) International Business Machines Corp., 2000-2004 | |
4 | * Portions Copyright (C) Christoph Hellwig, 2001-2002 | |
1da177e4 LT |
5 | */ |
6 | ||
7 | #include <linux/fs.h> | |
8 | #include <linux/ctype.h> | |
9 | #include <linux/module.h> | |
10 | #include <linux/proc_fs.h> | |
b2e03ca7 | 11 | #include <linux/seq_file.h> |
7c0f6ba6 | 12 | #include <linux/uaccess.h> |
1da177e4 LT |
13 | #include "jfs_incore.h" |
14 | #include "jfs_filsys.h" | |
15 | #include "jfs_debug.h" | |
16 | ||
1da177e4 LT |
17 | #ifdef PROC_FS_JFS /* see jfs_debug.h */ |
18 | ||
1da177e4 | 19 | #ifdef CONFIG_JFS_DEBUG |
b2e03ca7 | 20 | static int jfs_loglevel_proc_show(struct seq_file *m, void *v) |
1da177e4 | 21 | { |
b2e03ca7 AD |
22 | seq_printf(m, "%d\n", jfsloglevel); |
23 | return 0; | |
24 | } | |
1da177e4 | 25 | |
b2e03ca7 AD |
26 | static int jfs_loglevel_proc_open(struct inode *inode, struct file *file) |
27 | { | |
28 | return single_open(file, jfs_loglevel_proc_show, NULL); | |
1da177e4 LT |
29 | } |
30 | ||
b2e03ca7 AD |
31 | static ssize_t jfs_loglevel_proc_write(struct file *file, |
32 | const char __user *buffer, size_t count, loff_t *ppos) | |
1da177e4 LT |
33 | { |
34 | char c; | |
35 | ||
36 | if (get_user(c, buffer)) | |
37 | return -EFAULT; | |
38 | ||
39 | /* yes, I know this is an ASCIIism. --hch */ | |
40 | if (c < '0' || c > '9') | |
41 | return -EINVAL; | |
42 | jfsloglevel = c - '0'; | |
43 | return count; | |
44 | } | |
b2e03ca7 | 45 | |
97a32539 AD |
46 | static const struct proc_ops jfs_loglevel_proc_ops = { |
47 | .proc_open = jfs_loglevel_proc_open, | |
48 | .proc_read = seq_read, | |
49 | .proc_lseek = seq_lseek, | |
50 | .proc_release = single_release, | |
51 | .proc_write = jfs_loglevel_proc_write, | |
b2e03ca7 | 52 | }; |
1da177e4 LT |
53 | #endif |
54 | ||
1da177e4 LT |
55 | void jfs_proc_init(void) |
56 | { | |
07a3b8ed | 57 | struct proc_dir_entry *base; |
1da177e4 | 58 | |
07a3b8ed CH |
59 | base = proc_mkdir("fs/jfs", NULL); |
60 | if (!base) | |
1da177e4 | 61 | return; |
1da177e4 | 62 | |
07a3b8ed CH |
63 | #ifdef CONFIG_JFS_STATISTICS |
64 | proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show); | |
65 | proc_create_single("txstats", 0, base, jfs_txstats_proc_show); | |
66 | proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show); | |
67 | proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show); | |
68 | #endif | |
69 | #ifdef CONFIG_JFS_DEBUG | |
70 | proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show); | |
97a32539 | 71 | proc_create("loglevel", 0, base, &jfs_loglevel_proc_ops); |
07a3b8ed | 72 | #endif |
1da177e4 LT |
73 | } |
74 | ||
75 | void jfs_proc_clean(void) | |
76 | { | |
07a3b8ed | 77 | remove_proc_subtree("fs/jfs", NULL); |
1da177e4 LT |
78 | } |
79 | ||
80 | #endif /* PROC_FS_JFS */ |