2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* sysctl.h: General linux system control interface
|
|
|
|
*
|
|
|
|
* Begun 24 March 1995, Stephen Tweedie
|
|
|
|
*
|
|
|
|
****************************************************************
|
|
|
|
****************************************************************
|
|
|
|
**
|
2006-11-06 10:52:13 +03:00
|
|
|
** WARNING:
|
2005-04-17 02:20:36 +04:00
|
|
|
** The values in this file are exported to user space via
|
2006-11-06 10:52:13 +03:00
|
|
|
** 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
|
2006-12-12 21:23:02 +03:00
|
|
|
** redefine an existing interface, use a new number for it.
|
2006-11-06 10:52:13 +03:00
|
|
|
** The kernel will then return -ENOTDIR to any application using
|
|
|
|
** the old binary interface.
|
|
|
|
**
|
2005-04-17 02:20:36 +04:00
|
|
|
****************************************************************
|
|
|
|
****************************************************************
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_SYSCTL_H
|
|
|
|
#define _LINUX_SYSCTL_H
|
|
|
|
|
2005-11-15 11:09:06 +03:00
|
|
|
#include <linux/list.h>
|
2011-03-10 03:14:17 +03:00
|
|
|
#include <linux/rcupdate.h>
|
2011-11-03 00:39:22 +04:00
|
|
|
#include <linux/wait.h>
|
2012-01-10 05:24:30 +04:00
|
|
|
#include <linux/rbtree.h>
|
2016-08-11 00:36:02 +03:00
|
|
|
#include <linux/uidgid.h>
|
2012-10-13 13:46:48 +04:00
|
|
|
#include <uapi/linux/sysctl.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-02-14 11:34:11 +03:00
|
|
|
/* For the /proc/sys support */
|
2016-08-03 00:03:36 +03:00
|
|
|
struct completion;
|
2007-02-14 11:34:11 +03:00
|
|
|
struct ctl_table;
|
2007-11-30 15:54:00 +03:00
|
|
|
struct nsproxy;
|
2008-04-29 12:02:44 +04:00
|
|
|
struct ctl_table_root;
|
2008-07-15 09:44:23 +04:00
|
|
|
struct ctl_table_header;
|
2011-12-29 20:24:29 +04:00
|
|
|
struct ctl_dir;
|
2008-07-15 09:44:23 +04:00
|
|
|
|
2009-09-24 02:57:19 +04:00
|
|
|
typedef int proc_handler (struct ctl_table *ctl, int write,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *buffer, size_t *lenp, loff_t *ppos);
|
|
|
|
|
2009-09-24 02:57:19 +04:00
|
|
|
extern int proc_dostring(struct ctl_table *, int,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2009-09-24 02:57:19 +04:00
|
|
|
extern int proc_dointvec(struct ctl_table *, int,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2016-08-26 01:16:51 +03:00
|
|
|
extern int proc_douintvec(struct ctl_table *, int,
|
|
|
|
void __user *, size_t *, loff_t *);
|
2009-09-24 02:57:19 +04:00
|
|
|
extern int proc_dointvec_minmax(struct ctl_table *, int,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2009-09-24 02:57:19 +04:00
|
|
|
extern int proc_dointvec_jiffies(struct ctl_table *, int,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2009-09-24 02:57:19 +04:00
|
|
|
extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2009-09-24 02:57:19 +04:00
|
|
|
extern int proc_dointvec_ms_jiffies(struct ctl_table *, int,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2009-09-24 02:57:19 +04:00
|
|
|
extern int proc_doulongvec_minmax(struct ctl_table *, int,
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2007-10-18 14:05:22 +04:00
|
|
|
extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int,
|
2009-09-24 02:57:19 +04:00
|
|
|
void __user *, size_t *, loff_t *);
|
2010-05-05 04:26:55 +04:00
|
|
|
extern int proc_do_large_bitmap(struct ctl_table *, int,
|
|
|
|
void __user *, size_t *, loff_t *);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register a set of sysctl names by calling register_sysctl_table
|
2009-04-03 14:18:02 +04:00
|
|
|
* with an initialised array of struct ctl_table's. An entry with
|
|
|
|
* NULL procname terminates the table. table->de will be
|
2006-11-06 10:52:12 +03:00
|
|
|
* set up by the registration and need not be initialised in advance.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* 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.
|
2006-11-06 10:52:12 +03:00
|
|
|
*
|
2005-04-17 02:20:36 +04:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-11-03 00:39:22 +04:00
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* A sysctl table is an array of struct ctl_table: */
|
|
|
|
struct ctl_table
|
|
|
|
{
|
|
|
|
const char *procname; /* Text ID for /proc/sys, or zero */
|
|
|
|
void *data;
|
|
|
|
int maxlen;
|
2011-07-26 11:47:31 +04:00
|
|
|
umode_t mode;
|
2012-01-23 06:22:05 +04:00
|
|
|
struct ctl_table *child; /* Deprecated */
|
2005-04-17 02:20:36 +04:00
|
|
|
proc_handler *proc_handler; /* Callback for text formatting */
|
2011-11-03 00:39:22 +04:00
|
|
|
struct ctl_table_poll *poll;
|
2005-04-17 02:20:36 +04:00
|
|
|
void *extra1;
|
|
|
|
void *extra2;
|
|
|
|
};
|
|
|
|
|
2012-01-10 05:24:30 +04:00
|
|
|
struct ctl_node {
|
|
|
|
struct rb_node node;
|
|
|
|
struct ctl_table_header *header;
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* struct ctl_table_header is used to maintain dynamic lists of
|
2007-10-18 14:05:22 +04:00
|
|
|
struct ctl_table trees. */
|
2005-04-17 02:20:36 +04:00
|
|
|
struct ctl_table_header
|
|
|
|
{
|
2011-03-08 09:25:28 +03:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct ctl_table *ctl_table;
|
|
|
|
int used;
|
|
|
|
int count;
|
2012-01-10 05:24:30 +04:00
|
|
|
int nreg;
|
2011-03-08 09:25:28 +03:00
|
|
|
};
|
|
|
|
struct rcu_head rcu;
|
|
|
|
};
|
2005-11-04 13:18:40 +03:00
|
|
|
struct completion *unregistering;
|
2007-11-30 15:52:10 +03:00
|
|
|
struct ctl_table *ctl_table_arg;
|
2007-11-30 15:54:00 +03:00
|
|
|
struct ctl_table_root *root;
|
2008-07-15 05:22:20 +04:00
|
|
|
struct ctl_table_set *set;
|
2011-12-29 20:24:29 +04:00
|
|
|
struct ctl_dir *parent;
|
2012-01-10 05:24:30 +04:00
|
|
|
struct ctl_node *node;
|
2011-12-29 20:24:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ctl_dir {
|
|
|
|
/* Header must be at the start of ctl_dir */
|
|
|
|
struct ctl_table_header header;
|
2012-01-10 05:24:30 +04:00
|
|
|
struct rb_root root;
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2012-01-06 15:13:27 +04:00
|
|
|
struct ctl_table_set {
|
|
|
|
int (*is_seen)(struct ctl_table_set *);
|
2012-01-08 11:24:30 +04:00
|
|
|
struct ctl_dir dir;
|
2012-01-06 15:13:27 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ctl_table_root {
|
|
|
|
struct ctl_table_set default_set;
|
2016-07-16 23:22:55 +03:00
|
|
|
struct ctl_table_set *(*lookup)(struct ctl_table_root *root);
|
2016-08-11 00:36:02 +03:00
|
|
|
void (*set_ownership)(struct ctl_table_header *head,
|
|
|
|
struct ctl_table *table,
|
|
|
|
kuid_t *uid, kgid_t *gid);
|
2012-11-16 07:02:58 +04:00
|
|
|
int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
|
2012-01-06 15:13:27 +04:00
|
|
|
};
|
|
|
|
|
2007-11-30 15:50:18 +03:00
|
|
|
/* struct ctl_path describes where in the hierarchy a table is added */
|
|
|
|
struct ctl_path {
|
|
|
|
const char *procname;
|
|
|
|
};
|
|
|
|
|
2012-01-06 15:13:27 +04:00
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
|
|
|
|
void proc_sys_poll_notify(struct ctl_table_poll *poll);
|
|
|
|
|
|
|
|
extern void setup_sysctl_set(struct ctl_table_set *p,
|
2012-01-23 09:26:00 +04:00
|
|
|
struct ctl_table_root *root,
|
2012-01-06 15:13:27 +04:00
|
|
|
int (*is_seen)(struct ctl_table_set *));
|
2012-01-10 10:19:13 +04:00
|
|
|
extern void retire_sysctl_set(struct ctl_table_set *set);
|
2012-01-06 15:13:27 +04:00
|
|
|
|
2007-11-30 15:54:00 +03:00
|
|
|
void register_sysctl_root(struct ctl_table_root *root);
|
2012-01-21 22:26:26 +04:00
|
|
|
struct ctl_table_header *__register_sysctl_table(
|
2012-01-08 12:02:37 +04:00
|
|
|
struct ctl_table_set *set,
|
2012-01-21 22:26:26 +04:00
|
|
|
const char *path, struct ctl_table *table);
|
2007-11-30 15:54:00 +03:00
|
|
|
struct ctl_table_header *__register_sysctl_paths(
|
2012-01-08 12:02:37 +04:00
|
|
|
struct ctl_table_set *set,
|
2007-11-30 15:54:00 +03:00
|
|
|
const struct ctl_path *path, struct ctl_table *table);
|
2012-01-21 09:47:03 +04:00
|
|
|
struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
|
2007-10-18 14:05:22 +04:00
|
|
|
struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
|
2007-11-30 15:50:18 +03:00
|
|
|
struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
|
|
|
|
struct ctl_table *table);
|
2007-02-14 11:34:09 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
void unregister_sysctl_table(struct ctl_table_header * table);
|
|
|
|
|
2012-01-06 15:34:20 +04:00
|
|
|
extern int sysctl_init(void);
|
2015-05-10 06:09:14 +03:00
|
|
|
|
|
|
|
extern struct ctl_table sysctl_mount_point[];
|
|
|
|
|
2012-01-06 15:13:27 +04:00
|
|
|
#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,
|
2012-01-23 09:26:00 +04:00
|
|
|
struct ctl_table_root *root,
|
2012-01-06 15:13:27 +04:00
|
|
|
int (*is_seen)(struct ctl_table_set *))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_SYSCTL */
|
|
|
|
|
2015-04-16 22:47:50 +03:00
|
|
|
int sysctl_max_threads(struct ctl_table *table, int write,
|
|
|
|
void __user *buffer, size_t *lenp, loff_t *ppos);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif /* _LINUX_SYSCTL_H */
|