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