xref: /openbmc/linux/fs/ntfs/sysctl.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1a1d312deSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * sysctl.c - Code for sysctl handling in NTFS Linux kernel driver. Part of
41da177e4SLinus Torvalds  *	      the Linux-NTFS project. Adapted from the old NTFS driver,
596de0e25SJan Engelhardt  *	      Copyright (C) 1997 Martin von Löwis, Régis Duchesne
61da177e4SLinus Torvalds  *
7c002f425SAnton Altaparmakov  * Copyright (c) 2002-2005 Anton Altaparmakov
81da177e4SLinus Torvalds  */
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds #ifdef DEBUG
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds #include <linux/module.h>
131da177e4SLinus Torvalds 
141da177e4SLinus Torvalds #ifdef CONFIG_SYSCTL
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds #include <linux/proc_fs.h>
171da177e4SLinus Torvalds #include <linux/sysctl.h>
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds #include "sysctl.h"
201da177e4SLinus Torvalds #include "debug.h"
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds /* Definition of the ntfs sysctl. */
235eccdf39SJoe Perches static struct ctl_table ntfs_sysctls[] = {
244ed075e9SEric W. Biederman 	{
254ed075e9SEric W. Biederman 		.procname	= "ntfs-debug",
264ed075e9SEric W. Biederman 		.data		= &debug_msgs,		/* Data pointer and size. */
274ed075e9SEric W. Biederman 		.maxlen		= sizeof(debug_msgs),
284ed075e9SEric W. Biederman 		.mode		= 0644,			/* Mode, proc handler. */
296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec
304ed075e9SEric W. Biederman 	},
314ed075e9SEric W. Biederman 	{}
321da177e4SLinus Torvalds };
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds /* Storage for the sysctls header. */
35504e0e2fSFabian Frederick static struct ctl_table_header *sysctls_root_table;
361da177e4SLinus Torvalds 
371da177e4SLinus Torvalds /**
381da177e4SLinus Torvalds  * ntfs_sysctl - add or remove the debug sysctl
391da177e4SLinus Torvalds  * @add:	add (1) or remove (0) the sysctl
401da177e4SLinus Torvalds  *
411da177e4SLinus Torvalds  * Add or remove the debug sysctl. Return 0 on success or -errno on error.
421da177e4SLinus Torvalds  */
ntfs_sysctl(int add)431da177e4SLinus Torvalds int ntfs_sysctl(int add)
441da177e4SLinus Torvalds {
451da177e4SLinus Torvalds 	if (add) {
461da177e4SLinus Torvalds 		BUG_ON(sysctls_root_table);
47*02148ff3SLuis Chamberlain 		sysctls_root_table = register_sysctl("fs", ntfs_sysctls);
481da177e4SLinus Torvalds 		if (!sysctls_root_table)
491da177e4SLinus Torvalds 			return -ENOMEM;
501da177e4SLinus Torvalds 	} else {
511da177e4SLinus Torvalds 		BUG_ON(!sysctls_root_table);
521da177e4SLinus Torvalds 		unregister_sysctl_table(sysctls_root_table);
531da177e4SLinus Torvalds 		sysctls_root_table = NULL;
541da177e4SLinus Torvalds 	}
551da177e4SLinus Torvalds 	return 0;
561da177e4SLinus Torvalds }
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds #endif /* CONFIG_SYSCTL */
591da177e4SLinus Torvalds #endif /* DEBUG */
60