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