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