linux-2_6_7
[linux-2.6.git] / kernel / sysctl.c
1 /*
2  * sysctl.c: General linux system control interface
3  *
4  * Begun 24 March 1995, Stephen Tweedie
5  * Added /proc support, Dec 1995
6  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9  * Dynamic registration fixes, Stephen Tweedie.
10  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12  *  Horn.
13  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16  *  Wendling.
17  * The list_for_each() macro wasn't appropriate for the sysctl loop.
18  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
19  */
20
21 #include <linux/config.h>
22 #include <linux/module.h>
23 #include <linux/mm.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/proc_fs.h>
28 #include <linux/ctype.h>
29 #include <linux/utsname.h>
30 #include <linux/capability.h>
31 #include <linux/smp_lock.h>
32 #include <linux/init.h>
33 #include <linux/kernel.h>
34 #include <linux/sysrq.h>
35 #include <linux/highuid.h>
36 #include <linux/writeback.h>
37 #include <linux/hugetlb.h>
38 #include <linux/security.h>
39 #include <linux/initrd.h>
40 #include <linux/times.h>
41 #include <linux/limits.h>
42 #include <asm/uaccess.h>
43
44 #ifdef CONFIG_ROOT_NFS
45 #include <linux/nfs_fs.h>
46 #endif
47
48 #if defined(CONFIG_SYSCTL)
49
50 /* External variables not in a header file. */
51 extern int panic_timeout;
52 extern int C_A_D;
53 extern int sysctl_overcommit_memory;
54 extern int sysctl_overcommit_ratio;
55 extern int max_threads;
56 extern atomic_t nr_queued_signals;
57 extern int max_queued_signals;
58 extern int sysrq_enabled;
59 extern int core_uses_pid;
60 extern char core_pattern[];
61 extern int cad_pid;
62 extern int pid_max;
63 extern int sysctl_lower_zone_protection;
64 extern int min_free_kbytes;
65 extern int printk_ratelimit_jiffies;
66 extern int printk_ratelimit_burst;
67
68 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
69 static int maxolduid = 65535;
70 static int minolduid;
71
72 static int ngroups_max = NGROUPS_MAX;
73
74 #ifdef CONFIG_KMOD
75 extern char modprobe_path[];
76 #endif
77 #ifdef CONFIG_HOTPLUG
78 extern char hotplug_path[];
79 #endif
80 #ifdef CONFIG_CHR_DEV_SG
81 extern int sg_big_buff;
82 #endif
83 #ifdef CONFIG_SYSVIPC
84 extern size_t shm_ctlmax;
85 extern size_t shm_ctlall;
86 extern int shm_ctlmni;
87 extern int msg_ctlmax;
88 extern int msg_ctlmnb;
89 extern int msg_ctlmni;
90 extern int sem_ctls[];
91 #endif
92
93 #ifdef __sparc__
94 extern char reboot_command [];
95 extern int stop_a_enabled;
96 extern int scons_pwroff;
97 #endif
98
99 #ifdef __hppa__
100 extern int pwrsw_enabled;
101 extern int unaligned_enabled;
102 #endif
103
104 #ifdef CONFIG_ARCH_S390
105 #ifdef CONFIG_MATHEMU
106 extern int sysctl_ieee_emulation_warnings;
107 #endif
108 extern int sysctl_userprocess_debug;
109 #endif
110
111 extern int sysctl_hz_timer;
112
113 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
114 extern unsigned long powersave_nap;
115 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
116                   void *buffer, size_t *lenp);
117 #endif
118
119 #ifdef CONFIG_BSD_PROCESS_ACCT
120 extern int acct_parm[];
121 #endif
122
123 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
124                        ctl_table *, void **);
125 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
126                   void __user *buffer, size_t *lenp);
127
128 static ctl_table root_table[];
129 static struct ctl_table_header root_table_header =
130         { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
131
132 static ctl_table kern_table[];
133 static ctl_table vm_table[];
134 #ifdef CONFIG_NET
135 extern ctl_table net_table[];
136 #endif
137 static ctl_table proc_table[];
138 static ctl_table fs_table[];
139 static ctl_table debug_table[];
140 static ctl_table dev_table[];
141 extern ctl_table random_table[];
142 #ifdef CONFIG_UNIX98_PTYS
143 extern ctl_table pty_table[];
144 #endif
145
146 /* /proc declarations: */
147
148 #ifdef CONFIG_PROC_FS
149
150 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
151 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
152 static int proc_opensys(struct inode *, struct file *);
153
154 struct file_operations proc_sys_file_operations = {
155         .open           = proc_opensys,
156         .read           = proc_readsys,
157         .write          = proc_writesys,
158 };
159
160 extern struct proc_dir_entry *proc_sys_root;
161
162 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
163 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
164 #endif
165
166 /* The default sysctl tables: */
167
168 static ctl_table root_table[] = {
169         {
170                 .ctl_name       = CTL_KERN,
171                 .procname       = "kernel",
172                 .mode           = 0555,
173                 .child          = kern_table,
174         },
175         {
176                 .ctl_name       = CTL_VM,
177                 .procname       = "vm",
178                 .mode           = 0555,
179                 .child          = vm_table,
180         },
181 #ifdef CONFIG_NET
182         {
183                 .ctl_name       = CTL_NET,
184                 .procname       = "net",
185                 .mode           = 0555,
186                 .child          = net_table,
187         },
188 #endif
189         {
190                 .ctl_name       = CTL_PROC,
191                 .procname       = "proc",
192                 .mode           = 0555,
193                 .child          = proc_table,
194         },
195         {
196                 .ctl_name       = CTL_FS,
197                 .procname       = "fs",
198                 .mode           = 0555,
199                 .child          = fs_table,
200         },
201         {
202                 .ctl_name       = CTL_DEBUG,
203                 .procname       = "debug",
204                 .mode           = 0555,
205                 .child          = debug_table,
206         },
207         {
208                 .ctl_name       = CTL_DEV,
209                 .procname       = "dev",
210                 .mode           = 0555,
211                 .child          = dev_table,
212         },
213         { .ctl_name = 0 }
214 };
215
216 static ctl_table kern_table[] = {
217         {
218                 .ctl_name       = KERN_OSTYPE,
219                 .procname       = "ostype",
220                 .data           = system_utsname.sysname,
221                 .maxlen         = sizeof(system_utsname.sysname),
222                 .mode           = 0444,
223                 .proc_handler   = &proc_doutsstring,
224                 .strategy       = &sysctl_string,
225         },
226         {
227                 .ctl_name       = KERN_OSRELEASE,
228                 .procname       = "osrelease",
229                 .data           = system_utsname.release,
230                 .maxlen         = sizeof(system_utsname.release),
231                 .mode           = 0444,
232                 .proc_handler   = &proc_doutsstring,
233                 .strategy       = &sysctl_string,
234         },
235         {
236                 .ctl_name       = KERN_VERSION,
237                 .procname       = "version",
238                 .data           = system_utsname.version,
239                 .maxlen         = sizeof(system_utsname.version),
240                 .mode           = 0444,
241                 .proc_handler   = &proc_doutsstring,
242                 .strategy       = &sysctl_string,
243         },
244         {
245                 .ctl_name       = KERN_NODENAME,
246                 .procname       = "hostname",
247                 .data           = system_utsname.nodename,
248                 .maxlen         = sizeof(system_utsname.nodename),
249                 .mode           = 0644,
250                 .proc_handler   = &proc_doutsstring,
251                 .strategy       = &sysctl_string,
252         },
253         {
254                 .ctl_name       = KERN_DOMAINNAME,
255                 .procname       = "domainname",
256                 .data           = system_utsname.domainname,
257                 .maxlen         = sizeof(system_utsname.domainname),
258                 .mode           = 0644,
259                 .proc_handler   = &proc_doutsstring,
260                 .strategy       = &sysctl_string,
261         },
262         {
263                 .ctl_name       = KERN_PANIC,
264                 .procname       = "panic",
265                 .data           = &panic_timeout,
266                 .maxlen         = sizeof(int),
267                 .mode           = 0644,
268                 .proc_handler   = &proc_dointvec,
269         },
270         {
271                 .ctl_name       = KERN_CORE_USES_PID,
272                 .procname       = "core_uses_pid",
273                 .data           = &core_uses_pid,
274                 .maxlen         = sizeof(int),
275                 .mode           = 0644,
276                 .proc_handler   = &proc_dointvec,
277         },
278         {
279                 .ctl_name       = KERN_CORE_PATTERN,
280                 .procname       = "core_pattern",
281                 .data           = core_pattern,
282                 .maxlen         = 64,
283                 .mode           = 0644,
284                 .proc_handler   = &proc_dostring,
285                 .strategy       = &sysctl_string,
286         },
287         {
288                 .ctl_name       = KERN_TAINTED,
289                 .procname       = "tainted",
290                 .data           = &tainted,
291                 .maxlen         = sizeof(int),
292                 .mode           = 0644,
293                 .proc_handler   = &proc_dointvec,
294         },
295         {
296                 .ctl_name       = KERN_CAP_BSET,
297                 .procname       = "cap-bound",
298                 .data           = &cap_bset,
299                 .maxlen         = sizeof(kernel_cap_t),
300                 .mode           = 0600,
301                 .proc_handler   = &proc_dointvec_bset,
302         },
303 #ifdef CONFIG_BLK_DEV_INITRD
304         {
305                 .ctl_name       = KERN_REALROOTDEV,
306                 .procname       = "real-root-dev",
307                 .data           = &real_root_dev,
308                 .maxlen         = sizeof(int),
309                 .mode           = 0644,
310                 .proc_handler   = &proc_dointvec,
311         },
312 #endif
313 #ifdef __sparc__
314         {
315                 .ctl_name       = KERN_SPARC_REBOOT,
316                 .procname       = "reboot-cmd",
317                 .data           = reboot_command,
318                 .maxlen         = 256,
319                 .mode           = 0644,
320                 .proc_handler   = &proc_dostring,
321                 .strategy       = &sysctl_string,
322         },
323         {
324                 .ctl_name       = KERN_SPARC_STOP_A,
325                 .procname       = "stop-a",
326                 .data           = &stop_a_enabled,
327                 .maxlen         = sizeof (int),
328                 .mode           = 0644,
329                 .proc_handler   = &proc_dointvec,
330         },
331         {
332                 .ctl_name       = KERN_SPARC_SCONS_PWROFF,
333                 .procname       = "scons-poweroff",
334                 .data           = &scons_pwroff,
335                 .maxlen         = sizeof (int),
336                 .mode           = 0644,
337                 .proc_handler   = &proc_dointvec,
338         },
339 #endif
340 #ifdef __hppa__
341         {
342                 .ctl_name       = KERN_HPPA_PWRSW,
343                 .procname       = "soft-power",
344                 .data           = &pwrsw_enabled,
345                 .maxlen         = sizeof (int),
346                 .mode           = 0644,
347                 .proc_handler   = &proc_dointvec,
348         },
349         {
350                 .ctl_name       = KERN_HPPA_UNALIGNED,
351                 .procname       = "unaligned-trap",
352                 .data           = &unaligned_enabled,
353                 .maxlen         = sizeof (int),
354                 .mode           = 0644,
355                 .proc_handler   = &proc_dointvec,
356         },
357 #endif
358 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
359         {
360                 .ctl_name       = KERN_PPC_POWERSAVE_NAP,
361                 .procname       = "powersave-nap",
362                 .data           = &powersave_nap,
363                 .maxlen         = sizeof(int),
364                 .mode           = 0644,
365                 .proc_handler   = &proc_dointvec,
366         },
367         {
368                 .ctl_name       = KERN_PPC_L2CR,
369                 .procname       = "l2cr",
370                 .mode           = 0644,
371                 .proc_handler   = &proc_dol2crvec,
372         },
373 #endif
374         {
375                 .ctl_name       = KERN_CTLALTDEL,
376                 .procname       = "ctrl-alt-del",
377                 .data           = &C_A_D,
378                 .maxlen         = sizeof(int),
379                 .mode           = 0644,
380                 .proc_handler   = &proc_dointvec,
381         },
382         {
383                 .ctl_name       = KERN_PRINTK,
384                 .procname       = "printk",
385                 .data           = &console_loglevel,
386                 .maxlen         = 4*sizeof(int),
387                 .mode           = 0644,
388                 .proc_handler   = &proc_dointvec,
389         },
390 #ifdef CONFIG_KMOD
391         {
392                 .ctl_name       = KERN_MODPROBE,
393                 .procname       = "modprobe",
394                 .data           = &modprobe_path,
395                 .maxlen         = KMOD_PATH_LEN,
396                 .mode           = 0644,
397                 .proc_handler   = &proc_dostring,
398                 .strategy       = &sysctl_string,
399         },
400 #endif
401 #ifdef CONFIG_HOTPLUG
402         {
403                 .ctl_name       = KERN_HOTPLUG,
404                 .procname       = "hotplug",
405                 .data           = &hotplug_path,
406                 .maxlen         = KMOD_PATH_LEN,
407                 .mode           = 0644,
408                 .proc_handler   = &proc_dostring,
409                 .strategy       = &sysctl_string,
410         },
411 #endif
412 #ifdef CONFIG_CHR_DEV_SG
413         {
414                 .ctl_name       = KERN_SG_BIG_BUFF,
415                 .procname       = "sg-big-buff",
416                 .data           = &sg_big_buff,
417                 .maxlen         = sizeof (int),
418                 .mode           = 0444,
419                 .proc_handler   = &proc_dointvec,
420         },
421 #endif
422 #ifdef CONFIG_BSD_PROCESS_ACCT
423         {
424                 .ctl_name       = KERN_ACCT,
425                 .procname       = "acct",
426                 .data           = &acct_parm,
427                 .maxlen         = 3*sizeof(int),
428                 .mode           = 0644,
429                 .proc_handler   = &proc_dointvec,
430         },
431 #endif
432         {
433                 .ctl_name       = KERN_RTSIGNR,
434                 .procname       = "rtsig-nr",
435                 .data           = &nr_queued_signals,
436                 .maxlen         = sizeof(int),
437                 .mode           = 0444,
438                 .proc_handler   = &proc_dointvec,
439         },
440         {
441                 .ctl_name       = KERN_RTSIGMAX,
442                 .procname       = "rtsig-max",
443                 .data           = &max_queued_signals,
444                 .maxlen         = sizeof(int),
445                 .mode           = 0644,
446                 .proc_handler   = &proc_dointvec,
447         },
448 #ifdef CONFIG_SYSVIPC
449         {
450                 .ctl_name       = KERN_SHMMAX,
451                 .procname       = "shmmax",
452                 .data           = &shm_ctlmax,
453                 .maxlen         = sizeof (size_t),
454                 .mode           = 0644,
455                 .proc_handler   = &proc_doulongvec_minmax,
456         },
457         {
458                 .ctl_name       = KERN_SHMALL,
459                 .procname       = "shmall",
460                 .data           = &shm_ctlall,
461                 .maxlen         = sizeof (size_t),
462                 .mode           = 0644,
463                 .proc_handler   = &proc_doulongvec_minmax,
464         },
465         {
466                 .ctl_name       = KERN_SHMMNI,
467                 .procname       = "shmmni",
468                 .data           = &shm_ctlmni,
469                 .maxlen         = sizeof (int),
470                 .mode           = 0644,
471                 .proc_handler   = &proc_dointvec,
472         },
473         {
474                 .ctl_name       = KERN_MSGMAX,
475                 .procname       = "msgmax",
476                 .data           = &msg_ctlmax,
477                 .maxlen         = sizeof (int),
478                 .mode           = 0644,
479                 .proc_handler   = &proc_dointvec,
480         },
481         {
482                 .ctl_name       = KERN_MSGMNI,
483                 .procname       = "msgmni",
484                 .data           = &msg_ctlmni,
485                 .maxlen         = sizeof (int),
486                 .mode           = 0644,
487                 .proc_handler   = &proc_dointvec,
488         },
489         {
490                 .ctl_name       = KERN_MSGMNB,
491                 .procname       =  "msgmnb",
492                 .data           = &msg_ctlmnb,
493                 .maxlen         = sizeof (int),
494                 .mode           = 0644,
495                 .proc_handler   = &proc_dointvec,
496         },
497         {
498                 .ctl_name       = KERN_SEM,
499                 .procname       = "sem",
500                 .data           = &sem_ctls,
501                 .maxlen         = 4*sizeof (int),
502                 .mode           = 0644,
503                 .proc_handler   = &proc_dointvec,
504         },
505 #endif
506 #ifdef CONFIG_MAGIC_SYSRQ
507         {
508                 .ctl_name       = KERN_SYSRQ,
509                 .procname       = "sysrq",
510                 .data           = &sysrq_enabled,
511                 .maxlen         = sizeof (int),
512                 .mode           = 0644,
513                 .proc_handler   = &proc_dointvec,
514         },
515 #endif
516         {
517                 .ctl_name       = KERN_CADPID,
518                 .procname       = "cad_pid",
519                 .data           = &cad_pid,
520                 .maxlen         = sizeof (int),
521                 .mode           = 0600,
522                 .proc_handler   = &proc_dointvec,
523         },
524         {
525                 .ctl_name       = KERN_MAX_THREADS,
526                 .procname       = "threads-max",
527                 .data           = &max_threads,
528                 .maxlen         = sizeof(int),
529                 .mode           = 0644,
530                 .proc_handler   = &proc_dointvec,
531         },
532         {
533                 .ctl_name       = KERN_RANDOM,
534                 .procname       = "random",
535                 .mode           = 0555,
536                 .child          = random_table,
537         },
538 #ifdef CONFIG_UNIX98_PTYS
539         {
540                 .ctl_name       = KERN_PTY,
541                 .procname       = "pty",
542                 .mode           = 0555,
543                 .child          = pty_table,
544         },
545 #endif
546         {
547                 .ctl_name       = KERN_OVERFLOWUID,
548                 .procname       = "overflowuid",
549                 .data           = &overflowuid,
550                 .maxlen         = sizeof(int),
551                 .mode           = 0644,
552                 .proc_handler   = &proc_dointvec_minmax,
553                 .strategy       = &sysctl_intvec,
554                 .extra1         = &minolduid,
555                 .extra2         = &maxolduid,
556         },
557         {
558                 .ctl_name       = KERN_OVERFLOWGID,
559                 .procname       = "overflowgid",
560                 .data           = &overflowgid,
561                 .maxlen         = sizeof(int),
562                 .mode           = 0644,
563                 .proc_handler   = &proc_dointvec_minmax,
564                 .strategy       = &sysctl_intvec,
565                 .extra1         = &minolduid,
566                 .extra2         = &maxolduid,
567         },
568 #ifdef CONFIG_ARCH_S390
569 #ifdef CONFIG_MATHEMU
570         {
571                 .ctl_name       = KERN_IEEE_EMULATION_WARNINGS,
572                 .procname       = "ieee_emulation_warnings",
573                 .data           = &sysctl_ieee_emulation_warnings,
574                 .maxlen         = sizeof(int),
575                 .mode           = 0644,
576                 .proc_handler   = &proc_dointvec,
577         },
578 #endif
579 #ifdef CONFIG_NO_IDLE_HZ
580         {
581                 .ctl_name       = KERN_HZ_TIMER,
582                 .procname       = "hz_timer",
583                 .data           = &sysctl_hz_timer,
584                 .maxlen         = sizeof(int),
585                 .mode           = 0644,
586                 .proc_handler   = &proc_dointvec,
587         },
588 #endif
589         {
590                 .ctl_name       = KERN_S390_USER_DEBUG_LOGGING,
591                 .procname       = "userprocess_debug",
592                 .data           = &sysctl_userprocess_debug,
593                 .maxlen         = sizeof(int),
594                 .mode           = 0644,
595                 .proc_handler   = &proc_dointvec,
596         },
597 #endif
598         {
599                 .ctl_name       = KERN_PIDMAX,
600                 .procname       = "pid_max",
601                 .data           = &pid_max,
602                 .maxlen         = sizeof (int),
603                 .mode           = 0644,
604                 .proc_handler   = &proc_dointvec,
605         },
606         {
607                 .ctl_name       = KERN_PANIC_ON_OOPS,
608                 .procname       = "panic_on_oops",
609                 .data           = &panic_on_oops,
610                 .maxlen         = sizeof(int),
611                 .mode           = 0644,
612                 .proc_handler   = &proc_dointvec,
613         },
614         {
615                 .ctl_name       = KERN_PRINTK_RATELIMIT,
616                 .procname       = "printk_ratelimit",
617                 .data           = &printk_ratelimit_jiffies,
618                 .maxlen         = sizeof(int),
619                 .mode           = 0644,
620                 .proc_handler   = &proc_dointvec_jiffies,
621                 .strategy       = &sysctl_jiffies,
622         },
623         {
624                 .ctl_name       = KERN_PRINTK_RATELIMIT_BURST,
625                 .procname       = "printk_ratelimit_burst",
626                 .data           = &printk_ratelimit_burst,
627                 .maxlen         = sizeof(int),
628                 .mode           = 0644,
629                 .proc_handler   = &proc_dointvec,
630         },
631         {
632                 .ctl_name       = KERN_NGROUPS_MAX,
633                 .procname       = "ngroups_max",
634                 .data           = &ngroups_max,
635                 .maxlen         = sizeof (int),
636                 .mode           = 0444,
637                 .proc_handler   = &proc_dointvec,
638         },
639         { .ctl_name = 0 }
640 };
641
642 /* Constants for minimum and maximum testing in vm_table.
643    We use these as one-element integer vectors. */
644 static int zero;
645 static int one_hundred = 100;
646
647
648 static ctl_table vm_table[] = {
649         {
650                 .ctl_name       = VM_OVERCOMMIT_MEMORY,
651                 .procname       = "overcommit_memory",
652                 .data           = &sysctl_overcommit_memory,
653                 .maxlen         = sizeof(sysctl_overcommit_memory),
654                 .mode           = 0644,
655                 .proc_handler   = &proc_dointvec,
656         },
657         {
658                 .ctl_name       = VM_OVERCOMMIT_RATIO,
659                 .procname       = "overcommit_ratio",
660                 .data           = &sysctl_overcommit_ratio,
661                 .maxlen         = sizeof(sysctl_overcommit_ratio),
662                 .mode           = 0644,
663                 .proc_handler   = &proc_dointvec,
664         },
665         {
666                 .ctl_name       = VM_PAGE_CLUSTER,
667                 .procname       = "page-cluster", 
668                 .data           = &page_cluster,
669                 .maxlen         = sizeof(int),
670                 .mode           = 0644,
671                 .proc_handler   = &proc_dointvec,
672         },
673         {
674                 .ctl_name       = VM_DIRTY_BACKGROUND,
675                 .procname       = "dirty_background_ratio",
676                 .data           = &dirty_background_ratio,
677                 .maxlen         = sizeof(dirty_background_ratio),
678                 .mode           = 0644,
679                 .proc_handler   = &proc_dointvec_minmax,
680                 .strategy       = &sysctl_intvec,
681                 .extra1         = &zero,
682                 .extra2         = &one_hundred,
683         },
684         {
685                 .ctl_name       = VM_DIRTY_RATIO,
686                 .procname       = "dirty_ratio",
687                 .data           = &vm_dirty_ratio,
688                 .maxlen         = sizeof(vm_dirty_ratio),
689                 .mode           = 0644,
690                 .proc_handler   = &proc_dointvec_minmax,
691                 .strategy       = &sysctl_intvec,
692                 .extra1         = &zero,
693                 .extra2         = &one_hundred,
694         },
695         {
696                 .ctl_name       = VM_DIRTY_WB_CS,
697                 .procname       = "dirty_writeback_centisecs",
698                 .data           = &dirty_writeback_centisecs,
699                 .maxlen         = sizeof(dirty_writeback_centisecs),
700                 .mode           = 0644,
701                 .proc_handler   = &dirty_writeback_centisecs_handler,
702         },
703         {
704                 .ctl_name       = VM_DIRTY_EXPIRE_CS,
705                 .procname       = "dirty_expire_centisecs",
706                 .data           = &dirty_expire_centisecs,
707                 .maxlen         = sizeof(dirty_expire_centisecs),
708                 .mode           = 0644,
709                 .proc_handler   = &proc_dointvec,
710         },
711         {
712                 .ctl_name       = VM_NR_PDFLUSH_THREADS,
713                 .procname       = "nr_pdflush_threads",
714                 .data           = &nr_pdflush_threads,
715                 .maxlen         = sizeof nr_pdflush_threads,
716                 .mode           = 0444 /* read-only*/,
717                 .proc_handler   = &proc_dointvec,
718         },
719         {
720                 .ctl_name       = VM_SWAPPINESS,
721                 .procname       = "swappiness",
722                 .data           = &vm_swappiness,
723                 .maxlen         = sizeof(vm_swappiness),
724                 .mode           = 0644,
725                 .proc_handler   = &proc_dointvec_minmax,
726                 .strategy       = &sysctl_intvec,
727                 .extra1         = &zero,
728                 .extra2         = &one_hundred,
729         },
730 #ifdef CONFIG_HUGETLB_PAGE
731          {
732                 .ctl_name       = VM_HUGETLB_PAGES,
733                 .procname       = "nr_hugepages",
734                 .data           = &max_huge_pages,
735                 .maxlen         = sizeof(unsigned long),
736                 .mode           = 0644,
737                 .proc_handler   = &hugetlb_sysctl_handler,
738                 .extra1         = (void *)&hugetlb_zero,
739                 .extra2         = (void *)&hugetlb_infinity,
740          },
741          {
742                 .ctl_name       = VM_HUGETLB_GROUP,
743                 .procname       = "hugetlb_shm_group",
744                 .data           = &sysctl_hugetlb_shm_group,
745                 .maxlen         = sizeof(gid_t),
746                 .mode           = 0644,
747                 .proc_handler   = &proc_dointvec,
748          },
749 #endif
750         {
751                 .ctl_name       = VM_LOWER_ZONE_PROTECTION,
752                 .procname       = "lower_zone_protection",
753                 .data           = &sysctl_lower_zone_protection,
754                 .maxlen         = sizeof(sysctl_lower_zone_protection),
755                 .mode           = 0644,
756                 .proc_handler   = &lower_zone_protection_sysctl_handler,
757                 .strategy       = &sysctl_intvec,
758                 .extra1         = &zero,
759         },
760         {
761                 .ctl_name       = VM_MIN_FREE_KBYTES,
762                 .procname       = "min_free_kbytes",
763                 .data           = &min_free_kbytes,
764                 .maxlen         = sizeof(min_free_kbytes),
765                 .mode           = 0644,
766                 .proc_handler   = &min_free_kbytes_sysctl_handler,
767                 .strategy       = &sysctl_intvec,
768                 .extra1         = &zero,
769         },
770         {
771                 .ctl_name       = VM_MAX_MAP_COUNT,
772                 .procname       = "max_map_count",
773                 .data           = &sysctl_max_map_count,
774                 .maxlen         = sizeof(sysctl_max_map_count),
775                 .mode           = 0644,
776                 .proc_handler   = &proc_dointvec
777         },
778         {
779                 .ctl_name       = VM_LAPTOP_MODE,
780                 .procname       = "laptop_mode",
781                 .data           = &laptop_mode,
782                 .maxlen         = sizeof(laptop_mode),
783                 .mode           = 0644,
784                 .proc_handler   = &proc_dointvec,
785                 .strategy       = &sysctl_intvec,
786                 .extra1         = &zero,
787         },
788         {
789                 .ctl_name       = VM_BLOCK_DUMP,
790                 .procname       = "block_dump",
791                 .data           = &block_dump,
792                 .maxlen         = sizeof(block_dump),
793                 .mode           = 0644,
794                 .proc_handler   = &proc_dointvec,
795                 .strategy       = &sysctl_intvec,
796                 .extra1         = &zero,
797         },
798         { .ctl_name = 0 }
799 };
800
801 static ctl_table proc_table[] = {
802         { .ctl_name = 0 }
803 };
804
805 static ctl_table fs_table[] = {
806         {
807                 .ctl_name       = FS_NRINODE,
808                 .procname       = "inode-nr",
809                 .data           = &inodes_stat,
810                 .maxlen         = 2*sizeof(int),
811                 .mode           = 0444,
812                 .proc_handler   = &proc_dointvec,
813         },
814         {
815                 .ctl_name       = FS_STATINODE,
816                 .procname       = "inode-state",
817                 .data           = &inodes_stat,
818                 .maxlen         = 7*sizeof(int),
819                 .mode           = 0444,
820                 .proc_handler   = &proc_dointvec,
821         },
822         {
823                 .ctl_name       = FS_NRFILE,
824                 .procname       = "file-nr",
825                 .data           = &files_stat,
826                 .maxlen         = 3*sizeof(int),
827                 .mode           = 0444,
828                 .proc_handler   = &proc_dointvec,
829         },
830         {
831                 .ctl_name       = FS_MAXFILE,
832                 .procname       = "file-max",
833                 .data           = &files_stat.max_files,
834                 .maxlen         = sizeof(int),
835                 .mode           = 0644,
836                 .proc_handler   = &proc_dointvec,
837         },
838         {
839                 .ctl_name       = FS_DENTRY,
840                 .procname       = "dentry-state",
841                 .data           = &dentry_stat,
842                 .maxlen         = 6*sizeof(int),
843                 .mode           = 0444,
844                 .proc_handler   = &proc_dointvec,
845         },
846         {
847                 .ctl_name       = FS_OVERFLOWUID,
848                 .procname       = "overflowuid",
849                 .data           = &fs_overflowuid,
850                 .maxlen         = sizeof(int),
851                 .mode           = 0644,
852                 .proc_handler   = &proc_dointvec_minmax,
853                 .strategy       = &sysctl_intvec,
854                 .extra1         = &minolduid,
855                 .extra2         = &maxolduid,
856         },
857         {
858                 .ctl_name       = FS_OVERFLOWGID,
859                 .procname       = "overflowgid",
860                 .data           = &fs_overflowgid,
861                 .maxlen         = sizeof(int),
862                 .mode           = 0644,
863                 .proc_handler   = &proc_dointvec_minmax,
864                 .strategy       = &sysctl_intvec,
865                 .extra1         = &minolduid,
866                 .extra2         = &maxolduid,
867         },
868         {
869                 .ctl_name       = FS_LEASES,
870                 .procname       = "leases-enable",
871                 .data           = &leases_enable,
872                 .maxlen         = sizeof(int),
873                 .mode           = 0644,
874                 .proc_handler   = &proc_dointvec,
875         },
876         {
877                 .ctl_name       = FS_DIR_NOTIFY,
878                 .procname       = "dir-notify-enable",
879                 .data           = &dir_notify_enable,
880                 .maxlen         = sizeof(int),
881                 .mode           = 0644,
882                 .proc_handler   = &proc_dointvec,
883         },
884         {
885                 .ctl_name       = FS_LEASE_TIME,
886                 .procname       = "lease-break-time",
887                 .data           = &lease_break_time,
888                 .maxlen         = sizeof(int),
889                 .mode           = 0644,
890                 .proc_handler   = &proc_dointvec,
891         },
892         {
893                 .ctl_name       = FS_AIO_NR,
894                 .procname       = "aio-nr",
895                 .data           = &aio_nr,
896                 .maxlen         = sizeof(aio_nr),
897                 .mode           = 0444,
898                 .proc_handler   = &proc_dointvec,
899         },
900         {
901                 .ctl_name       = FS_AIO_MAX_NR,
902                 .procname       = "aio-max-nr",
903                 .data           = &aio_max_nr,
904                 .maxlen         = sizeof(aio_max_nr),
905                 .mode           = 0644,
906                 .proc_handler   = &proc_dointvec,
907         },
908         { .ctl_name = 0 }
909 };
910
911 static ctl_table debug_table[] = {
912         { .ctl_name = 0 }
913 };
914
915 static ctl_table dev_table[] = {
916         { .ctl_name = 0 }
917 };  
918
919 extern void init_irq_proc (void);
920
921 void __init sysctl_init(void)
922 {
923 #ifdef CONFIG_PROC_FS
924         register_proc_table(root_table, proc_sys_root);
925         init_irq_proc();
926 #endif
927 }
928
929 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
930                void __user *newval, size_t newlen)
931 {
932         struct list_head *tmp;
933
934         if (nlen <= 0 || nlen >= CTL_MAXNAME)
935                 return -ENOTDIR;
936         if (oldval) {
937                 int old_len;
938                 if (!oldlenp || get_user(old_len, oldlenp))
939                         return -EFAULT;
940         }
941         tmp = &root_table_header.ctl_entry;
942         do {
943                 struct ctl_table_header *head =
944                         list_entry(tmp, struct ctl_table_header, ctl_entry);
945                 void *context = NULL;
946                 int error = parse_table(name, nlen, oldval, oldlenp, 
947                                         newval, newlen, head->ctl_table,
948                                         &context);
949                 if (context)
950                         kfree(context);
951                 if (error != -ENOTDIR)
952                         return error;
953                 tmp = tmp->next;
954         } while (tmp != &root_table_header.ctl_entry);
955         return -ENOTDIR;
956 }
957
958 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
959 {
960         struct __sysctl_args tmp;
961         int error;
962
963         if (copy_from_user(&tmp, args, sizeof(tmp)))
964                 return -EFAULT;
965
966         lock_kernel();
967         error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
968                           tmp.newval, tmp.newlen);
969         unlock_kernel();
970         return error;
971 }
972
973 /*
974  * ctl_perm does NOT grant the superuser all rights automatically, because
975  * some sysctl variables are readonly even to root.
976  */
977
978 static int test_perm(int mode, int op)
979 {
980         if (!current->euid)
981                 mode >>= 6;
982         else if (in_egroup_p(0))
983                 mode >>= 3;
984         if ((mode & op & 0007) == op)
985                 return 0;
986         return -EACCES;
987 }
988
989 static inline int ctl_perm(ctl_table *table, int op)
990 {
991         int error;
992         error = security_sysctl(table, op);
993         if (error)
994                 return error;
995         return test_perm(table->mode, op);
996 }
997
998 static int parse_table(int __user *name, int nlen,
999                        void __user *oldval, size_t __user *oldlenp,
1000                        void __user *newval, size_t newlen,
1001                        ctl_table *table, void **context)
1002 {
1003         int n;
1004 repeat:
1005         if (!nlen)
1006                 return -ENOTDIR;
1007         if (get_user(n, name))
1008                 return -EFAULT;
1009         for ( ; table->ctl_name; table++) {
1010                 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1011                         int error;
1012                         if (table->child) {
1013                                 if (ctl_perm(table, 001))
1014                                         return -EPERM;
1015                                 if (table->strategy) {
1016                                         error = table->strategy(
1017                                                 table, name, nlen,
1018                                                 oldval, oldlenp,
1019                                                 newval, newlen, context);
1020                                         if (error)
1021                                                 return error;
1022                                 }
1023                                 name++;
1024                                 nlen--;
1025                                 table = table->child;
1026                                 goto repeat;
1027                         }
1028                         error = do_sysctl_strategy(table, name, nlen,
1029                                                    oldval, oldlenp,
1030                                                    newval, newlen, context);
1031                         return error;
1032                 }
1033         }
1034         return -ENOTDIR;
1035 }
1036
1037 /* Perform the actual read/write of a sysctl table entry. */
1038 int do_sysctl_strategy (ctl_table *table, 
1039                         int __user *name, int nlen,
1040                         void __user *oldval, size_t __user *oldlenp,
1041                         void __user *newval, size_t newlen, void **context)
1042 {
1043         int op = 0, rc;
1044         size_t len;
1045
1046         if (oldval)
1047                 op |= 004;
1048         if (newval) 
1049                 op |= 002;
1050         if (ctl_perm(table, op))
1051                 return -EPERM;
1052
1053         if (table->strategy) {
1054                 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1055                                      newval, newlen, context);
1056                 if (rc < 0)
1057                         return rc;
1058                 if (rc > 0)
1059                         return 0;
1060         }
1061
1062         /* If there is no strategy routine, or if the strategy returns
1063          * zero, proceed with automatic r/w */
1064         if (table->data && table->maxlen) {
1065                 if (oldval && oldlenp) {
1066                         if (get_user(len, oldlenp))
1067                                 return -EFAULT;
1068                         if (len) {
1069                                 if (len > table->maxlen)
1070                                         len = table->maxlen;
1071                                 if(copy_to_user(oldval, table->data, len))
1072                                         return -EFAULT;
1073                                 if(put_user(len, oldlenp))
1074                                         return -EFAULT;
1075                         }
1076                 }
1077                 if (newval && newlen) {
1078                         len = newlen;
1079                         if (len > table->maxlen)
1080                                 len = table->maxlen;
1081                         if(copy_from_user(table->data, newval, len))
1082                                 return -EFAULT;
1083                 }
1084         }
1085         return 0;
1086 }
1087
1088 /**
1089  * register_sysctl_table - register a sysctl hierarchy
1090  * @table: the top-level table structure
1091  * @insert_at_head: whether the entry should be inserted in front or at the end
1092  *
1093  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1094  * array. An entry with a ctl_name of 0 terminates the table. 
1095  *
1096  * The members of the &ctl_table structure are used as follows:
1097  *
1098  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1099  *            must be unique within that level of sysctl
1100  *
1101  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1102  *            enter a sysctl file
1103  *
1104  * data - a pointer to data for use by proc_handler
1105  *
1106  * maxlen - the maximum size in bytes of the data
1107  *
1108  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1109  *
1110  * child - a pointer to the child sysctl table if this entry is a directory, or
1111  *         %NULL.
1112  *
1113  * proc_handler - the text handler routine (described below)
1114  *
1115  * strategy - the strategy routine (described below)
1116  *
1117  * de - for internal use by the sysctl routines
1118  *
1119  * extra1, extra2 - extra pointers usable by the proc handler routines
1120  *
1121  * Leaf nodes in the sysctl tree will be represented by a single file
1122  * under /proc; non-leaf nodes will be represented by directories.
1123  *
1124  * sysctl(2) can automatically manage read and write requests through
1125  * the sysctl table.  The data and maxlen fields of the ctl_table
1126  * struct enable minimal validation of the values being written to be
1127  * performed, and the mode field allows minimal authentication.
1128  *
1129  * More sophisticated management can be enabled by the provision of a
1130  * strategy routine with the table entry.  This will be called before
1131  * any automatic read or write of the data is performed.
1132  *
1133  * The strategy routine may return
1134  *
1135  * < 0 - Error occurred (error is passed to user process)
1136  *
1137  * 0   - OK - proceed with automatic read or write.
1138  *
1139  * > 0 - OK - read or write has been done by the strategy routine, so
1140  *       return immediately.
1141  *
1142  * There must be a proc_handler routine for any terminal nodes
1143  * mirrored under /proc/sys (non-terminals are handled by a built-in
1144  * directory handler).  Several default handlers are available to
1145  * cover common cases -
1146  *
1147  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1148  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 
1149  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1150  *
1151  * It is the handler's job to read the input buffer from user memory
1152  * and process it. The handler should return 0 on success.
1153  *
1154  * This routine returns %NULL on a failure to register, and a pointer
1155  * to the table header on success.
1156  */
1157 struct ctl_table_header *register_sysctl_table(ctl_table * table, 
1158                                                int insert_at_head)
1159 {
1160         struct ctl_table_header *tmp;
1161         tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1162         if (!tmp)
1163                 return NULL;
1164         tmp->ctl_table = table;
1165         INIT_LIST_HEAD(&tmp->ctl_entry);
1166         if (insert_at_head)
1167                 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1168         else
1169                 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1170 #ifdef CONFIG_PROC_FS
1171         register_proc_table(table, proc_sys_root);
1172 #endif
1173         return tmp;
1174 }
1175
1176 /**
1177  * unregister_sysctl_table - unregister a sysctl table hierarchy
1178  * @header: the header returned from register_sysctl_table
1179  *
1180  * Unregisters the sysctl table and all children. proc entries may not
1181  * actually be removed until they are no longer used by anyone.
1182  */
1183 void unregister_sysctl_table(struct ctl_table_header * header)
1184 {
1185         list_del(&header->ctl_entry);
1186 #ifdef CONFIG_PROC_FS
1187         unregister_proc_table(header->ctl_table, proc_sys_root);
1188 #endif
1189         kfree(header);
1190 }
1191
1192 /*
1193  * /proc/sys support
1194  */
1195
1196 #ifdef CONFIG_PROC_FS
1197
1198 /* Scan the sysctl entries in table and add them all into /proc */
1199 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1200 {
1201         struct proc_dir_entry *de;
1202         int len;
1203         mode_t mode;
1204         
1205         for (; table->ctl_name; table++) {
1206                 /* Can't do anything without a proc name. */
1207                 if (!table->procname)
1208                         continue;
1209                 /* Maybe we can't do anything with it... */
1210                 if (!table->proc_handler && !table->child) {
1211                         printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1212                                 table->procname);
1213                         continue;
1214                 }
1215
1216                 len = strlen(table->procname);
1217                 mode = table->mode;
1218
1219                 de = NULL;
1220                 if (table->proc_handler)
1221                         mode |= S_IFREG;
1222                 else {
1223                         mode |= S_IFDIR;
1224                         for (de = root->subdir; de; de = de->next) {
1225                                 if (proc_match(len, table->procname, de))
1226                                         break;
1227                         }
1228                         /* If the subdir exists already, de is non-NULL */
1229                 }
1230
1231                 if (!de) {
1232                         de = create_proc_entry(table->procname, mode, root);
1233                         if (!de)
1234                                 continue;
1235                         de->data = (void *) table;
1236                         if (table->proc_handler)
1237                                 de->proc_fops = &proc_sys_file_operations;
1238                 }
1239                 table->de = de;
1240                 if (de->mode & S_IFDIR)
1241                         register_proc_table(table->child, de);
1242         }
1243 }
1244
1245 /*
1246  * Unregister a /proc sysctl table and any subdirectories.
1247  */
1248 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1249 {
1250         struct proc_dir_entry *de;
1251         for (; table->ctl_name; table++) {
1252                 if (!(de = table->de))
1253                         continue;
1254                 if (de->mode & S_IFDIR) {
1255                         if (!table->child) {
1256                                 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1257                                 continue;
1258                         }
1259                         unregister_proc_table(table->child, de);
1260
1261                         /* Don't unregister directories which still have entries.. */
1262                         if (de->subdir)
1263                                 continue;
1264                 }
1265
1266                 /* Don't unregister proc entries that are still being used.. */
1267                 if (atomic_read(&de->count))
1268                         continue;
1269
1270                 table->de = NULL;
1271                 remove_proc_entry(table->procname, root);
1272         }
1273 }
1274
1275 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1276                           size_t count, loff_t *ppos)
1277 {
1278         int op;
1279         struct proc_dir_entry *de;
1280         struct ctl_table *table;
1281         size_t res;
1282         ssize_t error;
1283         
1284         de = PDE(file->f_dentry->d_inode);
1285         if (!de || !de->data)
1286                 return -ENOTDIR;
1287         table = (struct ctl_table *) de->data;
1288         if (!table || !table->proc_handler)
1289                 return -ENOTDIR;
1290         op = (write ? 002 : 004);
1291         if (ctl_perm(table, op))
1292                 return -EPERM;
1293         
1294         res = count;
1295
1296         /*
1297          * FIXME: we need to pass on ppos to the handler.
1298          */
1299
1300         error = (*table->proc_handler) (table, write, file, buf, &res);
1301         if (error)
1302                 return error;
1303         return res;
1304 }
1305
1306 static int proc_opensys(struct inode *inode, struct file *file)
1307 {
1308         if (file->f_mode & FMODE_WRITE) {
1309                 /*
1310                  * sysctl entries that are not writable,
1311                  * are _NOT_ writable, capabilities or not.
1312                  */
1313                 if (!(inode->i_mode & S_IWUSR))
1314                         return -EPERM;
1315         }
1316
1317         return 0;
1318 }
1319
1320 static ssize_t proc_readsys(struct file * file, char __user * buf,
1321                             size_t count, loff_t *ppos)
1322 {
1323         return do_rw_proc(0, file, buf, count, ppos);
1324 }
1325
1326 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1327                              size_t count, loff_t *ppos)
1328 {
1329         return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1330 }
1331
1332 /**
1333  * proc_dostring - read a string sysctl
1334  * @table: the sysctl table
1335  * @write: %TRUE if this is a write to the sysctl file
1336  * @filp: the file structure
1337  * @buffer: the user buffer
1338  * @lenp: the size of the user buffer
1339  *
1340  * Reads/writes a string from/to the user buffer. If the kernel
1341  * buffer provided is not large enough to hold the string, the
1342  * string is truncated. The copied string is %NULL-terminated.
1343  * If the string is being read by the user process, it is copied
1344  * and a newline '\n' is added. It is truncated if the buffer is
1345  * not large enough.
1346  *
1347  * Returns 0 on success.
1348  */
1349 int proc_dostring(ctl_table *table, int write, struct file *filp,
1350                   void __user *buffer, size_t *lenp)
1351 {
1352         size_t len;
1353         char __user *p;
1354         char c;
1355         
1356         if (!table->data || !table->maxlen || !*lenp ||
1357             (filp->f_pos && !write)) {
1358                 *lenp = 0;
1359                 return 0;
1360         }
1361         
1362         if (write) {
1363                 len = 0;
1364                 p = buffer;
1365                 while (len < *lenp) {
1366                         if (get_user(c, p++))
1367                                 return -EFAULT;
1368                         if (c == 0 || c == '\n')
1369                                 break;
1370                         len++;
1371                 }
1372                 if (len >= table->maxlen)
1373                         len = table->maxlen-1;
1374                 if(copy_from_user(table->data, buffer, len))
1375                         return -EFAULT;
1376                 ((char *) table->data)[len] = 0;
1377                 filp->f_pos += *lenp;
1378         } else {
1379                 len = strlen(table->data);
1380                 if (len > table->maxlen)
1381                         len = table->maxlen;
1382                 if (len > *lenp)
1383                         len = *lenp;
1384                 if (len)
1385                         if(copy_to_user(buffer, table->data, len))
1386                                 return -EFAULT;
1387                 if (len < *lenp) {
1388                         if(put_user('\n', ((char __user *) buffer) + len))
1389                                 return -EFAULT;
1390                         len++;
1391                 }
1392                 *lenp = len;
1393                 filp->f_pos += len;
1394         }
1395         return 0;
1396 }
1397
1398 /*
1399  *      Special case of dostring for the UTS structure. This has locks
1400  *      to observe. Should this be in kernel/sys.c ????
1401  */
1402  
1403 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1404                   void __user *buffer, size_t *lenp)
1405 {
1406         int r;
1407
1408         if (!write) {
1409                 down_read(&uts_sem);
1410                 r=proc_dostring(table,0,filp,buffer,lenp);
1411                 up_read(&uts_sem);
1412         } else {
1413                 down_write(&uts_sem);
1414                 r=proc_dostring(table,1,filp,buffer,lenp);
1415                 up_write(&uts_sem);
1416         }
1417         return r;
1418 }
1419
1420 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1421                                  int *valp,
1422                                  int write, void *data)
1423 {
1424         if (write) {
1425                 *valp = *negp ? -*lvalp : *lvalp;
1426         } else {
1427                 int val = *valp;
1428                 if (val < 0) {
1429                         *negp = -1;
1430                         *lvalp = (unsigned long)-val;
1431                 } else {
1432                         *negp = 0;
1433                         *lvalp = (unsigned long)val;
1434                 }
1435         }
1436         return 0;
1437 }
1438
1439 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1440                   void __user *buffer, size_t *lenp, 
1441                   int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1442                               int write, void *data),
1443                   void *data)
1444 {
1445 #define TMPBUFLEN 20
1446         int *i, vleft, first=1, neg, val;
1447         unsigned long lval;
1448         size_t left, len;
1449         
1450         char buf[TMPBUFLEN], *p;
1451         char __user *s = buffer;
1452         
1453         if (!table->data || !table->maxlen || !*lenp ||
1454             (filp->f_pos && !write)) {
1455                 *lenp = 0;
1456                 return 0;
1457         }
1458         
1459         i = (int *) table->data;
1460         vleft = table->maxlen / sizeof(*i);
1461         left = *lenp;
1462
1463         if (!conv)
1464                 conv = do_proc_dointvec_conv;
1465
1466         for (; left && vleft--; i++, first=0) {
1467                 if (write) {
1468                         while (left) {
1469                                 char c;
1470                                 if (get_user(c, s))
1471                                         return -EFAULT;
1472                                 if (!isspace(c))
1473                                         break;
1474                                 left--;
1475                                 s++;
1476                         }
1477                         if (!left)
1478                                 break;
1479                         neg = 0;
1480                         len = left;
1481                         if (len > sizeof(buf) - 1)
1482                                 len = sizeof(buf) - 1;
1483                         if (copy_from_user(buf, s, len))
1484                                 return -EFAULT;
1485                         buf[len] = 0;
1486                         p = buf;
1487                         if (*p == '-' && left > 1) {
1488                                 neg = 1;
1489                                 left--, p++;
1490                         }
1491                         if (*p < '0' || *p > '9')
1492                                 break;
1493
1494                         lval = simple_strtoul(p, &p, 0);
1495
1496                         len = p-buf;
1497                         if ((len < left) && *p && !isspace(*p))
1498                                 break;
1499                         if (neg)
1500                                 val = -val;
1501                         s += len;
1502                         left -= len;
1503
1504                         if (conv(&neg, &lval, i, 1, data))
1505                                 break;
1506                 } else {
1507                         p = buf;
1508                         if (!first)
1509                                 *p++ = '\t';
1510         
1511                         if (conv(&neg, &lval, i, 0, data))
1512                                 break;
1513
1514                         sprintf(p, "%s%lu", neg ? "-" : "", lval);
1515                         len = strlen(buf);
1516                         if (len > left)
1517                                 len = left;
1518                         if(copy_to_user(s, buf, len))
1519                                 return -EFAULT;
1520                         left -= len;
1521                         s += len;
1522                 }
1523         }
1524
1525         if (!write && !first && left) {
1526                 if(put_user('\n', s))
1527                         return -EFAULT;
1528                 left--, s++;
1529         }
1530         if (write) {
1531                 while (left) {
1532                         char c;
1533                         if (get_user(c, s++))
1534                                 return -EFAULT;
1535                         if (!isspace(c))
1536                                 break;
1537                         left--;
1538                 }
1539         }
1540         if (write && first)
1541                 return -EINVAL;
1542         *lenp -= left;
1543         filp->f_pos += *lenp;
1544         return 0;
1545 #undef TMPBUFLEN
1546 }
1547
1548 /**
1549  * proc_dointvec - read a vector of integers
1550  * @table: the sysctl table
1551  * @write: %TRUE if this is a write to the sysctl file
1552  * @filp: the file structure
1553  * @buffer: the user buffer
1554  * @lenp: the size of the user buffer
1555  *
1556  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1557  * values from/to the user buffer, treated as an ASCII string. 
1558  *
1559  * Returns 0 on success.
1560  */
1561 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1562                      void __user *buffer, size_t *lenp)
1563 {
1564     return do_proc_dointvec(table,write,filp,buffer,lenp,
1565                             NULL,NULL);
1566 }
1567
1568 #define OP_SET  0
1569 #define OP_AND  1
1570 #define OP_OR   2
1571 #define OP_MAX  3
1572 #define OP_MIN  4
1573
1574 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1575                                       int *valp,
1576                                       int write, void *data)
1577 {
1578         int op = *(int *)data;
1579         if (write) {
1580                 int val = *negp ? -*lvalp : *lvalp;
1581                 switch(op) {
1582                 case OP_SET:    *valp = val; break;
1583                 case OP_AND:    *valp &= val; break;
1584                 case OP_OR:     *valp |= val; break;
1585                 case OP_MAX:    if(*valp < val)
1586                                         *valp = val;
1587                                 break;
1588                 case OP_MIN:    if(*valp > val)
1589                                 *valp = val;
1590                                 break;
1591                 }
1592         } else {
1593                 int val = *valp;
1594                 if (val < 0) {
1595                         *negp = -1;
1596                         *lvalp = (unsigned long)-val;
1597                 } else {
1598                         *negp = 0;
1599                         *lvalp = (unsigned long)val;
1600                 }
1601         }
1602         return 0;
1603 }
1604
1605 /*
1606  *      init may raise the set.
1607  */
1608  
1609 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1610                         void __user *buffer, size_t *lenp)
1611 {
1612         int op;
1613
1614         if (!capable(CAP_SYS_MODULE)) {
1615                 return -EPERM;
1616         }
1617
1618         op = (current->pid == 1) ? OP_SET : OP_AND;
1619         return do_proc_dointvec(table,write,filp,buffer,lenp,
1620                                 do_proc_dointvec_bset_conv,&op);
1621 }
1622
1623 struct do_proc_dointvec_minmax_conv_param {
1624         int *min;
1625         int *max;
1626 };
1627
1628 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 
1629                                         int *valp, 
1630                                         int write, void *data)
1631 {
1632         struct do_proc_dointvec_minmax_conv_param *param = data;
1633         if (write) {
1634                 int val = *negp ? -*lvalp : *lvalp;
1635                 if ((param->min && *param->min > val) ||
1636                     (param->max && *param->max < val))
1637                         return -EINVAL;
1638                 *valp = val;
1639         } else {
1640                 int val = *valp;
1641                 if (val < 0) {
1642                         *negp = -1;
1643                         *lvalp = (unsigned long)-val;
1644                 } else {
1645                         *negp = 0;
1646                         *lvalp = (unsigned long)val;
1647                 }
1648         }
1649         return 0;
1650 }
1651
1652 /**
1653  * proc_dointvec_minmax - read a vector of integers with min/max values
1654  * @table: the sysctl table
1655  * @write: %TRUE if this is a write to the sysctl file
1656  * @filp: the file structure
1657  * @buffer: the user buffer
1658  * @lenp: the size of the user buffer
1659  *
1660  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1661  * values from/to the user buffer, treated as an ASCII string.
1662  *
1663  * This routine will ensure the values are within the range specified by
1664  * table->extra1 (min) and table->extra2 (max).
1665  *
1666  * Returns 0 on success.
1667  */
1668 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1669                   void __user *buffer, size_t *lenp)
1670 {
1671         struct do_proc_dointvec_minmax_conv_param param = {
1672                 .min = (int *) table->extra1,
1673                 .max = (int *) table->extra2,
1674         };
1675         return do_proc_dointvec(table, write, filp, buffer, lenp,
1676                                 do_proc_dointvec_minmax_conv, &param);
1677 }
1678
1679 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1680                                      struct file *filp,
1681                                      void __user *buffer, size_t *lenp,
1682                                      unsigned long convmul,
1683                                      unsigned long convdiv)
1684 {
1685 #define TMPBUFLEN 20
1686         unsigned long *i, *min, *max, val;
1687         int vleft, first=1, neg;
1688         size_t len, left;
1689         char buf[TMPBUFLEN], *p;
1690         char __user *s = buffer;
1691         
1692         if (!table->data || !table->maxlen || !*lenp ||
1693             (filp->f_pos && !write)) {
1694                 *lenp = 0;
1695                 return 0;
1696         }
1697         
1698         i = (unsigned long *) table->data;
1699         min = (unsigned long *) table->extra1;
1700         max = (unsigned long *) table->extra2;
1701         vleft = table->maxlen / sizeof(unsigned long);
1702         left = *lenp;
1703         
1704         for (; left && vleft--; i++, min++, max++, first=0) {
1705                 if (write) {
1706                         while (left) {
1707                                 char c;
1708                                 if (get_user(c, s))
1709                                         return -EFAULT;
1710                                 if (!isspace(c))
1711                                         break;
1712                                 left--;
1713                                 s++;
1714                         }
1715                         if (!left)
1716                                 break;
1717                         neg = 0;
1718                         len = left;
1719                         if (len > TMPBUFLEN-1)
1720                                 len = TMPBUFLEN-1;
1721                         if (copy_from_user(buf, s, len))
1722                                 return -EFAULT;
1723                         buf[len] = 0;
1724                         p = buf;
1725                         if (*p == '-' && left > 1) {
1726                                 neg = 1;
1727                                 left--, p++;
1728                         }
1729                         if (*p < '0' || *p > '9')
1730                                 break;
1731                         val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1732                         len = p-buf;
1733                         if ((len < left) && *p && !isspace(*p))
1734                                 break;
1735                         if (neg)
1736                                 val = -val;
1737                         s += len;
1738                         left -= len;
1739
1740                         if(neg)
1741                                 continue;
1742                         if ((min && val < *min) || (max && val > *max))
1743                                 continue;
1744                         *i = val;
1745                 } else {
1746                         p = buf;
1747                         if (!first)
1748                                 *p++ = '\t';
1749                         sprintf(p, "%lu", convdiv * (*i) / convmul);
1750                         len = strlen(buf);
1751                         if (len > left)
1752                                 len = left;
1753                         if(copy_to_user(s, buf, len))
1754                                 return -EFAULT;
1755                         left -= len;
1756                         s += len;
1757                 }
1758         }
1759
1760         if (!write && !first && left) {
1761                 if(put_user('\n', s))
1762                         return -EFAULT;
1763                 left--, s++;
1764         }
1765         if (write) {
1766                 while (left) {
1767                         char c;
1768                         if (get_user(c, s++))
1769                                 return -EFAULT;
1770                         if (!isspace(c))
1771                                 break;
1772                         left--;
1773                 }
1774         }
1775         if (write && first)
1776                 return -EINVAL;
1777         *lenp -= left;
1778         filp->f_pos += *lenp;
1779         return 0;
1780 #undef TMPBUFLEN
1781 }
1782
1783 /**
1784  * proc_doulongvec_minmax - read a vector of long integers with min/max values
1785  * @table: the sysctl table
1786  * @write: %TRUE if this is a write to the sysctl file
1787  * @filp: the file structure
1788  * @buffer: the user buffer
1789  * @lenp: the size of the user buffer
1790  *
1791  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1792  * values from/to the user buffer, treated as an ASCII string.
1793  *
1794  * This routine will ensure the values are within the range specified by
1795  * table->extra1 (min) and table->extra2 (max).
1796  *
1797  * Returns 0 on success.
1798  */
1799 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1800                            void __user *buffer, size_t *lenp)
1801 {
1802     return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1803 }
1804
1805 /**
1806  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1807  * @table: the sysctl table
1808  * @write: %TRUE if this is a write to the sysctl file
1809  * @filp: the file structure
1810  * @buffer: the user buffer
1811  * @lenp: the size of the user buffer
1812  *
1813  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1814  * values from/to the user buffer, treated as an ASCII string. The values
1815  * are treated as milliseconds, and converted to jiffies when they are stored.
1816  *
1817  * This routine will ensure the values are within the range specified by
1818  * table->extra1 (min) and table->extra2 (max).
1819  *
1820  * Returns 0 on success.
1821  */
1822 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1823                                       struct file *filp,
1824                                       void __user *buffer, size_t *lenp)
1825 {
1826     return do_proc_doulongvec_minmax(table, write, filp, buffer,
1827                                      lenp, HZ, 1000l);
1828 }
1829
1830
1831 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1832                                          int *valp,
1833                                          int write, void *data)
1834 {
1835         if (write) {
1836                 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1837         } else {
1838                 int val = *valp;
1839                 unsigned long lval;
1840                 if (val < 0) {
1841                         *negp = -1;
1842                         lval = (unsigned long)-val;
1843                 } else {
1844                         *negp = 0;
1845                         lval = (unsigned long)val;
1846                 }
1847                 *lvalp = lval / HZ;
1848         }
1849         return 0;
1850 }
1851
1852 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1853                                                 int *valp,
1854                                                 int write, void *data)
1855 {
1856         if (write) {
1857                 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1858         } else {
1859                 int val = *valp;
1860                 unsigned long lval;
1861                 if (val < 0) {
1862                         *negp = -1;
1863                         lval = (unsigned long)-val;
1864                 } else {
1865                         *negp = 0;
1866                         lval = (unsigned long)val;
1867                 }
1868                 *lvalp = jiffies_to_clock_t(lval);
1869         }
1870         return 0;
1871 }
1872
1873 /**
1874  * proc_dointvec_jiffies - read a vector of integers as seconds
1875  * @table: the sysctl table
1876  * @write: %TRUE if this is a write to the sysctl file
1877  * @filp: the file structure
1878  * @buffer: the user buffer
1879  * @lenp: the size of the user buffer
1880  *
1881  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1882  * values from/to the user buffer, treated as an ASCII string. 
1883  * The values read are assumed to be in seconds, and are converted into
1884  * jiffies.
1885  *
1886  * Returns 0 on success.
1887  */
1888 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1889                           void __user *buffer, size_t *lenp)
1890 {
1891     return do_proc_dointvec(table,write,filp,buffer,lenp,
1892                             do_proc_dointvec_jiffies_conv,NULL);
1893 }
1894
1895 /**
1896  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1897  * @table: the sysctl table
1898  * @write: %TRUE if this is a write to the sysctl file
1899  * @filp: the file structure
1900  * @buffer: the user buffer
1901  * @lenp: the size of the user buffer
1902  *
1903  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1904  * values from/to the user buffer, treated as an ASCII string. 
1905  * The values read are assumed to be in 1/USER_HZ seconds, and 
1906  * are converted into jiffies.
1907  *
1908  * Returns 0 on success.
1909  */
1910 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1911                                  void __user *buffer, size_t *lenp)
1912 {
1913     return do_proc_dointvec(table,write,filp,buffer,lenp,
1914                             do_proc_dointvec_userhz_jiffies_conv,NULL);
1915 }
1916
1917 #else /* CONFIG_PROC_FS */
1918
1919 int proc_dostring(ctl_table *table, int write, struct file *filp,
1920                   void __user *buffer, size_t *lenp)
1921 {
1922         return -ENOSYS;
1923 }
1924
1925 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1926                             void __user *buffer, size_t *lenp)
1927 {
1928         return -ENOSYS;
1929 }
1930
1931 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1932                   void __user *buffer, size_t *lenp)
1933 {
1934         return -ENOSYS;
1935 }
1936
1937 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1938                         void __user *buffer, size_t *lenp)
1939 {
1940         return -ENOSYS;
1941 }
1942
1943 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1944                     void __user *buffer, size_t *lenp)
1945 {
1946         return -ENOSYS;
1947 }
1948
1949 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1950                     void __user *buffer, size_t *lenp)
1951 {
1952         return -ENOSYS;
1953 }
1954
1955 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1956                     void __user *buffer, size_t *lenp)
1957 {
1958         return -ENOSYS;
1959 }
1960
1961 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1962                     void __user *buffer, size_t *lenp)
1963 {
1964         return -ENOSYS;
1965 }
1966
1967 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1968                                       struct file *filp,
1969                                       void __user *buffer, size_t *lenp)
1970 {
1971     return -ENOSYS;
1972 }
1973
1974
1975 #endif /* CONFIG_PROC_FS */
1976
1977
1978 /*
1979  * General sysctl support routines 
1980  */
1981
1982 /* The generic string strategy routine: */
1983 int sysctl_string(ctl_table *table, int __user *name, int nlen,
1984                   void __user *oldval, size_t __user *oldlenp,
1985                   void __user *newval, size_t newlen, void **context)
1986 {
1987         size_t l, len;
1988         
1989         if (!table->data || !table->maxlen) 
1990                 return -ENOTDIR;
1991         
1992         if (oldval && oldlenp) {
1993                 if (get_user(len, oldlenp))
1994                         return -EFAULT;
1995                 if (len) {
1996                         l = strlen(table->data);
1997                         if (len > l) len = l;
1998                         if (len >= table->maxlen)
1999                                 len = table->maxlen;
2000                         if(copy_to_user(oldval, table->data, len))
2001                                 return -EFAULT;
2002                         if(put_user(0, ((char __user *) oldval) + len))
2003                                 return -EFAULT;
2004                         if(put_user(len, oldlenp))
2005                                 return -EFAULT;
2006                 }
2007         }
2008         if (newval && newlen) {
2009                 len = newlen;
2010                 if (len > table->maxlen)
2011                         len = table->maxlen;
2012                 if(copy_from_user(table->data, newval, len))
2013                         return -EFAULT;
2014                 if (len == table->maxlen)
2015                         len--;
2016                 ((char *) table->data)[len] = 0;
2017         }
2018         return 0;
2019 }
2020
2021 /*
2022  * This function makes sure that all of the integers in the vector
2023  * are between the minimum and maximum values given in the arrays
2024  * table->extra1 and table->extra2, respectively.
2025  */
2026 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2027                 void __user *oldval, size_t __user *oldlenp,
2028                 void __user *newval, size_t newlen, void **context)
2029 {
2030
2031         if (newval && newlen) {
2032                 int __user *vec = (int __user *) newval;
2033                 int *min = (int *) table->extra1;
2034                 int *max = (int *) table->extra2;
2035                 size_t length;
2036                 int i;
2037
2038                 if (newlen % sizeof(int) != 0)
2039                         return -EINVAL;
2040
2041                 if (!table->extra1 && !table->extra2)
2042                         return 0;
2043
2044                 if (newlen > table->maxlen)
2045                         newlen = table->maxlen;
2046                 length = newlen / sizeof(int);
2047
2048                 for (i = 0; i < length; i++) {
2049                         int value;
2050                         if (get_user(value, vec + i))
2051                                 return -EFAULT;
2052                         if (min && value < min[i])
2053                                 return -EINVAL;
2054                         if (max && value > max[i])
2055                                 return -EINVAL;
2056                 }
2057         }
2058         return 0;
2059 }
2060
2061 /* Strategy function to convert jiffies to seconds */ 
2062 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2063                 void __user *oldval, size_t __user *oldlenp,
2064                 void __user *newval, size_t newlen, void **context)
2065 {
2066         if (oldval) {
2067                 size_t olen;
2068                 if (oldlenp) { 
2069                         if (get_user(olen, oldlenp))
2070                                 return -EFAULT;
2071                         if (olen!=sizeof(int))
2072                                 return -EINVAL; 
2073                 }
2074                 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2075                     (oldlenp && put_user(sizeof(int),oldlenp)))
2076                         return -EFAULT;
2077         }
2078         if (newval && newlen) { 
2079                 int new;
2080                 if (newlen != sizeof(int))
2081                         return -EINVAL; 
2082                 if (get_user(new, (int __user *)newval))
2083                         return -EFAULT;
2084                 *(int *)(table->data) = new*HZ; 
2085         }
2086         return 1;
2087 }
2088
2089
2090 #else /* CONFIG_SYSCTL */
2091
2092
2093 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2094 {
2095         return -ENOSYS;
2096 }
2097
2098 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2099                   void __user *oldval, size_t __user *oldlenp,
2100                   void __user *newval, size_t newlen, void **context)
2101 {
2102         return -ENOSYS;
2103 }
2104
2105 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2106                 void __user *oldval, size_t __user *oldlenp,
2107                 void __user *newval, size_t newlen, void **context)
2108 {
2109         return -ENOSYS;
2110 }
2111
2112 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2113                 void __user *oldval, size_t __user *oldlenp,
2114                 void __user *newval, size_t newlen, void **context)
2115 {
2116         return -ENOSYS;
2117 }
2118
2119 int proc_dostring(ctl_table *table, int write, struct file *filp,
2120                   void __user *buffer, size_t *lenp)
2121 {
2122         return -ENOSYS;
2123 }
2124
2125 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2126                   void __user *buffer, size_t *lenp)
2127 {
2128         return -ENOSYS;
2129 }
2130
2131 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2132                         void __user *buffer, size_t *lenp)
2133 {
2134         return -ENOSYS;
2135 }
2136
2137 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2138                     void __user *buffer, size_t *lenp)
2139 {
2140         return -ENOSYS;
2141 }
2142
2143 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2144                           void __user *buffer, size_t *lenp)
2145 {
2146         return -ENOSYS;
2147 }
2148
2149 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2150                           void __user *buffer, size_t *lenp)
2151 {
2152         return -ENOSYS;
2153 }
2154
2155 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2156                     void __user *buffer, size_t *lenp)
2157 {
2158         return -ENOSYS;
2159 }
2160
2161 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2162                                       struct file *filp,
2163                                       void __user *buffer, size_t *lenp)
2164 {
2165     return -ENOSYS;
2166 }
2167
2168 struct ctl_table_header * register_sysctl_table(ctl_table * table, 
2169                                                 int insert_at_head)
2170 {
2171         return 0;
2172 }
2173
2174 void unregister_sysctl_table(struct ctl_table_header * table)
2175 {
2176 }
2177
2178 #endif /* CONFIG_SYSCTL */
2179
2180 /*
2181  * No sense putting this after each symbol definition, twice,
2182  * exception granted :-)
2183  */
2184 EXPORT_SYMBOL(proc_dointvec);
2185 EXPORT_SYMBOL(proc_dointvec_jiffies);
2186 EXPORT_SYMBOL(proc_dointvec_minmax);
2187 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2188 EXPORT_SYMBOL(proc_dostring);
2189 EXPORT_SYMBOL(proc_doulongvec_minmax);
2190 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2191 EXPORT_SYMBOL(register_sysctl_table);
2192 EXPORT_SYMBOL(sysctl_intvec);
2193 EXPORT_SYMBOL(sysctl_jiffies);
2194 EXPORT_SYMBOL(sysctl_string);
2195 EXPORT_SYMBOL(unregister_sysctl_table);