Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Apr 14-17, 2025
Register
Loading...
v4.17
 
  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
  7 *   the Free Software Foundation; either version 2 of the License, or
  8 *   (at your option) any later version.
  9 *
 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
 16 *   along with this program;  if not, write to the Free Software
 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>
 24#include <linux/seq_file.h>
 25#include <linux/uaccess.h>
 26#include "jfs_incore.h"
 27#include "jfs_filsys.h"
 28#include "jfs_debug.h"
 29
 30#ifdef PROC_FS_JFS /* see jfs_debug.h */
 31
 32static struct proc_dir_entry *base;
 33#ifdef CONFIG_JFS_DEBUG
 34static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
 35{
 36	seq_printf(m, "%d\n", jfsloglevel);
 37	return 0;
 38}
 39
 40static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
 41{
 42	return single_open(file, jfs_loglevel_proc_show, NULL);
 43}
 44
 45static ssize_t jfs_loglevel_proc_write(struct file *file,
 46		const char __user *buffer, size_t count, loff_t *ppos)
 47{
 48	char c;
 49
 50	if (get_user(c, buffer))
 51		return -EFAULT;
 52
 53	/* yes, I know this is an ASCIIism.  --hch */
 54	if (c < '0' || c > '9')
 55		return -EINVAL;
 56	jfsloglevel = c - '0';
 57	return count;
 58}
 59
 60static const struct file_operations jfs_loglevel_proc_fops = {
 61	.open		= jfs_loglevel_proc_open,
 62	.read		= seq_read,
 63	.llseek		= seq_lseek,
 64	.release	= single_release,
 65	.write		= jfs_loglevel_proc_write,
 66};
 67#endif
 68
 69static struct {
 70	const char	*name;
 71	const struct file_operations *proc_fops;
 72} Entries[] = {
 73#ifdef CONFIG_JFS_STATISTICS
 74	{ "lmstats",	&jfs_lmstats_proc_fops, },
 75	{ "txstats",	&jfs_txstats_proc_fops, },
 76	{ "xtstat",	&jfs_xtstat_proc_fops, },
 77	{ "mpstat",	&jfs_mpstat_proc_fops, },
 78#endif
 79#ifdef CONFIG_JFS_DEBUG
 80	{ "TxAnchor",	&jfs_txanchor_proc_fops, },
 81	{ "loglevel",	&jfs_loglevel_proc_fops }
 82#endif
 83};
 84#define NPROCENT	ARRAY_SIZE(Entries)
 85
 86void jfs_proc_init(void)
 87{
 88	int i;
 89
 90	if (!(base = proc_mkdir("fs/jfs", NULL)))
 
 91		return;
 92
 93	for (i = 0; i < NPROCENT; i++)
 94		proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
 
 
 
 
 
 
 
 
 95}
 96
 97void jfs_proc_clean(void)
 98{
 99	int i;
100
101	if (base) {
102		for (i = 0; i < NPROCENT; i++)
103			remove_proc_entry(Entries[i].name, base);
104		remove_proc_entry("fs/jfs", NULL);
105	}
106}
107
108#endif /* PROC_FS_JFS */
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 *   Copyright (C) International Business Machines Corp., 2000-2004
 4 *   Portions Copyright (C) Christoph Hellwig, 2001-2002
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 5 */
 6
 7#include <linux/fs.h>
 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"
16
17#ifdef PROC_FS_JFS /* see jfs_debug.h */
18
 
19#ifdef CONFIG_JFS_DEBUG
20static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
21{
22	seq_printf(m, "%d\n", jfsloglevel);
23	return 0;
24}
25
26static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
27{
28	return single_open(file, jfs_loglevel_proc_show, NULL);
29}
30
31static ssize_t jfs_loglevel_proc_write(struct file *file,
32		const char __user *buffer, size_t count, loff_t *ppos)
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}
45
46static 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,
52};
53#endif
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55void jfs_proc_init(void)
56{
57	struct proc_dir_entry *base;
58
59	base = proc_mkdir("fs/jfs", NULL);
60	if (!base)
61		return;
62
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_ops);
72#endif
73}
74
75void jfs_proc_clean(void)
76{
77	remove_proc_subtree("fs/jfs", NULL);
 
 
 
 
 
 
78}
79
80#endif /* PROC_FS_JFS */