]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - fs/jfs/jfs_debug.c
Merge branch 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar...
[mirror_ubuntu-jammy-kernel.git] / fs / jfs / jfs_debug.c
CommitLineData
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 20static 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
26static 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
31static 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
AD
45
46static const struct file_operations jfs_loglevel_proc_fops = {
b2e03ca7
AD
47 .open = jfs_loglevel_proc_open,
48 .read = seq_read,
49 .llseek = seq_lseek,
50 .release = single_release,
51 .write = jfs_loglevel_proc_write,
52};
1da177e4
LT
53#endif
54
1da177e4
LT
55void 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);
71 proc_create("loglevel", 0, base, &jfs_loglevel_proc_fops);
72#endif
1da177e4
LT
73}
74
75void jfs_proc_clean(void)
76{
07a3b8ed 77 remove_proc_subtree("fs/jfs", NULL);
1da177e4
LT
78}
79
80#endif /* PROC_FS_JFS */