Blame view

include/linux/sysctl.h 6.71 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
  /*
   * sysctl.h: General linux system control interface
   *
   * Begun 24 March 1995, Stephen Tweedie
   *
   ****************************************************************
   ****************************************************************
   **
7cc13edc1   Eric W. Biederman   [PATCH] sysctl: i...
9
   **  WARNING:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
   **  The values in this file are exported to user space via 
7cc13edc1   Eric W. Biederman   [PATCH] sysctl: i...
11
12
13
   **  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
93aec2040   Rolf Eike Beer   Remove duplicate ...
14
   **  redefine an existing interface, use a new number for it.
7cc13edc1   Eric W. Biederman   [PATCH] sysctl: i...
15
16
17
   **  The kernel will then return -ENOTDIR to any application using
   **  the old binary interface.
   **
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
19
20
   ****************************************************************
   ****************************************************************
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
  #ifndef _LINUX_SYSCTL_H
  #define _LINUX_SYSCTL_H
d4ed803c5   Harald Welte   [PATCH] Make sysc...
23
  #include <linux/list.h>
684adca4f   Stephen Rothwell   sysctl: the inclu...
24
  #include <linux/rcupdate.h>
f1ecf0685   Lucas De Marchi   sysctl: add suppo...
25
  #include <linux/wait.h>
ac13ac6f4   Eric W. Biederman   sysctl: Index sys...
26
  #include <linux/rbtree.h>
607ca46e9   David Howells   UAPI: (Scripted) ...
27
  #include <uapi/linux/sysctl.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28

805b5d5e0   Eric W. Biederman   [PATCH] sysctl: f...
29
  /* For the /proc/sys support */
1ff007eb8   Eric W. Biederman   [PATCH] sysctl: a...
30
  struct ctl_table;
e51b6ba07   Eric W. Biederman   sysctl: Infrastru...
31
  struct nsproxy;
d7321cd62   Pavel Emelyanov   sysctl: add the -...
32
  struct ctl_table_root;
f7e6ced40   Al Viro   [PATCH] allow del...
33
  struct ctl_table_header;
7ec66d063   Eric W. Biederman   sysctl: Stop requ...
34
  struct ctl_dir;
f7e6ced40   Al Viro   [PATCH] allow del...
35

8d65af789   Alexey Dobriyan   sysctl: remove "s...
36
  typedef int proc_handler (struct ctl_table *ctl, int write,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
  			  void __user *buffer, size_t *lenp, loff_t *ppos);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
38
  extern int proc_dostring(struct ctl_table *, int,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
  			 void __user *, size_t *, loff_t *);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
40
  extern int proc_dointvec(struct ctl_table *, int,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
  			 void __user *, size_t *, loff_t *);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
42
  extern int proc_dointvec_minmax(struct ctl_table *, int,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
  				void __user *, size_t *, loff_t *);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
44
  extern int proc_dointvec_jiffies(struct ctl_table *, int,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
  				 void __user *, size_t *, loff_t *);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
46
  extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
  					void __user *, size_t *, loff_t *);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
48
  extern int proc_dointvec_ms_jiffies(struct ctl_table *, int,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
  				    void __user *, size_t *, loff_t *);
8d65af789   Alexey Dobriyan   sysctl: remove "s...
50
  extern int proc_doulongvec_minmax(struct ctl_table *, int,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
  				  void __user *, size_t *, loff_t *);
d8217f076   Eric W. Biederman   sysctl core: Stop...
52
  extern int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int,
8d65af789   Alexey Dobriyan   sysctl: remove "s...
53
  				      void __user *, size_t *, loff_t *);
9f977fb7a   Octavian Purdila   sysctl: add proc_...
54
55
  extern int proc_do_large_bitmap(struct ctl_table *, int,
  				void __user *, size_t *, loff_t *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
57
58
  /*
   * Register a set of sysctl names by calling register_sysctl_table
2315ffa0a   Eric W. Biederman   sysctl: Don't loo...
59
60
   * with an initialised array of struct ctl_table's.  An entry with 
   * NULL procname terminates the table.  table->de will be
d99f160ac   Eric W. Biederman   [PATCH] sysctl: a...
61
   * set up by the registration and need not be initialised in advance.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
64
65
66
67
68
69
70
71
   *
   * 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.
d99f160ac   Eric W. Biederman   [PATCH] sysctl: a...
72
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
74
75
76
77
   * 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.
   * 
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
79
80
81
82
   * 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.
   */
f1ecf0685   Lucas De Marchi   sysctl: add suppo...
83
84
85
86
87
88
89
90
91
92
  /* 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);
  }
f1ecf0685   Lucas De Marchi   sysctl: add suppo...
93
94
95
96
97
98
  #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)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99
100
101
  /* A sysctl table is an array of struct ctl_table: */
  struct ctl_table 
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
103
104
  	const char *procname;		/* Text ID for /proc/sys, or zero */
  	void *data;
  	int maxlen;
36fcb589e   Al Viro   sysctl: use umode...
105
  	umode_t mode;
f728019bb   Eric W. Biederman   sysctl: register ...
106
  	struct ctl_table *child;	/* Deprecated */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
  	proc_handler *proc_handler;	/* Callback for text formatting */
f1ecf0685   Lucas De Marchi   sysctl: add suppo...
108
  	struct ctl_table_poll *poll;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
109
110
111
  	void *extra1;
  	void *extra2;
  };
