Whamcloud - gitweb
add snapfs to cvs
[fs/lustre-release.git] / lustre / snapfs / sysctl.c
1 /*
2  *  Sysctrl entries for Snapfs
3  */
4
5 #define __NO_VERSION__
6 #include <linux/config.h> /* for CONFIG_PROC_FS */
7 #include <linux/module.h>
8 #include <linux/sched.h>
9 #include <linux/mm.h>
10 #include <linux/sysctl.h>
11 #include <linux/swapctl.h>
12 #include <linux/proc_fs.h>
13 #include <linux/malloc.h>
14 #include <linux/vmalloc.h>
15 #include <linux/stat.h>
16 #include <linux/ctype.h>
17 #include <linux/init.h>
18 #include <asm/bitops.h>
19 #include <asm/segment.h>
20 #include <asm/uaccess.h>
21 #include <linux/utsname.h>
22 #include <linux/blk.h>
23  
24 #include <linux/filter.h>
25 #include <linux/snapfs.h>
26 #include <linux/snapsupport.h>
27
28
29 /* /proc entries */
30
31 #ifdef CONFIG_PROC_FS
32
33
34 static void snapfs_proc_modcount(struct inode *inode, int fill)
35 {
36         if (fill)
37                 MOD_INC_USE_COUNT;
38         else
39                 MOD_DEC_USE_COUNT;
40 }
41
42 struct proc_dir_entry proc_fs_snapfs = {
43         0, 10, "snapfs",
44         S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0,
45         0, &proc_dir_inode_operations,
46         NULL, NULL,
47         NULL,
48         NULL, NULL
49 };
50
51
52 #endif
53
54
55 /* SYSCTL below */
56
57 static struct ctl_table_header *snapfs_table_header = NULL;
58 /* 0x100 to avoid any chance of collisions at any point in the tree with
59  * non-directories
60  */
61 #define PSDEV_SNAPFS  (0x120)
62
63 #define PSDEV_DEBUG        1      /* control debugging */
64 #define PSDEV_TRACE        2      /* control enter/leave pattern */
65
66 /* These are global control options */
67 #define ENTRY_CNT 3
68
69 /* XXX - doesn't seem to be working in 2.2.15 */
70 static struct ctl_table snapfs_ctltable[ENTRY_CNT] =
71 {
72         {PSDEV_DEBUG, "debug", &snap_debug_level, sizeof(int), 0644, NULL, &proc_dointvec},
73         {PSDEV_TRACE, "trace", &snap_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
74         {0}
75 };
76
77 static ctl_table snapfs_table[2] = {
78         {PSDEV_SNAPFS, "snapfs",    NULL, 0, 0555, snapfs_ctltable},
79         {0}
80 };
81
82
83 int /* __init */ init_snapfs_proc_sys(void)
84 {
85
86 #ifdef CONFIG_SYSCTL
87         if ( !snapfs_table_header )
88                 snapfs_table_header =
89                         register_sysctl_table(snapfs_table, 0);
90 #endif
91 #ifdef CONFIG_PROC_FS
92         proc_register(&proc_root_fs, &proc_fs_snapfs);
93         proc_fs_snapfs.fill_inode = &snapfs_proc_modcount;
94 #endif
95         return 0;
96 }
97
98 void cleanup_snapfs_proc_sys(void) {
99
100 #ifdef CONFIG_SYSCTL
101         if ( snapfs_table_header )
102                 unregister_sysctl_table(snapfs_table_header);
103         snapfs_table_header = NULL;
104 #endif
105
106 #if CONFIG_PROC_FS
107         proc_unregister(&proc_root_fs, proc_fs_snapfs.low_ino);
108 #endif
109 }
110