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