1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef _LINUX_SYSCTL_H
22#define _LINUX_SYSCTL_H
23
24#include <linux/list.h>
25#include <linux/rcupdate.h>
26#include <linux/wait.h>
27#include <linux/rbtree.h>
28#include <uapi/linux/sysctl.h>
29
30
31struct ctl_table;
32struct nsproxy;
33struct ctl_table_root;
34struct ctl_table_header;
35struct ctl_dir;
36
37typedef int proc_handler (struct ctl_table *ctl, int write,
38 void __user *buffer, size_t *lenp, loff_t *ppos);
39
40extern int proc_dostring(struct ctl_table *, int,
41 void __user *, size_t *, loff_t *);
42extern int proc_dointvec(struct ctl_table *, int,
43 void __user *, size_t *, loff_t *);
44extern int proc_dointvec_minmax(struct ctl_table *, int,
45 void __user *, size_t *, loff_t *);
46extern int proc_dointvec_jiffies(struct ctl_table *, int,
47 void __user *, size_t *, loff_t *);
48extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
49 void __user *, size_t *, loff_t *);
50extern int proc_dointvec_ms_jiffies(struct ctl_table *, int,
51 void __user *, size_t *, loff_t *);
52extern int proc_doulongvec_minmax(struct ctl_table *, int,
53 void __user *, size_t *, loff_t *);
54extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int,
55 void __user *, size_t *, loff_t *);
56extern int proc_do_large_bitmap(struct ctl_table *, int,
57 void __user *, size_t *, loff_t *);
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87struct ctl_table_poll {
88 atomic_t event;
89 wait_queue_head_t wait;
90};
91
92static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
93{
94 return (void *)(unsigned long)atomic_read(&poll->event);
95}
96
97#define __CTL_TABLE_POLL_INITIALIZER(name) { \
98 .event = ATOMIC_INIT(0), \
99 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait) }
100
101#define DEFINE_CTL_TABLE_POLL(name) \
102 struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name)
103
104
105struct ctl_table
106{
107 const char *procname;
108 void *data;
109 int maxlen;
110 umode_t mode;
111 struct ctl_table *child;
112 proc_handler *proc_handler;
113 struct ctl_table_poll *poll;
114 void *extra1;
115 void *extra2;
116};
117
118struct ctl_node {
119 struct rb_node node;
120 struct ctl_table_header *header;
121};
122
123
124
125struct ctl_table_header
126{
127 union {
128 struct {
129 struct ctl_table *ctl_table;
130 int used;
131 int count;
132 int nreg;
133 };
134 struct rcu_head rcu;
135 };
136 struct completion *unregistering;
137 struct ctl_table *ctl_table_arg;
138 struct ctl_table_root *root;
139 struct ctl_table_set *set;
140 struct ctl_dir *parent;
141 struct ctl_node *node;
142};
143
144struct ctl_dir {
145
146 struct ctl_table_header header;
147 struct rb_root root;
148};
149
150struct ctl_table_set {
151 int (*is_seen)(struct ctl_table_set *);
152 struct ctl_dir dir;
153};
154
155struct ctl_table_root {
156 struct ctl_table_set default_set;
157 struct ctl_table_set *(*lookup)(struct ctl_table_root *root,
158 struct nsproxy *namespaces);
159 int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
160};
161
162
163struct ctl_path {
164 const char *procname;
165};
166
167#ifdef CONFIG_SYSCTL
168
169void proc_sys_poll_notify(struct ctl_table_poll *poll);
170
171extern void setup_sysctl_set(struct ctl_table_set *p,
172 struct ctl_table_root *root,
173 int (*is_seen)(struct ctl_table_set *));
174extern void retire_sysctl_set(struct ctl_table_set *set);
175
176void register_sysctl_root(struct ctl_table_root *root);
177struct ctl_table_header *__register_sysctl_table(
178 struct ctl_table_set *set,
179 const char *path, struct ctl_table *table);
180struct ctl_table_header *__register_sysctl_paths(
181 struct ctl_table_set *set,
182 const struct ctl_path *path, struct ctl_table *table);
183struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
184struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
185struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
186 struct ctl_table *table);
187
188void unregister_sysctl_table(struct ctl_table_header * table);
189
190extern int sysctl_init(void);
191#else
192static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
193{
194 return NULL;
195}
196
197static inline struct ctl_table_header *register_sysctl_paths(
198 const struct ctl_path *path, struct ctl_table *table)
199{
200 return NULL;
201}
202
203static inline void unregister_sysctl_table(struct ctl_table_header * table)
204{
205}
206
207static inline void setup_sysctl_set(struct ctl_table_set *p,
208 struct ctl_table_root *root,
209 int (*is_seen)(struct ctl_table_set *))
210{
211}
212
213#endif
214
215int sysctl_max_threads(struct ctl_table *table, int write,
216 void __user *buffer, size_t *lenp, loff_t *ppos);
217
218#endif
219