xref: /linux/fs/ntfs/sysctl.c (revision 5218cd102aec7ae8df6af6e681ebb0b6d8e798f4)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Code for sysctl handling in NTFS Linux kernel driver.
4  *
5  * Copyright (C) 1997 Martin von Löwis, Régis Duchesne
6  * Copyright (c) 2002-2005 Anton Altaparmakov
7  */
8 
9 #ifdef DEBUG
10 
11 #include <linux/module.h>
12 
13 #ifdef CONFIG_SYSCTL
14 
15 #include <linux/proc_fs.h>
16 #include <linux/sysctl.h>
17 
18 #include "sysctl.h"
19 #include "debug.h"
20 
21 /* Definition of the ntfs sysctl. */
22 static const struct ctl_table ntfs_sysctls[] = {
23 	{
24 		.procname	= "ntfs-debug",
25 		.data		= &debug_msgs,		/* Data pointer and size. */
26 		.maxlen		= sizeof(debug_msgs),
27 		.mode		= 0644,			/* Mode, proc handler. */
28 		.proc_handler	= proc_dointvec
29 	},
30 	{}
31 };
32 
33 /* Storage for the sysctls header. */
34 static struct ctl_table_header *sysctls_root_table;
35 
36 /*
37  * ntfs_sysctl - add or remove the debug sysctl
38  * @add:	add (1) or remove (0) the sysctl
39  *
40  * Add or remove the debug sysctl. Return 0 on success or -errno on error.
41  */
42 int ntfs_sysctl(int add)
43 {
44 	if (add) {
45 		sysctls_root_table = register_sysctl("fs", ntfs_sysctls);
46 		if (!sysctls_root_table)
47 			return -ENOMEM;
48 	} else {
49 		unregister_sysctl_table(sysctls_root_table);
50 		sysctls_root_table = NULL;
51 	}
52 	return 0;
53 }
54 #endif /* CONFIG_SYSCTL */
55 #endif /* DEBUG */
56