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