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