[PATCH] mv643xx_eth: use MII library for PHY management
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / kernel / sysctl.c
blobcb99a42f8b37c60e991332ce33b4fba1dacb9dc6
1 /*
2 * sysctl.c: General linux system control interface
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
21 #include <linux/config.h>
22 #include <linux/module.h>
23 #include <linux/mm.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/proc_fs.h>
28 #include <linux/capability.h>
29 #include <linux/ctype.h>
30 #include <linux/utsname.h>
31 #include <linux/capability.h>
32 #include <linux/smp_lock.h>
33 #include <linux/init.h>
34 #include <linux/kernel.h>
35 #include <linux/kobject.h>
36 #include <linux/net.h>
37 #include <linux/sysrq.h>
38 #include <linux/highuid.h>
39 #include <linux/writeback.h>
40 #include <linux/hugetlb.h>
41 #include <linux/security.h>
42 #include <linux/initrd.h>
43 #include <linux/times.h>
44 #include <linux/limits.h>
45 #include <linux/dcache.h>
46 #include <linux/syscalls.h>
48 #include <asm/uaccess.h>
49 #include <asm/processor.h>
51 #ifdef CONFIG_ROOT_NFS
52 #include <linux/nfs_fs.h>
53 #endif
55 #if defined(CONFIG_SYSCTL)
57 /* External variables not in a header file. */
58 extern int C_A_D;
59 extern int sysctl_overcommit_memory;
60 extern int sysctl_overcommit_ratio;
61 extern int max_threads;
62 extern int sysrq_enabled;
63 extern int core_uses_pid;
64 extern int suid_dumpable;
65 extern char core_pattern[];
66 extern int cad_pid;
67 extern int pid_max;
68 extern int min_free_kbytes;
69 extern int printk_ratelimit_jiffies;
70 extern int printk_ratelimit_burst;
71 extern int pid_max_min, pid_max_max;
72 extern int sysctl_drop_caches;
73 extern int percpu_pagelist_fraction;
75 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
76 int unknown_nmi_panic;
77 extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
78 void __user *, size_t *, loff_t *);
79 #endif
81 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
82 static int maxolduid = 65535;
83 static int minolduid;
84 static int min_percpu_pagelist_fract = 8;
86 static int ngroups_max = NGROUPS_MAX;
88 #ifdef CONFIG_KMOD
89 extern char modprobe_path[];
90 #endif
91 #ifdef CONFIG_CHR_DEV_SG
92 extern int sg_big_buff;
93 #endif
94 #ifdef CONFIG_SYSVIPC
95 extern size_t shm_ctlmax;
96 extern size_t shm_ctlall;
97 extern int shm_ctlmni;
98 extern int msg_ctlmax;
99 extern int msg_ctlmnb;
100 extern int msg_ctlmni;
101 extern int sem_ctls[];
102 #endif
104 #ifdef __sparc__
105 extern char reboot_command [];
106 extern int stop_a_enabled;
107 extern int scons_pwroff;
108 #endif
110 #ifdef __hppa__
111 extern int pwrsw_enabled;
112 extern int unaligned_enabled;
113 #endif
115 #ifdef CONFIG_S390
116 #ifdef CONFIG_MATHEMU
117 extern int sysctl_ieee_emulation_warnings;
118 #endif
119 extern int sysctl_userprocess_debug;
120 extern int spin_retry;
121 #endif
123 extern int sysctl_hz_timer;
125 #ifdef CONFIG_BSD_PROCESS_ACCT
126 extern int acct_parm[];
127 #endif
129 int randomize_va_space = 1;
131 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
132 ctl_table *, void **);
133 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
134 void __user *buffer, size_t *lenp, loff_t *ppos);
136 static ctl_table root_table[];
137 static struct ctl_table_header root_table_header =
138 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
140 static ctl_table kern_table[];
141 static ctl_table vm_table[];
142 static ctl_table proc_table[];
143 static ctl_table fs_table[];
144 static ctl_table debug_table[];
145 static ctl_table dev_table[];
146 extern ctl_table random_table[];
147 #ifdef CONFIG_UNIX98_PTYS
148 extern ctl_table pty_table[];
149 #endif
150 #ifdef CONFIG_INOTIFY
151 extern ctl_table inotify_table[];
152 #endif
154 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
155 int sysctl_legacy_va_layout;
156 #endif
158 /* /proc declarations: */
160 #ifdef CONFIG_PROC_FS
162 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
163 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
164 static int proc_opensys(struct inode *, struct file *);
166 struct file_operations proc_sys_file_operations = {
167 .open = proc_opensys,
168 .read = proc_readsys,
169 .write = proc_writesys,
172 extern struct proc_dir_entry *proc_sys_root;
174 static void register_proc_table(ctl_table *, struct proc_dir_entry *, void *);
175 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
176 #endif
178 /* The default sysctl tables: */
180 static ctl_table root_table[] = {
182 .ctl_name = CTL_KERN,
183 .procname = "kernel",
184 .mode = 0555,
185 .child = kern_table,
188 .ctl_name = CTL_VM,
189 .procname = "vm",
190 .mode = 0555,
191 .child = vm_table,
193 #ifdef CONFIG_NET
195 .ctl_name = CTL_NET,
196 .procname = "net",
197 .mode = 0555,
198 .child = net_table,
200 #endif
202 .ctl_name = CTL_PROC,
203 .procname = "proc",
204 .mode = 0555,
205 .child = proc_table,
208 .ctl_name = CTL_FS,
209 .procname = "fs",
210 .mode = 0555,
211 .child = fs_table,
214 .ctl_name = CTL_DEBUG,
215 .procname = "debug",
216 .mode = 0555,
217 .child = debug_table,
220 .ctl_name = CTL_DEV,
221 .procname = "dev",
222 .mode = 0555,
223 .child = dev_table,
226 { .ctl_name = 0 }
229 static ctl_table kern_table[] = {
231 .ctl_name = KERN_OSTYPE,
232 .procname = "ostype",
233 .data = system_utsname.sysname,
234 .maxlen = sizeof(system_utsname.sysname),
235 .mode = 0444,
236 .proc_handler = &proc_doutsstring,
237 .strategy = &sysctl_string,
240 .ctl_name = KERN_OSRELEASE,
241 .procname = "osrelease",
242 .data = system_utsname.release,
243 .maxlen = sizeof(system_utsname.release),
244 .mode = 0444,
245 .proc_handler = &proc_doutsstring,
246 .strategy = &sysctl_string,
249 .ctl_name = KERN_VERSION,
250 .procname = "version",
251 .data = system_utsname.version,
252 .maxlen = sizeof(system_utsname.version),
253 .mode = 0444,
254 .proc_handler = &proc_doutsstring,
255 .strategy = &sysctl_string,
258 .ctl_name = KERN_NODENAME,
259 .procname = "hostname",
260 .data = system_utsname.nodename,
261 .maxlen = sizeof(system_utsname.nodename),
262 .mode = 0644,
263 .proc_handler = &proc_doutsstring,
264 .strategy = &sysctl_string,
267 .ctl_name = KERN_DOMAINNAME,
268 .procname = "domainname",
269 .data = system_utsname.domainname,
270 .maxlen = sizeof(system_utsname.domainname),
271 .mode = 0644,
272 .proc_handler = &proc_doutsstring,
273 .strategy = &sysctl_string,
276 .ctl_name = KERN_PANIC,
277 .procname = "panic",
278 .data = &panic_timeout,
279 .maxlen = sizeof(int),
280 .mode = 0644,
281 .proc_handler = &proc_dointvec,
284 .ctl_name = KERN_CORE_USES_PID,
285 .procname = "core_uses_pid",
286 .data = &core_uses_pid,
287 .maxlen = sizeof(int),
288 .mode = 0644,
289 .proc_handler = &proc_dointvec,
292 .ctl_name = KERN_CORE_PATTERN,
293 .procname = "core_pattern",
294 .data = core_pattern,
295 .maxlen = 64,
296 .mode = 0644,
297 .proc_handler = &proc_dostring,
298 .strategy = &sysctl_string,
301 .ctl_name = KERN_TAINTED,
302 .procname = "tainted",
303 .data = &tainted,
304 .maxlen = sizeof(int),
305 .mode = 0444,
306 .proc_handler = &proc_dointvec,
309 .ctl_name = KERN_CAP_BSET,
310 .procname = "cap-bound",
311 .data = &cap_bset,
312 .maxlen = sizeof(kernel_cap_t),
313 .mode = 0600,
314 .proc_handler = &proc_dointvec_bset,
316 #ifdef CONFIG_BLK_DEV_INITRD
318 .ctl_name = KERN_REALROOTDEV,
319 .procname = "real-root-dev",
320 .data = &real_root_dev,
321 .maxlen = sizeof(int),
322 .mode = 0644,
323 .proc_handler = &proc_dointvec,
325 #endif
326 #ifdef __sparc__
328 .ctl_name = KERN_SPARC_REBOOT,
329 .procname = "reboot-cmd",
330 .data = reboot_command,
331 .maxlen = 256,
332 .mode = 0644,
333 .proc_handler = &proc_dostring,
334 .strategy = &sysctl_string,
337 .ctl_name = KERN_SPARC_STOP_A,
338 .procname = "stop-a",
339 .data = &stop_a_enabled,
340 .maxlen = sizeof (int),
341 .mode = 0644,
342 .proc_handler = &proc_dointvec,
345 .ctl_name = KERN_SPARC_SCONS_PWROFF,
346 .procname = "scons-poweroff",
347 .data = &scons_pwroff,
348 .maxlen = sizeof (int),
349 .mode = 0644,
350 .proc_handler = &proc_dointvec,
352 #endif
353 #ifdef __hppa__
355 .ctl_name = KERN_HPPA_PWRSW,
356 .procname = "soft-power",
357 .data = &pwrsw_enabled,
358 .maxlen = sizeof (int),
359 .mode = 0644,
360 .proc_handler = &proc_dointvec,
363 .ctl_name = KERN_HPPA_UNALIGNED,
364 .procname = "unaligned-trap",
365 .data = &unaligned_enabled,
366 .maxlen = sizeof (int),
367 .mode = 0644,
368 .proc_handler = &proc_dointvec,
370 #endif
372 .ctl_name = KERN_CTLALTDEL,
373 .procname = "ctrl-alt-del",
374 .data = &C_A_D,
375 .maxlen = sizeof(int),
376 .mode = 0644,
377 .proc_handler = &proc_dointvec,
380 .ctl_name = KERN_PRINTK,
381 .procname = "printk",
382 .data = &console_loglevel,
383 .maxlen = 4*sizeof(int),
384 .mode = 0644,
385 .proc_handler = &proc_dointvec,
387 #ifdef CONFIG_KMOD
389 .ctl_name = KERN_MODPROBE,
390 .procname = "modprobe",
391 .data = &modprobe_path,
392 .maxlen = KMOD_PATH_LEN,
393 .mode = 0644,
394 .proc_handler = &proc_dostring,
395 .strategy = &sysctl_string,
397 #endif
398 #ifdef CONFIG_HOTPLUG
400 .ctl_name = KERN_HOTPLUG,
401 .procname = "hotplug",
402 .data = &uevent_helper,
403 .maxlen = UEVENT_HELPER_PATH_LEN,
404 .mode = 0644,
405 .proc_handler = &proc_dostring,
406 .strategy = &sysctl_string,
408 #endif
409 #ifdef CONFIG_CHR_DEV_SG
411 .ctl_name = KERN_SG_BIG_BUFF,
412 .procname = "sg-big-buff",
413 .data = &sg_big_buff,
414 .maxlen = sizeof (int),
415 .mode = 0444,
416 .proc_handler = &proc_dointvec,
418 #endif
419 #ifdef CONFIG_BSD_PROCESS_ACCT
421 .ctl_name = KERN_ACCT,
422 .procname = "acct",
423 .data = &acct_parm,
424 .maxlen = 3*sizeof(int),
425 .mode = 0644,
426 .proc_handler = &proc_dointvec,
428 #endif
429 #ifdef CONFIG_SYSVIPC
431 .ctl_name = KERN_SHMMAX,
432 .procname = "shmmax",
433 .data = &shm_ctlmax,
434 .maxlen = sizeof (size_t),
435 .mode = 0644,
436 .proc_handler = &proc_doulongvec_minmax,
439 .ctl_name = KERN_SHMALL,
440 .procname = "shmall",
441 .data = &shm_ctlall,
442 .maxlen = sizeof (size_t),
443 .mode = 0644,
444 .proc_handler = &proc_doulongvec_minmax,
447 .ctl_name = KERN_SHMMNI,
448 .procname = "shmmni",
449 .data = &shm_ctlmni,
450 .maxlen = sizeof (int),
451 .mode = 0644,
452 .proc_handler = &proc_dointvec,
455 .ctl_name = KERN_MSGMAX,
456 .procname = "msgmax",
457 .data = &msg_ctlmax,
458 .maxlen = sizeof (int),
459 .mode = 0644,
460 .proc_handler = &proc_dointvec,
463 .ctl_name = KERN_MSGMNI,
464 .procname = "msgmni",
465 .data = &msg_ctlmni,
466 .maxlen = sizeof (int),
467 .mode = 0644,
468 .proc_handler = &proc_dointvec,
471 .ctl_name = KERN_MSGMNB,
472 .procname = "msgmnb",
473 .data = &msg_ctlmnb,
474 .maxlen = sizeof (int),
475 .mode = 0644,
476 .proc_handler = &proc_dointvec,
479 .ctl_name = KERN_SEM,
480 .procname = "sem",
481 .data = &sem_ctls,
482 .maxlen = 4*sizeof (int),
483 .mode = 0644,
484 .proc_handler = &proc_dointvec,
486 #endif
487 #ifdef CONFIG_MAGIC_SYSRQ
489 .ctl_name = KERN_SYSRQ,
490 .procname = "sysrq",
491 .data = &sysrq_enabled,
492 .maxlen = sizeof (int),
493 .mode = 0644,
494 .proc_handler = &proc_dointvec,
496 #endif
498 .ctl_name = KERN_CADPID,
499 .procname = "cad_pid",
500 .data = &cad_pid,
501 .maxlen = sizeof (int),
502 .mode = 0600,
503 .proc_handler = &proc_dointvec,
506 .ctl_name = KERN_MAX_THREADS,
507 .procname = "threads-max",
508 .data = &max_threads,
509 .maxlen = sizeof(int),
510 .mode = 0644,
511 .proc_handler = &proc_dointvec,
514 .ctl_name = KERN_RANDOM,
515 .procname = "random",
516 .mode = 0555,
517 .child = random_table,
519 #ifdef CONFIG_UNIX98_PTYS
521 .ctl_name = KERN_PTY,
522 .procname = "pty",
523 .mode = 0555,
524 .child = pty_table,
526 #endif
528 .ctl_name = KERN_OVERFLOWUID,
529 .procname = "overflowuid",
530 .data = &overflowuid,
531 .maxlen = sizeof(int),
532 .mode = 0644,
533 .proc_handler = &proc_dointvec_minmax,
534 .strategy = &sysctl_intvec,
535 .extra1 = &minolduid,
536 .extra2 = &maxolduid,
539 .ctl_name = KERN_OVERFLOWGID,
540 .procname = "overflowgid",
541 .data = &overflowgid,
542 .maxlen = sizeof(int),
543 .mode = 0644,
544 .proc_handler = &proc_dointvec_minmax,
545 .strategy = &sysctl_intvec,
546 .extra1 = &minolduid,
547 .extra2 = &maxolduid,
549 #ifdef CONFIG_S390
550 #ifdef CONFIG_MATHEMU
552 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
553 .procname = "ieee_emulation_warnings",
554 .data = &sysctl_ieee_emulation_warnings,
555 .maxlen = sizeof(int),
556 .mode = 0644,
557 .proc_handler = &proc_dointvec,
559 #endif
560 #ifdef CONFIG_NO_IDLE_HZ
562 .ctl_name = KERN_HZ_TIMER,
563 .procname = "hz_timer",
564 .data = &sysctl_hz_timer,
565 .maxlen = sizeof(int),
566 .mode = 0644,
567 .proc_handler = &proc_dointvec,
569 #endif
571 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
572 .procname = "userprocess_debug",
573 .data = &sysctl_userprocess_debug,
574 .maxlen = sizeof(int),
575 .mode = 0644,
576 .proc_handler = &proc_dointvec,
578 #endif
580 .ctl_name = KERN_PIDMAX,
581 .procname = "pid_max",
582 .data = &pid_max,
583 .maxlen = sizeof (int),
584 .mode = 0644,
585 .proc_handler = &proc_dointvec_minmax,
586 .strategy = sysctl_intvec,
587 .extra1 = &pid_max_min,
588 .extra2 = &pid_max_max,
591 .ctl_name = KERN_PANIC_ON_OOPS,
592 .procname = "panic_on_oops",
593 .data = &panic_on_oops,
594 .maxlen = sizeof(int),
595 .mode = 0644,
596 .proc_handler = &proc_dointvec,
599 .ctl_name = KERN_PRINTK_RATELIMIT,
600 .procname = "printk_ratelimit",
601 .data = &printk_ratelimit_jiffies,
602 .maxlen = sizeof(int),
603 .mode = 0644,
604 .proc_handler = &proc_dointvec_jiffies,
605 .strategy = &sysctl_jiffies,
608 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
609 .procname = "printk_ratelimit_burst",
610 .data = &printk_ratelimit_burst,
611 .maxlen = sizeof(int),
612 .mode = 0644,
613 .proc_handler = &proc_dointvec,
616 .ctl_name = KERN_NGROUPS_MAX,
617 .procname = "ngroups_max",
618 .data = &ngroups_max,
619 .maxlen = sizeof (int),
620 .mode = 0444,
621 .proc_handler = &proc_dointvec,
623 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
625 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
626 .procname = "unknown_nmi_panic",
627 .data = &unknown_nmi_panic,
628 .maxlen = sizeof (int),
629 .mode = 0644,
630 .proc_handler = &proc_unknown_nmi_panic,
632 #endif
633 #if defined(CONFIG_X86)
635 .ctl_name = KERN_BOOTLOADER_TYPE,
636 .procname = "bootloader_type",
637 .data = &bootloader_type,
638 .maxlen = sizeof (int),
639 .mode = 0444,
640 .proc_handler = &proc_dointvec,
642 #endif
644 .ctl_name = KERN_RANDOMIZE,
645 .procname = "randomize_va_space",
646 .data = &randomize_va_space,
647 .maxlen = sizeof(int),
648 .mode = 0644,
649 .proc_handler = &proc_dointvec,
651 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
653 .ctl_name = KERN_SPIN_RETRY,
654 .procname = "spin_retry",
655 .data = &spin_retry,
656 .maxlen = sizeof (int),
657 .mode = 0644,
658 .proc_handler = &proc_dointvec,
660 #endif
661 { .ctl_name = 0 }
664 /* Constants for minimum and maximum testing in vm_table.
665 We use these as one-element integer vectors. */
666 static int zero;
667 static int one_hundred = 100;
670 static ctl_table vm_table[] = {
672 .ctl_name = VM_OVERCOMMIT_MEMORY,
673 .procname = "overcommit_memory",
674 .data = &sysctl_overcommit_memory,
675 .maxlen = sizeof(sysctl_overcommit_memory),
676 .mode = 0644,
677 .proc_handler = &proc_dointvec,
680 .ctl_name = VM_OVERCOMMIT_RATIO,
681 .procname = "overcommit_ratio",
682 .data = &sysctl_overcommit_ratio,
683 .maxlen = sizeof(sysctl_overcommit_ratio),
684 .mode = 0644,
685 .proc_handler = &proc_dointvec,
688 .ctl_name = VM_PAGE_CLUSTER,
689 .procname = "page-cluster",
690 .data = &page_cluster,
691 .maxlen = sizeof(int),
692 .mode = 0644,
693 .proc_handler = &proc_dointvec,
696 .ctl_name = VM_DIRTY_BACKGROUND,
697 .procname = "dirty_background_ratio",
698 .data = &dirty_background_ratio,
699 .maxlen = sizeof(dirty_background_ratio),
700 .mode = 0644,
701 .proc_handler = &proc_dointvec_minmax,
702 .strategy = &sysctl_intvec,
703 .extra1 = &zero,
704 .extra2 = &one_hundred,
707 .ctl_name = VM_DIRTY_RATIO,
708 .procname = "dirty_ratio",
709 .data = &vm_dirty_ratio,
710 .maxlen = sizeof(vm_dirty_ratio),
711 .mode = 0644,
712 .proc_handler = &proc_dointvec_minmax,
713 .strategy = &sysctl_intvec,
714 .extra1 = &zero,
715 .extra2 = &one_hundred,
718 .ctl_name = VM_DIRTY_WB_CS,
719 .procname = "dirty_writeback_centisecs",
720 .data = &dirty_writeback_centisecs,
721 .maxlen = sizeof(dirty_writeback_centisecs),
722 .mode = 0644,
723 .proc_handler = &dirty_writeback_centisecs_handler,
726 .ctl_name = VM_DIRTY_EXPIRE_CS,
727 .procname = "dirty_expire_centisecs",
728 .data = &dirty_expire_centisecs,
729 .maxlen = sizeof(dirty_expire_centisecs),
730 .mode = 0644,
731 .proc_handler = &proc_dointvec,
734 .ctl_name = VM_NR_PDFLUSH_THREADS,
735 .procname = "nr_pdflush_threads",
736 .data = &nr_pdflush_threads,
737 .maxlen = sizeof nr_pdflush_threads,
738 .mode = 0444 /* read-only*/,
739 .proc_handler = &proc_dointvec,
742 .ctl_name = VM_SWAPPINESS,
743 .procname = "swappiness",
744 .data = &vm_swappiness,
745 .maxlen = sizeof(vm_swappiness),
746 .mode = 0644,
747 .proc_handler = &proc_dointvec_minmax,
748 .strategy = &sysctl_intvec,
749 .extra1 = &zero,
750 .extra2 = &one_hundred,
752 #ifdef CONFIG_HUGETLB_PAGE
754 .ctl_name = VM_HUGETLB_PAGES,
755 .procname = "nr_hugepages",
756 .data = &max_huge_pages,
757 .maxlen = sizeof(unsigned long),
758 .mode = 0644,
759 .proc_handler = &hugetlb_sysctl_handler,
760 .extra1 = (void *)&hugetlb_zero,
761 .extra2 = (void *)&hugetlb_infinity,
764 .ctl_name = VM_HUGETLB_GROUP,
765 .procname = "hugetlb_shm_group",
766 .data = &sysctl_hugetlb_shm_group,
767 .maxlen = sizeof(gid_t),
768 .mode = 0644,
769 .proc_handler = &proc_dointvec,
771 #endif
773 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
774 .procname = "lowmem_reserve_ratio",
775 .data = &sysctl_lowmem_reserve_ratio,
776 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
777 .mode = 0644,
778 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
779 .strategy = &sysctl_intvec,
782 .ctl_name = VM_DROP_PAGECACHE,
783 .procname = "drop_caches",
784 .data = &sysctl_drop_caches,
785 .maxlen = sizeof(int),
786 .mode = 0644,
787 .proc_handler = drop_caches_sysctl_handler,
788 .strategy = &sysctl_intvec,
791 .ctl_name = VM_MIN_FREE_KBYTES,
792 .procname = "min_free_kbytes",
793 .data = &min_free_kbytes,
794 .maxlen = sizeof(min_free_kbytes),
795 .mode = 0644,
796 .proc_handler = &min_free_kbytes_sysctl_handler,
797 .strategy = &sysctl_intvec,
798 .extra1 = &zero,
801 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
802 .procname = "percpu_pagelist_fraction",
803 .data = &percpu_pagelist_fraction,
804 .maxlen = sizeof(percpu_pagelist_fraction),
805 .mode = 0644,
806 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
807 .strategy = &sysctl_intvec,
808 .extra1 = &min_percpu_pagelist_fract,
810 #ifdef CONFIG_MMU
812 .ctl_name = VM_MAX_MAP_COUNT,
813 .procname = "max_map_count",
814 .data = &sysctl_max_map_count,
815 .maxlen = sizeof(sysctl_max_map_count),
816 .mode = 0644,
817 .proc_handler = &proc_dointvec
819 #endif
821 .ctl_name = VM_LAPTOP_MODE,
822 .procname = "laptop_mode",
823 .data = &laptop_mode,
824 .maxlen = sizeof(laptop_mode),
825 .mode = 0644,
826 .proc_handler = &proc_dointvec,
827 .strategy = &sysctl_intvec,
828 .extra1 = &zero,
831 .ctl_name = VM_BLOCK_DUMP,
832 .procname = "block_dump",
833 .data = &block_dump,
834 .maxlen = sizeof(block_dump),
835 .mode = 0644,
836 .proc_handler = &proc_dointvec,
837 .strategy = &sysctl_intvec,
838 .extra1 = &zero,
841 .ctl_name = VM_VFS_CACHE_PRESSURE,
842 .procname = "vfs_cache_pressure",
843 .data = &sysctl_vfs_cache_pressure,
844 .maxlen = sizeof(sysctl_vfs_cache_pressure),
845 .mode = 0644,
846 .proc_handler = &proc_dointvec,
847 .strategy = &sysctl_intvec,
848 .extra1 = &zero,
850 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
852 .ctl_name = VM_LEGACY_VA_LAYOUT,
853 .procname = "legacy_va_layout",
854 .data = &sysctl_legacy_va_layout,
855 .maxlen = sizeof(sysctl_legacy_va_layout),
856 .mode = 0644,
857 .proc_handler = &proc_dointvec,
858 .strategy = &sysctl_intvec,
859 .extra1 = &zero,
861 #endif
862 #ifdef CONFIG_SWAP
864 .ctl_name = VM_SWAP_TOKEN_TIMEOUT,
865 .procname = "swap_token_timeout",
866 .data = &swap_token_default_timeout,
867 .maxlen = sizeof(swap_token_default_timeout),
868 .mode = 0644,
869 .proc_handler = &proc_dointvec_jiffies,
870 .strategy = &sysctl_jiffies,
872 #endif
873 #ifdef CONFIG_NUMA
875 .ctl_name = VM_ZONE_RECLAIM_MODE,
876 .procname = "zone_reclaim_mode",
877 .data = &zone_reclaim_mode,
878 .maxlen = sizeof(zone_reclaim_mode),
879 .mode = 0644,
880 .proc_handler = &proc_dointvec,
881 .strategy = &zero,
883 #endif
884 { .ctl_name = 0 }
887 static ctl_table proc_table[] = {
888 { .ctl_name = 0 }
891 static ctl_table fs_table[] = {
893 .ctl_name = FS_NRINODE,
894 .procname = "inode-nr",
895 .data = &inodes_stat,
896 .maxlen = 2*sizeof(int),
897 .mode = 0444,
898 .proc_handler = &proc_dointvec,
901 .ctl_name = FS_STATINODE,
902 .procname = "inode-state",
903 .data = &inodes_stat,
904 .maxlen = 7*sizeof(int),
905 .mode = 0444,
906 .proc_handler = &proc_dointvec,
909 .ctl_name = FS_NRFILE,
910 .procname = "file-nr",
911 .data = &files_stat,
912 .maxlen = 3*sizeof(int),
913 .mode = 0444,
914 .proc_handler = &proc_dointvec,
917 .ctl_name = FS_MAXFILE,
918 .procname = "file-max",
919 .data = &files_stat.max_files,
920 .maxlen = sizeof(int),
921 .mode = 0644,
922 .proc_handler = &proc_dointvec,
925 .ctl_name = FS_DENTRY,
926 .procname = "dentry-state",
927 .data = &dentry_stat,
928 .maxlen = 6*sizeof(int),
929 .mode = 0444,
930 .proc_handler = &proc_dointvec,
933 .ctl_name = FS_OVERFLOWUID,
934 .procname = "overflowuid",
935 .data = &fs_overflowuid,
936 .maxlen = sizeof(int),
937 .mode = 0644,
938 .proc_handler = &proc_dointvec_minmax,
939 .strategy = &sysctl_intvec,
940 .extra1 = &minolduid,
941 .extra2 = &maxolduid,
944 .ctl_name = FS_OVERFLOWGID,
945 .procname = "overflowgid",
946 .data = &fs_overflowgid,
947 .maxlen = sizeof(int),
948 .mode = 0644,
949 .proc_handler = &proc_dointvec_minmax,
950 .strategy = &sysctl_intvec,
951 .extra1 = &minolduid,
952 .extra2 = &maxolduid,
955 .ctl_name = FS_LEASES,
956 .procname = "leases-enable",
957 .data = &leases_enable,
958 .maxlen = sizeof(int),
959 .mode = 0644,
960 .proc_handler = &proc_dointvec,
962 #ifdef CONFIG_DNOTIFY
964 .ctl_name = FS_DIR_NOTIFY,
965 .procname = "dir-notify-enable",
966 .data = &dir_notify_enable,
967 .maxlen = sizeof(int),
968 .mode = 0644,
969 .proc_handler = &proc_dointvec,
971 #endif
972 #ifdef CONFIG_MMU
974 .ctl_name = FS_LEASE_TIME,
975 .procname = "lease-break-time",
976 .data = &lease_break_time,
977 .maxlen = sizeof(int),
978 .mode = 0644,
979 .proc_handler = &proc_dointvec,
982 .ctl_name = FS_AIO_NR,
983 .procname = "aio-nr",
984 .data = &aio_nr,
985 .maxlen = sizeof(aio_nr),
986 .mode = 0444,
987 .proc_handler = &proc_doulongvec_minmax,
990 .ctl_name = FS_AIO_MAX_NR,
991 .procname = "aio-max-nr",
992 .data = &aio_max_nr,
993 .maxlen = sizeof(aio_max_nr),
994 .mode = 0644,
995 .proc_handler = &proc_doulongvec_minmax,
997 #ifdef CONFIG_INOTIFY
999 .ctl_name = FS_INOTIFY,
1000 .procname = "inotify",
1001 .mode = 0555,
1002 .child = inotify_table,
1004 #endif
1005 #endif
1007 .ctl_name = KERN_SETUID_DUMPABLE,
1008 .procname = "suid_dumpable",
1009 .data = &suid_dumpable,
1010 .maxlen = sizeof(int),
1011 .mode = 0644,
1012 .proc_handler = &proc_dointvec,
1014 { .ctl_name = 0 }
1017 static ctl_table debug_table[] = {
1018 { .ctl_name = 0 }
1021 static ctl_table dev_table[] = {
1022 { .ctl_name = 0 }
1025 extern void init_irq_proc (void);
1027 static DEFINE_SPINLOCK(sysctl_lock);
1029 /* called under sysctl_lock */
1030 static int use_table(struct ctl_table_header *p)
1032 if (unlikely(p->unregistering))
1033 return 0;
1034 p->used++;
1035 return 1;
1038 /* called under sysctl_lock */
1039 static void unuse_table(struct ctl_table_header *p)
1041 if (!--p->used)
1042 if (unlikely(p->unregistering))
1043 complete(p->unregistering);
1046 /* called under sysctl_lock, will reacquire if has to wait */
1047 static void start_unregistering(struct ctl_table_header *p)
1050 * if p->used is 0, nobody will ever touch that entry again;
1051 * we'll eliminate all paths to it before dropping sysctl_lock
1053 if (unlikely(p->used)) {
1054 struct completion wait;
1055 init_completion(&wait);
1056 p->unregistering = &wait;
1057 spin_unlock(&sysctl_lock);
1058 wait_for_completion(&wait);
1059 spin_lock(&sysctl_lock);
1062 * do not remove from the list until nobody holds it; walking the
1063 * list in do_sysctl() relies on that.
1065 list_del_init(&p->ctl_entry);
1068 void __init sysctl_init(void)
1070 #ifdef CONFIG_PROC_FS
1071 register_proc_table(root_table, proc_sys_root, &root_table_header);
1072 init_irq_proc();
1073 #endif
1076 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1077 void __user *newval, size_t newlen)
1079 struct list_head *tmp;
1080 int error = -ENOTDIR;
1082 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1083 return -ENOTDIR;
1084 if (oldval) {
1085 int old_len;
1086 if (!oldlenp || get_user(old_len, oldlenp))
1087 return -EFAULT;
1089 spin_lock(&sysctl_lock);
1090 tmp = &root_table_header.ctl_entry;
1091 do {
1092 struct ctl_table_header *head =
1093 list_entry(tmp, struct ctl_table_header, ctl_entry);
1094 void *context = NULL;
1096 if (!use_table(head))
1097 continue;
1099 spin_unlock(&sysctl_lock);
1101 error = parse_table(name, nlen, oldval, oldlenp,
1102 newval, newlen, head->ctl_table,
1103 &context);
1104 kfree(context);
1106 spin_lock(&sysctl_lock);
1107 unuse_table(head);
1108 if (error != -ENOTDIR)
1109 break;
1110 } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
1111 spin_unlock(&sysctl_lock);
1112 return error;
1115 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1117 struct __sysctl_args tmp;
1118 int error;
1120 if (copy_from_user(&tmp, args, sizeof(tmp)))
1121 return -EFAULT;
1123 lock_kernel();
1124 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1125 tmp.newval, tmp.newlen);
1126 unlock_kernel();
1127 return error;
1131 * ctl_perm does NOT grant the superuser all rights automatically, because
1132 * some sysctl variables are readonly even to root.
1135 static int test_perm(int mode, int op)
1137 if (!current->euid)
1138 mode >>= 6;
1139 else if (in_egroup_p(0))
1140 mode >>= 3;
1141 if ((mode & op & 0007) == op)
1142 return 0;
1143 return -EACCES;
1146 static inline int ctl_perm(ctl_table *table, int op)
1148 int error;
1149 error = security_sysctl(table, op);
1150 if (error)
1151 return error;
1152 return test_perm(table->mode, op);
1155 static int parse_table(int __user *name, int nlen,
1156 void __user *oldval, size_t __user *oldlenp,
1157 void __user *newval, size_t newlen,
1158 ctl_table *table, void **context)
1160 int n;
1161 repeat:
1162 if (!nlen)
1163 return -ENOTDIR;
1164 if (get_user(n, name))
1165 return -EFAULT;
1166 for ( ; table->ctl_name; table++) {
1167 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1168 int error;
1169 if (table->child) {
1170 if (ctl_perm(table, 001))
1171 return -EPERM;
1172 if (table->strategy) {
1173 error = table->strategy(
1174 table, name, nlen,
1175 oldval, oldlenp,
1176 newval, newlen, context);
1177 if (error)
1178 return error;
1180 name++;
1181 nlen--;
1182 table = table->child;
1183 goto repeat;
1185 error = do_sysctl_strategy(table, name, nlen,
1186 oldval, oldlenp,
1187 newval, newlen, context);
1188 return error;
1191 return -ENOTDIR;
1194 /* Perform the actual read/write of a sysctl table entry. */
1195 int do_sysctl_strategy (ctl_table *table,
1196 int __user *name, int nlen,
1197 void __user *oldval, size_t __user *oldlenp,
1198 void __user *newval, size_t newlen, void **context)
1200 int op = 0, rc;
1201 size_t len;
1203 if (oldval)
1204 op |= 004;
1205 if (newval)
1206 op |= 002;
1207 if (ctl_perm(table, op))
1208 return -EPERM;
1210 if (table->strategy) {
1211 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1212 newval, newlen, context);
1213 if (rc < 0)
1214 return rc;
1215 if (rc > 0)
1216 return 0;
1219 /* If there is no strategy routine, or if the strategy returns
1220 * zero, proceed with automatic r/w */
1221 if (table->data && table->maxlen) {
1222 if (oldval && oldlenp) {
1223 if (get_user(len, oldlenp))
1224 return -EFAULT;
1225 if (len) {
1226 if (len > table->maxlen)
1227 len = table->maxlen;
1228 if(copy_to_user(oldval, table->data, len))
1229 return -EFAULT;
1230 if(put_user(len, oldlenp))
1231 return -EFAULT;
1234 if (newval && newlen) {
1235 len = newlen;
1236 if (len > table->maxlen)
1237 len = table->maxlen;
1238 if(copy_from_user(table->data, newval, len))
1239 return -EFAULT;
1242 return 0;
1246 * register_sysctl_table - register a sysctl hierarchy
1247 * @table: the top-level table structure
1248 * @insert_at_head: whether the entry should be inserted in front or at the end
1250 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1251 * array. An entry with a ctl_name of 0 terminates the table.
1253 * The members of the &ctl_table structure are used as follows:
1255 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1256 * must be unique within that level of sysctl
1258 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1259 * enter a sysctl file
1261 * data - a pointer to data for use by proc_handler
1263 * maxlen - the maximum size in bytes of the data
1265 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1267 * child - a pointer to the child sysctl table if this entry is a directory, or
1268 * %NULL.
1270 * proc_handler - the text handler routine (described below)
1272 * strategy - the strategy routine (described below)
1274 * de - for internal use by the sysctl routines
1276 * extra1, extra2 - extra pointers usable by the proc handler routines
1278 * Leaf nodes in the sysctl tree will be represented by a single file
1279 * under /proc; non-leaf nodes will be represented by directories.
1281 * sysctl(2) can automatically manage read and write requests through
1282 * the sysctl table. The data and maxlen fields of the ctl_table
1283 * struct enable minimal validation of the values being written to be
1284 * performed, and the mode field allows minimal authentication.
1286 * More sophisticated management can be enabled by the provision of a
1287 * strategy routine with the table entry. This will be called before
1288 * any automatic read or write of the data is performed.
1290 * The strategy routine may return
1292 * < 0 - Error occurred (error is passed to user process)
1294 * 0 - OK - proceed with automatic read or write.
1296 * > 0 - OK - read or write has been done by the strategy routine, so
1297 * return immediately.
1299 * There must be a proc_handler routine for any terminal nodes
1300 * mirrored under /proc/sys (non-terminals are handled by a built-in
1301 * directory handler). Several default handlers are available to
1302 * cover common cases -
1304 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1305 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1306 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1308 * It is the handler's job to read the input buffer from user memory
1309 * and process it. The handler should return 0 on success.
1311 * This routine returns %NULL on a failure to register, and a pointer
1312 * to the table header on success.
1314 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1315 int insert_at_head)
1317 struct ctl_table_header *tmp;
1318 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1319 if (!tmp)
1320 return NULL;
1321 tmp->ctl_table = table;
1322 INIT_LIST_HEAD(&tmp->ctl_entry);
1323 tmp->used = 0;
1324 tmp->unregistering = NULL;
1325 spin_lock(&sysctl_lock);
1326 if (insert_at_head)
1327 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1328 else
1329 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1330 spin_unlock(&sysctl_lock);
1331 #ifdef CONFIG_PROC_FS
1332 register_proc_table(table, proc_sys_root, tmp);
1333 #endif
1334 return tmp;
1338 * unregister_sysctl_table - unregister a sysctl table hierarchy
1339 * @header: the header returned from register_sysctl_table
1341 * Unregisters the sysctl table and all children. proc entries may not
1342 * actually be removed until they are no longer used by anyone.
1344 void unregister_sysctl_table(struct ctl_table_header * header)
1346 might_sleep();
1347 spin_lock(&sysctl_lock);
1348 start_unregistering(header);
1349 #ifdef CONFIG_PROC_FS
1350 unregister_proc_table(header->ctl_table, proc_sys_root);
1351 #endif
1352 spin_unlock(&sysctl_lock);
1353 kfree(header);
1357 * /proc/sys support
1360 #ifdef CONFIG_PROC_FS
1362 /* Scan the sysctl entries in table and add them all into /proc */
1363 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
1365 struct proc_dir_entry *de;
1366 int len;
1367 mode_t mode;
1369 for (; table->ctl_name; table++) {
1370 /* Can't do anything without a proc name. */
1371 if (!table->procname)
1372 continue;
1373 /* Maybe we can't do anything with it... */
1374 if (!table->proc_handler && !table->child) {
1375 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1376 table->procname);
1377 continue;
1380 len = strlen(table->procname);
1381 mode = table->mode;
1383 de = NULL;
1384 if (table->proc_handler)
1385 mode |= S_IFREG;
1386 else {
1387 mode |= S_IFDIR;
1388 for (de = root->subdir; de; de = de->next) {
1389 if (proc_match(len, table->procname, de))
1390 break;
1392 /* If the subdir exists already, de is non-NULL */
1395 if (!de) {
1396 de = create_proc_entry(table->procname, mode, root);
1397 if (!de)
1398 continue;
1399 de->set = set;
1400 de->data = (void *) table;
1401 if (table->proc_handler)
1402 de->proc_fops = &proc_sys_file_operations;
1404 table->de = de;
1405 if (de->mode & S_IFDIR)
1406 register_proc_table(table->child, de, set);
1411 * Unregister a /proc sysctl table and any subdirectories.
1413 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1415 struct proc_dir_entry *de;
1416 for (; table->ctl_name; table++) {
1417 if (!(de = table->de))
1418 continue;
1419 if (de->mode & S_IFDIR) {
1420 if (!table->child) {
1421 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1422 continue;
1424 unregister_proc_table(table->child, de);
1426 /* Don't unregister directories which still have entries.. */
1427 if (de->subdir)
1428 continue;
1432 * In any case, mark the entry as goner; we'll keep it
1433 * around if it's busy, but we'll know to do nothing with
1434 * its fields. We are under sysctl_lock here.
1436 de->data = NULL;
1438 /* Don't unregister proc entries that are still being used.. */
1439 if (atomic_read(&de->count))
1440 continue;
1442 table->de = NULL;
1443 remove_proc_entry(table->procname, root);
1447 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1448 size_t count, loff_t *ppos)
1450 int op;
1451 struct proc_dir_entry *de = PDE(file->f_dentry->d_inode);
1452 struct ctl_table *table;
1453 size_t res;
1454 ssize_t error = -ENOTDIR;
1456 spin_lock(&sysctl_lock);
1457 if (de && de->data && use_table(de->set)) {
1459 * at that point we know that sysctl was not unregistered
1460 * and won't be until we finish
1462 spin_unlock(&sysctl_lock);
1463 table = (struct ctl_table *) de->data;
1464 if (!table || !table->proc_handler)
1465 goto out;
1466 error = -EPERM;
1467 op = (write ? 002 : 004);
1468 if (ctl_perm(table, op))
1469 goto out;
1471 /* careful: calling conventions are nasty here */
1472 res = count;
1473 error = (*table->proc_handler)(table, write, file,
1474 buf, &res, ppos);
1475 if (!error)
1476 error = res;
1477 out:
1478 spin_lock(&sysctl_lock);
1479 unuse_table(de->set);
1481 spin_unlock(&sysctl_lock);
1482 return error;
1485 static int proc_opensys(struct inode *inode, struct file *file)
1487 if (file->f_mode & FMODE_WRITE) {
1489 * sysctl entries that are not writable,
1490 * are _NOT_ writable, capabilities or not.
1492 if (!(inode->i_mode & S_IWUSR))
1493 return -EPERM;
1496 return 0;
1499 static ssize_t proc_readsys(struct file * file, char __user * buf,
1500 size_t count, loff_t *ppos)
1502 return do_rw_proc(0, file, buf, count, ppos);
1505 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1506 size_t count, loff_t *ppos)
1508 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1512 * proc_dostring - read a string sysctl
1513 * @table: the sysctl table
1514 * @write: %TRUE if this is a write to the sysctl file
1515 * @filp: the file structure
1516 * @buffer: the user buffer
1517 * @lenp: the size of the user buffer
1518 * @ppos: file position
1520 * Reads/writes a string from/to the user buffer. If the kernel
1521 * buffer provided is not large enough to hold the string, the
1522 * string is truncated. The copied string is %NULL-terminated.
1523 * If the string is being read by the user process, it is copied
1524 * and a newline '\n' is added. It is truncated if the buffer is
1525 * not large enough.
1527 * Returns 0 on success.
1529 int proc_dostring(ctl_table *table, int write, struct file *filp,
1530 void __user *buffer, size_t *lenp, loff_t *ppos)
1532 size_t len;
1533 char __user *p;
1534 char c;
1536 if (!table->data || !table->maxlen || !*lenp ||
1537 (*ppos && !write)) {
1538 *lenp = 0;
1539 return 0;
1542 if (write) {
1543 len = 0;
1544 p = buffer;
1545 while (len < *lenp) {
1546 if (get_user(c, p++))
1547 return -EFAULT;
1548 if (c == 0 || c == '\n')
1549 break;
1550 len++;
1552 if (len >= table->maxlen)
1553 len = table->maxlen-1;
1554 if(copy_from_user(table->data, buffer, len))
1555 return -EFAULT;
1556 ((char *) table->data)[len] = 0;
1557 *ppos += *lenp;
1558 } else {
1559 len = strlen(table->data);
1560 if (len > table->maxlen)
1561 len = table->maxlen;
1562 if (len > *lenp)
1563 len = *lenp;
1564 if (len)
1565 if(copy_to_user(buffer, table->data, len))
1566 return -EFAULT;
1567 if (len < *lenp) {
1568 if(put_user('\n', ((char __user *) buffer) + len))
1569 return -EFAULT;
1570 len++;
1572 *lenp = len;
1573 *ppos += len;
1575 return 0;
1579 * Special case of dostring for the UTS structure. This has locks
1580 * to observe. Should this be in kernel/sys.c ????
1583 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1584 void __user *buffer, size_t *lenp, loff_t *ppos)
1586 int r;
1588 if (!write) {
1589 down_read(&uts_sem);
1590 r=proc_dostring(table,0,filp,buffer,lenp, ppos);
1591 up_read(&uts_sem);
1592 } else {
1593 down_write(&uts_sem);
1594 r=proc_dostring(table,1,filp,buffer,lenp, ppos);
1595 up_write(&uts_sem);
1597 return r;
1600 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1601 int *valp,
1602 int write, void *data)
1604 if (write) {
1605 *valp = *negp ? -*lvalp : *lvalp;
1606 } else {
1607 int val = *valp;
1608 if (val < 0) {
1609 *negp = -1;
1610 *lvalp = (unsigned long)-val;
1611 } else {
1612 *negp = 0;
1613 *lvalp = (unsigned long)val;
1616 return 0;
1619 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1620 void __user *buffer, size_t *lenp, loff_t *ppos,
1621 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1622 int write, void *data),
1623 void *data)
1625 #define TMPBUFLEN 21
1626 int *i, vleft, first=1, neg, val;
1627 unsigned long lval;
1628 size_t left, len;
1630 char buf[TMPBUFLEN], *p;
1631 char __user *s = buffer;
1633 if (!table->data || !table->maxlen || !*lenp ||
1634 (*ppos && !write)) {
1635 *lenp = 0;
1636 return 0;
1639 i = (int *) table->data;
1640 vleft = table->maxlen / sizeof(*i);
1641 left = *lenp;
1643 if (!conv)
1644 conv = do_proc_dointvec_conv;
1646 for (; left && vleft--; i++, first=0) {
1647 if (write) {
1648 while (left) {
1649 char c;
1650 if (get_user(c, s))
1651 return -EFAULT;
1652 if (!isspace(c))
1653 break;
1654 left--;
1655 s++;
1657 if (!left)
1658 break;
1659 neg = 0;
1660 len = left;
1661 if (len > sizeof(buf) - 1)
1662 len = sizeof(buf) - 1;
1663 if (copy_from_user(buf, s, len))
1664 return -EFAULT;
1665 buf[len] = 0;
1666 p = buf;
1667 if (*p == '-' && left > 1) {
1668 neg = 1;
1669 left--, p++;
1671 if (*p < '0' || *p > '9')
1672 break;
1674 lval = simple_strtoul(p, &p, 0);
1676 len = p-buf;
1677 if ((len < left) && *p && !isspace(*p))
1678 break;
1679 if (neg)
1680 val = -val;
1681 s += len;
1682 left -= len;
1684 if (conv(&neg, &lval, i, 1, data))
1685 break;
1686 } else {
1687 p = buf;
1688 if (!first)
1689 *p++ = '\t';
1691 if (conv(&neg, &lval, i, 0, data))
1692 break;
1694 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1695 len = strlen(buf);
1696 if (len > left)
1697 len = left;
1698 if(copy_to_user(s, buf, len))
1699 return -EFAULT;
1700 left -= len;
1701 s += len;
1705 if (!write && !first && left) {
1706 if(put_user('\n', s))
1707 return -EFAULT;
1708 left--, s++;
1710 if (write) {
1711 while (left) {
1712 char c;
1713 if (get_user(c, s++))
1714 return -EFAULT;
1715 if (!isspace(c))
1716 break;
1717 left--;
1720 if (write && first)
1721 return -EINVAL;
1722 *lenp -= left;
1723 *ppos += *lenp;
1724 return 0;
1725 #undef TMPBUFLEN
1729 * proc_dointvec - read a vector of integers
1730 * @table: the sysctl table
1731 * @write: %TRUE if this is a write to the sysctl file
1732 * @filp: the file structure
1733 * @buffer: the user buffer
1734 * @lenp: the size of the user buffer
1735 * @ppos: file position
1737 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1738 * values from/to the user buffer, treated as an ASCII string.
1740 * Returns 0 on success.
1742 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1743 void __user *buffer, size_t *lenp, loff_t *ppos)
1745 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1746 NULL,NULL);
1749 #define OP_SET 0
1750 #define OP_AND 1
1751 #define OP_OR 2
1752 #define OP_MAX 3
1753 #define OP_MIN 4
1755 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1756 int *valp,
1757 int write, void *data)
1759 int op = *(int *)data;
1760 if (write) {
1761 int val = *negp ? -*lvalp : *lvalp;
1762 switch(op) {
1763 case OP_SET: *valp = val; break;
1764 case OP_AND: *valp &= val; break;
1765 case OP_OR: *valp |= val; break;
1766 case OP_MAX: if(*valp < val)
1767 *valp = val;
1768 break;
1769 case OP_MIN: if(*valp > val)
1770 *valp = val;
1771 break;
1773 } else {
1774 int val = *valp;
1775 if (val < 0) {
1776 *negp = -1;
1777 *lvalp = (unsigned long)-val;
1778 } else {
1779 *negp = 0;
1780 *lvalp = (unsigned long)val;
1783 return 0;
1787 * init may raise the set.
1790 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1791 void __user *buffer, size_t *lenp, loff_t *ppos)
1793 int op;
1795 if (!capable(CAP_SYS_MODULE)) {
1796 return -EPERM;
1799 op = (current->pid == 1) ? OP_SET : OP_AND;
1800 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1801 do_proc_dointvec_bset_conv,&op);
1804 struct do_proc_dointvec_minmax_conv_param {
1805 int *min;
1806 int *max;
1809 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1810 int *valp,
1811 int write, void *data)
1813 struct do_proc_dointvec_minmax_conv_param *param = data;
1814 if (write) {
1815 int val = *negp ? -*lvalp : *lvalp;
1816 if ((param->min && *param->min > val) ||
1817 (param->max && *param->max < val))
1818 return -EINVAL;
1819 *valp = val;
1820 } else {
1821 int val = *valp;
1822 if (val < 0) {
1823 *negp = -1;
1824 *lvalp = (unsigned long)-val;
1825 } else {
1826 *negp = 0;
1827 *lvalp = (unsigned long)val;
1830 return 0;
1834 * proc_dointvec_minmax - read a vector of integers with min/max values
1835 * @table: the sysctl table
1836 * @write: %TRUE if this is a write to the sysctl file
1837 * @filp: the file structure
1838 * @buffer: the user buffer
1839 * @lenp: the size of the user buffer
1840 * @ppos: file position
1842 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1843 * values from/to the user buffer, treated as an ASCII string.
1845 * This routine will ensure the values are within the range specified by
1846 * table->extra1 (min) and table->extra2 (max).
1848 * Returns 0 on success.
1850 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1851 void __user *buffer, size_t *lenp, loff_t *ppos)
1853 struct do_proc_dointvec_minmax_conv_param param = {
1854 .min = (int *) table->extra1,
1855 .max = (int *) table->extra2,
1857 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
1858 do_proc_dointvec_minmax_conv, &param);
1861 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1862 struct file *filp,
1863 void __user *buffer,
1864 size_t *lenp, loff_t *ppos,
1865 unsigned long convmul,
1866 unsigned long convdiv)
1868 #define TMPBUFLEN 21
1869 unsigned long *i, *min, *max, val;
1870 int vleft, first=1, neg;
1871 size_t len, left;
1872 char buf[TMPBUFLEN], *p;
1873 char __user *s = buffer;
1875 if (!table->data || !table->maxlen || !*lenp ||
1876 (*ppos && !write)) {
1877 *lenp = 0;
1878 return 0;
1881 i = (unsigned long *) table->data;
1882 min = (unsigned long *) table->extra1;
1883 max = (unsigned long *) table->extra2;
1884 vleft = table->maxlen / sizeof(unsigned long);
1885 left = *lenp;
1887 for (; left && vleft--; i++, min++, max++, first=0) {
1888 if (write) {
1889 while (left) {
1890 char c;
1891 if (get_user(c, s))
1892 return -EFAULT;
1893 if (!isspace(c))
1894 break;
1895 left--;
1896 s++;
1898 if (!left)
1899 break;
1900 neg = 0;
1901 len = left;
1902 if (len > TMPBUFLEN-1)
1903 len = TMPBUFLEN-1;
1904 if (copy_from_user(buf, s, len))
1905 return -EFAULT;
1906 buf[len] = 0;
1907 p = buf;
1908 if (*p == '-' && left > 1) {
1909 neg = 1;
1910 left--, p++;
1912 if (*p < '0' || *p > '9')
1913 break;
1914 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1915 len = p-buf;
1916 if ((len < left) && *p && !isspace(*p))
1917 break;
1918 if (neg)
1919 val = -val;
1920 s += len;
1921 left -= len;
1923 if(neg)
1924 continue;
1925 if ((min && val < *min) || (max && val > *max))
1926 continue;
1927 *i = val;
1928 } else {
1929 p = buf;
1930 if (!first)
1931 *p++ = '\t';
1932 sprintf(p, "%lu", convdiv * (*i) / convmul);
1933 len = strlen(buf);
1934 if (len > left)
1935 len = left;
1936 if(copy_to_user(s, buf, len))
1937 return -EFAULT;
1938 left -= len;
1939 s += len;
1943 if (!write && !first && left) {
1944 if(put_user('\n', s))
1945 return -EFAULT;
1946 left--, s++;
1948 if (write) {
1949 while (left) {
1950 char c;
1951 if (get_user(c, s++))
1952 return -EFAULT;
1953 if (!isspace(c))
1954 break;
1955 left--;
1958 if (write && first)
1959 return -EINVAL;
1960 *lenp -= left;
1961 *ppos += *lenp;
1962 return 0;
1963 #undef TMPBUFLEN
1967 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1968 * @table: the sysctl table
1969 * @write: %TRUE if this is a write to the sysctl file
1970 * @filp: the file structure
1971 * @buffer: the user buffer
1972 * @lenp: the size of the user buffer
1973 * @ppos: file position
1975 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1976 * values from/to the user buffer, treated as an ASCII string.
1978 * This routine will ensure the values are within the range specified by
1979 * table->extra1 (min) and table->extra2 (max).
1981 * Returns 0 on success.
1983 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1984 void __user *buffer, size_t *lenp, loff_t *ppos)
1986 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
1990 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1991 * @table: the sysctl table
1992 * @write: %TRUE if this is a write to the sysctl file
1993 * @filp: the file structure
1994 * @buffer: the user buffer
1995 * @lenp: the size of the user buffer
1996 * @ppos: file position
1998 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1999 * values from/to the user buffer, treated as an ASCII string. The values
2000 * are treated as milliseconds, and converted to jiffies when they are stored.
2002 * This routine will ensure the values are within the range specified by
2003 * table->extra1 (min) and table->extra2 (max).
2005 * Returns 0 on success.
2007 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2008 struct file *filp,
2009 void __user *buffer,
2010 size_t *lenp, loff_t *ppos)
2012 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2013 lenp, ppos, HZ, 1000l);
2017 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2018 int *valp,
2019 int write, void *data)
2021 if (write) {
2022 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2023 } else {
2024 int val = *valp;
2025 unsigned long lval;
2026 if (val < 0) {
2027 *negp = -1;
2028 lval = (unsigned long)-val;
2029 } else {
2030 *negp = 0;
2031 lval = (unsigned long)val;
2033 *lvalp = lval / HZ;
2035 return 0;
2038 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2039 int *valp,
2040 int write, void *data)
2042 if (write) {
2043 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2044 } else {
2045 int val = *valp;
2046 unsigned long lval;
2047 if (val < 0) {
2048 *negp = -1;
2049 lval = (unsigned long)-val;
2050 } else {
2051 *negp = 0;
2052 lval = (unsigned long)val;
2054 *lvalp = jiffies_to_clock_t(lval);
2056 return 0;
2059 static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2060 int *valp,
2061 int write, void *data)
2063 if (write) {
2064 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2065 } else {
2066 int val = *valp;
2067 unsigned long lval;
2068 if (val < 0) {
2069 *negp = -1;
2070 lval = (unsigned long)-val;
2071 } else {
2072 *negp = 0;
2073 lval = (unsigned long)val;
2075 *lvalp = jiffies_to_msecs(lval);
2077 return 0;
2081 * proc_dointvec_jiffies - read a vector of integers as seconds
2082 * @table: the sysctl table
2083 * @write: %TRUE if this is a write to the sysctl file
2084 * @filp: the file structure
2085 * @buffer: the user buffer
2086 * @lenp: the size of the user buffer
2087 * @ppos: file position
2089 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2090 * values from/to the user buffer, treated as an ASCII string.
2091 * The values read are assumed to be in seconds, and are converted into
2092 * jiffies.
2094 * Returns 0 on success.
2096 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2097 void __user *buffer, size_t *lenp, loff_t *ppos)
2099 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2100 do_proc_dointvec_jiffies_conv,NULL);
2104 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2105 * @table: the sysctl table
2106 * @write: %TRUE if this is a write to the sysctl file
2107 * @filp: the file structure
2108 * @buffer: the user buffer
2109 * @lenp: the size of the user buffer
2110 * @ppos: pointer to the file position
2112 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2113 * values from/to the user buffer, treated as an ASCII string.
2114 * The values read are assumed to be in 1/USER_HZ seconds, and
2115 * are converted into jiffies.
2117 * Returns 0 on success.
2119 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2120 void __user *buffer, size_t *lenp, loff_t *ppos)
2122 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2123 do_proc_dointvec_userhz_jiffies_conv,NULL);
2127 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2128 * @table: the sysctl table
2129 * @write: %TRUE if this is a write to the sysctl file
2130 * @filp: the file structure
2131 * @buffer: the user buffer
2132 * @lenp: the size of the user buffer
2133 * @ppos: file position
2134 * @ppos: the current position in the file
2136 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2137 * values from/to the user buffer, treated as an ASCII string.
2138 * The values read are assumed to be in 1/1000 seconds, and
2139 * are converted into jiffies.
2141 * Returns 0 on success.
2143 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2144 void __user *buffer, size_t *lenp, loff_t *ppos)
2146 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2147 do_proc_dointvec_ms_jiffies_conv, NULL);
2150 #else /* CONFIG_PROC_FS */
2152 int proc_dostring(ctl_table *table, int write, struct file *filp,
2153 void __user *buffer, size_t *lenp, loff_t *ppos)
2155 return -ENOSYS;
2158 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
2159 void __user *buffer, size_t *lenp, loff_t *ppos)
2161 return -ENOSYS;
2164 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2165 void __user *buffer, size_t *lenp, loff_t *ppos)
2167 return -ENOSYS;
2170 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2171 void __user *buffer, size_t *lenp, loff_t *ppos)
2173 return -ENOSYS;
2176 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2177 void __user *buffer, size_t *lenp, loff_t *ppos)
2179 return -ENOSYS;
2182 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2183 void __user *buffer, size_t *lenp, loff_t *ppos)
2185 return -ENOSYS;
2188 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2189 void __user *buffer, size_t *lenp, loff_t *ppos)
2191 return -ENOSYS;
2194 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2195 void __user *buffer, size_t *lenp, loff_t *ppos)
2197 return -ENOSYS;
2200 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2201 void __user *buffer, size_t *lenp, loff_t *ppos)
2203 return -ENOSYS;
2206 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2207 struct file *filp,
2208 void __user *buffer,
2209 size_t *lenp, loff_t *ppos)
2211 return -ENOSYS;
2215 #endif /* CONFIG_PROC_FS */
2219 * General sysctl support routines
2222 /* The generic string strategy routine: */
2223 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2224 void __user *oldval, size_t __user *oldlenp,
2225 void __user *newval, size_t newlen, void **context)
2227 if (!table->data || !table->maxlen)
2228 return -ENOTDIR;
2230 if (oldval && oldlenp) {
2231 size_t bufsize;
2232 if (get_user(bufsize, oldlenp))
2233 return -EFAULT;
2234 if (bufsize) {
2235 size_t len = strlen(table->data), copied;
2237 /* This shouldn't trigger for a well-formed sysctl */
2238 if (len > table->maxlen)
2239 len = table->maxlen;
2241 /* Copy up to a max of bufsize-1 bytes of the string */
2242 copied = (len >= bufsize) ? bufsize - 1 : len;
2244 if (copy_to_user(oldval, table->data, copied) ||
2245 put_user(0, (char __user *)(oldval + copied)))
2246 return -EFAULT;
2247 if (put_user(len, oldlenp))
2248 return -EFAULT;
2251 if (newval && newlen) {
2252 size_t len = newlen;
2253 if (len > table->maxlen)
2254 len = table->maxlen;
2255 if(copy_from_user(table->data, newval, len))
2256 return -EFAULT;
2257 if (len == table->maxlen)
2258 len--;
2259 ((char *) table->data)[len] = 0;
2261 return 1;
2265 * This function makes sure that all of the integers in the vector
2266 * are between the minimum and maximum values given in the arrays
2267 * table->extra1 and table->extra2, respectively.
2269 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2270 void __user *oldval, size_t __user *oldlenp,
2271 void __user *newval, size_t newlen, void **context)
2274 if (newval && newlen) {
2275 int __user *vec = (int __user *) newval;
2276 int *min = (int *) table->extra1;
2277 int *max = (int *) table->extra2;
2278 size_t length;
2279 int i;
2281 if (newlen % sizeof(int) != 0)
2282 return -EINVAL;
2284 if (!table->extra1 && !table->extra2)
2285 return 0;
2287 if (newlen > table->maxlen)
2288 newlen = table->maxlen;
2289 length = newlen / sizeof(int);
2291 for (i = 0; i < length; i++) {
2292 int value;
2293 if (get_user(value, vec + i))
2294 return -EFAULT;
2295 if (min && value < min[i])
2296 return -EINVAL;
2297 if (max && value > max[i])
2298 return -EINVAL;
2301 return 0;
2304 /* Strategy function to convert jiffies to seconds */
2305 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2306 void __user *oldval, size_t __user *oldlenp,
2307 void __user *newval, size_t newlen, void **context)
2309 if (oldval) {
2310 size_t olen;
2311 if (oldlenp) {
2312 if (get_user(olen, oldlenp))
2313 return -EFAULT;
2314 if (olen!=sizeof(int))
2315 return -EINVAL;
2317 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2318 (oldlenp && put_user(sizeof(int),oldlenp)))
2319 return -EFAULT;
2321 if (newval && newlen) {
2322 int new;
2323 if (newlen != sizeof(int))
2324 return -EINVAL;
2325 if (get_user(new, (int __user *)newval))
2326 return -EFAULT;
2327 *(int *)(table->data) = new*HZ;
2329 return 1;
2332 /* Strategy function to convert jiffies to seconds */
2333 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2334 void __user *oldval, size_t __user *oldlenp,
2335 void __user *newval, size_t newlen, void **context)
2337 if (oldval) {
2338 size_t olen;
2339 if (oldlenp) {
2340 if (get_user(olen, oldlenp))
2341 return -EFAULT;
2342 if (olen!=sizeof(int))
2343 return -EINVAL;
2345 if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
2346 (oldlenp && put_user(sizeof(int),oldlenp)))
2347 return -EFAULT;
2349 if (newval && newlen) {
2350 int new;
2351 if (newlen != sizeof(int))
2352 return -EINVAL;
2353 if (get_user(new, (int __user *)newval))
2354 return -EFAULT;
2355 *(int *)(table->data) = msecs_to_jiffies(new);
2357 return 1;
2360 #else /* CONFIG_SYSCTL */
2363 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2365 return -ENOSYS;
2368 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2369 void __user *oldval, size_t __user *oldlenp,
2370 void __user *newval, size_t newlen, void **context)
2372 return -ENOSYS;
2375 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2376 void __user *oldval, size_t __user *oldlenp,
2377 void __user *newval, size_t newlen, void **context)
2379 return -ENOSYS;
2382 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2383 void __user *oldval, size_t __user *oldlenp,
2384 void __user *newval, size_t newlen, void **context)
2386 return -ENOSYS;
2389 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2390 void __user *oldval, size_t __user *oldlenp,
2391 void __user *newval, size_t newlen, void **context)
2393 return -ENOSYS;
2396 int proc_dostring(ctl_table *table, int write, struct file *filp,
2397 void __user *buffer, size_t *lenp, loff_t *ppos)
2399 return -ENOSYS;
2402 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2403 void __user *buffer, size_t *lenp, loff_t *ppos)
2405 return -ENOSYS;
2408 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2409 void __user *buffer, size_t *lenp, loff_t *ppos)
2411 return -ENOSYS;
2414 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2415 void __user *buffer, size_t *lenp, loff_t *ppos)
2417 return -ENOSYS;
2420 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2421 void __user *buffer, size_t *lenp, loff_t *ppos)
2423 return -ENOSYS;
2426 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2427 void __user *buffer, size_t *lenp, loff_t *ppos)
2429 return -ENOSYS;
2432 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2433 void __user *buffer, size_t *lenp, loff_t *ppos)
2435 return -ENOSYS;
2438 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2439 void __user *buffer, size_t *lenp, loff_t *ppos)
2441 return -ENOSYS;
2444 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2445 struct file *filp,
2446 void __user *buffer,
2447 size_t *lenp, loff_t *ppos)
2449 return -ENOSYS;
2452 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2453 int insert_at_head)
2455 return NULL;
2458 void unregister_sysctl_table(struct ctl_table_header * table)
2462 #endif /* CONFIG_SYSCTL */
2465 * No sense putting this after each symbol definition, twice,
2466 * exception granted :-)
2468 EXPORT_SYMBOL(proc_dointvec);
2469 EXPORT_SYMBOL(proc_dointvec_jiffies);
2470 EXPORT_SYMBOL(proc_dointvec_minmax);
2471 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2472 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2473 EXPORT_SYMBOL(proc_dostring);
2474 EXPORT_SYMBOL(proc_doulongvec_minmax);
2475 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2476 EXPORT_SYMBOL(register_sysctl_table);
2477 EXPORT_SYMBOL(sysctl_intvec);
2478 EXPORT_SYMBOL(sysctl_jiffies);
2479 EXPORT_SYMBOL(sysctl_ms_jiffies);
2480 EXPORT_SYMBOL(sysctl_string);
2481 EXPORT_SYMBOL(unregister_sysctl_table);