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