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