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