Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) International Business Machines Corp., 2000-2004 |
| 3 | * Portions Copyright (C) Christoph Hellwig, 2001-2002 |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 7 | * the Free Software Foundation; either version 2 of the License, or |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * (at your option) any later version. |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 9 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 13 | * the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 16 | * along with this program; if not, write to the Free Software |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | #include <linux/fs.h> |
| 21 | #include <linux/ctype.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/proc_fs.h> |
Alexey Dobriyan | b2e03ca | 2008-05-13 08:22:10 -0500 | [diff] [blame] | 24 | #include <linux/seq_file.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 25 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include "jfs_incore.h" |
| 27 | #include "jfs_filsys.h" |
| 28 | #include "jfs_debug.h" |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #ifdef PROC_FS_JFS /* see jfs_debug.h */ |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #ifdef CONFIG_JFS_DEBUG |
Alexey Dobriyan | b2e03ca | 2008-05-13 08:22:10 -0500 | [diff] [blame] | 33 | static int jfs_loglevel_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Alexey Dobriyan | b2e03ca | 2008-05-13 08:22:10 -0500 | [diff] [blame] | 35 | seq_printf(m, "%d\n", jfsloglevel); |
| 36 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Alexey Dobriyan | b2e03ca | 2008-05-13 08:22:10 -0500 | [diff] [blame] | 39 | static int jfs_loglevel_proc_open(struct inode *inode, struct file *file) |
| 40 | { |
| 41 | return single_open(file, jfs_loglevel_proc_show, NULL); |
| 42 | } |
| 43 | |
| 44 | static ssize_t jfs_loglevel_proc_write(struct file *file, |
| 45 | const char __user *buffer, size_t count, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { |
| 47 | char c; |
| 48 | |
| 49 | if (get_user(c, buffer)) |
| 50 | return -EFAULT; |
| 51 | |
| 52 | /* yes, I know this is an ASCIIism. --hch */ |
| 53 | if (c < '0' || c > '9') |
| 54 | return -EINVAL; |
| 55 | jfsloglevel = c - '0'; |
| 56 | return count; |
| 57 | } |
Alexey Dobriyan | b2e03ca | 2008-05-13 08:22:10 -0500 | [diff] [blame] | 58 | |
| 59 | static const struct file_operations jfs_loglevel_proc_fops = { |
Alexey Dobriyan | b2e03ca | 2008-05-13 08:22:10 -0500 | [diff] [blame] | 60 | .open = jfs_loglevel_proc_open, |
| 61 | .read = seq_read, |
| 62 | .llseek = seq_lseek, |
| 63 | .release = single_release, |
| 64 | .write = jfs_loglevel_proc_write, |
| 65 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | #endif |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | void jfs_proc_init(void) |
| 69 | { |
Christoph Hellwig | 07a3b8e | 2018-04-11 16:51:18 +0200 | [diff] [blame] | 70 | struct proc_dir_entry *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
Christoph Hellwig | 07a3b8e | 2018-04-11 16:51:18 +0200 | [diff] [blame] | 72 | base = proc_mkdir("fs/jfs", NULL); |
| 73 | if (!base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Christoph Hellwig | 07a3b8e | 2018-04-11 16:51:18 +0200 | [diff] [blame] | 76 | #ifdef CONFIG_JFS_STATISTICS |
| 77 | proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show); |
| 78 | proc_create_single("txstats", 0, base, jfs_txstats_proc_show); |
| 79 | proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show); |
| 80 | proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show); |
| 81 | #endif |
| 82 | #ifdef CONFIG_JFS_DEBUG |
| 83 | proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show); |
| 84 | proc_create("loglevel", 0, base, &jfs_loglevel_proc_fops); |
| 85 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | void jfs_proc_clean(void) |
| 89 | { |
Christoph Hellwig | 07a3b8e | 2018-04-11 16:51:18 +0200 | [diff] [blame] | 90 | remove_proc_subtree("fs/jfs", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | #endif /* PROC_FS_JFS */ |