ac13ac6f4   Eric W. Biederman   sysctl: Index sys...
112
113
114
115
  struct ctl_node {
  	struct rb_node node;
  	struct ctl_table_header *header;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
116
  /* struct ctl_table_header is used to maintain dynamic lists of
d8217f076   Eric W. Biederman   sysctl core: Stop...
117
     struct ctl_table trees. */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
119
  struct ctl_table_header
  {
dfef6dcd3   Al Viro   unfuck proc_sysct...
120
121
122
  	union {
  		struct {
  			struct ctl_table *ctl_table;
dfef6dcd3   Al Viro   unfuck proc_sysct...
123
124
  			int used;
  			int count;
938aaa4f9   Eric W. Biederman   sysctl: Initial s...
125
  			int nreg;
dfef6dcd3   Al Viro   unfuck proc_sysct...
126
127
128
  		};
  		struct rcu_head rcu;
  	};
330d57fb9   Al Viro   [PATCH] Fix sysct...
129
  	struct completion *unregistering;
23eb06de7   Eric W. Biederman   sysctl: Remember ...
130
  	struct ctl_table *ctl_table_arg;
e51b6ba07   Eric W. Biederman   sysctl: Infrastru...
131
  	struct ctl_table_root *root;
734550921   Al Viro   [PATCH] beginning...
132
  	struct ctl_table_set *set;
7ec66d063   Eric W. Biederman   sysctl: Stop requ...
133
  	struct ctl_dir *parent;
ac13ac6f4   Eric W. Biederman   sysctl: Index sys...
134
  	struct ctl_node *node;
7ec66d063   Eric W. Biederman   sysctl: Stop requ...
135
136
137
138
139
  };
  
  struct ctl_dir {
  	/* Header must be at the start of ctl_dir */
  	struct ctl_table_header header;
ac13ac6f4   Eric W. Biederman   sysctl: Index sys...
140
  	struct rb_root root;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141
  };
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
142
  struct ctl_table_set {
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
143
  	int (*is_seen)(struct ctl_table_set *);
0e47c99d7   Eric W. Biederman   sysctl: Replace r...
144
  	struct ctl_dir dir;
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
145
146
147
  };
  
  struct ctl_table_root {
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
148
149
150
  	struct ctl_table_set default_set;
  	struct ctl_table_set *(*lookup)(struct ctl_table_root *root,
  					   struct nsproxy *namespaces);
73f7ef435   Eric W. Biederman   sysctl: Pass usef...
151
  	int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
152
  };
29e796fd4   Eric W. Biederman   sysctl: Add regis...
153
154
155
  /* struct ctl_path describes where in the hierarchy a table is added */
  struct ctl_path {
  	const char *procname;
29e796fd4   Eric W. Biederman   sysctl: Add regis...
156
  };
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
157
158
159
160
161
  #ifdef CONFIG_SYSCTL
  
  void proc_sys_poll_notify(struct ctl_table_poll *poll);
  
  extern void setup_sysctl_set(struct ctl_table_set *p,
9eb47c26f   Eric W. Biederman   sysctl: Add a roo...
162
  	struct ctl_table_root *root,
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
163
  	int (*is_seen)(struct ctl_table_set *));
97324cd80   Eric W. Biederman   sysctl: Implement...
164
  extern void retire_sysctl_set(struct ctl_table_set *set);
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
165

e51b6ba07   Eric W. Biederman   sysctl: Infrastru...
166
  void register_sysctl_root(struct ctl_table_root *root);
6e9d51641   Eric W. Biederman   sysctl: Add suppo...
167
  struct ctl_table_header *__register_sysctl_table(
60a47a2e8   Eric W. Biederman   sysctl: Modify __...
168
  	struct ctl_table_set *set,
6e9d51641   Eric W. Biederman   sysctl: Add suppo...
169
  	const char *path, struct ctl_table *table);
e51b6ba07   Eric W. Biederman   sysctl: Infrastru...
170
  struct ctl_table_header *__register_sysctl_paths(
60a47a2e8   Eric W. Biederman   sysctl: Modify __...
171
  	struct ctl_table_set *set,
e51b6ba07   Eric W. Biederman   sysctl: Infrastru...
172
  	const struct ctl_path *path, struct ctl_table *table);
fea478d41   Eric W. Biederman   sysctl: Add regis...
173
  struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
d8217f076   Eric W. Biederman   sysctl core: Stop...
174
  struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
29e796fd4   Eric W. Biederman   sysctl: Add regis...
175
176
  struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
  						struct ctl_table *table);
0b4d41471   Eric W. Biederman   [PATCH] sysctl: r...
177

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
178
  void unregister_sysctl_table(struct ctl_table_header * table);
de4e83bd6   Eric W. Biederman   sysctl: Register ...
179
  extern int sysctl_init(void);
f9bd6733d   Eric W. Biederman   sysctl: Allow cre...
180
181
  
  extern struct ctl_table sysctl_mount_point[];
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
  #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,
9eb47c26f   Eric W. Biederman   sysctl: Add a roo...
199
  	struct ctl_table_root *root,
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
200
201
202
  	int (*is_seen)(struct ctl_table_set *))
  {
  }
0ce8974d5   Eric W. Biederman   sysctl: Consolida...
203
  #endif /* CONFIG_SYSCTL */
16db3d3f1   Heinrich Schuchardt   kernel/sysctl.c: ...
204
205
  int sysctl_max_threads(struct ctl_table *table, int write,
  		       void __user *buffer, size_t *lenp, loff_t *ppos);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
206
  #endif /* _LINUX_SYSCTL_H */