1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) International Business Machines Corp., 2000-2004
4 * Portions Copyright (C) Christoph Hellwig, 2001-2002
8 #include <linux/ctype.h>
9 #include <linux/module.h>
10 #include <linux/proc_fs.h>
11 #include <linux/seq_file.h>
12 #include <linux/uaccess.h>
13 #include "jfs_incore.h"
14 #include "jfs_filsys.h"
15 #include "jfs_debug.h"
17 #ifdef PROC_FS_JFS /* see jfs_debug.h */
19 #ifdef CONFIG_JFS_DEBUG
20 static int jfs_loglevel_proc_show(struct seq_file
*m
, void *v
)
22 seq_printf(m
, "%d\n", jfsloglevel
);
26 static int jfs_loglevel_proc_open(struct inode
*inode
, struct file
*file
)
28 return single_open(file
, jfs_loglevel_proc_show
, NULL
);
31 static ssize_t
jfs_loglevel_proc_write(struct file
*file
,
32 const char __user
*buffer
, size_t count
, loff_t
*ppos
)
36 if (get_user(c
, buffer
))
39 /* yes, I know this is an ASCIIism. --hch */
40 if (c
< '0' || c
> '9')
42 jfsloglevel
= c
- '0';
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
,
55 void jfs_proc_init(void)
57 struct proc_dir_entry
*base
;
59 base
= proc_mkdir("fs/jfs", NULL
);
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
);
69 #ifdef CONFIG_JFS_DEBUG
70 proc_create_single("TxAnchor", 0, base
, jfs_txanchor_proc_show
);
71 proc_create("loglevel", 0, base
, &jfs_loglevel_proc_ops
);
75 void jfs_proc_clean(void)
77 remove_proc_subtree("fs/jfs", NULL
);
80 #endif /* PROC_FS_JFS */