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