Whamcloud - gitweb
add .cvsignore
[fs/lustre-release.git] / lustre / snapfs / sysctl.c
1 /*
2  *  Sysctrl entries for Snapfs
3  */
4
5 /* /proc entries */
6
7 #define DEBUG_SUBSYSTEM S_SNAP
8
9 #include <linux/module.h>
10 #include <linux/kmod.h>
11 #include <linux/init.h>
12 #include <linux/fs.h>
13 #include <linux/slab.h>
14 #include <linux/string.h>
15 #include <linux/sysctl.h>
16 #include <linux/proc_fs.h>
17 #include <linux/jbd.h>
18 #include <linux/ext3_fs.h>
19 #include <linux/snap.h>
20
21 #include "snapfs_internal.h" 
22
23
24 #ifdef CONFIG_PROC_FS
25 static struct proc_dir_entry *proc_snapfs_root;
26 #endif
27
28
29 /* SYSCTL below */
30
31 static struct ctl_table_header *snapfs_table_header = NULL;
32 /* 0x100 to avoid any chance of collisions at any point in the tree with
33  * non-directories
34  */
35 #define PSDEV_SNAPFS  (0x120)
36
37 #define PSDEV_DEBUG        1      /* control debugging */
38 #define PSDEV_TRACE        2      /* control enter/leave pattern */
39
40 /* These are global control options */
41 #define ENTRY_CNT 3
42
43 /* XXX - doesn't seem to be working in 2.2.15 */
44 static struct ctl_table snapfs_ctltable[] =
45 {
46 #ifdef SNAP_DEBUG
47         {PSDEV_DEBUG, "debug", &snap_debug_level, sizeof(int), 0644, NULL, &proc_dointvec},
48 #endif
49         {PSDEV_TRACE, "trace", &snap_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
50         {0}
51 };
52
53 static ctl_table snapfs_table[2] = {
54         {PSDEV_SNAPFS, "snapfs",    NULL, 0, 0555, snapfs_ctltable},
55         {0}
56 };
57
58
59 int  __init  init_snapfs_proc_sys(void)
60 {
61 #ifdef CONFIG_PROC_FS
62         proc_snapfs_root = proc_mkdir("snapfs", proc_root_fs);
63         if (!proc_snapfs_root) {
64                 printk(KERN_ERR "SNAPFS: error registering /proc/fs/snapfs\n");
65                 RETURN(-ENOMEM);
66         }
67         proc_snapfs_root->owner = THIS_MODULE;
68 #endif
69
70 #ifdef CONFIG_SYSCTL
71         if ( !snapfs_table_header )
72                 snapfs_table_header =
73                         register_sysctl_table(snapfs_table, 0);
74 #endif
75         return 0;
76 }
77
78 void cleanup_snapfs_proc_sys(void) 
79 {
80 #ifdef CONFIG_SYSCTL
81         if ( snapfs_table_header )
82                 unregister_sysctl_table(snapfs_table_header);
83         snapfs_table_header = NULL;
84 #endif
85 #if CONFIG_PROC_FS
86         remove_proc_entry("snapfs", proc_root_fs);
87 #endif
88
89 }
90