0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef _LINUX_SYSCTL_H
0023 #define _LINUX_SYSCTL_H
0024
0025 #include <linux/list.h>
0026 #include <linux/rcupdate.h>
0027 #include <linux/wait.h>
0028 #include <linux/rbtree.h>
0029 #include <linux/uidgid.h>
0030 #include <uapi/linux/sysctl.h>
0031
0032
0033 struct completion;
0034 struct ctl_table;
0035 struct nsproxy;
0036 struct ctl_table_root;
0037 struct ctl_table_header;
0038 struct ctl_dir;
0039
0040
0041 #define SYSCTL_ZERO ((void *)&sysctl_vals[0])
0042 #define SYSCTL_ONE ((void *)&sysctl_vals[1])
0043 #define SYSCTL_TWO ((void *)&sysctl_vals[2])
0044 #define SYSCTL_THREE ((void *)&sysctl_vals[3])
0045 #define SYSCTL_FOUR ((void *)&sysctl_vals[4])
0046 #define SYSCTL_ONE_HUNDRED ((void *)&sysctl_vals[5])
0047 #define SYSCTL_TWO_HUNDRED ((void *)&sysctl_vals[6])
0048 #define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[7])
0049 #define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[8])
0050 #define SYSCTL_INT_MAX ((void *)&sysctl_vals[9])
0051
0052
0053 #define SYSCTL_MAXOLDUID ((void *)&sysctl_vals[10])
0054 #define SYSCTL_NEG_ONE ((void *)&sysctl_vals[11])
0055
0056 extern const int sysctl_vals[];
0057
0058 #define SYSCTL_LONG_ZERO ((void *)&sysctl_long_vals[0])
0059 #define SYSCTL_LONG_ONE ((void *)&sysctl_long_vals[1])
0060 #define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[2])
0061
0062 extern const unsigned long sysctl_long_vals[];
0063
0064 typedef int proc_handler(struct ctl_table *ctl, int write, void *buffer,
0065 size_t *lenp, loff_t *ppos);
0066
0067 int proc_dostring(struct ctl_table *, int, void *, size_t *, loff_t *);
0068 int proc_dobool(struct ctl_table *table, int write, void *buffer,
0069 size_t *lenp, loff_t *ppos);
0070 int proc_dointvec(struct ctl_table *, int, void *, size_t *, loff_t *);
0071 int proc_douintvec(struct ctl_table *, int, void *, size_t *, loff_t *);
0072 int proc_dointvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);
0073 int proc_douintvec_minmax(struct ctl_table *table, int write, void *buffer,
0074 size_t *lenp, loff_t *ppos);
0075 int proc_dou8vec_minmax(struct ctl_table *table, int write, void *buffer,
0076 size_t *lenp, loff_t *ppos);
0077 int proc_dointvec_jiffies(struct ctl_table *, int, void *, size_t *, loff_t *);
0078 int proc_dointvec_ms_jiffies_minmax(struct ctl_table *table, int write,
0079 void *buffer, size_t *lenp, loff_t *ppos);
0080 int proc_dointvec_userhz_jiffies(struct ctl_table *, int, void *, size_t *,
0081 loff_t *);
0082 int proc_dointvec_ms_jiffies(struct ctl_table *, int, void *, size_t *,
0083 loff_t *);
0084 int proc_doulongvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);
0085 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int, void *,
0086 size_t *, loff_t *);
0087 int proc_do_large_bitmap(struct ctl_table *, int, void *, size_t *, loff_t *);
0088 int proc_do_static_key(struct ctl_table *table, int write, void *buffer,
0089 size_t *lenp, loff_t *ppos);
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 struct ctl_table_poll {
0118 atomic_t event;
0119 wait_queue_head_t wait;
0120 };
0121
0122 static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
0123 {
0124 return (void *)(unsigned long)atomic_read(&poll->event);
0125 }
0126
0127 #define __CTL_TABLE_POLL_INITIALIZER(name) { \
0128 .event = ATOMIC_INIT(0), \
0129 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait) }
0130
0131 #define DEFINE_CTL_TABLE_POLL(name) \
0132 struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name)
0133
0134
0135 struct ctl_table {
0136 const char *procname;
0137 void *data;
0138 int maxlen;
0139 umode_t mode;
0140 struct ctl_table *child;
0141 proc_handler *proc_handler;
0142 struct ctl_table_poll *poll;
0143 void *extra1;
0144 void *extra2;
0145 } __randomize_layout;
0146
0147 struct ctl_node {
0148 struct rb_node node;
0149 struct ctl_table_header *header;
0150 };
0151
0152
0153
0154 struct ctl_table_header {
0155 union {
0156 struct {
0157 struct ctl_table *ctl_table;
0158 int used;
0159 int count;
0160 int nreg;
0161 };
0162 struct rcu_head rcu;
0163 };
0164 struct completion *unregistering;
0165 struct ctl_table *ctl_table_arg;
0166 struct ctl_table_root *root;
0167 struct ctl_table_set *set;
0168 struct ctl_dir *parent;
0169 struct ctl_node *node;
0170 struct hlist_head inodes;
0171 };
0172
0173 struct ctl_dir {
0174
0175 struct ctl_table_header header;
0176 struct rb_root root;
0177 };
0178
0179 struct ctl_table_set {
0180 int (*is_seen)(struct ctl_table_set *);
0181 struct ctl_dir dir;
0182 };
0183
0184 struct ctl_table_root {
0185 struct ctl_table_set default_set;
0186 struct ctl_table_set *(*lookup)(struct ctl_table_root *root);
0187 void (*set_ownership)(struct ctl_table_header *head,
0188 struct ctl_table *table,
0189 kuid_t *uid, kgid_t *gid);
0190 int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
0191 };
0192
0193
0194 struct ctl_path {
0195 const char *procname;
0196 };
0197
0198 #ifdef CONFIG_SYSCTL
0199
0200 #define DECLARE_SYSCTL_BASE(_name, _table) \
0201 static struct ctl_table _name##_base_table[] = { \
0202 { \
0203 .procname = #_name, \
0204 .mode = 0555, \
0205 .child = _table, \
0206 }, \
0207 { }, \
0208 }
0209
0210 extern int __register_sysctl_base(struct ctl_table *base_table);
0211
0212 #define register_sysctl_base(_name) __register_sysctl_base(_name##_base_table)
0213
0214 void proc_sys_poll_notify(struct ctl_table_poll *poll);
0215
0216 extern void setup_sysctl_set(struct ctl_table_set *p,
0217 struct ctl_table_root *root,
0218 int (*is_seen)(struct ctl_table_set *));
0219 extern void retire_sysctl_set(struct ctl_table_set *set);
0220
0221 struct ctl_table_header *__register_sysctl_table(
0222 struct ctl_table_set *set,
0223 const char *path, struct ctl_table *table);
0224 struct ctl_table_header *__register_sysctl_paths(
0225 struct ctl_table_set *set,
0226 const struct ctl_path *path, struct ctl_table *table);
0227 struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
0228 struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
0229 struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
0230 struct ctl_table *table);
0231
0232 void unregister_sysctl_table(struct ctl_table_header * table);
0233
0234 extern int sysctl_init_bases(void);
0235 extern void __register_sysctl_init(const char *path, struct ctl_table *table,
0236 const char *table_name);
0237 #define register_sysctl_init(path, table) __register_sysctl_init(path, table, #table)
0238 extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
0239
0240 void do_sysctl_args(void);
0241 int do_proc_douintvec(struct ctl_table *table, int write,
0242 void *buffer, size_t *lenp, loff_t *ppos,
0243 int (*conv)(unsigned long *lvalp,
0244 unsigned int *valp,
0245 int write, void *data),
0246 void *data);
0247
0248 extern int pwrsw_enabled;
0249 extern int unaligned_enabled;
0250 extern int unaligned_dump_stack;
0251 extern int no_unaligned_warning;
0252
0253 extern struct ctl_table sysctl_mount_point[];
0254
0255 #else
0256
0257 #define DECLARE_SYSCTL_BASE(_name, _table)
0258
0259 static inline int __register_sysctl_base(struct ctl_table *base_table)
0260 {
0261 return 0;
0262 }
0263
0264 #define register_sysctl_base(table) __register_sysctl_base(table)
0265
0266 static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
0267 {
0268 return NULL;
0269 }
0270
0271 static inline void register_sysctl_init(const char *path, struct ctl_table *table)
0272 {
0273 }
0274
0275 static inline struct ctl_table_header *register_sysctl_mount_point(const char *path)
0276 {
0277 return NULL;
0278 }
0279
0280 static inline struct ctl_table_header *register_sysctl_paths(
0281 const struct ctl_path *path, struct ctl_table *table)
0282 {
0283 return NULL;
0284 }
0285
0286 static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
0287 {
0288 return NULL;
0289 }
0290
0291 static inline void unregister_sysctl_table(struct ctl_table_header * table)
0292 {
0293 }
0294
0295 static inline void setup_sysctl_set(struct ctl_table_set *p,
0296 struct ctl_table_root *root,
0297 int (*is_seen)(struct ctl_table_set *))
0298 {
0299 }
0300
0301 static inline void do_sysctl_args(void)
0302 {
0303 }
0304 #endif
0305
0306 int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,
0307 size_t *lenp, loff_t *ppos);
0308
0309 #endif