Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.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/module.h>
22 #include <linux/mm.h>
23 #include <linux/swap.h>
24 #include <linux/slab.h>
25 #include <linux/sysctl.h>
26 #include <linux/proc_fs.h>
27 #include <linux/capability.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/kobject.h>
35 #include <linux/net.h>
36 #include <linux/sysrq.h>
37 #include <linux/highuid.h>
38 #include <linux/writeback.h>
39 #include <linux/hugetlb.h>
40 #include <linux/security.h>
41 #include <linux/initrd.h>
42 #include <linux/times.h>
43 #include <linux/limits.h>
44 #include <linux/dcache.h>
45 #include <linux/syscalls.h>
46 #include <linux/nfs_fs.h>
47 #include <linux/acpi.h>
48
49 #include <asm/uaccess.h>
50 #include <asm/processor.h>
51
52 extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
53                      void __user *buffer, size_t *lenp, loff_t *ppos);
54
55 #ifdef CONFIG_X86
56 #include <asm/nmi.h>
57 #include <asm/stacktrace.h>
58 #endif
59
60 #if defined(CONFIG_SYSCTL)
61
62 /* External variables not in a header file. */
63 extern int C_A_D;
64 extern int sysctl_overcommit_memory;
65 extern int sysctl_overcommit_ratio;
66 extern int sysctl_panic_on_oom;
67 extern int max_threads;
68 extern int core_uses_pid;
69 extern int suid_dumpable;
70 extern char core_pattern[];
71 extern int pid_max;
72 extern int min_free_kbytes;
73 extern int printk_ratelimit_jiffies;
74 extern int printk_ratelimit_burst;
75 extern int pid_max_min, pid_max_max;
76 extern int sysctl_drop_caches;
77 extern int percpu_pagelist_fraction;
78 extern int compat_log;
79
80 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
81 static int maxolduid = 65535;
82 static int minolduid;
83 static int min_percpu_pagelist_fract = 8;
84
85 static int ngroups_max = NGROUPS_MAX;
86
87 #ifdef CONFIG_KMOD
88 extern char modprobe_path[];
89 #endif
90 #ifdef CONFIG_CHR_DEV_SG
91 extern int sg_big_buff;
92 #endif
93 #ifdef CONFIG_SYSVIPC
94 static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
95                 void __user *buffer, size_t *lenp, loff_t *ppos);
96 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
97                 void __user *buffer, size_t *lenp, loff_t *ppos);
98 #endif
99
100 #ifdef __sparc__
101 extern char reboot_command [];
102 extern int stop_a_enabled;
103 extern int scons_pwroff;
104 #endif
105
106 #ifdef __hppa__
107 extern int pwrsw_enabled;
108 extern int unaligned_enabled;
109 #endif
110
111 #ifdef CONFIG_S390
112 #ifdef CONFIG_MATHEMU
113 extern int sysctl_ieee_emulation_warnings;
114 #endif
115 extern int sysctl_userprocess_debug;
116 extern int spin_retry;
117 #endif
118
119 extern int sysctl_hz_timer;
120
121 #ifdef CONFIG_BSD_PROCESS_ACCT
122 extern int acct_parm[];
123 #endif
124
125 #ifdef CONFIG_IA64
126 extern int no_unaligned_warning;
127 #endif
128
129 #ifdef CONFIG_RT_MUTEXES
130 extern int max_lock_depth;
131 #endif
132
133 #ifdef CONFIG_SYSCTL_SYSCALL
134 static int parse_table(int __user *, int, void __user *, size_t __user *,
135                 void __user *, size_t, ctl_table *);
136 #endif
137
138 static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
139                   void __user *buffer, size_t *lenp, loff_t *ppos);
140
141 static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
142                   void __user *oldval, size_t __user *oldlenp,
143                   void __user *newval, size_t newlen);
144
145 #ifdef CONFIG_SYSVIPC
146 static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
147                   void __user *oldval, size_t __user *oldlenp,
148                   void __user *newval, size_t newlen);
149 #endif
150
151 #ifdef CONFIG_PROC_SYSCTL
152 static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
153                   void __user *buffer, size_t *lenp, loff_t *ppos);
154 #endif
155
156 static ctl_table root_table[];
157 static struct ctl_table_header root_table_header =
158         { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
159
160 static ctl_table kern_table[];
161 static ctl_table vm_table[];
162 static ctl_table fs_table[];
163 static ctl_table debug_table[];
164 static ctl_table dev_table[];
165 extern ctl_table random_table[];
166 #ifdef CONFIG_UNIX98_PTYS
167 extern ctl_table pty_table[];
168 #endif
169 #ifdef CONFIG_INOTIFY_USER
170 extern ctl_table inotify_table[];
171 #endif
172
173 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
174 int sysctl_legacy_va_layout;
175 #endif
176
177 static void *get_uts(ctl_table *table, int write)
178 {
179         char *which = table->data;
180 #ifdef CONFIG_UTS_NS
181         struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
182         which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
183 #endif
184         if (!write)
185                 down_read(&uts_sem);
186         else
187                 down_write(&uts_sem);
188         return which;
189 }
190
191 static void put_uts(ctl_table *table, int write, void *which)
192 {
193         if (!write)
194                 up_read(&uts_sem);
195         else
196                 up_write(&uts_sem);
197 }
198
199 #ifdef CONFIG_SYSVIPC
200 static void *get_ipc(ctl_table *table, int write)
201 {
202         char *which = table->data;
203         struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
204         which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
205         return which;
206 }
207 #else
208 #define get_ipc(T,W) ((T)->data)
209 #endif
210
211 /* /proc declarations: */
212
213 #ifdef CONFIG_PROC_SYSCTL
214
215 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
216 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
217 static int proc_opensys(struct inode *, struct file *);
218
219 const struct file_operations proc_sys_file_operations = {
220         .open           = proc_opensys,
221         .read           = proc_readsys,
222         .write          = proc_writesys,
223 };
224
225 extern struct proc_dir_entry *proc_sys_root;
226
227 static void register_proc_table(ctl_table *, struct proc_dir_entry *, void *);
228 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
229 #endif
230
231 /* The default sysctl tables: */
232
233 static ctl_table root_table[] = {
234         {
235                 .ctl_name       = CTL_KERN,
236                 .procname       = "kernel",
237                 .mode           = 0555,
238                 .child          = kern_table,
239         },
240         {
241                 .ctl_name       = CTL_VM,
242                 .procname       = "vm",
243                 .mode           = 0555,
244                 .child          = vm_table,
245         },
246 #ifdef CONFIG_NET
247         {
248                 .ctl_name       = CTL_NET,
249                 .procname       = "net",
250                 .mode           = 0555,
251                 .child          = net_table,
252         },
253 #endif
254         {
255                 .ctl_name       = CTL_FS,
256                 .procname       = "fs",
257                 .mode           = 0555,
258                 .child          = fs_table,
259         },
260         {
261                 .ctl_name       = CTL_DEBUG,
262                 .procname       = "debug",
263                 .mode           = 0555,
264                 .child          = debug_table,
265         },
266         {
267                 .ctl_name       = CTL_DEV,
268                 .procname       = "dev",
269                 .mode           = 0555,
270                 .child          = dev_table,
271         },
272
273         { .ctl_name = 0 }
274 };
275
276 static ctl_table kern_table[] = {
277         {
278                 .ctl_name       = KERN_OSTYPE,
279                 .procname       = "ostype",
280                 .data           = init_uts_ns.name.sysname,
281                 .maxlen         = sizeof(init_uts_ns.name.sysname),
282                 .mode           = 0444,
283                 .proc_handler   = &proc_do_uts_string,
284                 .strategy       = &sysctl_uts_string,
285         },
286         {
287                 .ctl_name       = KERN_OSRELEASE,
288                 .procname       = "osrelease",
289                 .data           = init_uts_ns.name.release,
290                 .maxlen         = sizeof(init_uts_ns.name.release),
291                 .mode           = 0444,
292                 .proc_handler   = &proc_do_uts_string,
293                 .strategy       = &sysctl_uts_string,
294         },
295         {
296                 .ctl_name       = KERN_VERSION,
297                 .procname       = "version",
298                 .data           = init_uts_ns.name.version,
299                 .maxlen         = sizeof(init_uts_ns.name.version),
300                 .mode           = 0444,
301                 .proc_handler   = &proc_do_uts_string,
302                 .strategy       = &sysctl_uts_string,
303         },
304         {
305                 .ctl_name       = KERN_NODENAME,
306                 .procname       = "hostname",
307                 .data           = init_uts_ns.name.nodename,
308                 .maxlen         = sizeof(init_uts_ns.name.nodename),
309                 .mode           = 0644,
310                 .proc_handler   = &proc_do_uts_string,
311                 .strategy       = &sysctl_uts_string,
312         },
313         {
314                 .ctl_name       = KERN_DOMAINNAME,
315                 .procname       = "domainname",
316                 .data           = init_uts_ns.name.domainname,
317                 .maxlen         = sizeof(init_uts_ns.name.domainname),
318                 .mode           = 0644,
319                 .proc_handler   = &proc_do_uts_string,
320                 .strategy       = &sysctl_uts_string,
321         },
322         {
323                 .ctl_name       = KERN_PANIC,
324                 .procname       = "panic",
325                 .data           = &panic_timeout,
326                 .maxlen         = sizeof(int),
327                 .mode           = 0644,
328                 .proc_handler   = &proc_dointvec,
329         },
330         {
331                 .ctl_name       = KERN_CORE_USES_PID,
332                 .procname       = "core_uses_pid",
333                 .data           = &core_uses_pid,
334                 .maxlen         = sizeof(int),
335                 .mode           = 0644,
336                 .proc_handler   = &proc_dointvec,
337         },
338         {
339                 .ctl_name       = KERN_CORE_PATTERN,
340                 .procname       = "core_pattern",
341                 .data           = core_pattern,
342                 .maxlen         = 128,
343                 .mode           = 0644,
344                 .proc_handler   = &proc_dostring,
345                 .strategy       = &sysctl_string,
346         },
347         {
348                 .ctl_name       = KERN_TAINTED,
349                 .procname       = "tainted",
350                 .data           = &tainted,
351                 .maxlen         = sizeof(int),
352                 .mode           = 0444,
353                 .proc_handler   = &proc_dointvec,
354         },
355         {
356                 .ctl_name       = KERN_CAP_BSET,
357                 .procname       = "cap-bound",
358                 .data           = &cap_bset,
359                 .maxlen         = sizeof(kernel_cap_t),
360                 .mode           = 0600,
361                 .proc_handler   = &proc_dointvec_bset,
362         },
363 #ifdef CONFIG_BLK_DEV_INITRD
364         {
365                 .ctl_name       = KERN_REALROOTDEV,
366                 .procname       = "real-root-dev",
367                 .data           = &real_root_dev,
368                 .maxlen         = sizeof(int),
369                 .mode           = 0644,
370                 .proc_handler   = &proc_dointvec,
371         },
372 #endif
373 #ifdef __sparc__
374         {
375                 .ctl_name       = KERN_SPARC_REBOOT,
376                 .procname       = "reboot-cmd",
377                 .data           = reboot_command,
378                 .maxlen         = 256,
379                 .mode           = 0644,
380                 .proc_handler   = &proc_dostring,
381                 .strategy       = &sysctl_string,
382         },
383         {
384                 .ctl_name       = KERN_SPARC_STOP_A,
385                 .procname       = "stop-a",
386                 .data           = &stop_a_enabled,
387                 .maxlen         = sizeof (int),
388                 .mode           = 0644,
389                 .proc_handler   = &proc_dointvec,
390         },
391         {
392                 .ctl_name       = KERN_SPARC_SCONS_PWROFF,
393                 .procname       = "scons-poweroff",
394                 .data           = &scons_pwroff,
395                 .maxlen         = sizeof (int),
396                 .mode           = 0644,
397                 .proc_handler   = &proc_dointvec,
398         },
399 #endif
400 #ifdef __hppa__
401         {
402                 .ctl_name       = KERN_HPPA_PWRSW,
403                 .procname       = "soft-power",
404                 .data           = &pwrsw_enabled,
405                 .maxlen         = sizeof (int),
406                 .mode           = 0644,
407                 .proc_handler   = &proc_dointvec,
408         },
409         {
410                 .ctl_name       = KERN_HPPA_UNALIGNED,
411                 .procname       = "unaligned-trap",
412                 .data           = &unaligned_enabled,
413                 .maxlen         = sizeof (int),
414                 .mode           = 0644,
415                 .proc_handler   = &proc_dointvec,
416         },
417 #endif
418         {
419                 .ctl_name       = KERN_CTLALTDEL,
420                 .procname       = "ctrl-alt-del",
421                 .data           = &C_A_D,
422                 .maxlen         = sizeof(int),
423                 .mode           = 0644,
424                 .proc_handler   = &proc_dointvec,
425         },
426         {
427                 .ctl_name       = KERN_PRINTK,
428                 .procname       = "printk",
429                 .data           = &console_loglevel,
430                 .maxlen         = 4*sizeof(int),
431                 .mode           = 0644,
432                 .proc_handler   = &proc_dointvec,
433         },
434 #ifdef CONFIG_KMOD
435         {
436                 .ctl_name       = KERN_MODPROBE,
437                 .procname       = "modprobe",
438                 .data           = &modprobe_path,
439                 .maxlen         = KMOD_PATH_LEN,
440                 .mode           = 0644,
441                 .proc_handler   = &proc_dostring,
442                 .strategy       = &sysctl_string,
443         },
444 #endif
445 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
446         {
447                 .ctl_name       = KERN_HOTPLUG,
448                 .procname       = "hotplug",
449                 .data           = &uevent_helper,
450                 .maxlen         = UEVENT_HELPER_PATH_LEN,
451                 .mode           = 0644,
452                 .proc_handler   = &proc_dostring,
453                 .strategy       = &sysctl_string,
454         },
455 #endif
456 #ifdef CONFIG_CHR_DEV_SG
457         {
458                 .ctl_name       = KERN_SG_BIG_BUFF,
459                 .procname       = "sg-big-buff",
460                 .data           = &sg_big_buff,
461                 .maxlen         = sizeof (int),
462                 .mode           = 0444,
463                 .proc_handler   = &proc_dointvec,
464         },
465 #endif
466 #ifdef CONFIG_BSD_PROCESS_ACCT
467         {
468                 .ctl_name       = KERN_ACCT,
469                 .procname       = "acct",
470                 .data           = &acct_parm,
471                 .maxlen         = 3*sizeof(int),
472                 .mode           = 0644,
473                 .proc_handler   = &proc_dointvec,
474         },
475 #endif
476 #ifdef CONFIG_SYSVIPC
477         {
478                 .ctl_name       = KERN_SHMMAX,
479                 .procname       = "shmmax",
480                 .data           = &init_ipc_ns.shm_ctlmax,
481                 .maxlen         = sizeof (init_ipc_ns.shm_ctlmax),
482                 .mode           = 0644,
483                 .proc_handler   = &proc_ipc_doulongvec_minmax,
484                 .strategy       = sysctl_ipc_data,
485         },
486         {
487                 .ctl_name       = KERN_SHMALL,
488                 .procname       = "shmall",
489                 .data           = &init_ipc_ns.shm_ctlall,
490                 .maxlen         = sizeof (init_ipc_ns.shm_ctlall),
491                 .mode           = 0644,
492                 .proc_handler   = &proc_ipc_doulongvec_minmax,
493                 .strategy       = sysctl_ipc_data,
494         },
495         {
496                 .ctl_name       = KERN_SHMMNI,
497                 .procname       = "shmmni",
498                 .data           = &init_ipc_ns.shm_ctlmni,
499                 .maxlen         = sizeof (init_ipc_ns.shm_ctlmni),
500                 .mode           = 0644,
501                 .proc_handler   = &proc_ipc_dointvec,
502                 .strategy       = sysctl_ipc_data,
503         },
504         {
505                 .ctl_name       = KERN_MSGMAX,
506                 .procname       = "msgmax",
507                 .data           = &init_ipc_ns.msg_ctlmax,
508                 .maxlen         = sizeof (init_ipc_ns.msg_ctlmax),
509                 .mode           = 0644,
510                 .proc_handler   = &proc_ipc_dointvec,
511                 .strategy       = sysctl_ipc_data,
512         },
513         {
514                 .ctl_name       = KERN_MSGMNI,
515                 .procname       = "msgmni",
516                 .data           = &init_ipc_ns.msg_ctlmni,
517                 .maxlen         = sizeof (init_ipc_ns.msg_ctlmni),
518                 .mode           = 0644,
519                 .proc_handler   = &proc_ipc_dointvec,
520                 .strategy       = sysctl_ipc_data,
521         },
522         {
523                 .ctl_name       = KERN_MSGMNB,
524                 .procname       =  "msgmnb",
525                 .data           = &init_ipc_ns.msg_ctlmnb,
526                 .maxlen         = sizeof (init_ipc_ns.msg_ctlmnb),
527                 .mode           = 0644,
528                 .proc_handler   = &proc_ipc_dointvec,
529                 .strategy       = sysctl_ipc_data,
530         },
531         {
532                 .ctl_name       = KERN_SEM,
533                 .procname       = "sem",
534                 .data           = &init_ipc_ns.sem_ctls,
535                 .maxlen         = 4*sizeof (int),
536                 .mode           = 0644,
537                 .proc_handler   = &proc_ipc_dointvec,
538                 .strategy       = sysctl_ipc_data,
539         },
540 #endif
541 #ifdef CONFIG_MAGIC_SYSRQ
542         {
543                 .ctl_name       = KERN_SYSRQ,
544                 .procname       = "sysrq",
545                 .data           = &__sysrq_enabled,
546                 .maxlen         = sizeof (int),
547                 .mode           = 0644,
548                 .proc_handler   = &proc_dointvec,
549         },
550 #endif
551 #ifdef CONFIG_PROC_SYSCTL
552         {
553                 .ctl_name       = KERN_CADPID,
554                 .procname       = "cad_pid",
555                 .data           = NULL,
556                 .maxlen         = sizeof (int),
557                 .mode           = 0600,
558                 .proc_handler   = &proc_do_cad_pid,
559         },
560 #endif
561         {
562                 .ctl_name       = KERN_MAX_THREADS,
563                 .procname       = "threads-max",
564                 .data           = &max_threads,
565                 .maxlen         = sizeof(int),
566                 .mode           = 0644,
567                 .proc_handler   = &proc_dointvec,
568         },
569         {
570                 .ctl_name       = KERN_RANDOM,
571                 .procname       = "random",
572                 .mode           = 0555,
573                 .child          = random_table,
574         },
575 #ifdef CONFIG_UNIX98_PTYS
576         {
577                 .ctl_name       = KERN_PTY,
578                 .procname       = "pty",
579                 .mode           = 0555,
580                 .child          = pty_table,
581         },
582 #endif
583         {
584                 .ctl_name       = KERN_OVERFLOWUID,
585                 .procname       = "overflowuid",
586                 .data           = &overflowuid,
587                 .maxlen         = sizeof(int),
588                 .mode           = 0644,
589                 .proc_handler   = &proc_dointvec_minmax,
590                 .strategy       = &sysctl_intvec,
591                 .extra1         = &minolduid,
592                 .extra2         = &maxolduid,
593         },
594         {
595                 .ctl_name       = KERN_OVERFLOWGID,
596                 .procname       = "overflowgid",
597                 .data           = &overflowgid,
598                 .maxlen         = sizeof(int),
599                 .mode           = 0644,
600                 .proc_handler   = &proc_dointvec_minmax,
601                 .strategy       = &sysctl_intvec,
602                 .extra1         = &minolduid,
603                 .extra2         = &maxolduid,
604         },
605 #ifdef CONFIG_S390
606 #ifdef CONFIG_MATHEMU
607         {
608                 .ctl_name       = KERN_IEEE_EMULATION_WARNINGS,
609                 .procname       = "ieee_emulation_warnings",
610                 .data           = &sysctl_ieee_emulation_warnings,
611                 .maxlen         = sizeof(int),
612                 .mode           = 0644,
613                 .proc_handler   = &proc_dointvec,
614         },
615 #endif
616 #ifdef CONFIG_NO_IDLE_HZ
617         {
618                 .ctl_name       = KERN_HZ_TIMER,
619                 .procname       = "hz_timer",
620                 .data           = &sysctl_hz_timer,
621                 .maxlen         = sizeof(int),
622                 .mode           = 0644,
623                 .proc_handler   = &proc_dointvec,
624         },
625 #endif
626         {
627                 .ctl_name       = KERN_S390_USER_DEBUG_LOGGING,
628                 .procname       = "userprocess_debug",
629                 .data           = &sysctl_userprocess_debug,
630                 .maxlen         = sizeof(int),
631                 .mode           = 0644,
632                 .proc_handler   = &proc_dointvec,
633         },
634 #endif
635         {
636                 .ctl_name       = KERN_PIDMAX,
637                 .procname       = "pid_max",
638                 .data           = &pid_max,
639                 .maxlen         = sizeof (int),
640                 .mode           = 0644,
641                 .proc_handler   = &proc_dointvec_minmax,
642                 .strategy       = sysctl_intvec,
643                 .extra1         = &pid_max_min,
644                 .extra2         = &pid_max_max,
645         },
646         {
647                 .ctl_name       = KERN_PANIC_ON_OOPS,
648                 .procname       = "panic_on_oops",
649                 .data           = &panic_on_oops,
650                 .maxlen         = sizeof(int),
651                 .mode           = 0644,
652                 .proc_handler   = &proc_dointvec,
653         },
654         {
655                 .ctl_name       = KERN_PRINTK_RATELIMIT,
656                 .procname       = "printk_ratelimit",
657                 .data           = &printk_ratelimit_jiffies,
658                 .maxlen         = sizeof(int),
659                 .mode           = 0644,
660                 .proc_handler   = &proc_dointvec_jiffies,
661                 .strategy       = &sysctl_jiffies,
662         },
663         {
664                 .ctl_name       = KERN_PRINTK_RATELIMIT_BURST,
665                 .procname       = "printk_ratelimit_burst",
666                 .data           = &printk_ratelimit_burst,
667                 .maxlen         = sizeof(int),
668                 .mode           = 0644,
669                 .proc_handler   = &proc_dointvec,
670         },
671         {
672                 .ctl_name       = KERN_NGROUPS_MAX,
673                 .procname       = "ngroups_max",
674                 .data           = &ngroups_max,
675                 .maxlen         = sizeof (int),
676                 .mode           = 0444,
677                 .proc_handler   = &proc_dointvec,
678         },
679 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
680         {
681                 .ctl_name       = KERN_UNKNOWN_NMI_PANIC,
682                 .procname       = "unknown_nmi_panic",
683                 .data           = &unknown_nmi_panic,
684                 .maxlen         = sizeof (int),
685                 .mode           = 0644,
686                 .proc_handler   = &proc_dointvec,
687         },
688         {
689                 .ctl_name       = KERN_NMI_WATCHDOG,
690                 .procname       = "nmi_watchdog",
691                 .data           = &nmi_watchdog_enabled,
692                 .maxlen         = sizeof (int),
693                 .mode           = 0644,
694                 .proc_handler   = &proc_nmi_enabled,
695         },
696 #endif
697 #if defined(CONFIG_X86)
698         {
699                 .ctl_name       = KERN_PANIC_ON_NMI,
700                 .procname       = "panic_on_unrecovered_nmi",
701                 .data           = &panic_on_unrecovered_nmi,
702                 .maxlen         = sizeof(int),
703                 .mode           = 0644,
704                 .proc_handler   = &proc_dointvec,
705         },
706         {
707                 .ctl_name       = KERN_BOOTLOADER_TYPE,
708                 .procname       = "bootloader_type",
709                 .data           = &bootloader_type,
710                 .maxlen         = sizeof (int),
711                 .mode           = 0444,
712                 .proc_handler   = &proc_dointvec,
713         },
714         {
715                 .ctl_name       = CTL_UNNUMBERED,
716                 .procname       = "kstack_depth_to_print",
717                 .data           = &kstack_depth_to_print,
718                 .maxlen         = sizeof(int),
719                 .mode           = 0644,
720                 .proc_handler   = &proc_dointvec,
721         },
722 #endif
723 #if defined(CONFIG_MMU)
724         {
725                 .ctl_name       = KERN_RANDOMIZE,
726                 .procname       = "randomize_va_space",
727                 .data           = &randomize_va_space,
728                 .maxlen         = sizeof(int),
729                 .mode           = 0644,
730                 .proc_handler   = &proc_dointvec,
731         },
732 #endif
733 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
734         {
735                 .ctl_name       = KERN_SPIN_RETRY,
736                 .procname       = "spin_retry",
737                 .data           = &spin_retry,
738                 .maxlen         = sizeof (int),
739                 .mode           = 0644,
740                 .proc_handler   = &proc_dointvec,
741         },
742 #endif
743 #ifdef CONFIG_ACPI_SLEEP
744         {
745                 .ctl_name       = KERN_ACPI_VIDEO_FLAGS,
746                 .procname       = "acpi_video_flags",
747                 .data           = &acpi_video_flags,
748                 .maxlen         = sizeof (unsigned long),
749                 .mode           = 0644,
750                 .proc_handler   = &proc_doulongvec_minmax,
751         },
752 #endif
753 #ifdef CONFIG_IA64
754         {
755                 .ctl_name       = KERN_IA64_UNALIGNED,
756                 .procname       = "ignore-unaligned-usertrap",
757                 .data           = &no_unaligned_warning,
758                 .maxlen         = sizeof (int),
759                 .mode           = 0644,
760                 .proc_handler   = &proc_dointvec,
761         },
762 #endif
763 #ifdef CONFIG_COMPAT
764         {
765                 .ctl_name       = KERN_COMPAT_LOG,
766                 .procname       = "compat-log",
767                 .data           = &compat_log,
768                 .maxlen         = sizeof (int),
769                 .mode           = 0644,
770                 .proc_handler   = &proc_dointvec,
771         },
772 #endif
773 #ifdef CONFIG_RT_MUTEXES
774         {
775                 .ctl_name       = KERN_MAX_LOCK_DEPTH,
776                 .procname       = "max_lock_depth",
777                 .data           = &max_lock_depth,
778                 .maxlen         = sizeof(int),
779                 .mode           = 0644,
780                 .proc_handler   = &proc_dointvec,
781         },
782 #endif
783
784         { .ctl_name = 0 }
785 };
786
787 /* Constants for minimum and maximum testing in vm_table.
788    We use these as one-element integer vectors. */
789 static int zero;
790 static int one_hundred = 100;
791
792
793 static ctl_table vm_table[] = {
794         {
795                 .ctl_name       = VM_OVERCOMMIT_MEMORY,
796                 .procname       = "overcommit_memory",
797                 .data           = &sysctl_overcommit_memory,
798                 .maxlen         = sizeof(sysctl_overcommit_memory),
799                 .mode           = 0644,
800                 .proc_handler   = &proc_dointvec,
801         },
802         {
803                 .ctl_name       = VM_PANIC_ON_OOM,
804                 .procname       = "panic_on_oom",
805                 .data           = &sysctl_panic_on_oom,
806                 .maxlen         = sizeof(sysctl_panic_on_oom),
807                 .mode           = 0644,
808                 .proc_handler   = &proc_dointvec,
809         },
810         {
811                 .ctl_name       = VM_OVERCOMMIT_RATIO,
812                 .procname       = "overcommit_ratio",
813                 .data           = &sysctl_overcommit_ratio,
814                 .maxlen         = sizeof(sysctl_overcommit_ratio),
815                 .mode           = 0644,
816                 .proc_handler   = &proc_dointvec,
817         },
818         {
819                 .ctl_name       = VM_PAGE_CLUSTER,
820                 .procname       = "page-cluster", 
821                 .data           = &page_cluster,
822                 .maxlen         = sizeof(int),
823                 .mode           = 0644,
824                 .proc_handler   = &proc_dointvec,
825         },
826         {
827                 .ctl_name       = VM_DIRTY_BACKGROUND,
828                 .procname       = "dirty_background_ratio",
829                 .data           = &dirty_background_ratio,
830                 .maxlen         = sizeof(dirty_background_ratio),
831                 .mode           = 0644,
832                 .proc_handler   = &proc_dointvec_minmax,
833                 .strategy       = &sysctl_intvec,
834                 .extra1         = &zero,
835                 .extra2         = &one_hundred,
836         },
837         {
838                 .ctl_name       = VM_DIRTY_RATIO,
839                 .procname       = "dirty_ratio",
840                 .data           = &vm_dirty_ratio,
841                 .maxlen         = sizeof(vm_dirty_ratio),
842                 .mode           = 0644,
843                 .proc_handler   = &proc_dointvec_minmax,
844                 .strategy       = &sysctl_intvec,
845                 .extra1         = &zero,
846                 .extra2         = &one_hundred,
847         },
848         {
849                 .ctl_name       = VM_DIRTY_WB_CS,
850                 .procname       = "dirty_writeback_centisecs",
851                 .data           = &dirty_writeback_interval,
852                 .maxlen         = sizeof(dirty_writeback_interval),
853                 .mode           = 0644,
854                 .proc_handler   = &dirty_writeback_centisecs_handler,
855         },
856         {
857                 .ctl_name       = VM_DIRTY_EXPIRE_CS,
858                 .procname       = "dirty_expire_centisecs",
859                 .data           = &dirty_expire_interval,
860                 .maxlen         = sizeof(dirty_expire_interval),
861                 .mode           = 0644,
862                 .proc_handler   = &proc_dointvec_userhz_jiffies,
863         },
864         {
865                 .ctl_name       = VM_NR_PDFLUSH_THREADS,
866                 .procname       = "nr_pdflush_threads",
867                 .data           = &nr_pdflush_threads,
868                 .maxlen         = sizeof nr_pdflush_threads,
869                 .mode           = 0444 /* read-only*/,
870                 .proc_handler   = &proc_dointvec,
871         },
872         {
873                 .ctl_name       = VM_SWAPPINESS,
874                 .procname       = "swappiness",
875                 .data           = &vm_swappiness,
876                 .maxlen         = sizeof(vm_swappiness),
877                 .mode           = 0644,
878                 .proc_handler   = &proc_dointvec_minmax,
879                 .strategy       = &sysctl_intvec,
880                 .extra1         = &zero,
881                 .extra2         = &one_hundred,
882         },
883 #ifdef CONFIG_HUGETLB_PAGE
884          {
885                 .ctl_name       = VM_HUGETLB_PAGES,
886                 .procname       = "nr_hugepages",
887                 .data           = &max_huge_pages,
888                 .maxlen         = sizeof(unsigned long),
889                 .mode           = 0644,
890                 .proc_handler   = &hugetlb_sysctl_handler,
891                 .extra1         = (void *)&hugetlb_zero,
892                 .extra2         = (void *)&hugetlb_infinity,
893          },
894          {
895                 .ctl_name       = VM_HUGETLB_GROUP,
896                 .procname       = "hugetlb_shm_group",
897                 .data           = &sysctl_hugetlb_shm_group,
898                 .maxlen         = sizeof(gid_t),
899                 .mode           = 0644,
900                 .proc_handler   = &proc_dointvec,
901          },
902 #endif
903         {
904                 .ctl_name       = VM_LOWMEM_RESERVE_RATIO,
905                 .procname       = "lowmem_reserve_ratio",
906                 .data           = &sysctl_lowmem_reserve_ratio,
907                 .maxlen         = sizeof(sysctl_lowmem_reserve_ratio),
908                 .mode           = 0644,
909                 .proc_handler   = &lowmem_reserve_ratio_sysctl_handler,
910                 .strategy       = &sysctl_intvec,
911         },
912         {
913                 .ctl_name       = VM_DROP_PAGECACHE,
914                 .procname       = "drop_caches",
915                 .data           = &sysctl_drop_caches,
916                 .maxlen         = sizeof(int),
917                 .mode           = 0644,
918                 .proc_handler   = drop_caches_sysctl_handler,
919                 .strategy       = &sysctl_intvec,
920         },
921         {
922                 .ctl_name       = VM_MIN_FREE_KBYTES,
923                 .procname       = "min_free_kbytes",
924                 .data           = &min_free_kbytes,
925                 .maxlen         = sizeof(min_free_kbytes),
926                 .mode           = 0644,
927                 .proc_handler   = &min_free_kbytes_sysctl_handler,
928                 .strategy       = &sysctl_intvec,
929                 .extra1         = &zero,
930         },
931         {
932                 .ctl_name       = VM_PERCPU_PAGELIST_FRACTION,
933                 .procname       = "percpu_pagelist_fraction",
934                 .data           = &percpu_pagelist_fraction,
935                 .maxlen         = sizeof(percpu_pagelist_fraction),
936                 .mode           = 0644,
937                 .proc_handler   = &percpu_pagelist_fraction_sysctl_handler,
938                 .strategy       = &sysctl_intvec,
939                 .extra1         = &min_percpu_pagelist_fract,
940         },
941 #ifdef CONFIG_MMU
942         {
943                 .ctl_name       = VM_MAX_MAP_COUNT,
944                 .procname       = "max_map_count",
945                 .data           = &sysctl_max_map_count,
946                 .maxlen         = sizeof(sysctl_max_map_count),
947                 .mode           = 0644,
948                 .proc_handler   = &proc_dointvec
949         },
950 #endif
951         {
952                 .ctl_name       = VM_LAPTOP_MODE,
953                 .procname       = "laptop_mode",
954                 .data           = &laptop_mode,
955                 .maxlen         = sizeof(laptop_mode),
956                 .mode           = 0644,
957                 .proc_handler   = &proc_dointvec_jiffies,
958                 .strategy       = &sysctl_jiffies,
959         },
960         {
961                 .ctl_name       = VM_BLOCK_DUMP,
962                 .procname       = "block_dump",
963                 .data           = &block_dump,
964                 .maxlen         = sizeof(block_dump),
965                 .mode           = 0644,
966                 .proc_handler   = &proc_dointvec,
967                 .strategy       = &sysctl_intvec,
968                 .extra1         = &zero,
969         },
970         {
971                 .ctl_name       = VM_VFS_CACHE_PRESSURE,
972                 .procname       = "vfs_cache_pressure",
973                 .data           = &sysctl_vfs_cache_pressure,
974                 .maxlen         = sizeof(sysctl_vfs_cache_pressure),
975                 .mode           = 0644,
976                 .proc_handler   = &proc_dointvec,
977                 .strategy       = &sysctl_intvec,
978                 .extra1         = &zero,
979         },
980 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
981         {
982                 .ctl_name       = VM_LEGACY_VA_LAYOUT,
983                 .procname       = "legacy_va_layout",
984                 .data           = &sysctl_legacy_va_layout,
985                 .maxlen         = sizeof(sysctl_legacy_va_layout),
986                 .mode           = 0644,
987                 .proc_handler   = &proc_dointvec,
988                 .strategy       = &sysctl_intvec,
989                 .extra1         = &zero,
990         },
991 #endif
992 #ifdef CONFIG_NUMA
993         {
994                 .ctl_name       = VM_ZONE_RECLAIM_MODE,
995                 .procname       = "zone_reclaim_mode",
996                 .data           = &zone_reclaim_mode,
997                 .maxlen         = sizeof(zone_reclaim_mode),
998                 .mode           = 0644,
999                 .proc_handler   = &proc_dointvec,
1000                 .strategy       = &sysctl_intvec,
1001                 .extra1         = &zero,
1002         },
1003         {
1004                 .ctl_name       = VM_MIN_UNMAPPED,
1005                 .procname       = "min_unmapped_ratio",
1006                 .data           = &sysctl_min_unmapped_ratio,
1007                 .maxlen         = sizeof(sysctl_min_unmapped_ratio),
1008                 .mode           = 0644,
1009                 .proc_handler   = &sysctl_min_unmapped_ratio_sysctl_handler,
1010                 .strategy       = &sysctl_intvec,
1011                 .extra1         = &zero,
1012                 .extra2         = &one_hundred,
1013         },
1014         {
1015                 .ctl_name       = VM_MIN_SLAB,
1016                 .procname       = "min_slab_ratio",
1017                 .data           = &sysctl_min_slab_ratio,
1018                 .maxlen         = sizeof(sysctl_min_slab_ratio),
1019                 .mode           = 0644,
1020                 .proc_handler   = &sysctl_min_slab_ratio_sysctl_handler,
1021                 .strategy       = &sysctl_intvec,
1022                 .extra1         = &zero,
1023                 .extra2         = &one_hundred,
1024         },
1025 #endif
1026 #ifdef CONFIG_X86_32
1027         {
1028                 .ctl_name       = VM_VDSO_ENABLED,
1029                 .procname       = "vdso_enabled",
1030                 .data           = &vdso_enabled,
1031                 .maxlen         = sizeof(vdso_enabled),
1032                 .mode           = 0644,
1033                 .proc_handler   = &proc_dointvec,
1034                 .strategy       = &sysctl_intvec,
1035                 .extra1         = &zero,
1036         },
1037 #endif
1038         { .ctl_name = 0 }
1039 };
1040
1041 static ctl_table fs_table[] = {
1042         {
1043                 .ctl_name       = FS_NRINODE,
1044                 .procname       = "inode-nr",
1045                 .data           = &inodes_stat,
1046                 .maxlen         = 2*sizeof(int),
1047                 .mode           = 0444,
1048                 .proc_handler   = &proc_dointvec,
1049         },
1050         {
1051                 .ctl_name       = FS_STATINODE,
1052                 .procname       = "inode-state",
1053                 .data           = &inodes_stat,
1054                 .maxlen         = 7*sizeof(int),
1055                 .mode           = 0444,
1056                 .proc_handler   = &proc_dointvec,
1057         },
1058         {
1059                 .ctl_name       = FS_NRFILE,
1060                 .procname       = "file-nr",
1061                 .data           = &files_stat,
1062                 .maxlen         = 3*sizeof(int),
1063                 .mode           = 0444,
1064                 .proc_handler   = &proc_nr_files,
1065         },
1066         {
1067                 .ctl_name       = FS_MAXFILE,
1068                 .procname       = "file-max",
1069                 .data           = &files_stat.max_files,
1070                 .maxlen         = sizeof(int),
1071                 .mode           = 0644,
1072                 .proc_handler   = &proc_dointvec,
1073         },
1074         {
1075                 .ctl_name       = FS_DENTRY,
1076                 .procname       = "dentry-state",
1077                 .data           = &dentry_stat,
1078                 .maxlen         = 6*sizeof(int),
1079                 .mode           = 0444,
1080                 .proc_handler   = &proc_dointvec,
1081         },
1082         {
1083                 .ctl_name       = FS_OVERFLOWUID,
1084                 .procname       = "overflowuid",
1085                 .data           = &fs_overflowuid,
1086                 .maxlen         = sizeof(int),
1087                 .mode           = 0644,
1088                 .proc_handler   = &proc_dointvec_minmax,
1089                 .strategy       = &sysctl_intvec,
1090                 .extra1         = &minolduid,
1091                 .extra2         = &maxolduid,
1092         },
1093         {
1094                 .ctl_name       = FS_OVERFLOWGID,
1095                 .procname       = "overflowgid",
1096                 .data           = &fs_overflowgid,
1097                 .maxlen         = sizeof(int),
1098                 .mode           = 0644,
1099                 .proc_handler   = &proc_dointvec_minmax,
1100                 .strategy       = &sysctl_intvec,
1101                 .extra1         = &minolduid,
1102                 .extra2         = &maxolduid,
1103         },
1104         {
1105                 .ctl_name       = FS_LEASES,
1106                 .procname       = "leases-enable",
1107                 .data           = &leases_enable,
1108                 .maxlen         = sizeof(int),
1109                 .mode           = 0644,
1110                 .proc_handler   = &proc_dointvec,
1111         },
1112 #ifdef CONFIG_DNOTIFY
1113         {
1114                 .ctl_name       = FS_DIR_NOTIFY,
1115                 .procname       = "dir-notify-enable",
1116                 .data           = &dir_notify_enable,
1117                 .maxlen         = sizeof(int),
1118                 .mode           = 0644,
1119                 .proc_handler   = &proc_dointvec,
1120         },
1121 #endif
1122 #ifdef CONFIG_MMU
1123         {
1124                 .ctl_name       = FS_LEASE_TIME,
1125                 .procname       = "lease-break-time",
1126                 .data           = &lease_break_time,
1127                 .maxlen         = sizeof(int),
1128                 .mode           = 0644,
1129                 .proc_handler   = &proc_dointvec,
1130         },
1131         {
1132                 .ctl_name       = FS_AIO_NR,
1133                 .procname       = "aio-nr",
1134                 .data           = &aio_nr,
1135                 .maxlen         = sizeof(aio_nr),
1136                 .mode           = 0444,
1137                 .proc_handler   = &proc_doulongvec_minmax,
1138         },
1139         {
1140                 .ctl_name       = FS_AIO_MAX_NR,
1141                 .procname       = "aio-max-nr",
1142                 .data           = &aio_max_nr,
1143                 .maxlen         = sizeof(aio_max_nr),
1144                 .mode           = 0644,
1145                 .proc_handler   = &proc_doulongvec_minmax,
1146         },
1147 #ifdef CONFIG_INOTIFY_USER
1148         {
1149                 .ctl_name       = FS_INOTIFY,
1150                 .procname       = "inotify",
1151                 .mode           = 0555,
1152                 .child          = inotify_table,
1153         },
1154 #endif  
1155 #endif
1156         {
1157                 .ctl_name       = KERN_SETUID_DUMPABLE,
1158                 .procname       = "suid_dumpable",
1159                 .data           = &suid_dumpable,
1160                 .maxlen         = sizeof(int),
1161                 .mode           = 0644,
1162                 .proc_handler   = &proc_dointvec,
1163         },
1164         { .ctl_name = 0 }
1165 };
1166
1167 static ctl_table debug_table[] = {
1168         { .ctl_name = 0 }
1169 };
1170
1171 static ctl_table dev_table[] = {
1172         { .ctl_name = 0 }
1173 };
1174
1175 extern void init_irq_proc (void);
1176
1177 static DEFINE_SPINLOCK(sysctl_lock);
1178
1179 /* called under sysctl_lock */
1180 static int use_table(struct ctl_table_header *p)
1181 {
1182         if (unlikely(p->unregistering))
1183                 return 0;
1184         p->used++;
1185         return 1;
1186 }
1187
1188 /* called under sysctl_lock */
1189 static void unuse_table(struct ctl_table_header *p)
1190 {
1191         if (!--p->used)
1192                 if (unlikely(p->unregistering))
1193                         complete(p->unregistering);
1194 }
1195
1196 /* called under sysctl_lock, will reacquire if has to wait */
1197 static void start_unregistering(struct ctl_table_header *p)
1198 {
1199         /*
1200          * if p->used is 0, nobody will ever touch that entry again;
1201          * we'll eliminate all paths to it before dropping sysctl_lock
1202          */
1203         if (unlikely(p->used)) {
1204                 struct completion wait;
1205                 init_completion(&wait);
1206                 p->unregistering = &wait;
1207                 spin_unlock(&sysctl_lock);
1208                 wait_for_completion(&wait);
1209                 spin_lock(&sysctl_lock);
1210         }
1211         /*
1212          * do not remove from the list until nobody holds it; walking the
1213          * list in do_sysctl() relies on that.
1214          */
1215         list_del_init(&p->ctl_entry);
1216 }
1217
1218 void __init sysctl_init(void)
1219 {
1220 #ifdef CONFIG_PROC_SYSCTL
1221         register_proc_table(root_table, proc_sys_root, &root_table_header);
1222         init_irq_proc();
1223 #endif
1224 }
1225
1226 #ifdef CONFIG_SYSCTL_SYSCALL
1227 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1228                void __user *newval, size_t newlen)
1229 {
1230         struct list_head *tmp;
1231         int error = -ENOTDIR;
1232
1233         if (nlen <= 0 || nlen >= CTL_MAXNAME)
1234                 return -ENOTDIR;
1235         if (oldval) {
1236                 int old_len;
1237                 if (!oldlenp || get_user(old_len, oldlenp))
1238                         return -EFAULT;
1239         }
1240         spin_lock(&sysctl_lock);
1241         tmp = &root_table_header.ctl_entry;
1242         do {
1243                 struct ctl_table_header *head =
1244                         list_entry(tmp, struct ctl_table_header, ctl_entry);
1245
1246                 if (!use_table(head))
1247                         continue;
1248
1249                 spin_unlock(&sysctl_lock);
1250
1251                 error = parse_table(name, nlen, oldval, oldlenp, 
1252                                         newval, newlen, head->ctl_table);
1253
1254                 spin_lock(&sysctl_lock);
1255                 unuse_table(head);
1256                 if (error != -ENOTDIR)
1257                         break;
1258         } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
1259         spin_unlock(&sysctl_lock);
1260         return error;
1261 }
1262
1263 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1264 {
1265         struct __sysctl_args tmp;
1266         int error;
1267
1268         if (copy_from_user(&tmp, args, sizeof(tmp)))
1269                 return -EFAULT;
1270
1271         lock_kernel();
1272         error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1273                           tmp.newval, tmp.newlen);
1274         unlock_kernel();
1275         return error;
1276 }
1277 #endif /* CONFIG_SYSCTL_SYSCALL */
1278
1279 /*
1280  * ctl_perm does NOT grant the superuser all rights automatically, because
1281  * some sysctl variables are readonly even to root.
1282  */
1283
1284 static int test_perm(int mode, int op)
1285 {
1286         if (!current->euid)
1287                 mode >>= 6;
1288         else if (in_egroup_p(0))
1289                 mode >>= 3;
1290         if ((mode & op & 0007) == op)
1291                 return 0;
1292         return -EACCES;
1293 }
1294
1295 static inline int ctl_perm(ctl_table *table, int op)
1296 {
1297         int error;
1298         error = security_sysctl(table, op);
1299         if (error)
1300                 return error;
1301         return test_perm(table->mode, op);
1302 }
1303
1304 #ifdef CONFIG_SYSCTL_SYSCALL
1305 static int parse_table(int __user *name, int nlen,
1306                        void __user *oldval, size_t __user *oldlenp,
1307                        void __user *newval, size_t newlen,
1308                        ctl_table *table)
1309 {
1310         int n;
1311 repeat:
1312         if (!nlen)
1313                 return -ENOTDIR;
1314         if (get_user(n, name))
1315                 return -EFAULT;
1316         for ( ; table->ctl_name || table->procname; table++) {
1317                 if (!table->ctl_name)
1318                         continue;
1319                 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1320                         int error;
1321                         if (table->child) {
1322                                 if (ctl_perm(table, 001))
1323                                         return -EPERM;
1324                                 if (table->strategy) {
1325                                         error = table->strategy(
1326                                                 table, name, nlen,
1327                                                 oldval, oldlenp,
1328                                                 newval, newlen);
1329                                         if (error)
1330                                                 return error;
1331                                 }
1332                                 name++;
1333                                 nlen--;
1334                                 table = table->child;
1335                                 goto repeat;
1336                         }
1337                         error = do_sysctl_strategy(table, name, nlen,
1338                                                    oldval, oldlenp,
1339                                                    newval, newlen);
1340                         return error;
1341                 }
1342         }
1343         return -ENOTDIR;
1344 }
1345
1346 /* Perform the actual read/write of a sysctl table entry. */
1347 int do_sysctl_strategy (ctl_table *table, 
1348                         int __user *name, int nlen,
1349                         void __user *oldval, size_t __user *oldlenp,
1350                         void __user *newval, size_t newlen)
1351 {
1352         int op = 0, rc;
1353         size_t len;
1354
1355         if (oldval)
1356                 op |= 004;
1357         if (newval) 
1358                 op |= 002;
1359         if (ctl_perm(table, op))
1360                 return -EPERM;
1361
1362         if (table->strategy) {
1363                 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1364                                      newval, newlen);
1365                 if (rc < 0)
1366                         return rc;
1367                 if (rc > 0)
1368                         return 0;
1369         }
1370
1371         /* If there is no strategy routine, or if the strategy returns
1372          * zero, proceed with automatic r/w */
1373         if (table->data && table->maxlen) {
1374                 if (oldval && oldlenp) {
1375                         if (get_user(len, oldlenp))
1376                                 return -EFAULT;
1377                         if (len) {
1378                                 if (len > table->maxlen)
1379                                         len = table->maxlen;
1380                                 if(copy_to_user(oldval, table->data, len))
1381                                         return -EFAULT;
1382                                 if(put_user(len, oldlenp))
1383                                         return -EFAULT;
1384                         }
1385                 }
1386                 if (newval && newlen) {
1387                         len = newlen;
1388                         if (len > table->maxlen)
1389                                 len = table->maxlen;
1390                         if(copy_from_user(table->data, newval, len))
1391                                 return -EFAULT;
1392                 }
1393         }
1394         return 0;
1395 }
1396 #endif /* CONFIG_SYSCTL_SYSCALL */
1397
1398 /**
1399  * register_sysctl_table - register a sysctl hierarchy
1400  * @table: the top-level table structure
1401  * @insert_at_head: whether the entry should be inserted in front or at the end
1402  *
1403  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1404  * array. An entry with a ctl_name of 0 terminates the table. 
1405  *
1406  * The members of the &ctl_table structure are used as follows:
1407  *
1408  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1409  *            must be unique within that level of sysctl
1410  *
1411  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1412  *            enter a sysctl file
1413  *
1414  * data - a pointer to data for use by proc_handler
1415  *
1416  * maxlen - the maximum size in bytes of the data
1417  *
1418  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1419  *
1420  * child - a pointer to the child sysctl table if this entry is a directory, or
1421  *         %NULL.
1422  *
1423  * proc_handler - the text handler routine (described below)
1424  *
1425  * strategy - the strategy routine (described below)
1426  *
1427  * de - for internal use by the sysctl routines
1428  *
1429  * extra1, extra2 - extra pointers usable by the proc handler routines
1430  *
1431  * Leaf nodes in the sysctl tree will be represented by a single file
1432  * under /proc; non-leaf nodes will be represented by directories.
1433  *
1434  * sysctl(2) can automatically manage read and write requests through
1435  * the sysctl table.  The data and maxlen fields of the ctl_table
1436  * struct enable minimal validation of the values being written to be
1437  * performed, and the mode field allows minimal authentication.
1438  *
1439  * More sophisticated management can be enabled by the provision of a
1440  * strategy routine with the table entry.  This will be called before
1441  * any automatic read or write of the data is performed.
1442  *
1443  * The strategy routine may return
1444  *
1445  * < 0 - Error occurred (error is passed to user process)
1446  *
1447  * 0   - OK - proceed with automatic read or write.
1448  *
1449  * > 0 - OK - read or write has been done by the strategy routine, so
1450  *       return immediately.
1451  *
1452  * There must be a proc_handler routine for any terminal nodes
1453  * mirrored under /proc/sys (non-terminals are handled by a built-in
1454  * directory handler).  Several default handlers are available to
1455  * cover common cases -
1456  *
1457  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1458  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 
1459  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1460  *
1461  * It is the handler's job to read the input buffer from user memory
1462  * and process it. The handler should return 0 on success.
1463  *
1464  * This routine returns %NULL on a failure to register, and a pointer
1465  * to the table header on success.
1466  */
1467 struct ctl_table_header *register_sysctl_table(ctl_table * table, 
1468                                                int insert_at_head)
1469 {
1470         struct ctl_table_header *tmp;
1471         tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1472         if (!tmp)
1473                 return NULL;
1474         tmp->ctl_table = table;
1475         INIT_LIST_HEAD(&tmp->ctl_entry);
1476         tmp->used = 0;
1477         tmp->unregistering = NULL;
1478         spin_lock(&sysctl_lock);
1479         if (insert_at_head)
1480                 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1481         else
1482                 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1483         spin_unlock(&sysctl_lock);
1484 #ifdef CONFIG_PROC_SYSCTL
1485         register_proc_table(table, proc_sys_root, tmp);
1486 #endif
1487         return tmp;
1488 }
1489
1490 /**
1491  * unregister_sysctl_table - unregister a sysctl table hierarchy
1492  * @header: the header returned from register_sysctl_table
1493  *
1494  * Unregisters the sysctl table and all children. proc entries may not
1495  * actually be removed until they are no longer used by anyone.
1496  */
1497 void unregister_sysctl_table(struct ctl_table_header * header)
1498 {
1499         might_sleep();
1500         spin_lock(&sysctl_lock);
1501         start_unregistering(header);
1502 #ifdef CONFIG_PROC_SYSCTL
1503         unregister_proc_table(header->ctl_table, proc_sys_root);
1504 #endif
1505         spin_unlock(&sysctl_lock);
1506         kfree(header);
1507 }
1508
1509 #else /* !CONFIG_SYSCTL */
1510 struct ctl_table_header * register_sysctl_table(ctl_table * table,
1511                                                 int insert_at_head)
1512 {
1513         return NULL;
1514 }
1515
1516 void unregister_sysctl_table(struct ctl_table_header * table)
1517 {
1518 }
1519
1520 #endif /* CONFIG_SYSCTL */
1521
1522 /*
1523  * /proc/sys support
1524  */
1525
1526 #ifdef CONFIG_PROC_SYSCTL
1527
1528 /* Scan the sysctl entries in table and add them all into /proc */
1529 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
1530 {
1531         struct proc_dir_entry *de;
1532         int len;
1533         mode_t mode;
1534         
1535         for (; table->ctl_name || table->procname; table++) {
1536                 /* Can't do anything without a proc name. */
1537                 if (!table->procname)
1538                         continue;
1539                 /* Maybe we can't do anything with it... */
1540                 if (!table->proc_handler && !table->child) {
1541                         printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1542                                 table->procname);
1543                         continue;
1544                 }
1545
1546                 len = strlen(table->procname);
1547                 mode = table->mode;
1548
1549                 de = NULL;
1550                 if (table->proc_handler)
1551                         mode |= S_IFREG;
1552                 else {
1553                         mode |= S_IFDIR;
1554                         for (de = root->subdir; de; de = de->next) {
1555                                 if (proc_match(len, table->procname, de))
1556                                         break;
1557                         }
1558                         /* If the subdir exists already, de is non-NULL */
1559                 }
1560
1561                 if (!de) {
1562                         de = create_proc_entry(table->procname, mode, root);
1563                         if (!de)
1564                                 continue;
1565                         de->set = set;
1566                         de->data = (void *) table;
1567                         if (table->proc_handler)
1568                                 de->proc_fops = &proc_sys_file_operations;
1569                 }
1570                 table->de = de;
1571                 if (de->mode & S_IFDIR)
1572                         register_proc_table(table->child, de, set);
1573         }
1574 }
1575
1576 /*
1577  * Unregister a /proc sysctl table and any subdirectories.
1578  */
1579 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1580 {
1581         struct proc_dir_entry *de;
1582         for (; table->ctl_name || table->procname; table++) {
1583                 if (!(de = table->de))
1584                         continue;
1585                 if (de->mode & S_IFDIR) {
1586                         if (!table->child) {
1587                                 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1588                                 continue;
1589                         }
1590                         unregister_proc_table(table->child, de);
1591
1592                         /* Don't unregister directories which still have entries.. */
1593                         if (de->subdir)
1594                                 continue;
1595                 }
1596
1597                 /*
1598                  * In any case, mark the entry as goner; we'll keep it
1599                  * around if it's busy, but we'll know to do nothing with
1600                  * its fields.  We are under sysctl_lock here.
1601                  */
1602                 de->data = NULL;
1603
1604                 /* Don't unregister proc entries that are still being used.. */
1605                 if (atomic_read(&de->count))
1606                         continue;
1607
1608                 table->de = NULL;
1609                 remove_proc_entry(table->procname, root);
1610         }
1611 }
1612
1613 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1614                           size_t count, loff_t *ppos)
1615 {
1616         int op;
1617         struct proc_dir_entry *de = PDE(file->f_path.dentry->d_inode);
1618         struct ctl_table *table;
1619         size_t res;
1620         ssize_t error = -ENOTDIR;
1621         
1622         spin_lock(&sysctl_lock);
1623         if (de && de->data && use_table(de->set)) {
1624                 /*
1625                  * at that point we know that sysctl was not unregistered
1626                  * and won't be until we finish
1627                  */
1628                 spin_unlock(&sysctl_lock);
1629                 table = (struct ctl_table *) de->data;
1630                 if (!table || !table->proc_handler)
1631                         goto out;
1632                 error = -EPERM;
1633                 op = (write ? 002 : 004);
1634                 if (ctl_perm(table, op))
1635                         goto out;
1636                 
1637                 /* careful: calling conventions are nasty here */
1638                 res = count;
1639                 error = (*table->proc_handler)(table, write, file,
1640                                                 buf, &res, ppos);
1641                 if (!error)
1642                         error = res;
1643         out:
1644                 spin_lock(&sysctl_lock);
1645                 unuse_table(de->set);
1646         }
1647         spin_unlock(&sysctl_lock);
1648         return error;
1649 }
1650
1651 static int proc_opensys(struct inode *inode, struct file *file)
1652 {
1653         if (file->f_mode & FMODE_WRITE) {
1654                 /*
1655                  * sysctl entries that are not writable,
1656                  * are _NOT_ writable, capabilities or not.
1657                  */
1658                 if (!(inode->i_mode & S_IWUSR))
1659                         return -EPERM;
1660         }
1661
1662         return 0;
1663 }
1664
1665 static ssize_t proc_readsys(struct file * file, char __user * buf,
1666                             size_t count, loff_t *ppos)
1667 {
1668         return do_rw_proc(0, file, buf, count, ppos);
1669 }
1670
1671 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1672                              size_t count, loff_t *ppos)
1673 {
1674         return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1675 }
1676
1677 static int _proc_do_string(void* data, int maxlen, int write,
1678                            struct file *filp, void __user *buffer,
1679                            size_t *lenp, loff_t *ppos)
1680 {
1681         size_t len;
1682         char __user *p;
1683         char c;
1684         
1685         if (!data || !maxlen || !*lenp ||
1686             (*ppos && !write)) {
1687                 *lenp = 0;
1688                 return 0;
1689         }
1690         
1691         if (write) {
1692                 len = 0;
1693                 p = buffer;
1694                 while (len < *lenp) {
1695                         if (get_user(c, p++))
1696                                 return -EFAULT;
1697                         if (c == 0 || c == '\n')
1698                                 break;
1699                         len++;
1700                 }
1701                 if (len >= maxlen)
1702                         len = maxlen-1;
1703                 if(copy_from_user(data, buffer, len))
1704                         return -EFAULT;
1705                 ((char *) data)[len] = 0;
1706                 *ppos += *lenp;
1707         } else {
1708                 len = strlen(data);
1709                 if (len > maxlen)
1710                         len = maxlen;
1711                 if (len > *lenp)
1712                         len = *lenp;
1713                 if (len)
1714                         if(copy_to_user(buffer, data, len))
1715                                 return -EFAULT;
1716                 if (len < *lenp) {
1717                         if(put_user('\n', ((char __user *) buffer) + len))
1718                                 return -EFAULT;
1719                         len++;
1720                 }
1721                 *lenp = len;
1722                 *ppos += len;
1723         }
1724         return 0;
1725 }
1726
1727 /**
1728  * proc_dostring - read a string sysctl
1729  * @table: the sysctl table
1730  * @write: %TRUE if this is a write to the sysctl file
1731  * @filp: the file structure
1732  * @buffer: the user buffer
1733  * @lenp: the size of the user buffer
1734  * @ppos: file position
1735  *
1736  * Reads/writes a string from/to the user buffer. If the kernel
1737  * buffer provided is not large enough to hold the string, the
1738  * string is truncated. The copied string is %NULL-terminated.
1739  * If the string is being read by the user process, it is copied
1740  * and a newline '\n' is added. It is truncated if the buffer is
1741  * not large enough.
1742  *
1743  * Returns 0 on success.
1744  */
1745 int proc_dostring(ctl_table *table, int write, struct file *filp,
1746                   void __user *buffer, size_t *lenp, loff_t *ppos)
1747 {
1748         return _proc_do_string(table->data, table->maxlen, write, filp,
1749                                buffer, lenp, ppos);
1750 }
1751
1752 /*
1753  *      Special case of dostring for the UTS structure. This has locks
1754  *      to observe. Should this be in kernel/sys.c ????
1755  */
1756
1757 static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
1758                   void __user *buffer, size_t *lenp, loff_t *ppos)
1759 {
1760         int r;
1761         void *which;
1762         which = get_uts(table, write);
1763         r = _proc_do_string(which, table->maxlen,write,filp,buffer,lenp, ppos);
1764         put_uts(table, write, which);
1765         return r;
1766 }
1767
1768 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1769                                  int *valp,
1770                                  int write, void *data)
1771 {
1772         if (write) {
1773                 *valp = *negp ? -*lvalp : *lvalp;
1774         } else {
1775                 int val = *valp;
1776                 if (val < 0) {
1777                         *negp = -1;
1778                         *lvalp = (unsigned long)-val;
1779                 } else {
1780                         *negp = 0;
1781                         *lvalp = (unsigned long)val;
1782                 }
1783         }
1784         return 0;
1785 }
1786
1787 static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
1788                   int write, struct file *filp, void __user *buffer,
1789                   size_t *lenp, loff_t *ppos,
1790                   int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1791                               int write, void *data),
1792                   void *data)
1793 {
1794 #define TMPBUFLEN 21
1795         int *i, vleft, first=1, neg, val;
1796         unsigned long lval;
1797         size_t left, len;
1798         
1799         char buf[TMPBUFLEN], *p;
1800         char __user *s = buffer;
1801         
1802         if (!tbl_data || !table->maxlen || !*lenp ||
1803             (*ppos && !write)) {
1804                 *lenp = 0;
1805                 return 0;
1806         }
1807         
1808         i = (int *) tbl_data;
1809         vleft = table->maxlen / sizeof(*i);
1810         left = *lenp;
1811
1812         if (!conv)
1813                 conv = do_proc_dointvec_conv;
1814
1815         for (; left && vleft--; i++, first=0) {
1816                 if (write) {
1817                         while (left) {
1818                                 char c;
1819                                 if (get_user(c, s))
1820                                         return -EFAULT;
1821                                 if (!isspace(c))
1822                                         break;
1823                                 left--;
1824                                 s++;
1825                         }
1826                         if (!left)
1827                                 break;
1828                         neg = 0;
1829                         len = left;
1830                         if (len > sizeof(buf) - 1)
1831                                 len = sizeof(buf) - 1;
1832                         if (copy_from_user(buf, s, len))
1833                                 return -EFAULT;
1834                         buf[len] = 0;
1835                         p = buf;
1836                         if (*p == '-' && left > 1) {
1837                                 neg = 1;
1838                                 p++;
1839                         }
1840                         if (*p < '0' || *p > '9')
1841                                 break;
1842
1843                         lval = simple_strtoul(p, &p, 0);
1844
1845                         len = p-buf;
1846                         if ((len < left) && *p && !isspace(*p))
1847                                 break;
1848                         if (neg)
1849                                 val = -val;
1850                         s += len;
1851                         left -= len;
1852
1853                         if (conv(&neg, &lval, i, 1, data))
1854                                 break;
1855                 } else {
1856                         p = buf;
1857                         if (!first)
1858                                 *p++ = '\t';
1859         
1860                         if (conv(&neg, &lval, i, 0, data))
1861                                 break;
1862
1863                         sprintf(p, "%s%lu", neg ? "-" : "", lval);
1864                         len = strlen(buf);
1865                         if (len > left)
1866                                 len = left;
1867                         if(copy_to_user(s, buf, len))
1868                                 return -EFAULT;
1869                         left -= len;
1870                         s += len;
1871                 }
1872         }
1873
1874         if (!write && !first && left) {
1875                 if(put_user('\n', s))
1876                         return -EFAULT;
1877                 left--, s++;
1878         }
1879         if (write) {
1880                 while (left) {
1881                         char c;
1882                         if (get_user(c, s++))
1883                                 return -EFAULT;
1884                         if (!isspace(c))
1885                                 break;
1886                         left--;
1887                 }
1888         }
1889         if (write && first)
1890                 return -EINVAL;
1891         *lenp -= left;
1892         *ppos += *lenp;
1893         return 0;
1894 #undef TMPBUFLEN
1895 }
1896
1897 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1898                   void __user *buffer, size_t *lenp, loff_t *ppos,
1899                   int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1900                               int write, void *data),
1901                   void *data)
1902 {
1903         return __do_proc_dointvec(table->data, table, write, filp,
1904                         buffer, lenp, ppos, conv, data);
1905 }
1906
1907 /**
1908  * proc_dointvec - read a vector of integers
1909  * @table: the sysctl table
1910  * @write: %TRUE if this is a write to the sysctl file
1911  * @filp: the file structure
1912  * @buffer: the user buffer
1913  * @lenp: the size of the user buffer
1914  * @ppos: file position
1915  *
1916  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1917  * values from/to the user buffer, treated as an ASCII string. 
1918  *
1919  * Returns 0 on success.
1920  */
1921 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1922                      void __user *buffer, size_t *lenp, loff_t *ppos)
1923 {
1924     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1925                             NULL,NULL);
1926 }
1927
1928 #define OP_SET  0
1929 #define OP_AND  1
1930
1931 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1932                                       int *valp,
1933                                       int write, void *data)
1934 {
1935         int op = *(int *)data;
1936         if (write) {
1937                 int val = *negp ? -*lvalp : *lvalp;
1938                 switch(op) {
1939                 case OP_SET:    *valp = val; break;
1940                 case OP_AND:    *valp &= val; break;
1941                 }
1942         } else {
1943                 int val = *valp;
1944                 if (val < 0) {
1945                         *negp = -1;
1946                         *lvalp = (unsigned long)-val;
1947                 } else {
1948                         *negp = 0;
1949                         *lvalp = (unsigned long)val;
1950                 }
1951         }
1952         return 0;
1953 }
1954
1955 /*
1956  *      init may raise the set.
1957  */
1958  
1959 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1960                         void __user *buffer, size_t *lenp, loff_t *ppos)
1961 {
1962         int op;
1963
1964         if (!capable(CAP_SYS_MODULE)) {
1965                 return -EPERM;
1966         }
1967
1968         op = is_init(current) ? OP_SET : OP_AND;
1969         return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1970                                 do_proc_dointvec_bset_conv,&op);
1971 }
1972
1973 struct do_proc_dointvec_minmax_conv_param {
1974         int *min;
1975         int *max;
1976 };
1977
1978 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 
1979                                         int *valp, 
1980                                         int write, void *data)
1981 {
1982         struct do_proc_dointvec_minmax_conv_param *param = data;
1983         if (write) {
1984                 int val = *negp ? -*lvalp : *lvalp;
1985                 if ((param->min && *param->min > val) ||
1986                     (param->max && *param->max < val))
1987                         return -EINVAL;
1988                 *valp = val;
1989         } else {
1990                 int val = *valp;
1991                 if (val < 0) {
1992                         *negp = -1;
1993                         *lvalp = (unsigned long)-val;
1994                 } else {
1995                         *negp = 0;
1996                         *lvalp = (unsigned long)val;
1997                 }
1998         }
1999         return 0;
2000 }
2001
2002 /**
2003  * proc_dointvec_minmax - read a vector of integers with min/max values
2004  * @table: the sysctl table
2005  * @write: %TRUE if this is a write to the sysctl file
2006  * @filp: the file structure
2007  * @buffer: the user buffer
2008  * @lenp: the size of the user buffer
2009  * @ppos: file position
2010  *
2011  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2012  * values from/to the user buffer, treated as an ASCII string.
2013  *
2014  * This routine will ensure the values are within the range specified by
2015  * table->extra1 (min) and table->extra2 (max).
2016  *
2017  * Returns 0 on success.
2018  */
2019 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2020                   void __user *buffer, size_t *lenp, loff_t *ppos)
2021 {
2022         struct do_proc_dointvec_minmax_conv_param param = {
2023                 .min = (int *) table->extra1,
2024                 .max = (int *) table->extra2,
2025         };
2026         return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2027                                 do_proc_dointvec_minmax_conv, &param);
2028 }
2029
2030 static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
2031                                      struct file *filp,
2032                                      void __user *buffer,
2033                                      size_t *lenp, loff_t *ppos,
2034                                      unsigned long convmul,
2035                                      unsigned long convdiv)
2036 {
2037 #define TMPBUFLEN 21
2038         unsigned long *i, *min, *max, val;
2039         int vleft, first=1, neg;
2040         size_t len, left;
2041         char buf[TMPBUFLEN], *p;
2042         char __user *s = buffer;
2043         
2044         if (!data || !table->maxlen || !*lenp ||
2045             (*ppos && !write)) {
2046                 *lenp = 0;
2047                 return 0;
2048         }
2049         
2050         i = (unsigned long *) data;
2051         min = (unsigned long *) table->extra1;
2052         max = (unsigned long *) table->extra2;
2053         vleft = table->maxlen / sizeof(unsigned long);
2054         left = *lenp;
2055         
2056         for (; left && vleft--; i++, min++, max++, first=0) {
2057                 if (write) {
2058                         while (left) {
2059                                 char c;
2060                                 if (get_user(c, s))
2061                                         return -EFAULT;
2062                                 if (!isspace(c))
2063                                         break;
2064                                 left--;
2065                                 s++;
2066                         }
2067                         if (!left)
2068                                 break;
2069                         neg = 0;
2070                         len = left;
2071                         if (len > TMPBUFLEN-1)
2072                                 len = TMPBUFLEN-1;
2073                         if (copy_from_user(buf, s, len))
2074                                 return -EFAULT;
2075                         buf[len] = 0;
2076                         p = buf;
2077                         if (*p == '-' && left > 1) {
2078                                 neg = 1;
2079                                 p++;
2080                         }
2081                         if (*p < '0' || *p > '9')
2082                                 break;
2083                         val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2084                         len = p-buf;
2085                         if ((len < left) && *p && !isspace(*p))
2086                                 break;
2087                         if (neg)
2088                                 val = -val;
2089                         s += len;
2090                         left -= len;
2091
2092                         if(neg)
2093                                 continue;
2094                         if ((min && val < *min) || (max && val > *max))
2095                                 continue;
2096                         *i = val;
2097                 } else {
2098                         p = buf;
2099                         if (!first)
2100                                 *p++ = '\t';
2101                         sprintf(p, "%lu", convdiv * (*i) / convmul);
2102                         len = strlen(buf);
2103                         if (len > left)
2104                                 len = left;
2105                         if(copy_to_user(s, buf, len))
2106                                 return -EFAULT;
2107                         left -= len;
2108                         s += len;
2109                 }
2110         }
2111
2112         if (!write && !first && left) {
2113                 if(put_user('\n', s))
2114                         return -EFAULT;
2115                 left--, s++;
2116         }
2117         if (write) {
2118                 while (left) {
2119                         char c;
2120                         if (get_user(c, s++))
2121                                 return -EFAULT;
2122                         if (!isspace(c))
2123                                 break;
2124                         left--;
2125                 }
2126         }
2127         if (write && first)
2128                 return -EINVAL;
2129         *lenp -= left;
2130         *ppos += *lenp;
2131         return 0;
2132 #undef TMPBUFLEN
2133 }
2134
2135 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
2136                                      struct file *filp,
2137                                      void __user *buffer,
2138                                      size_t *lenp, loff_t *ppos,
2139                                      unsigned long convmul,
2140                                      unsigned long convdiv)
2141 {
2142         return __do_proc_doulongvec_minmax(table->data, table, write,
2143                         filp, buffer, lenp, ppos, convmul, convdiv);
2144 }
2145
2146 /**
2147  * proc_doulongvec_minmax - read a vector of long integers with min/max values
2148  * @table: the sysctl table
2149  * @write: %TRUE if this is a write to the sysctl file
2150  * @filp: the file structure
2151  * @buffer: the user buffer
2152  * @lenp: the size of the user buffer
2153  * @ppos: file position
2154  *
2155  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2156  * values from/to the user buffer, treated as an ASCII string.
2157  *
2158  * This routine will ensure the values are within the range specified by
2159  * table->extra1 (min) and table->extra2 (max).
2160  *
2161  * Returns 0 on success.
2162  */
2163 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2164                            void __user *buffer, size_t *lenp, loff_t *ppos)
2165 {
2166     return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2167 }
2168
2169 /**
2170  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2171  * @table: the sysctl table
2172  * @write: %TRUE if this is a write to the sysctl file
2173  * @filp: the file structure
2174  * @buffer: the user buffer
2175  * @lenp: the size of the user buffer
2176  * @ppos: file position
2177  *
2178  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2179  * values from/to the user buffer, treated as an ASCII string. The values
2180  * are treated as milliseconds, and converted to jiffies when they are stored.
2181  *
2182  * This routine will ensure the values are within the range specified by
2183  * table->extra1 (min) and table->extra2 (max).
2184  *
2185  * Returns 0 on success.
2186  */
2187 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2188                                       struct file *filp,
2189                                       void __user *buffer,
2190                                       size_t *lenp, loff_t *ppos)
2191 {
2192     return do_proc_doulongvec_minmax(table, write, filp, buffer,
2193                                      lenp, ppos, HZ, 1000l);
2194 }
2195
2196
2197 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2198                                          int *valp,
2199                                          int write, void *data)
2200 {
2201         if (write) {
2202                 if (*lvalp > LONG_MAX / HZ)
2203                         return 1;
2204                 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2205         } else {
2206                 int val = *valp;
2207                 unsigned long lval;
2208                 if (val < 0) {
2209                         *negp = -1;
2210                         lval = (unsigned long)-val;
2211                 } else {
2212                         *negp = 0;
2213                         lval = (unsigned long)val;
2214                 }
2215                 *lvalp = lval / HZ;
2216         }
2217         return 0;
2218 }
2219
2220 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2221                                                 int *valp,
2222                                                 int write, void *data)
2223 {
2224         if (write) {
2225                 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2226                         return 1;
2227                 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2228         } else {
2229                 int val = *valp;
2230                 unsigned long lval;
2231                 if (val < 0) {
2232                         *negp = -1;
2233                         lval = (unsigned long)-val;
2234                 } else {
2235                         *negp = 0;
2236                         lval = (unsigned long)val;
2237                 }
2238                 *lvalp = jiffies_to_clock_t(lval);
2239         }
2240         return 0;
2241 }
2242
2243 static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2244                                             int *valp,
2245                                             int write, void *data)
2246 {
2247         if (write) {
2248                 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2249         } else {
2250                 int val = *valp;
2251                 unsigned long lval;
2252                 if (val < 0) {
2253                         *negp = -1;
2254                         lval = (unsigned long)-val;
2255                 } else {
2256                         *negp = 0;
2257                         lval = (unsigned long)val;
2258                 }
2259                 *lvalp = jiffies_to_msecs(lval);
2260         }
2261         return 0;
2262 }
2263
2264 /**
2265  * proc_dointvec_jiffies - read a vector of integers as seconds
2266  * @table: the sysctl table
2267  * @write: %TRUE if this is a write to the sysctl file
2268  * @filp: the file structure
2269  * @buffer: the user buffer
2270  * @lenp: the size of the user buffer
2271  * @ppos: file position
2272  *
2273  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2274  * values from/to the user buffer, treated as an ASCII string. 
2275  * The values read are assumed to be in seconds, and are converted into
2276  * jiffies.
2277  *
2278  * Returns 0 on success.
2279  */
2280 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2281                           void __user *buffer, size_t *lenp, loff_t *ppos)
2282 {
2283     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2284                             do_proc_dointvec_jiffies_conv,NULL);
2285 }
2286
2287 /**
2288  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2289  * @table: the sysctl table
2290  * @write: %TRUE if this is a write to the sysctl file
2291  * @filp: the file structure
2292  * @buffer: the user buffer
2293  * @lenp: the size of the user buffer
2294  * @ppos: pointer to the file position
2295  *
2296  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2297  * values from/to the user buffer, treated as an ASCII string. 
2298  * The values read are assumed to be in 1/USER_HZ seconds, and 
2299  * are converted into jiffies.
2300  *
2301  * Returns 0 on success.
2302  */
2303 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2304                                  void __user *buffer, size_t *lenp, loff_t *ppos)
2305 {
2306     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2307                             do_proc_dointvec_userhz_jiffies_conv,NULL);
2308 }
2309
2310 /**
2311  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2312  * @table: the sysctl table
2313  * @write: %TRUE if this is a write to the sysctl file
2314  * @filp: the file structure
2315  * @buffer: the user buffer
2316  * @lenp: the size of the user buffer
2317  * @ppos: file position
2318  * @ppos: the current position in the file
2319  *
2320  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2321  * values from/to the user buffer, treated as an ASCII string. 
2322  * The values read are assumed to be in 1/1000 seconds, and 
2323  * are converted into jiffies.
2324  *
2325  * Returns 0 on success.
2326  */
2327 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2328                              void __user *buffer, size_t *lenp, loff_t *ppos)
2329 {
2330         return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2331                                 do_proc_dointvec_ms_jiffies_conv, NULL);
2332 }
2333
2334 #ifdef CONFIG_SYSVIPC
2335 static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
2336         void __user *buffer, size_t *lenp, loff_t *ppos)
2337 {
2338         void *which;
2339         which = get_ipc(table, write);
2340         return __do_proc_dointvec(which, table, write, filp, buffer,
2341                         lenp, ppos, NULL, NULL);
2342 }
2343
2344 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
2345         struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
2346 {
2347         void *which;
2348         which = get_ipc(table, write);
2349         return __do_proc_doulongvec_minmax(which, table, write, filp, buffer,
2350                         lenp, ppos, 1l, 1l);
2351 }
2352
2353 #endif
2354
2355 static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
2356                            void __user *buffer, size_t *lenp, loff_t *ppos)
2357 {
2358         struct pid *new_pid;
2359         pid_t tmp;
2360         int r;
2361
2362         tmp = pid_nr(cad_pid);
2363
2364         r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2365                                lenp, ppos, NULL, NULL);
2366         if (r || !write)
2367                 return r;
2368
2369         new_pid = find_get_pid(tmp);
2370         if (!new_pid)
2371                 return -ESRCH;
2372
2373         put_pid(xchg(&cad_pid, new_pid));
2374         return 0;
2375 }
2376
2377 #else /* CONFIG_PROC_FS */
2378
2379 int proc_dostring(ctl_table *table, int write, struct file *filp,
2380                   void __user *buffer, size_t *lenp, loff_t *ppos)
2381 {
2382         return -ENOSYS;
2383 }
2384
2385 static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
2386                 void __user *buffer, size_t *lenp, loff_t *ppos)
2387 {
2388         return -ENOSYS;
2389 }
2390
2391 #ifdef CONFIG_SYSVIPC
2392 static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
2393                 void __user *buffer, size_t *lenp, loff_t *ppos)
2394 {
2395         return -ENOSYS;
2396 }
2397 static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
2398                 void __user *buffer, size_t *lenp, loff_t *ppos)
2399 {
2400         return -ENOSYS;
2401 }
2402 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
2403                 struct file *filp, void __user *buffer,
2404                 size_t *lenp, loff_t *ppos)
2405 {
2406         return -ENOSYS;
2407 }
2408 #endif
2409
2410 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2411                   void __user *buffer, size_t *lenp, loff_t *ppos)
2412 {
2413         return -ENOSYS;
2414 }
2415
2416 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2417                         void __user *buffer, size_t *lenp, loff_t *ppos)
2418 {
2419         return -ENOSYS;
2420 }
2421
2422 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2423                     void __user *buffer, size_t *lenp, loff_t *ppos)
2424 {
2425         return -ENOSYS;
2426 }
2427
2428 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2429                     void __user *buffer, size_t *lenp, loff_t *ppos)
2430 {
2431         return -ENOSYS;
2432 }
2433
2434 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2435                     void __user *buffer, size_t *lenp, loff_t *ppos)
2436 {
2437         return -ENOSYS;
2438 }
2439
2440 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2441                              void __user *buffer, size_t *lenp, loff_t *ppos)
2442 {
2443         return -ENOSYS;
2444 }
2445
2446 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2447                     void __user *buffer, size_t *lenp, loff_t *ppos)
2448 {
2449         return -ENOSYS;
2450 }
2451
2452 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2453                                       struct file *filp,
2454                                       void __user *buffer,
2455                                       size_t *lenp, loff_t *ppos)
2456 {
2457     return -ENOSYS;
2458 }
2459
2460
2461 #endif /* CONFIG_PROC_FS */
2462
2463
2464 #ifdef CONFIG_SYSCTL_SYSCALL
2465 /*
2466  * General sysctl support routines 
2467  */
2468
2469 /* The generic string strategy routine: */
2470 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2471                   void __user *oldval, size_t __user *oldlenp,
2472                   void __user *newval, size_t newlen)
2473 {
2474         if (!table->data || !table->maxlen) 
2475                 return -ENOTDIR;
2476         
2477         if (oldval && oldlenp) {
2478                 size_t bufsize;
2479                 if (get_user(bufsize, oldlenp))
2480                         return -EFAULT;
2481                 if (bufsize) {
2482                         size_t len = strlen(table->data), copied;
2483
2484                         /* This shouldn't trigger for a well-formed sysctl */
2485                         if (len > table->maxlen)
2486                                 len = table->maxlen;
2487
2488                         /* Copy up to a max of bufsize-1 bytes of the string */
2489                         copied = (len >= bufsize) ? bufsize - 1 : len;
2490
2491                         if (copy_to_user(oldval, table->data, copied) ||
2492                             put_user(0, (char __user *)(oldval + copied)))
2493                                 return -EFAULT;
2494                         if (put_user(len, oldlenp))
2495                                 return -EFAULT;
2496                 }
2497         }
2498         if (newval && newlen) {
2499                 size_t len = newlen;
2500                 if (len > table->maxlen)
2501                         len = table->maxlen;
2502                 if(copy_from_user(table->data, newval, len))
2503                         return -EFAULT;
2504                 if (len == table->maxlen)
2505                         len--;
2506                 ((char *) table->data)[len] = 0;
2507         }
2508         return 1;
2509 }
2510
2511 /*
2512  * This function makes sure that all of the integers in the vector
2513  * are between the minimum and maximum values given in the arrays
2514  * table->extra1 and table->extra2, respectively.
2515  */
2516 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2517                 void __user *oldval, size_t __user *oldlenp,
2518                 void __user *newval, size_t newlen)
2519 {
2520
2521         if (newval && newlen) {
2522                 int __user *vec = (int __user *) newval;
2523                 int *min = (int *) table->extra1;
2524                 int *max = (int *) table->extra2;
2525                 size_t length;
2526                 int i;
2527
2528                 if (newlen % sizeof(int) != 0)
2529                         return -EINVAL;
2530
2531                 if (!table->extra1 && !table->extra2)
2532                         return 0;
2533
2534                 if (newlen > table->maxlen)
2535                         newlen = table->maxlen;
2536                 length = newlen / sizeof(int);
2537
2538                 for (i = 0; i < length; i++) {
2539                         int value;
2540                         if (get_user(value, vec + i))
2541                                 return -EFAULT;
2542                         if (min && value < min[i])
2543                                 return -EINVAL;
2544                         if (max && value > max[i])
2545                                 return -EINVAL;
2546                 }
2547         }
2548         return 0;
2549 }
2550
2551 /* Strategy function to convert jiffies to seconds */ 
2552 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2553                 void __user *oldval, size_t __user *oldlenp,
2554                 void __user *newval, size_t newlen)
2555 {
2556         if (oldval) {
2557                 size_t olen;
2558                 if (oldlenp) { 
2559                         if (get_user(olen, oldlenp))
2560                                 return -EFAULT;
2561                         if (olen!=sizeof(int))
2562                                 return -EINVAL; 
2563                 }
2564                 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2565                     (oldlenp && put_user(sizeof(int),oldlenp)))
2566                         return -EFAULT;
2567         }
2568         if (newval && newlen) { 
2569                 int new;
2570                 if (newlen != sizeof(int))
2571                         return -EINVAL; 
2572                 if (get_user(new, (int __user *)newval))
2573                         return -EFAULT;
2574                 *(int *)(table->data) = new*HZ; 
2575         }
2576         return 1;
2577 }
2578
2579 /* Strategy function to convert jiffies to seconds */ 
2580 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2581                 void __user *oldval, size_t __user *oldlenp,
2582                 void __user *newval, size_t newlen)
2583 {
2584         if (oldval) {
2585                 size_t olen;
2586                 if (oldlenp) { 
2587                         if (get_user(olen, oldlenp))
2588                                 return -EFAULT;
2589                         if (olen!=sizeof(int))
2590                                 return -EINVAL; 
2591                 }
2592                 if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
2593                     (oldlenp && put_user(sizeof(int),oldlenp)))
2594                         return -EFAULT;
2595         }
2596         if (newval && newlen) { 
2597                 int new;
2598                 if (newlen != sizeof(int))
2599                         return -EINVAL; 
2600                 if (get_user(new, (int __user *)newval))
2601                         return -EFAULT;
2602                 *(int *)(table->data) = msecs_to_jiffies(new);
2603         }
2604         return 1;
2605 }
2606
2607
2608 /* The generic string strategy routine: */
2609 static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2610                   void __user *oldval, size_t __user *oldlenp,
2611                   void __user *newval, size_t newlen)
2612 {
2613         struct ctl_table uts_table;
2614         int r, write;
2615         write = newval && newlen;
2616         memcpy(&uts_table, table, sizeof(uts_table));
2617         uts_table.data = get_uts(table, write);
2618         r = sysctl_string(&uts_table, name, nlen,
2619                 oldval, oldlenp, newval, newlen);
2620         put_uts(table, write, uts_table.data);
2621         return r;
2622 }
2623
2624 #ifdef CONFIG_SYSVIPC
2625 /* The generic sysctl ipc data routine. */
2626 static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2627                 void __user *oldval, size_t __user *oldlenp,
2628                 void __user *newval, size_t newlen)
2629 {
2630         size_t len;
2631         void *data;
2632
2633         /* Get out of I don't have a variable */
2634         if (!table->data || !table->maxlen)
2635                 return -ENOTDIR;
2636
2637         data = get_ipc(table, 1);
2638         if (!data)
2639                 return -ENOTDIR;
2640
2641         if (oldval && oldlenp) {
2642                 if (get_user(len, oldlenp))
2643                         return -EFAULT;
2644                 if (len) {
2645                         if (len > table->maxlen)
2646                                 len = table->maxlen;
2647                         if (copy_to_user(oldval, data, len))
2648                                 return -EFAULT;
2649                         if (put_user(len, oldlenp))
2650                                 return -EFAULT;
2651                 }
2652         }
2653
2654         if (newval && newlen) {
2655                 if (newlen > table->maxlen)
2656                         newlen = table->maxlen;
2657
2658                 if (copy_from_user(data, newval, newlen))
2659                         return -EFAULT;
2660         }
2661         return 1;
2662 }
2663 #endif
2664
2665 #else /* CONFIG_SYSCTL_SYSCALL */
2666
2667
2668 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2669 {
2670         static int msg_count;
2671         struct __sysctl_args tmp;
2672         int name[CTL_MAXNAME];
2673         int i;
2674
2675         /* Read in the sysctl name for better debug message logging */
2676         if (copy_from_user(&tmp, args, sizeof(tmp)))
2677                 return -EFAULT;
2678         if (tmp.nlen <= 0 || tmp.nlen >= CTL_MAXNAME)
2679                 return -ENOTDIR;
2680         for (i = 0; i < tmp.nlen; i++)
2681                 if (get_user(name[i], tmp.name + i))
2682                         return -EFAULT;
2683
2684         /* Ignore accesses to kernel.version */
2685         if ((tmp.nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2686                 goto out;
2687
2688         if (msg_count < 5) {
2689                 msg_count++;
2690                 printk(KERN_INFO
2691                         "warning: process `%s' used the removed sysctl "
2692                         "system call with ", current->comm);
2693                 for (i = 0; i < tmp.nlen; i++)
2694                         printk("%d.", name[i]);
2695                 printk("\n");
2696         }
2697 out:
2698         return -ENOSYS;
2699 }
2700
2701 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2702                   void __user *oldval, size_t __user *oldlenp,
2703                   void __user *newval, size_t newlen)
2704 {
2705         return -ENOSYS;
2706 }
2707
2708 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2709                 void __user *oldval, size_t __user *oldlenp,
2710                 void __user *newval, size_t newlen)
2711 {
2712         return -ENOSYS;
2713 }
2714
2715 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2716                 void __user *oldval, size_t __user *oldlenp,
2717                 void __user *newval, size_t newlen)
2718 {
2719         return -ENOSYS;
2720 }
2721
2722 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2723                 void __user *oldval, size_t __user *oldlenp,
2724                 void __user *newval, size_t newlen)
2725 {
2726         return -ENOSYS;
2727 }
2728
2729 static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2730                   void __user *oldval, size_t __user *oldlenp,
2731                   void __user *newval, size_t newlen)
2732 {
2733         return -ENOSYS;
2734 }
2735 static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2736                 void __user *oldval, size_t __user *oldlenp,
2737                 void __user *newval, size_t newlen)
2738 {
2739         return -ENOSYS;
2740 }
2741 #endif /* CONFIG_SYSCTL_SYSCALL */
2742
2743 /*
2744  * No sense putting this after each symbol definition, twice,
2745  * exception granted :-)
2746  */
2747 EXPORT_SYMBOL(proc_dointvec);
2748 EXPORT_SYMBOL(proc_dointvec_jiffies);
2749 EXPORT_SYMBOL(proc_dointvec_minmax);
2750 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2751 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2752 EXPORT_SYMBOL(proc_dostring);
2753 EXPORT_SYMBOL(proc_doulongvec_minmax);
2754 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2755 EXPORT_SYMBOL(register_sysctl_table);
2756 EXPORT_SYMBOL(sysctl_intvec);
2757 EXPORT_SYMBOL(sysctl_jiffies);
2758 EXPORT_SYMBOL(sysctl_ms_jiffies);
2759 EXPORT_SYMBOL(sysctl_string);
2760 EXPORT_SYMBOL(unregister_sysctl_table);