11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * sysctl.c - Code for sysctl handling in NTFS Linux kernel driver. Part of 31da177e4SLinus Torvalds * the Linux-NTFS project. Adapted from the old NTFS driver, 496de0e25SJan Engelhardt * Copyright (C) 1997 Martin von Löwis, Régis Duchesne 51da177e4SLinus Torvalds * 6c002f425SAnton Altaparmakov * Copyright (c) 2002-2005 Anton Altaparmakov 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * This program/include file is free software; you can redistribute it and/or 91da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License as published 101da177e4SLinus Torvalds * by the Free Software Foundation; either version 2 of the License, or 111da177e4SLinus Torvalds * (at your option) any later version. 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * This program/include file is distributed in the hope that it will be 141da177e4SLinus Torvalds * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 151da177e4SLinus Torvalds * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 161da177e4SLinus Torvalds * GNU General Public License for more details. 171da177e4SLinus Torvalds * 181da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 191da177e4SLinus Torvalds * along with this program (in the main directory of the Linux-NTFS 201da177e4SLinus Torvalds * distribution in the file COPYING); if not, write to the Free Software 211da177e4SLinus Torvalds * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 221da177e4SLinus Torvalds */ 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds #ifdef DEBUG 251da177e4SLinus Torvalds 261da177e4SLinus Torvalds #include <linux/module.h> 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds #ifdef CONFIG_SYSCTL 291da177e4SLinus Torvalds 301da177e4SLinus Torvalds #include <linux/proc_fs.h> 311da177e4SLinus Torvalds #include <linux/sysctl.h> 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds #include "sysctl.h" 341da177e4SLinus Torvalds #include "debug.h" 351da177e4SLinus Torvalds 361da177e4SLinus Torvalds /* Definition of the ntfs sysctl. */ 371da177e4SLinus Torvalds static ctl_table ntfs_sysctls[] = { 384ed075e9SEric W. Biederman { 394ed075e9SEric W. Biederman .procname = "ntfs-debug", 404ed075e9SEric W. Biederman .data = &debug_msgs, /* Data pointer and size. */ 414ed075e9SEric W. Biederman .maxlen = sizeof(debug_msgs), 424ed075e9SEric W. Biederman .mode = 0644, /* Mode, proc handler. */ 436d456111SEric W. Biederman .proc_handler = proc_dointvec 444ed075e9SEric W. Biederman }, 454ed075e9SEric W. Biederman {} 461da177e4SLinus Torvalds }; 471da177e4SLinus Torvalds 481da177e4SLinus Torvalds /* Define the parent directory /proc/sys/fs. */ 491da177e4SLinus Torvalds static ctl_table sysctls_root[] = { 504ed075e9SEric W. Biederman { 514ed075e9SEric W. Biederman .procname = "fs", 524ed075e9SEric W. Biederman .mode = 0555, 534ed075e9SEric W. Biederman .child = ntfs_sysctls 544ed075e9SEric W. Biederman }, 554ed075e9SEric W. Biederman {} 561da177e4SLinus Torvalds }; 571da177e4SLinus Torvalds 581da177e4SLinus Torvalds /* Storage for the sysctls header. */ 59*504e0e2fSFabian Frederick static struct ctl_table_header *sysctls_root_table; 601da177e4SLinus Torvalds 611da177e4SLinus Torvalds /** 621da177e4SLinus Torvalds * ntfs_sysctl - add or remove the debug sysctl 631da177e4SLinus Torvalds * @add: add (1) or remove (0) the sysctl 641da177e4SLinus Torvalds * 651da177e4SLinus Torvalds * Add or remove the debug sysctl. Return 0 on success or -errno on error. 661da177e4SLinus Torvalds */ 671da177e4SLinus Torvalds int ntfs_sysctl(int add) 681da177e4SLinus Torvalds { 691da177e4SLinus Torvalds if (add) { 701da177e4SLinus Torvalds BUG_ON(sysctls_root_table); 710b4d4147SEric W. Biederman sysctls_root_table = register_sysctl_table(sysctls_root); 721da177e4SLinus Torvalds if (!sysctls_root_table) 731da177e4SLinus Torvalds return -ENOMEM; 741da177e4SLinus Torvalds } else { 751da177e4SLinus Torvalds BUG_ON(!sysctls_root_table); 761da177e4SLinus Torvalds unregister_sysctl_table(sysctls_root_table); 771da177e4SLinus Torvalds sysctls_root_table = NULL; 781da177e4SLinus Torvalds } 791da177e4SLinus Torvalds return 0; 801da177e4SLinus Torvalds } 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds #endif /* CONFIG_SYSCTL */ 831da177e4SLinus Torvalds #endif /* DEBUG */ 84