Blame view
include/linux/sysctl.h
6.71 KB
1da177e4c
|
1 2 3 4 5 6 7 8 |
/* * sysctl.h: General linux system control interface * * Begun 24 March 1995, Stephen Tweedie * **************************************************************** **************************************************************** ** |
7cc13edc1
|
9 |
** WARNING: |
1da177e4c
|
10 |
** The values in this file are exported to user space via |
7cc13edc1
|
11 12 13 |
** the sysctl() binary interface. Do *NOT* change the ** numbering of any existing values here, and do not change ** any numbers within any one set of values. If you have to |
93aec2040
|
14 |
** redefine an existing interface, use a new number for it. |
7cc13edc1
|
15 16 17 |
** The kernel will then return -ENOTDIR to any application using ** the old binary interface. ** |
1da177e4c
|
18 19 20 |
**************************************************************** **************************************************************** */ |
1da177e4c
|
21 22 |
#ifndef _LINUX_SYSCTL_H #define _LINUX_SYSCTL_H |
d4ed803c5
|
23 |
#include <linux/list.h> |
684adca4f
|
24 |
#include <linux/rcupdate.h> |
f1ecf0685
|
25 |
#include <linux/wait.h> |
ac13ac6f4
|
26 |
#include <linux/rbtree.h> |
607ca46e9
|
27 |
#include <uapi/linux/sysctl.h> |
1da177e4c
|
28 |
|
805b5d5e0
|
29 |
/* For the /proc/sys support */ |
1ff007eb8
|
30 |
struct ctl_table; |
e51b6ba07
|
31 |
struct nsproxy; |
d7321cd62
|
32 |
struct ctl_table_root; |
f7e6ced40
|
33 |
struct ctl_table_header; |
7ec66d063
|
34 |
struct ctl_dir; |
f7e6ced40
|
35 |
|
8d65af789
|
36 |
typedef int proc_handler (struct ctl_table *ctl, int write, |
1da177e4c
|
37 |
void __user *buffer, size_t *lenp, loff_t *ppos); |
8d65af789
|
38 |
extern int proc_dostring(struct ctl_table *, int, |
1da177e4c
|
39 |
void __user *, size_t *, loff_t *); |
8d65af789
|
40 |
extern int proc_dointvec(struct ctl_table *, int, |
1da177e4c
|
41 |
void __user *, size_t *, loff_t *); |
8d65af789
|
42 |
extern int proc_dointvec_minmax(struct ctl_table *, int, |
1da177e4c
|
43 |
void __user *, size_t *, loff_t *); |
8d65af789
|
44 |
extern int proc_dointvec_jiffies(struct ctl_table *, int, |
1da177e4c
|
45 |
void __user *, size_t *, loff_t *); |
8d65af789
|
46 |
extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int, |
1da177e4c
|
47 |
void __user *, size_t *, loff_t *); |
8d65af789
|
48 |
extern int proc_dointvec_ms_jiffies(struct ctl_table *, int, |
1da177e4c
|
49 |
void __user *, size_t *, loff_t *); |
8d65af789
|
50 |
extern int proc_doulongvec_minmax(struct ctl_table *, int, |
1da177e4c
|
51 |
void __user *, size_t *, loff_t *); |
d8217f076
|
52 |
extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int, |
8d65af789
|
53 |
void __user *, size_t *, loff_t *); |
9f977fb7a
|
54 55 |
extern int proc_do_large_bitmap(struct ctl_table *, int, void __user *, size_t *, loff_t *); |
1da177e4c
|
56 |
|
1da177e4c
|
57 58 |
/* * Register a set of sysctl names by calling register_sysctl_table |
2315ffa0a
|
59 60 |
* with an initialised array of struct ctl_table's. An entry with * NULL procname terminates the table. table->de will be |
d99f160ac
|
61 |
* set up by the registration and need not be initialised in advance. |
1da177e4c
|
62 63 64 65 66 67 68 69 70 71 |
* * sysctl names can be mirrored automatically under /proc/sys. The * procname supplied controls /proc naming. * * The table's mode will be honoured both for sys_sysctl(2) and * proc-fs access. * * Leaf nodes in the sysctl tree will be represented by a single file * under /proc; non-leaf nodes will be represented by directories. A * null procname disables /proc mirroring at this node. |
d99f160ac
|
72 |
* |
1da177e4c
|
73 74 75 76 77 |
* sysctl(2) can automatically manage read and write requests through * the sysctl table. The data and maxlen fields of the ctl_table * struct enable minimal validation of the values being written to be * performed, and the mode field allows minimal authentication. * |
1da177e4c
|
78 79 80 81 82 |
* There must be a proc_handler routine for any terminal nodes * mirrored under /proc/sys (non-terminals are handled by a built-in * directory handler). Several default handlers are available to * cover common cases. */ |
f1ecf0685
|
83 84 85 86 87 88 89 90 91 92 |
/* Support for userspace poll() to watch for changes */ struct ctl_table_poll { atomic_t event; wait_queue_head_t wait; }; static inline void *proc_sys_poll_event(struct ctl_table_poll *poll) { return (void *)(unsigned long)atomic_read(&poll->event); } |
f1ecf0685
|
93 94 95 96 97 98 |
#define __CTL_TABLE_POLL_INITIALIZER(name) { \ .event = ATOMIC_INIT(0), \ .wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait) } #define DEFINE_CTL_TABLE_POLL(name) \ struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name) |
1da177e4c
|
99 100 101 |
/* A sysctl table is an array of struct ctl_table: */ struct ctl_table { |
1da177e4c
|
102 103 104 |
const char *procname; /* Text ID for /proc/sys, or zero */ void *data; int maxlen; |
36fcb589e
|
105 |
umode_t mode; |
f728019bb
|
106 |
struct ctl_table *child; /* Deprecated */ |
1da177e4c
|
107 |
proc_handler *proc_handler; /* Callback for text formatting */ |
f1ecf0685
|
108 |
struct ctl_table_poll *poll; |
1da177e4c
|
109 110 111 |
void *extra1; void *extra2; }; |
ac13ac6f4
|
112 113 114 115 |
struct ctl_node { struct rb_node node; struct ctl_table_header *header; }; |
1da177e4c
|
116 |
/* struct ctl_table_header is used to maintain dynamic lists of |
d8217f076
|
117 |
struct ctl_table trees. */ |
1da177e4c
|
118 119 |
struct ctl_table_header { |
dfef6dcd3
|
120 121 122 |
union { struct { struct ctl_table *ctl_table; |
dfef6dcd3
|
123 124 |
int used; int count; |
938aaa4f9
|
125 |
int nreg; |
dfef6dcd3
|
126 127 128 |
}; struct rcu_head rcu; }; |
330d57fb9
|
129 |
struct completion *unregistering; |
23eb06de7
|
130 |
struct ctl_table *ctl_table_arg; |
e51b6ba07
|
131 |
struct ctl_table_root *root; |
734550921
|
132 |
struct ctl_table_set *set; |
7ec66d063
|
133 |
struct ctl_dir *parent; |
ac13ac6f4
|
134 |
struct ctl_node *node; |
7ec66d063
|
135 136 137 138 139 |
}; struct ctl_dir { /* Header must be at the start of ctl_dir */ struct ctl_table_header header; |
ac13ac6f4
|
140 |
struct rb_root root; |
1da177e4c
|
141 |
}; |
0ce8974d5
|
142 |
struct ctl_table_set { |
0ce8974d5
|
143 |
int (*is_seen)(struct ctl_table_set *); |
0e47c99d7
|
144 |
struct ctl_dir dir; |
0ce8974d5
|
145 146 147 |
}; struct ctl_table_root { |
0ce8974d5
|
148 149 150 |
struct ctl_table_set default_set; struct ctl_table_set *(*lookup)(struct ctl_table_root *root, struct nsproxy *namespaces); |
73f7ef435
|
151 |
int (*permissions)(struct ctl_table_header *head, struct ctl_table *table); |
0ce8974d5
|
152 |
}; |
29e796fd4
|
153 154 155 |
/* struct ctl_path describes where in the hierarchy a table is added */ struct ctl_path { const char *procname; |
29e796fd4
|
156 |
}; |
0ce8974d5
|
157 158 159 160 161 |
#ifdef CONFIG_SYSCTL void proc_sys_poll_notify(struct ctl_table_poll *poll); extern void setup_sysctl_set(struct ctl_table_set *p, |
9eb47c26f
|
162 |
struct ctl_table_root *root, |
0ce8974d5
|
163 |
int (*is_seen)(struct ctl_table_set *)); |
97324cd80
|
164 |
extern void retire_sysctl_set(struct ctl_table_set *set); |
0ce8974d5
|
165 |
|
e51b6ba07
|
166 |
void register_sysctl_root(struct ctl_table_root *root); |
6e9d51641
|
167 |
struct ctl_table_header *__register_sysctl_table( |
60a47a2e8
|
168 |
struct ctl_table_set *set, |
6e9d51641
|
169 |
const char *path, struct ctl_table *table); |
e51b6ba07
|
170 |
struct ctl_table_header *__register_sysctl_paths( |
60a47a2e8
|
171 |
struct ctl_table_set *set, |
e51b6ba07
|
172 |
const struct ctl_path *path, struct ctl_table *table); |
fea478d41
|
173 |
struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table); |
d8217f076
|
174 |
struct ctl_table_header *register_sysctl_table(struct ctl_table * table); |
29e796fd4
|
175 176 |
struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, struct ctl_table *table); |
0b4d41471
|
177 |
|
1da177e4c
|
178 |
void unregister_sysctl_table(struct ctl_table_header * table); |
de4e83bd6
|
179 |
extern int sysctl_init(void); |
f9bd6733d
|
180 181 |
extern struct ctl_table sysctl_mount_point[]; |
0ce8974d5
|
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
#else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * table) { return NULL; } static inline struct ctl_table_header *register_sysctl_paths( const struct ctl_path *path, struct ctl_table *table) { return NULL; } static inline void unregister_sysctl_table(struct ctl_table_header * table) { } static inline void setup_sysctl_set(struct ctl_table_set *p, |
9eb47c26f
|
199 |
struct ctl_table_root *root, |
0ce8974d5
|
200 201 202 |
int (*is_seen)(struct ctl_table_set *)) { } |
0ce8974d5
|
203 |
#endif /* CONFIG_SYSCTL */ |
16db3d3f1
|
204 205 |
int sysctl_max_threads(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos); |
1da177e4c
|
206 |
#endif /* _LINUX_SYSCTL_H */ |