Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * sysctl.c - Code for sysctl handling in NTFS Linux kernel driver. Part of
0004  *        the Linux-NTFS project. Adapted from the old NTFS driver,
0005  *        Copyright (C) 1997 Martin von Löwis, Régis Duchesne
0006  *
0007  * Copyright (c) 2002-2005 Anton Altaparmakov
0008  */
0009 
0010 #ifdef DEBUG
0011 
0012 #include <linux/module.h>
0013 
0014 #ifdef CONFIG_SYSCTL
0015 
0016 #include <linux/proc_fs.h>
0017 #include <linux/sysctl.h>
0018 
0019 #include "sysctl.h"
0020 #include "debug.h"
0021 
0022 /* Definition of the ntfs sysctl. */
0023 static struct ctl_table ntfs_sysctls[] = {
0024     {
0025         .procname   = "ntfs-debug",
0026         .data       = &debug_msgs,      /* Data pointer and size. */
0027         .maxlen     = sizeof(debug_msgs),
0028         .mode       = 0644,         /* Mode, proc handler. */
0029         .proc_handler   = proc_dointvec
0030     },
0031     {}
0032 };
0033 
0034 /* Define the parent directory /proc/sys/fs. */
0035 static struct ctl_table sysctls_root[] = {
0036     {
0037         .procname   = "fs",
0038         .mode       = 0555,
0039         .child      = ntfs_sysctls
0040     },
0041     {}
0042 };
0043 
0044 /* Storage for the sysctls header. */
0045 static struct ctl_table_header *sysctls_root_table;
0046 
0047 /**
0048  * ntfs_sysctl - add or remove the debug sysctl
0049  * @add:    add (1) or remove (0) the sysctl
0050  *
0051  * Add or remove the debug sysctl. Return 0 on success or -errno on error.
0052  */
0053 int ntfs_sysctl(int add)
0054 {
0055     if (add) {
0056         BUG_ON(sysctls_root_table);
0057         sysctls_root_table = register_sysctl_table(sysctls_root);
0058         if (!sysctls_root_table)
0059             return -ENOMEM;
0060     } else {
0061         BUG_ON(!sysctls_root_table);
0062         unregister_sysctl_table(sysctls_root_table);
0063         sysctls_root_table = NULL;
0064     }
0065     return 0;
0066 }
0067 
0068 #endif /* CONFIG_SYSCTL */
0069 #endif /* DEBUG */