[XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / xfs / linux-2.6 / xfs_sysctl.c
1 /*
2 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32 #include "xfs.h"
33 #include <linux/sysctl.h>
34 #include <linux/proc_fs.h>
35
36
37 static struct ctl_table_header *xfs_table_header;
38
39
40 #ifdef CONFIG_PROC_FS
41 STATIC int
42 xfs_stats_clear_proc_handler(
43 ctl_table *ctl,
44 int write,
45 struct file *filp,
46 void __user *buffer,
47 size_t *lenp,
48 loff_t *ppos)
49 {
50 int c, ret, *valp = ctl->data;
51 __uint32_t vn_active;
52
53 ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp, ppos);
54
55 if (!ret && write && *valp) {
56 printk("XFS Clearing xfsstats\n");
57 for (c = 0; c < NR_CPUS; c++) {
58 if (!cpu_possible(c)) continue;
59 preempt_disable();
60 /* save vn_active, it's a universal truth! */
61 vn_active = per_cpu(xfsstats, c).vn_active;
62 memset(&per_cpu(xfsstats, c), 0,
63 sizeof(struct xfsstats));
64 per_cpu(xfsstats, c).vn_active = vn_active;
65 preempt_enable();
66 }
67 xfs_stats_clear = 0;
68 }
69
70 return ret;
71 }
72 #endif /* CONFIG_PROC_FS */
73
74 STATIC ctl_table xfs_table[] = {
75 {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
76 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
77 &sysctl_intvec, NULL,
78 &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
79
80 {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
81 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
82 &sysctl_intvec, NULL,
83 &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
84
85 {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
86 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
87 &sysctl_intvec, NULL,
88 &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
89
90 {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
91 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
92 &sysctl_intvec, NULL,
93 &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
94
95 {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
96 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
97 &sysctl_intvec, NULL,
98 &xfs_params.error_level.min, &xfs_params.error_level.max},
99
100 {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val,
101 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
102 &sysctl_intvec, NULL,
103 &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max},
104
105 {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
106 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
107 &sysctl_intvec, NULL,
108 &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
109
110 {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
111 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
112 &sysctl_intvec, NULL,
113 &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
114
115 {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
116 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
117 &sysctl_intvec, NULL,
118 &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
119
120 {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
121 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
122 &sysctl_intvec, NULL,
123 &xfs_params.xfs_buf_timer.min, &xfs_params.xfs_buf_timer.max},
124
125 {XFS_BUF_AGE, "age_buffer_centisecs", &xfs_params.xfs_buf_age.val,
126 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
127 &sysctl_intvec, NULL,
128 &xfs_params.xfs_buf_age.min, &xfs_params.xfs_buf_age.max},
129
130 {XFS_INHERIT_NOSYM, "inherit_nosymlinks", &xfs_params.inherit_nosym.val,
131 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
132 &sysctl_intvec, NULL,
133 &xfs_params.inherit_nosym.min, &xfs_params.inherit_nosym.max},
134
135 {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
136 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
137 &sysctl_intvec, NULL,
138 &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
139
140 /* please keep this the last entry */
141 #ifdef CONFIG_PROC_FS
142 {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
143 sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
144 &sysctl_intvec, NULL,
145 &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
146 #endif /* CONFIG_PROC_FS */
147
148 {0}
149 };
150
151 STATIC ctl_table xfs_dir_table[] = {
152 {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
153 {0}
154 };
155
156 STATIC ctl_table xfs_root_table[] = {
157 {CTL_FS, "fs", NULL, 0, 0555, xfs_dir_table},
158 {0}
159 };
160
161 void
162 xfs_sysctl_register(void)
163 {
164 xfs_table_header = register_sysctl_table(xfs_root_table, 1);
165 }
166
167 void
168 xfs_sysctl_unregister(void)
169 {
170 if (xfs_table_header)
171 unregister_sysctl_table(xfs_table_header);
172 }