Whamcloud - gitweb
landing smfs.
[fs/lustre-release.git] / lustre / smfs / sysctl.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2004 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #define DEBUG_SUBSYSTEM S_SM
24
25 #include <linux/module.h>
26 #include <linux/kmod.h>
27 #include <linux/init.h>
28 #include <linux/fs.h>
29 #include <linux/slab.h>
30 #include <linux/string.h>
31 #include <linux/sysctl.h>
32 #include <linux/proc_fs.h>
33 #include <linux/obd_class.h>
34 #include <linux/obd_support.h>
35 #include <linux/lustre_lib.h>
36 #include <linux/lustre_idl.h>
37 #include <linux/lustre_smfs.h>
38
39 #include "smfs_internal.h"
40
41
42 #ifdef CONFIG_PROC_FS
43 static struct proc_dir_entry *proc_smfs_root;
44 #endif
45
46 /* SYSCTL below */
47
48 static struct ctl_table_header *smfs_table_header = NULL;
49 /* 0x100 to avoid any chance of collisions at any point in the tree with
50  * non-directories
51  */
52 #define PSDEV_SMFS  (0x130)
53
54 #define PSDEV_DEBUG           1      /* control debugging */
55 #define PSDEV_TRACE           2      /* control enter/leave pattern */
56
57 /* These are global control options */
58 #define ENTRY_CNT 3
59
60 int sm_print_entry = 1;
61 int sm_debug_level = 0;
62
63 /* XXX - doesn't seem to be working in 2.2.15 */
64 static struct ctl_table smfs_ctltable[] =
65 {
66         {PSDEV_DEBUG, "debug", &sm_debug_level, sizeof(int), 0644, NULL,
67          &proc_dointvec},
68         {PSDEV_TRACE, "trace", &sm_print_entry, sizeof(int), 0644, NULL,
69          &proc_dointvec},
70         {0}
71 };
72
73 static ctl_table smfs_table[2] = {
74         {PSDEV_SMFS, "smfs",    NULL, 0, 0555, smfs_ctltable},
75         {0}
76 };
77
78
79 int  __init  init_smfs_proc_sys(void)
80 {
81 #ifdef CONFIG_PROC_FS
82         proc_smfs_root = proc_mkdir("smfs", proc_root_fs);
83         if (!proc_smfs_root) {
84                 printk(KERN_ERR "SMFS: error registering /proc/fs/smfs\n");
85                 RETURN(-ENOMEM);
86         }
87         proc_smfs_root->owner = THIS_MODULE;
88 #endif
89
90 #ifdef CONFIG_SYSCTL
91         if ( !smfs_table_header )
92                 smfs_table_header =
93                         register_sysctl_table(smfs_table, 0);
94 #endif
95         return 0;
96 }
97
98 void cleanup_smfs_proc_sys(void)
99 {
100 #ifdef CONFIG_SYSCTL
101         if ( smfs_table_header )
102                 unregister_sysctl_table(smfs_table_header);
103         smfs_table_header = NULL;
104 #endif
105 #if CONFIG_PROC_FS
106         remove_proc_entry("smfs", proc_root_fs);
107 #endif
108 }