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 <linux/uidgid.h>
29#include <uapi/linux/sysctl.h>
30
31
32struct completion;
33struct ctl_table;
34struct nsproxy;
35struct ctl_table_root;
36struct ctl_table_header;
37struct ctl_dir;
38
39typedef int proc_handler (struct ctl_table *ctl, int write,
40 void __user *buffer, size_t *lenp, loff_t *ppos);
41
42extern int proc_dostring(struct ctl_table *, int,
43 void __user *, size_t *, loff_t *);
44extern int proc_dointvec(struct ctl_table *, int,
45 void __user *, size_t *, loff_t *);
46extern int proc_douintvec(struct ctl_table *, int,
47 void __user *, size_t *, loff_t *);
48extern int proc_dointvec_minmax(struct ctl_table *, int,
49 void __user *, size_t *, loff_t *);
50extern int proc_dointvec_jiffies(struct ctl_table *, int,
51 void __user *, size_t *, loff_t *);
52extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
53 void __user *, size_t *, loff_t *);
54extern int proc_dointvec_ms_jiffies(struct ctl_table *, int,
55 void __user *, size_t *, loff_t *);
56extern int proc_doulongvec_minmax(struct ctl_table *, int,
57 void __user *, size_t *, loff_t *);
58extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int,
59 void __user *, size_t *, loff_t *);
60extern int proc_do_large_bitmap(struct ctl_table *, int,
61 void __user *, size_t *, loff_t *);
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
87
88
89
90
91struct ctl_table_poll {
92 atomic_t event;
93 wait_queue_head_t wait;
94};
95
96static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
97{
98 return (void *)(unsigned long)atomic_read(&poll->event);
99}
100
101#define __CTL_TABLE_POLL_INITIALIZER(name) { \
102 .event = ATOMIC_INIT(0), \
103 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait) }
104
105#define DEFINE_CTL_TABLE_POLL(name) \
106 struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name)
107
108
109struct ctl_table
110{
111 const char *procname;
112 void *data;
113 int maxlen;
114 umode_t mode;
115 struct ctl_table *child;
116 proc_handler *proc_handler;
117 struct ctl_table_poll *poll;
118 void *extra1;
119 void *extra2;
120};
121
122struct ctl_node {
123 struct rb_node node;
124 struct ctl_table_header *header;
125};
126
127
128
129struct ctl_table_header
130{
131 union {
132 struct {
133 struct ctl_table *ctl_table;
134 int used;
135 int count;
136 int nreg;
137 };
138 struct rcu_head rcu;
139 };
140 struct completion *unregistering;
141 struct ctl_table *ctl_table_arg;
142 struct ctl_table_root *root;
143 struct ctl_table_set *set;
144 struct ctl_dir *parent;
145 struct ctl_node *node;
146};
147
148struct ctl_dir {
149
150 struct ctl_table_header header;
151 struct rb_root root;
152};
153
154struct ctl_table_set {
155 int (*is_seen)(struct ctl_table_set *);
156 struct ctl_dir dir;
157};
158
159struct ctl_table_root {
160 struct ctl_table_set default_set;
161 struct ctl_table_set *(*lookup)(struct ctl_table_root *root);
162 void (*set_ownership)(struct ctl_table_header *head,
163 struct ctl_table *table,
164 kuid_t *uid, kgid_t *gid);
165 int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
166};
167
168
169struct ctl_path {
170 const char *procname;
171};
172
173#ifdef CONFIG_SYSCTL
174
175void proc_sys_poll_notify(struct ctl_table_poll *poll);
176
177extern void setup_sysctl_set(struct ctl_table_set *p,
178 struct ctl_table_root *root,
179 int (*is_seen)(struct ctl_table_set *));
180extern void retire_sysctl_set(struct ctl_table_set *set);
181
182void register_sysctl_root(struct ctl_table_root *root);
183struct ctl_table_header *__register_sysctl_table(
184 struct ctl_table_set *set,
185 const char *path, struct ctl_table *table);
186struct ctl_table_header *__register_sysctl_paths(
187 struct ctl_table_set *set,
188 const struct ctl_path *path, struct ctl_table *table);
189struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
190struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
191struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
192 struct ctl_table *table);
193
194void unregister_sysctl_table(struct ctl_table_header * table);
195
196extern int sysctl_init(void);
197
198extern struct ctl_table sysctl_mount_point[];
199
200#else
201static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
202{
203 return NULL;
204}
205
206static inline struct ctl_table_header *register_sysctl_paths(
207 const struct ctl_path *path, struct ctl_table *table)
208{
209 return NULL;
210}
211
212static inline void unregister_sysctl_table(struct ctl_table_header * table)
213{
214}
215
216static inline void setup_sysctl_set(struct ctl_table_set *p,
217 struct ctl_table_root *root,
218 int (*is_seen)(struct ctl_table_set *))
219{
220}
221
222#endif
223
224int sysctl_max_threads(struct ctl_table *table, int write,
225 void __user *buffer, size_t *lenp, loff_t *ppos);
226
227#endif
228