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 struct ctl_table ctl_table;
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_douintvec_minmax(struct ctl_table *table, int write,
51 void __user *buffer, size_t *lenp,
52 loff_t *ppos);
53extern int proc_dopipe_max_size(struct ctl_table *table, int write,
54 void __user *buffer, size_t *lenp,
55 loff_t *ppos);
56extern int proc_dointvec_jiffies(struct ctl_table *, int,
57 void __user *, size_t *, loff_t *);
58extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
59 void __user *, size_t *, loff_t *);
60extern int proc_dointvec_ms_jiffies(struct ctl_table *, int,
61 void __user *, size_t *, loff_t *);
62extern int proc_doulongvec_minmax(struct ctl_table *, int,
63 void __user *, size_t *, loff_t *);
64extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int,
65 void __user *, size_t *, loff_t *);
66extern int proc_do_large_bitmap(struct ctl_table *, int,
67 void __user *, size_t *, loff_t *);
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97struct ctl_table_poll {
98 atomic_t event;
99 wait_queue_head_t wait;
100};
101
102static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
103{
104 return (void *)(unsigned long)atomic_read(&poll->event);
105}
106
107#define __CTL_TABLE_POLL_INITIALIZER(name) { \
108 .event = ATOMIC_INIT(0), \
109 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait) }
110
111#define DEFINE_CTL_TABLE_POLL(name) \
112 struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name)
113
114
115struct ctl_table
116{
117 const char *procname;
118 void *data;
119 int maxlen;
120 umode_t mode;
121 struct ctl_table *child;
122 proc_handler *proc_handler;
123 struct ctl_table_poll *poll;
124 void *extra1;
125 void *extra2;
126};
127
128struct ctl_node {
129 struct rb_node node;
130 struct ctl_table_header *header;
131};
132
133
134
135struct ctl_table_header
136{
137 union {
138 struct {
139 struct ctl_table *ctl_table;
140 int used;
141 int count;
142 int nreg;
143 };
144 struct rcu_head rcu;
145 };
146 struct completion *unregistering;
147 struct ctl_table *ctl_table_arg;
148 struct ctl_table_root *root;
149 struct ctl_table_set *set;
150 struct ctl_dir *parent;
151 struct ctl_node *node;
152 RH_KABI_EXTEND(struct hlist_head inodes)
153};
154
155struct ctl_dir {
156
157 struct ctl_table_header header;
158 struct rb_root root;
159};
160
161struct ctl_table_set {
162 int (*is_seen)(struct ctl_table_set *);
163 struct ctl_dir dir;
164};
165
166struct ctl_table_root {
167 struct ctl_table_set default_set;
168 struct ctl_table_set *(*lookup)(struct ctl_table_root *root,
169 struct nsproxy *namespaces);
170 int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
171};
172
173
174struct ctl_path {
175 const char *procname;
176};
177
178#ifdef CONFIG_SYSCTL
179
180void proc_sys_poll_notify(struct ctl_table_poll *poll);
181
182extern void setup_sysctl_set(struct ctl_table_set *p,
183 struct ctl_table_root *root,
184 int (*is_seen)(struct ctl_table_set *));
185extern void retire_sysctl_set(struct ctl_table_set *set);
186
187void register_sysctl_root(struct ctl_table_root *root);
188struct ctl_table_header *__register_sysctl_table(
189 struct ctl_table_set *set,
190 const char *path, struct ctl_table *table);
191struct ctl_table_header *__register_sysctl_paths(
192 struct ctl_table_set *set,
193 const struct ctl_path *path, struct ctl_table *table);
194struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
195struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
196struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
197 struct ctl_table *table);
198
199void unregister_sysctl_table(struct ctl_table_header * table);
200
201extern int sysctl_init(void);
202
203extern struct ctl_table sysctl_mount_point[];
204
205#else
206static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
207{
208 return NULL;
209}
210
211static inline struct ctl_table_header *register_sysctl_paths(
212 const struct ctl_path *path, struct ctl_table *table)
213{
214 return NULL;
215}
216
217static inline void unregister_sysctl_table(struct ctl_table_header * table)
218{
219}
220
221static inline void setup_sysctl_set(struct ctl_table_set *p,
222 struct ctl_table_root *root,
223 int (*is_seen)(struct ctl_table_set *))
224{
225}
226
227#endif
228
229#endif
230