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 /* Storage for the sysctls header. */ 33 static struct ctl_table_header *sysctls_root_table; 34 35 /* 36 * ntfs_sysctl - add or remove the debug sysctl 37 * @add: add (1) or remove (0) the sysctl 38 * 39 * Add or remove the debug sysctl. Return 0 on success or -errno on error. 40 */ 41 int ntfs_sysctl(int add) 42 { 43 if (add) { 44 sysctls_root_table = register_sysctl("fs/ntfs", ntfs_sysctls); 45 if (!sysctls_root_table) 46 return -ENOMEM; 47 } else { 48 unregister_sysctl_table(sysctls_root_table); 49 sysctls_root_table = NULL; 50 } 51 return 0; 52 } 53 #endif /* CONFIG_SYSCTL */ 54 #endif /* DEBUG */ 55