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