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