[PATCH] tmpfs: fix mount mpol nodelist parsing
[linux-2.6.22.y-op.git] / kernel / sysctl.c
blobc05a2b7125e16dc1bab36098dec5017d86815590
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>
47 #include <linux/nfs_fs.h>
48 #include <linux/acpi.h>
50 #include <asm/uaccess.h>
51 #include <asm/processor.h>
53 #if defined(CONFIG_SYSCTL)
55 /* External variables not in a header file. */
56 extern int C_A_D;
57 extern int sysctl_overcommit_memory;
58 extern int sysctl_overcommit_ratio;
59 extern int max_threads;
60 extern int sysrq_enabled;
61 extern int core_uses_pid;
62 extern int suid_dumpable;
63 extern char core_pattern[];
64 extern int cad_pid;
65 extern int pid_max;
66 extern int min_free_kbytes;
67 extern int printk_ratelimit_jiffies;
68 extern int printk_ratelimit_burst;
69 extern int pid_max_min, pid_max_max;
70 extern int sysctl_drop_caches;
71 extern int percpu_pagelist_fraction;
73 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
74 int unknown_nmi_panic;
75 extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
76 void __user *, size_t *, loff_t *);
77 #endif
79 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
80 static int maxolduid = 65535;
81 static int minolduid;
82 static int min_percpu_pagelist_fract = 8;
84 static int ngroups_max = NGROUPS_MAX;
86 #ifdef CONFIG_KMOD
87 extern char modprobe_path[];
88 #endif
89 #ifdef CONFIG_CHR_DEV_SG
90 extern int sg_big_buff;
91 #endif
92 #ifdef CONFIG_SYSVIPC
93 extern size_t shm_ctlmax;
94 extern size_t shm_ctlall;
95 extern int shm_ctlmni;
96 extern int msg_ctlmax;
97 extern int msg_ctlmnb;
98 extern int msg_ctlmni;
99 extern int sem_ctls[];
100 #endif
102 #ifdef __sparc__
103 extern char reboot_command [];
104 extern int stop_a_enabled;
105 extern int scons_pwroff;
106 #endif
108 #ifdef __hppa__
109 extern int pwrsw_enabled;
110 extern int unaligned_enabled;
111 #endif
113 #ifdef CONFIG_S390
114 #ifdef CONFIG_MATHEMU
115 extern int sysctl_ieee_emulation_warnings;
116 #endif
117 extern int sysctl_userprocess_debug;
118 extern int spin_retry;
119 #endif
121 extern int sysctl_hz_timer;
123 #ifdef CONFIG_BSD_PROCESS_ACCT
124 extern int acct_parm[];
125 #endif
127 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
128 ctl_table *, void **);
129 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
130 void __user *buffer, size_t *lenp, loff_t *ppos);
132 static ctl_table root_table[];
133 static struct ctl_table_header root_table_header =
134 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
136 static ctl_table kern_table[];
137 static ctl_table vm_table[];
138 static ctl_table proc_table[];
139 static ctl_table fs_table[];
140 static ctl_table debug_table[];
141 static ctl_table dev_table[];
142 extern ctl_table random_table[];
143 #ifdef CONFIG_UNIX98_PTYS
144 extern ctl_table pty_table[];
145 #endif
146 #ifdef CONFIG_INOTIFY
147 extern ctl_table inotify_table[];
148 #endif
150 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
151 int sysctl_legacy_va_layout;
152 #endif
154 /* /proc declarations: */
156 #ifdef CONFIG_PROC_FS
158 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
159 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
160 static int proc_opensys(struct inode *, struct file *);
162 struct file_operations proc_sys_file_operations = {
163 .open = proc_opensys,
164 .read = proc_readsys,
165 .write = proc_writesys,
168 extern struct proc_dir_entry *proc_sys_root;
170 static void register_proc_table(ctl_table *, struct proc_dir_entry *, void *);
171 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
172 #endif
174 /* The default sysctl tables: */
176 static ctl_table root_table[] = {
178 .ctl_name = CTL_KERN,
179 .procname = "kernel",
180 .mode = 0555,
181 .child = kern_table,
184 .ctl_name = CTL_VM,
185 .procname = "vm",
186 .mode = 0555,
187 .child = vm_table,
189 #ifdef CONFIG_NET
191 .ctl_name = CTL_NET,
192 .procname = "net",
193 .mode = 0555,
194 .child = net_table,
196 #endif
198 .ctl_name = CTL_PROC,
199 .procname = "proc",
200 .mode = 0555,
201 .child = proc_table,
204 .ctl_name = CTL_FS,
205 .procname = "fs",
206 .mode = 0555,
207 .child = fs_table,
210 .ctl_name = CTL_DEBUG,
211 .procname = "debug",
212 .mode = 0555,
213 .child = debug_table,
216 .ctl_name = CTL_DEV,
217 .procname = "dev",
218 .mode = 0555,
219 .child = dev_table,
222 { .ctl_name = 0 }
225 static ctl_table kern_table[] = {
227 .ctl_name = KERN_OSTYPE,
228 .procname = "ostype",
229 .data = system_utsname.sysname,
230 .maxlen = sizeof(system_utsname.sysname),
231 .mode = 0444,
232 .proc_handler = &proc_doutsstring,
233 .strategy = &sysctl_string,
236 .ctl_name = KERN_OSRELEASE,
237 .procname = "osrelease",
238 .data = system_utsname.release,
239 .maxlen = sizeof(system_utsname.release),
240 .mode = 0444,
241 .proc_handler = &proc_doutsstring,
242 .strategy = &sysctl_string,
245 .ctl_name = KERN_VERSION,
246 .procname = "version",
247 .data = system_utsname.version,
248 .maxlen = sizeof(system_utsname.version),
249 .mode = 0444,
250 .proc_handler = &proc_doutsstring,
251 .strategy = &sysctl_string,
254 .ctl_name = KERN_NODENAME,
255 .procname = "hostname",
256 .data = system_utsname.nodename,
257 .maxlen = sizeof(system_utsname.nodename),
258 .mode = 0644,
259 .proc_handler = &proc_doutsstring,
260 .strategy = &sysctl_string,
263 .ctl_name = KERN_DOMAINNAME,
264 .procname = "domainname",
265 .data = system_utsname.domainname,
266 .maxlen = sizeof(system_utsname.domainname),
267 .mode = 0644,
268 .proc_handler = &proc_doutsstring,
269 .strategy = &sysctl_string,
272 .ctl_name = KERN_PANIC,
273 .procname = "panic",
274 .data = &panic_timeout,
275 .maxlen = sizeof(int),
276 .mode = 0644,
277 .proc_handler = &proc_dointvec,
280 .ctl_name = KERN_CORE_USES_PID,
281 .procname = "core_uses_pid",
282 .data = &core_uses_pid,
283 .maxlen = sizeof(int),
284 .mode = 0644,
285 .proc_handler = &proc_dointvec,
288 .ctl_name = KERN_CORE_PATTERN,
289 .procname = "core_pattern",
290 .data = core_pattern,
291 .maxlen = 64,
292 .mode = 0644,
293 .proc_handler = &proc_dostring,
294 .strategy = &sysctl_string,
297 .ctl_name = KERN_TAINTED,
298 .procname = "tainted",
299 .data = &tainted,
300 .maxlen = sizeof(int),
301 .mode = 0444,
302 .proc_handler = &proc_dointvec,
305 .ctl_name = KERN_CAP_BSET,
306 .procname = "cap-bound",
307 .data = &cap_bset,
308 .maxlen = sizeof(kernel_cap_t),
309 .mode = 0600,
310 .proc_handler = &proc_dointvec_bset,
312 #ifdef CONFIG_BLK_DEV_INITRD
314 .ctl_name = KERN_REALROOTDEV,
315 .procname = "real-root-dev",
316 .data = &real_root_dev,
317 .maxlen = sizeof(int),
318 .mode = 0644,
319 .proc_handler = &proc_dointvec,
321 #endif
322 #ifdef __sparc__
324 .ctl_name = KERN_SPARC_REBOOT,
325 .procname = "reboot-cmd",
326 .data = reboot_command,
327 .maxlen = 256,
328 .mode = 0644,
329 .proc_handler = &proc_dostring,
330 .strategy = &sysctl_string,
333 .ctl_name = KERN_SPARC_STOP_A,
334 .procname = "stop-a",
335 .data = &stop_a_enabled,
336 .maxlen = sizeof (int),
337 .mode = 0644,
338 .proc_handler = &proc_dointvec,
341 .ctl_name = KERN_SPARC_SCONS_PWROFF,
342 .procname = "scons-poweroff",
343 .data = &scons_pwroff,
344 .maxlen = sizeof (int),
345 .mode = 0644,
346 .proc_handler = &proc_dointvec,
348 #endif
349 #ifdef __hppa__
351 .ctl_name = KERN_HPPA_PWRSW,
352 .procname = "soft-power",
353 .data = &pwrsw_enabled,
354 .maxlen = sizeof (int),
355 .mode = 0644,
356 .proc_handler = &proc_dointvec,
359 .ctl_name = KERN_HPPA_UNALIGNED,
360 .procname = "unaligned-trap",
361 .data = &unaligned_enabled,
362 .maxlen = sizeof (int),
363 .mode = 0644,
364 .proc_handler = &proc_dointvec,
366 #endif
368 .ctl_name = KERN_CTLALTDEL,
369 .procname = "ctrl-alt-del",
370 .data = &C_A_D,
371 .maxlen = sizeof(int),
372 .mode = 0644,
373 .proc_handler = &proc_dointvec,
376 .ctl_name = KERN_PRINTK,
377 .procname = "printk",
378 .data = &console_loglevel,
379 .maxlen = 4*sizeof(int),
380 .mode = 0644,
381 .proc_handler = &proc_dointvec,
383 #ifdef CONFIG_KMOD
385 .ctl_name = KERN_MODPROBE,
386 .procname = "modprobe",
387 .data = &modprobe_path,
388 .maxlen = KMOD_PATH_LEN,
389 .mode = 0644,
390 .proc_handler = &proc_dostring,
391 .strategy = &sysctl_string,
393 #endif
394 #ifdef CONFIG_HOTPLUG
396 .ctl_name = KERN_HOTPLUG,
397 .procname = "hotplug",
398 .data = &uevent_helper,
399 .maxlen = UEVENT_HELPER_PATH_LEN,
400 .mode = 0644,
401 .proc_handler = &proc_dostring,
402 .strategy = &sysctl_string,
404 #endif
405 #ifdef CONFIG_CHR_DEV_SG
407 .ctl_name = KERN_SG_BIG_BUFF,
408 .procname = "sg-big-buff",
409 .data = &sg_big_buff,
410 .maxlen = sizeof (int),
411 .mode = 0444,
412 .proc_handler = &proc_dointvec,
414 #endif
415 #ifdef CONFIG_BSD_PROCESS_ACCT
417 .ctl_name = KERN_ACCT,
418 .procname = "acct",
419 .data = &acct_parm,
420 .maxlen = 3*sizeof(int),
421 .mode = 0644,
422 .proc_handler = &proc_dointvec,
424 #endif
425 #ifdef CONFIG_SYSVIPC
427 .ctl_name = KERN_SHMMAX,
428 .procname = "shmmax",
429 .data = &shm_ctlmax,
430 .maxlen = sizeof (size_t),
431 .mode = 0644,
432 .proc_handler = &proc_doulongvec_minmax,
435 .ctl_name = KERN_SHMALL,
436 .procname = "shmall",
437 .data = &shm_ctlall,
438 .maxlen = sizeof (size_t),
439 .mode = 0644,
440 .proc_handler = &proc_doulongvec_minmax,
443 .ctl_name = KERN_SHMMNI,
444 .procname = "shmmni",
445 .data = &shm_ctlmni,
446 .maxlen = sizeof (int),
447 .mode = 0644,
448 .proc_handler = &proc_dointvec,
451 .ctl_name = KERN_MSGMAX,
452 .procname = "msgmax",
453 .data = &msg_ctlmax,
454 .maxlen = sizeof (int),
455 .mode = 0644,
456 .proc_handler = &proc_dointvec,
459 .ctl_name = KERN_MSGMNI,
460 .procname = "msgmni",
461 .data = &msg_ctlmni,
462 .maxlen = sizeof (int),
463 .mode = 0644,
464 .proc_handler = &proc_dointvec,
467 .ctl_name = KERN_MSGMNB,
468 .procname = "msgmnb",
469 .data = &msg_ctlmnb,
470 .maxlen = sizeof (int),
471 .mode = 0644,
472 .proc_handler = &proc_dointvec,
475 .ctl_name = KERN_SEM,
476 .procname = "sem",
477 .data = &sem_ctls,
478 .maxlen = 4*sizeof (int),
479 .mode = 0644,
480 .proc_handler = &proc_dointvec,
482 #endif
483 #ifdef CONFIG_MAGIC_SYSRQ
485 .ctl_name = KERN_SYSRQ,
486 .procname = "sysrq",
487 .data = &sysrq_enabled,
488 .maxlen = sizeof (int),
489 .mode = 0644,
490 .proc_handler = &proc_dointvec,
492 #endif
494 .ctl_name = KERN_CADPID,
495 .procname = "cad_pid",
496 .data = &cad_pid,
497 .maxlen = sizeof (int),
498 .mode = 0600,
499 .proc_handler = &proc_dointvec,
502 .ctl_name = KERN_MAX_THREADS,
503 .procname = "threads-max",
504 .data = &max_threads,
505 .maxlen = sizeof(int),
506 .mode = 0644,
507 .proc_handler = &proc_dointvec,
510 .ctl_name = KERN_RANDOM,
511 .procname = "random",
512 .mode = 0555,
513 .child = random_table,
515 #ifdef CONFIG_UNIX98_PTYS
517 .ctl_name = KERN_PTY,
518 .procname = "pty",
519 .mode = 0555,
520 .child = pty_table,
522 #endif
524 .ctl_name = KERN_OVERFLOWUID,
525 .procname = "overflowuid",
526 .data = &overflowuid,
527 .maxlen = sizeof(int),
528 .mode = 0644,
529 .proc_handler = &proc_dointvec_minmax,
530 .strategy = &sysctl_intvec,
531 .extra1 = &minolduid,
532 .extra2 = &maxolduid,
535 .ctl_name = KERN_OVERFLOWGID,
536 .procname = "overflowgid",
537 .data = &overflowgid,
538 .maxlen = sizeof(int),
539 .mode = 0644,
540 .proc_handler = &proc_dointvec_minmax,
541 .strategy = &sysctl_intvec,
542 .extra1 = &minolduid,
543 .extra2 = &maxolduid,
545 #ifdef CONFIG_S390
546 #ifdef CONFIG_MATHEMU
548 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
549 .procname = "ieee_emulation_warnings",
550 .data = &sysctl_ieee_emulation_warnings,
551 .maxlen = sizeof(int),
552 .mode = 0644,
553 .proc_handler = &proc_dointvec,
555 #endif
556 #ifdef CONFIG_NO_IDLE_HZ
558 .ctl_name = KERN_HZ_TIMER,
559 .procname = "hz_timer",
560 .data = &sysctl_hz_timer,
561 .maxlen = sizeof(int),
562 .mode = 0644,
563 .proc_handler = &proc_dointvec,
565 #endif
567 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
568 .procname = "userprocess_debug",
569 .data = &sysctl_userprocess_debug,
570 .maxlen = sizeof(int),
571 .mode = 0644,
572 .proc_handler = &proc_dointvec,
574 #endif
576 .ctl_name = KERN_PIDMAX,
577 .procname = "pid_max",
578 .data = &pid_max,
579 .maxlen = sizeof (int),
580 .mode = 0644,
581 .proc_handler = &proc_dointvec_minmax,
582 .strategy = sysctl_intvec,
583 .extra1 = &pid_max_min,
584 .extra2 = &pid_max_max,
587 .ctl_name = KERN_PANIC_ON_OOPS,
588 .procname = "panic_on_oops",
589 .data = &panic_on_oops,
590 .maxlen = sizeof(int),
591 .mode = 0644,
592 .proc_handler = &proc_dointvec,
595 .ctl_name = KERN_PRINTK_RATELIMIT,
596 .procname = "printk_ratelimit",
597 .data = &printk_ratelimit_jiffies,
598 .maxlen = sizeof(int),
599 .mode = 0644,
600 .proc_handler = &proc_dointvec_jiffies,
601 .strategy = &sysctl_jiffies,
604 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
605 .procname = "printk_ratelimit_burst",
606 .data = &printk_ratelimit_burst,
607 .maxlen = sizeof(int),
608 .mode = 0644,
609 .proc_handler = &proc_dointvec,
612 .ctl_name = KERN_NGROUPS_MAX,
613 .procname = "ngroups_max",
614 .data = &ngroups_max,
615 .maxlen = sizeof (int),
616 .mode = 0444,
617 .proc_handler = &proc_dointvec,
619 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
621 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
622 .procname = "unknown_nmi_panic",
623 .data = &unknown_nmi_panic,
624 .maxlen = sizeof (int),
625 .mode = 0644,
626 .proc_handler = &proc_unknown_nmi_panic,
628 #endif
629 #if defined(CONFIG_X86)
631 .ctl_name = KERN_BOOTLOADER_TYPE,
632 .procname = "bootloader_type",
633 .data = &bootloader_type,
634 .maxlen = sizeof (int),
635 .mode = 0444,
636 .proc_handler = &proc_dointvec,
638 #endif
639 #if defined(CONFIG_MMU)
641 .ctl_name = KERN_RANDOMIZE,
642 .procname = "randomize_va_space",
643 .data = &randomize_va_space,
644 .maxlen = sizeof(int),
645 .mode = 0644,
646 .proc_handler = &proc_dointvec,
648 #endif
649 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
651 .ctl_name = KERN_SPIN_RETRY,
652 .procname = "spin_retry",
653 .data = &spin_retry,
654 .maxlen = sizeof (int),
655 .mode = 0644,
656 .proc_handler = &proc_dointvec,
658 #endif
659 #ifdef CONFIG_ACPI_SLEEP
661 .ctl_name = KERN_ACPI_VIDEO_FLAGS,
662 .procname = "acpi_video_flags",
663 .data = &acpi_video_flags,
664 .maxlen = sizeof (unsigned long),
665 .mode = 0644,
666 .proc_handler = &proc_dointvec,
668 #endif
669 { .ctl_name = 0 }
672 /* Constants for minimum and maximum testing in vm_table.
673 We use these as one-element integer vectors. */
674 static int zero;
675 static int one_hundred = 100;
678 static ctl_table vm_table[] = {
680 .ctl_name = VM_OVERCOMMIT_MEMORY,
681 .procname = "overcommit_memory",
682 .data = &sysctl_overcommit_memory,
683 .maxlen = sizeof(sysctl_overcommit_memory),
684 .mode = 0644,
685 .proc_handler = &proc_dointvec,
688 .ctl_name = VM_OVERCOMMIT_RATIO,
689 .procname = "overcommit_ratio",
690 .data = &sysctl_overcommit_ratio,
691 .maxlen = sizeof(sysctl_overcommit_ratio),
692 .mode = 0644,
693 .proc_handler = &proc_dointvec,
696 .ctl_name = VM_PAGE_CLUSTER,
697 .procname = "page-cluster",
698 .data = &page_cluster,
699 .maxlen = sizeof(int),
700 .mode = 0644,
701 .proc_handler = &proc_dointvec,
704 .ctl_name = VM_DIRTY_BACKGROUND,
705 .procname = "dirty_background_ratio",
706 .data = &dirty_background_ratio,
707 .maxlen = sizeof(dirty_background_ratio),
708 .mode = 0644,
709 .proc_handler = &proc_dointvec_minmax,
710 .strategy = &sysctl_intvec,
711 .extra1 = &zero,
712 .extra2 = &one_hundred,
715 .ctl_name = VM_DIRTY_RATIO,
716 .procname = "dirty_ratio",
717 .data = &vm_dirty_ratio,
718 .maxlen = sizeof(vm_dirty_ratio),
719 .mode = 0644,
720 .proc_handler = &proc_dointvec_minmax,
721 .strategy = &sysctl_intvec,
722 .extra1 = &zero,
723 .extra2 = &one_hundred,
726 .ctl_name = VM_DIRTY_WB_CS,
727 .procname = "dirty_writeback_centisecs",
728 .data = &dirty_writeback_centisecs,
729 .maxlen = sizeof(dirty_writeback_centisecs),
730 .mode = 0644,
731 .proc_handler = &dirty_writeback_centisecs_handler,
734 .ctl_name = VM_DIRTY_EXPIRE_CS,
735 .procname = "dirty_expire_centisecs",
736 .data = &dirty_expire_centisecs,
737 .maxlen = sizeof(dirty_expire_centisecs),
738 .mode = 0644,
739 .proc_handler = &proc_dointvec,
742 .ctl_name = VM_NR_PDFLUSH_THREADS,
743 .procname = "nr_pdflush_threads",
744 .data = &nr_pdflush_threads,
745 .maxlen = sizeof nr_pdflush_threads,
746 .mode = 0444 /* read-only*/,
747 .proc_handler = &proc_dointvec,
750 .ctl_name = VM_SWAPPINESS,
751 .procname = "swappiness",
752 .data = &vm_swappiness,
753 .maxlen = sizeof(vm_swappiness),
754 .mode = 0644,
755 .proc_handler = &proc_dointvec_minmax,
756 .strategy = &sysctl_intvec,
757 .extra1 = &zero,
758 .extra2 = &one_hundred,
760 #ifdef CONFIG_HUGETLB_PAGE
762 .ctl_name = VM_HUGETLB_PAGES,
763 .procname = "nr_hugepages",
764 .data = &max_huge_pages,
765 .maxlen = sizeof(unsigned long),
766 .mode = 0644,
767 .proc_handler = &hugetlb_sysctl_handler,
768 .extra1 = (void *)&hugetlb_zero,
769 .extra2 = (void *)&hugetlb_infinity,
772 .ctl_name = VM_HUGETLB_GROUP,
773 .procname = "hugetlb_shm_group",
774 .data = &sysctl_hugetlb_shm_group,
775 .maxlen = sizeof(gid_t),
776 .mode = 0644,
777 .proc_handler = &proc_dointvec,
779 #endif
781 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
782 .procname = "lowmem_reserve_ratio",
783 .data = &sysctl_lowmem_reserve_ratio,
784 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
785 .mode = 0644,
786 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
787 .strategy = &sysctl_intvec,
790 .ctl_name = VM_DROP_PAGECACHE,
791 .procname = "drop_caches",
792 .data = &sysctl_drop_caches,
793 .maxlen = sizeof(int),
794 .mode = 0644,
795 .proc_handler = drop_caches_sysctl_handler,
796 .strategy = &sysctl_intvec,
799 .ctl_name = VM_MIN_FREE_KBYTES,
800 .procname = "min_free_kbytes",
801 .data = &min_free_kbytes,
802 .maxlen = sizeof(min_free_kbytes),
803 .mode = 0644,
804 .proc_handler = &min_free_kbytes_sysctl_handler,
805 .strategy = &sysctl_intvec,
806 .extra1 = &zero,
809 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
810 .procname = "percpu_pagelist_fraction",
811 .data = &percpu_pagelist_fraction,
812 .maxlen = sizeof(percpu_pagelist_fraction),
813 .mode = 0644,
814 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
815 .strategy = &sysctl_intvec,
816 .extra1 = &min_percpu_pagelist_fract,
818 #ifdef CONFIG_MMU
820 .ctl_name = VM_MAX_MAP_COUNT,
821 .procname = "max_map_count",
822 .data = &sysctl_max_map_count,
823 .maxlen = sizeof(sysctl_max_map_count),
824 .mode = 0644,
825 .proc_handler = &proc_dointvec
827 #endif
829 .ctl_name = VM_LAPTOP_MODE,
830 .procname = "laptop_mode",
831 .data = &laptop_mode,
832 .maxlen = sizeof(laptop_mode),
833 .mode = 0644,
834 .proc_handler = &proc_dointvec,
835 .strategy = &sysctl_intvec,
836 .extra1 = &zero,
839 .ctl_name = VM_BLOCK_DUMP,
840 .procname = "block_dump",
841 .data = &block_dump,
842 .maxlen = sizeof(block_dump),
843 .mode = 0644,
844 .proc_handler = &proc_dointvec,
845 .strategy = &sysctl_intvec,
846 .extra1 = &zero,
849 .ctl_name = VM_VFS_CACHE_PRESSURE,
850 .procname = "vfs_cache_pressure",
851 .data = &sysctl_vfs_cache_pressure,
852 .maxlen = sizeof(sysctl_vfs_cache_pressure),
853 .mode = 0644,
854 .proc_handler = &proc_dointvec,
855 .strategy = &sysctl_intvec,
856 .extra1 = &zero,
858 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
860 .ctl_name = VM_LEGACY_VA_LAYOUT,
861 .procname = "legacy_va_layout",
862 .data = &sysctl_legacy_va_layout,
863 .maxlen = sizeof(sysctl_legacy_va_layout),
864 .mode = 0644,
865 .proc_handler = &proc_dointvec,
866 .strategy = &sysctl_intvec,
867 .extra1 = &zero,
869 #endif
870 #ifdef CONFIG_SWAP
872 .ctl_name = VM_SWAP_TOKEN_TIMEOUT,
873 .procname = "swap_token_timeout",
874 .data = &swap_token_default_timeout,
875 .maxlen = sizeof(swap_token_default_timeout),
876 .mode = 0644,
877 .proc_handler = &proc_dointvec_jiffies,
878 .strategy = &sysctl_jiffies,
880 #endif
881 #ifdef CONFIG_NUMA
883 .ctl_name = VM_ZONE_RECLAIM_MODE,
884 .procname = "zone_reclaim_mode",
885 .data = &zone_reclaim_mode,
886 .maxlen = sizeof(zone_reclaim_mode),
887 .mode = 0644,
888 .proc_handler = &proc_dointvec,
889 .strategy = &sysctl_intvec,
890 .extra1 = &zero,
893 .ctl_name = VM_ZONE_RECLAIM_INTERVAL,
894 .procname = "zone_reclaim_interval",
895 .data = &zone_reclaim_interval,
896 .maxlen = sizeof(zone_reclaim_interval),
897 .mode = 0644,
898 .proc_handler = &proc_dointvec_jiffies,
899 .strategy = &sysctl_jiffies,
901 #endif
902 { .ctl_name = 0 }
905 static ctl_table proc_table[] = {
906 { .ctl_name = 0 }
909 static ctl_table fs_table[] = {
911 .ctl_name = FS_NRINODE,
912 .procname = "inode-nr",
913 .data = &inodes_stat,
914 .maxlen = 2*sizeof(int),
915 .mode = 0444,
916 .proc_handler = &proc_dointvec,
919 .ctl_name = FS_STATINODE,
920 .procname = "inode-state",
921 .data = &inodes_stat,
922 .maxlen = 7*sizeof(int),
923 .mode = 0444,
924 .proc_handler = &proc_dointvec,
927 .ctl_name = FS_NRFILE,
928 .procname = "file-nr",
929 .data = &files_stat,
930 .maxlen = 3*sizeof(int),
931 .mode = 0444,
932 .proc_handler = &proc_dointvec,
935 .ctl_name = FS_MAXFILE,
936 .procname = "file-max",
937 .data = &files_stat.max_files,
938 .maxlen = sizeof(int),
939 .mode = 0644,
940 .proc_handler = &proc_dointvec,
943 .ctl_name = FS_DENTRY,
944 .procname = "dentry-state",
945 .data = &dentry_stat,
946 .maxlen = 6*sizeof(int),
947 .mode = 0444,
948 .proc_handler = &proc_dointvec,
951 .ctl_name = FS_OVERFLOWUID,
952 .procname = "overflowuid",
953 .data = &fs_overflowuid,
954 .maxlen = sizeof(int),
955 .mode = 0644,
956 .proc_handler = &proc_dointvec_minmax,
957 .strategy = &sysctl_intvec,
958 .extra1 = &minolduid,
959 .extra2 = &maxolduid,
962 .ctl_name = FS_OVERFLOWGID,
963 .procname = "overflowgid",
964 .data = &fs_overflowgid,
965 .maxlen = sizeof(int),
966 .mode = 0644,
967 .proc_handler = &proc_dointvec_minmax,
968 .strategy = &sysctl_intvec,
969 .extra1 = &minolduid,
970 .extra2 = &maxolduid,
973 .ctl_name = FS_LEASES,
974 .procname = "leases-enable",
975 .data = &leases_enable,
976 .maxlen = sizeof(int),
977 .mode = 0644,
978 .proc_handler = &proc_dointvec,
980 #ifdef CONFIG_DNOTIFY
982 .ctl_name = FS_DIR_NOTIFY,
983 .procname = "dir-notify-enable",
984 .data = &dir_notify_enable,
985 .maxlen = sizeof(int),
986 .mode = 0644,
987 .proc_handler = &proc_dointvec,
989 #endif
990 #ifdef CONFIG_MMU
992 .ctl_name = FS_LEASE_TIME,
993 .procname = "lease-break-time",
994 .data = &lease_break_time,
995 .maxlen = sizeof(int),
996 .mode = 0644,
997 .proc_handler = &proc_dointvec,
1000 .ctl_name = FS_AIO_NR,
1001 .procname = "aio-nr",
1002 .data = &aio_nr,
1003 .maxlen = sizeof(aio_nr),
1004 .mode = 0444,
1005 .proc_handler = &proc_doulongvec_minmax,
1008 .ctl_name = FS_AIO_MAX_NR,
1009 .procname = "aio-max-nr",
1010 .data = &aio_max_nr,
1011 .maxlen = sizeof(aio_max_nr),
1012 .mode = 0644,
1013 .proc_handler = &proc_doulongvec_minmax,
1015 #ifdef CONFIG_INOTIFY
1017 .ctl_name = FS_INOTIFY,
1018 .procname = "inotify",
1019 .mode = 0555,
1020 .child = inotify_table,
1022 #endif
1023 #endif
1025 .ctl_name = KERN_SETUID_DUMPABLE,
1026 .procname = "suid_dumpable",
1027 .data = &suid_dumpable,
1028 .maxlen = sizeof(int),
1029 .mode = 0644,
1030 .proc_handler = &proc_dointvec,
1032 { .ctl_name = 0 }
1035 static ctl_table debug_table[] = {
1036 { .ctl_name = 0 }
1039 static ctl_table dev_table[] = {
1040 { .ctl_name = 0 }
1043 extern void init_irq_proc (void);
1045 static DEFINE_SPINLOCK(sysctl_lock);
1047 /* called under sysctl_lock */
1048 static int use_table(struct ctl_table_header *p)
1050 if (unlikely(p->unregistering))
1051 return 0;
1052 p->used++;
1053 return 1;
1056 /* called under sysctl_lock */
1057 static void unuse_table(struct ctl_table_header *p)
1059 if (!--p->used)
1060 if (unlikely(p->unregistering))
1061 complete(p->unregistering);
1064 /* called under sysctl_lock, will reacquire if has to wait */
1065 static void start_unregistering(struct ctl_table_header *p)
1068 * if p->used is 0, nobody will ever touch that entry again;
1069 * we'll eliminate all paths to it before dropping sysctl_lock
1071 if (unlikely(p->used)) {
1072 struct completion wait;
1073 init_completion(&wait);
1074 p->unregistering = &wait;
1075 spin_unlock(&sysctl_lock);
1076 wait_for_completion(&wait);
1077 spin_lock(&sysctl_lock);
1080 * do not remove from the list until nobody holds it; walking the
1081 * list in do_sysctl() relies on that.
1083 list_del_init(&p->ctl_entry);
1086 void __init sysctl_init(void)
1088 #ifdef CONFIG_PROC_FS
1089 register_proc_table(root_table, proc_sys_root, &root_table_header);
1090 init_irq_proc();
1091 #endif
1094 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1095 void __user *newval, size_t newlen)
1097 struct list_head *tmp;
1098 int error = -ENOTDIR;
1100 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1101 return -ENOTDIR;
1102 if (oldval) {
1103 int old_len;
1104 if (!oldlenp || get_user(old_len, oldlenp))
1105 return -EFAULT;
1107 spin_lock(&sysctl_lock);
1108 tmp = &root_table_header.ctl_entry;
1109 do {
1110 struct ctl_table_header *head =
1111 list_entry(tmp, struct ctl_table_header, ctl_entry);
1112 void *context = NULL;
1114 if (!use_table(head))
1115 continue;
1117 spin_unlock(&sysctl_lock);
1119 error = parse_table(name, nlen, oldval, oldlenp,
1120 newval, newlen, head->ctl_table,
1121 &context);
1122 kfree(context);
1124 spin_lock(&sysctl_lock);
1125 unuse_table(head);
1126 if (error != -ENOTDIR)
1127 break;
1128 } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
1129 spin_unlock(&sysctl_lock);
1130 return error;
1133 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1135 struct __sysctl_args tmp;
1136 int error;
1138 if (copy_from_user(&tmp, args, sizeof(tmp)))
1139 return -EFAULT;
1141 lock_kernel();
1142 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1143 tmp.newval, tmp.newlen);
1144 unlock_kernel();
1145 return error;
1149 * ctl_perm does NOT grant the superuser all rights automatically, because
1150 * some sysctl variables are readonly even to root.
1153 static int test_perm(int mode, int op)
1155 if (!current->euid)
1156 mode >>= 6;
1157 else if (in_egroup_p(0))
1158 mode >>= 3;
1159 if ((mode & op & 0007) == op)
1160 return 0;
1161 return -EACCES;
1164 static inline int ctl_perm(ctl_table *table, int op)
1166 int error;
1167 error = security_sysctl(table, op);
1168 if (error)
1169 return error;
1170 return test_perm(table->mode, op);
1173 static int parse_table(int __user *name, int nlen,
1174 void __user *oldval, size_t __user *oldlenp,
1175 void __user *newval, size_t newlen,
1176 ctl_table *table, void **context)
1178 int n;
1179 repeat:
1180 if (!nlen)
1181 return -ENOTDIR;
1182 if (get_user(n, name))
1183 return -EFAULT;
1184 for ( ; table->ctl_name; table++) {
1185 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1186 int error;
1187 if (table->child) {
1188 if (ctl_perm(table, 001))
1189 return -EPERM;
1190 if (table->strategy) {
1191 error = table->strategy(
1192 table, name, nlen,
1193 oldval, oldlenp,
1194 newval, newlen, context);
1195 if (error)
1196 return error;
1198 name++;
1199 nlen--;
1200 table = table->child;
1201 goto repeat;
1203 error = do_sysctl_strategy(table, name, nlen,
1204 oldval, oldlenp,
1205 newval, newlen, context);
1206 return error;
1209 return -ENOTDIR;
1212 /* Perform the actual read/write of a sysctl table entry. */
1213 int do_sysctl_strategy (ctl_table *table,
1214 int __user *name, int nlen,
1215 void __user *oldval, size_t __user *oldlenp,
1216 void __user *newval, size_t newlen, void **context)
1218 int op = 0, rc;
1219 size_t len;
1221 if (oldval)
1222 op |= 004;
1223 if (newval)
1224 op |= 002;
1225 if (ctl_perm(table, op))
1226 return -EPERM;
1228 if (table->strategy) {
1229 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1230 newval, newlen, context);
1231 if (rc < 0)
1232 return rc;
1233 if (rc > 0)
1234 return 0;
1237 /* If there is no strategy routine, or if the strategy returns
1238 * zero, proceed with automatic r/w */
1239 if (table->data && table->maxlen) {
1240 if (oldval && oldlenp) {
1241 if (get_user(len, oldlenp))
1242 return -EFAULT;
1243 if (len) {
1244 if (len > table->maxlen)
1245 len = table->maxlen;
1246 if(copy_to_user(oldval, table->data, len))
1247 return -EFAULT;
1248 if(put_user(len, oldlenp))
1249 return -EFAULT;
1252 if (newval && newlen) {
1253 len = newlen;
1254 if (len > table->maxlen)
1255 len = table->maxlen;
1256 if(copy_from_user(table->data, newval, len))
1257 return -EFAULT;
1260 return 0;
1264 * register_sysctl_table - register a sysctl hierarchy
1265 * @table: the top-level table structure
1266 * @insert_at_head: whether the entry should be inserted in front or at the end
1268 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1269 * array. An entry with a ctl_name of 0 terminates the table.
1271 * The members of the &ctl_table structure are used as follows:
1273 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1274 * must be unique within that level of sysctl
1276 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1277 * enter a sysctl file
1279 * data - a pointer to data for use by proc_handler
1281 * maxlen - the maximum size in bytes of the data
1283 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1285 * child - a pointer to the child sysctl table if this entry is a directory, or
1286 * %NULL.
1288 * proc_handler - the text handler routine (described below)
1290 * strategy - the strategy routine (described below)
1292 * de - for internal use by the sysctl routines
1294 * extra1, extra2 - extra pointers usable by the proc handler routines
1296 * Leaf nodes in the sysctl tree will be represented by a single file
1297 * under /proc; non-leaf nodes will be represented by directories.
1299 * sysctl(2) can automatically manage read and write requests through
1300 * the sysctl table. The data and maxlen fields of the ctl_table
1301 * struct enable minimal validation of the values being written to be
1302 * performed, and the mode field allows minimal authentication.
1304 * More sophisticated management can be enabled by the provision of a
1305 * strategy routine with the table entry. This will be called before
1306 * any automatic read or write of the data is performed.
1308 * The strategy routine may return
1310 * < 0 - Error occurred (error is passed to user process)
1312 * 0 - OK - proceed with automatic read or write.
1314 * > 0 - OK - read or write has been done by the strategy routine, so
1315 * return immediately.
1317 * There must be a proc_handler routine for any terminal nodes
1318 * mirrored under /proc/sys (non-terminals are handled by a built-in
1319 * directory handler). Several default handlers are available to
1320 * cover common cases -
1322 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1323 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1324 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1326 * It is the handler's job to read the input buffer from user memory
1327 * and process it. The handler should return 0 on success.
1329 * This routine returns %NULL on a failure to register, and a pointer
1330 * to the table header on success.
1332 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1333 int insert_at_head)
1335 struct ctl_table_header *tmp;
1336 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1337 if (!tmp)
1338 return NULL;
1339 tmp->ctl_table = table;
1340 INIT_LIST_HEAD(&tmp->ctl_entry);
1341 tmp->used = 0;
1342 tmp->unregistering = NULL;
1343 spin_lock(&sysctl_lock);
1344 if (insert_at_head)
1345 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1346 else
1347 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1348 spin_unlock(&sysctl_lock);
1349 #ifdef CONFIG_PROC_FS
1350 register_proc_table(table, proc_sys_root, tmp);
1351 #endif
1352 return tmp;
1356 * unregister_sysctl_table - unregister a sysctl table hierarchy
1357 * @header: the header returned from register_sysctl_table
1359 * Unregisters the sysctl table and all children. proc entries may not
1360 * actually be removed until they are no longer used by anyone.
1362 void unregister_sysctl_table(struct ctl_table_header * header)
1364 might_sleep();
1365 spin_lock(&sysctl_lock);
1366 start_unregistering(header);
1367 #ifdef CONFIG_PROC_FS
1368 unregister_proc_table(header->ctl_table, proc_sys_root);
1369 #endif
1370 spin_unlock(&sysctl_lock);
1371 kfree(header);
1375 * /proc/sys support
1378 #ifdef CONFIG_PROC_FS
1380 /* Scan the sysctl entries in table and add them all into /proc */
1381 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
1383 struct proc_dir_entry *de;
1384 int len;
1385 mode_t mode;
1387 for (; table->ctl_name; table++) {
1388 /* Can't do anything without a proc name. */
1389 if (!table->procname)
1390 continue;
1391 /* Maybe we can't do anything with it... */
1392 if (!table->proc_handler && !table->child) {
1393 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1394 table->procname);
1395 continue;
1398 len = strlen(table->procname);
1399 mode = table->mode;
1401 de = NULL;
1402 if (table->proc_handler)
1403 mode |= S_IFREG;
1404 else {
1405 mode |= S_IFDIR;
1406 for (de = root->subdir; de; de = de->next) {
1407 if (proc_match(len, table->procname, de))
1408 break;
1410 /* If the subdir exists already, de is non-NULL */
1413 if (!de) {
1414 de = create_proc_entry(table->procname, mode, root);
1415 if (!de)
1416 continue;
1417 de->set = set;
1418 de->data = (void *) table;
1419 if (table->proc_handler)
1420 de->proc_fops = &proc_sys_file_operations;
1422 table->de = de;
1423 if (de->mode & S_IFDIR)
1424 register_proc_table(table->child, de, set);
1429 * Unregister a /proc sysctl table and any subdirectories.
1431 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1433 struct proc_dir_entry *de;
1434 for (; table->ctl_name; table++) {
1435 if (!(de = table->de))
1436 continue;
1437 if (de->mode & S_IFDIR) {
1438 if (!table->child) {
1439 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1440 continue;
1442 unregister_proc_table(table->child, de);
1444 /* Don't unregister directories which still have entries.. */
1445 if (de->subdir)
1446 continue;
1450 * In any case, mark the entry as goner; we'll keep it
1451 * around if it's busy, but we'll know to do nothing with
1452 * its fields. We are under sysctl_lock here.
1454 de->data = NULL;
1456 /* Don't unregister proc entries that are still being used.. */
1457 if (atomic_read(&de->count))
1458 continue;
1460 table->de = NULL;
1461 remove_proc_entry(table->procname, root);
1465 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1466 size_t count, loff_t *ppos)
1468 int op;
1469 struct proc_dir_entry *de = PDE(file->f_dentry->d_inode);
1470 struct ctl_table *table;
1471 size_t res;
1472 ssize_t error = -ENOTDIR;
1474 spin_lock(&sysctl_lock);
1475 if (de && de->data && use_table(de->set)) {
1477 * at that point we know that sysctl was not unregistered
1478 * and won't be until we finish
1480 spin_unlock(&sysctl_lock);
1481 table = (struct ctl_table *) de->data;
1482 if (!table || !table->proc_handler)
1483 goto out;
1484 error = -EPERM;
1485 op = (write ? 002 : 004);
1486 if (ctl_perm(table, op))
1487 goto out;
1489 /* careful: calling conventions are nasty here */
1490 res = count;
1491 error = (*table->proc_handler)(table, write, file,
1492 buf, &res, ppos);
1493 if (!error)
1494 error = res;
1495 out:
1496 spin_lock(&sysctl_lock);
1497 unuse_table(de->set);
1499 spin_unlock(&sysctl_lock);
1500 return error;
1503 static int proc_opensys(struct inode *inode, struct file *file)
1505 if (file->f_mode & FMODE_WRITE) {
1507 * sysctl entries that are not writable,
1508 * are _NOT_ writable, capabilities or not.
1510 if (!(inode->i_mode & S_IWUSR))
1511 return -EPERM;
1514 return 0;
1517 static ssize_t proc_readsys(struct file * file, char __user * buf,
1518 size_t count, loff_t *ppos)
1520 return do_rw_proc(0, file, buf, count, ppos);
1523 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1524 size_t count, loff_t *ppos)
1526 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1530 * proc_dostring - read a string sysctl
1531 * @table: the sysctl table
1532 * @write: %TRUE if this is a write to the sysctl file
1533 * @filp: the file structure
1534 * @buffer: the user buffer
1535 * @lenp: the size of the user buffer
1536 * @ppos: file position
1538 * Reads/writes a string from/to the user buffer. If the kernel
1539 * buffer provided is not large enough to hold the string, the
1540 * string is truncated. The copied string is %NULL-terminated.
1541 * If the string is being read by the user process, it is copied
1542 * and a newline '\n' is added. It is truncated if the buffer is
1543 * not large enough.
1545 * Returns 0 on success.
1547 int proc_dostring(ctl_table *table, int write, struct file *filp,
1548 void __user *buffer, size_t *lenp, loff_t *ppos)
1550 size_t len;
1551 char __user *p;
1552 char c;
1554 if (!table->data || !table->maxlen || !*lenp ||
1555 (*ppos && !write)) {
1556 *lenp = 0;
1557 return 0;
1560 if (write) {
1561 len = 0;
1562 p = buffer;
1563 while (len < *lenp) {
1564 if (get_user(c, p++))
1565 return -EFAULT;
1566 if (c == 0 || c == '\n')
1567 break;
1568 len++;
1570 if (len >= table->maxlen)
1571 len = table->maxlen-1;
1572 if(copy_from_user(table->data, buffer, len))
1573 return -EFAULT;
1574 ((char *) table->data)[len] = 0;
1575 *ppos += *lenp;
1576 } else {
1577 len = strlen(table->data);
1578 if (len > table->maxlen)
1579 len = table->maxlen;
1580 if (len > *lenp)
1581 len = *lenp;
1582 if (len)
1583 if(copy_to_user(buffer, table->data, len))
1584 return -EFAULT;
1585 if (len < *lenp) {
1586 if(put_user('\n', ((char __user *) buffer) + len))
1587 return -EFAULT;
1588 len++;
1590 *lenp = len;
1591 *ppos += len;
1593 return 0;
1597 * Special case of dostring for the UTS structure. This has locks
1598 * to observe. Should this be in kernel/sys.c ????
1601 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1602 void __user *buffer, size_t *lenp, loff_t *ppos)
1604 int r;
1606 if (!write) {
1607 down_read(&uts_sem);
1608 r=proc_dostring(table,0,filp,buffer,lenp, ppos);
1609 up_read(&uts_sem);
1610 } else {
1611 down_write(&uts_sem);
1612 r=proc_dostring(table,1,filp,buffer,lenp, ppos);
1613 up_write(&uts_sem);
1615 return r;
1618 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1619 int *valp,
1620 int write, void *data)
1622 if (write) {
1623 *valp = *negp ? -*lvalp : *lvalp;
1624 } else {
1625 int val = *valp;
1626 if (val < 0) {
1627 *negp = -1;
1628 *lvalp = (unsigned long)-val;
1629 } else {
1630 *negp = 0;
1631 *lvalp = (unsigned long)val;
1634 return 0;
1637 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1638 void __user *buffer, size_t *lenp, loff_t *ppos,
1639 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1640 int write, void *data),
1641 void *data)
1643 #define TMPBUFLEN 21
1644 int *i, vleft, first=1, neg, val;
1645 unsigned long lval;
1646 size_t left, len;
1648 char buf[TMPBUFLEN], *p;
1649 char __user *s = buffer;
1651 if (!table->data || !table->maxlen || !*lenp ||
1652 (*ppos && !write)) {
1653 *lenp = 0;
1654 return 0;
1657 i = (int *) table->data;
1658 vleft = table->maxlen / sizeof(*i);
1659 left = *lenp;
1661 if (!conv)
1662 conv = do_proc_dointvec_conv;
1664 for (; left && vleft--; i++, first=0) {
1665 if (write) {
1666 while (left) {
1667 char c;
1668 if (get_user(c, s))
1669 return -EFAULT;
1670 if (!isspace(c))
1671 break;
1672 left--;
1673 s++;
1675 if (!left)
1676 break;
1677 neg = 0;
1678 len = left;
1679 if (len > sizeof(buf) - 1)
1680 len = sizeof(buf) - 1;
1681 if (copy_from_user(buf, s, len))
1682 return -EFAULT;
1683 buf[len] = 0;
1684 p = buf;
1685 if (*p == '-' && left > 1) {
1686 neg = 1;
1687 left--, p++;
1689 if (*p < '0' || *p > '9')
1690 break;
1692 lval = simple_strtoul(p, &p, 0);
1694 len = p-buf;
1695 if ((len < left) && *p && !isspace(*p))
1696 break;
1697 if (neg)
1698 val = -val;
1699 s += len;
1700 left -= len;
1702 if (conv(&neg, &lval, i, 1, data))
1703 break;
1704 } else {
1705 p = buf;
1706 if (!first)
1707 *p++ = '\t';
1709 if (conv(&neg, &lval, i, 0, data))
1710 break;
1712 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1713 len = strlen(buf);
1714 if (len > left)
1715 len = left;
1716 if(copy_to_user(s, buf, len))
1717 return -EFAULT;
1718 left -= len;
1719 s += len;
1723 if (!write && !first && left) {
1724 if(put_user('\n', s))
1725 return -EFAULT;
1726 left--, s++;
1728 if (write) {
1729 while (left) {
1730 char c;
1731 if (get_user(c, s++))
1732 return -EFAULT;
1733 if (!isspace(c))
1734 break;
1735 left--;
1738 if (write && first)
1739 return -EINVAL;
1740 *lenp -= left;
1741 *ppos += *lenp;
1742 return 0;
1743 #undef TMPBUFLEN
1747 * proc_dointvec - read a vector of integers
1748 * @table: the sysctl table
1749 * @write: %TRUE if this is a write to the sysctl file
1750 * @filp: the file structure
1751 * @buffer: the user buffer
1752 * @lenp: the size of the user buffer
1753 * @ppos: file position
1755 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1756 * values from/to the user buffer, treated as an ASCII string.
1758 * Returns 0 on success.
1760 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1761 void __user *buffer, size_t *lenp, loff_t *ppos)
1763 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1764 NULL,NULL);
1767 #define OP_SET 0
1768 #define OP_AND 1
1769 #define OP_OR 2
1770 #define OP_MAX 3
1771 #define OP_MIN 4
1773 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1774 int *valp,
1775 int write, void *data)
1777 int op = *(int *)data;
1778 if (write) {
1779 int val = *negp ? -*lvalp : *lvalp;
1780 switch(op) {
1781 case OP_SET: *valp = val; break;
1782 case OP_AND: *valp &= val; break;
1783 case OP_OR: *valp |= val; break;
1784 case OP_MAX: if(*valp < val)
1785 *valp = val;
1786 break;
1787 case OP_MIN: if(*valp > val)
1788 *valp = val;
1789 break;
1791 } else {
1792 int val = *valp;
1793 if (val < 0) {
1794 *negp = -1;
1795 *lvalp = (unsigned long)-val;
1796 } else {
1797 *negp = 0;
1798 *lvalp = (unsigned long)val;
1801 return 0;
1805 * init may raise the set.
1808 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1809 void __user *buffer, size_t *lenp, loff_t *ppos)
1811 int op;
1813 if (!capable(CAP_SYS_MODULE)) {
1814 return -EPERM;
1817 op = (current->pid == 1) ? OP_SET : OP_AND;
1818 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1819 do_proc_dointvec_bset_conv,&op);
1822 struct do_proc_dointvec_minmax_conv_param {
1823 int *min;
1824 int *max;
1827 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1828 int *valp,
1829 int write, void *data)
1831 struct do_proc_dointvec_minmax_conv_param *param = data;
1832 if (write) {
1833 int val = *negp ? -*lvalp : *lvalp;
1834 if ((param->min && *param->min > val) ||
1835 (param->max && *param->max < val))
1836 return -EINVAL;
1837 *valp = val;
1838 } else {
1839 int val = *valp;
1840 if (val < 0) {
1841 *negp = -1;
1842 *lvalp = (unsigned long)-val;
1843 } else {
1844 *negp = 0;
1845 *lvalp = (unsigned long)val;
1848 return 0;
1852 * proc_dointvec_minmax - read a vector of integers with min/max values
1853 * @table: the sysctl table
1854 * @write: %TRUE if this is a write to the sysctl file
1855 * @filp: the file structure
1856 * @buffer: the user buffer
1857 * @lenp: the size of the user buffer
1858 * @ppos: file position
1860 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1861 * values from/to the user buffer, treated as an ASCII string.
1863 * This routine will ensure the values are within the range specified by
1864 * table->extra1 (min) and table->extra2 (max).
1866 * Returns 0 on success.
1868 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1869 void __user *buffer, size_t *lenp, loff_t *ppos)
1871 struct do_proc_dointvec_minmax_conv_param param = {
1872 .min = (int *) table->extra1,
1873 .max = (int *) table->extra2,
1875 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
1876 do_proc_dointvec_minmax_conv, &param);
1879 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1880 struct file *filp,
1881 void __user *buffer,
1882 size_t *lenp, loff_t *ppos,
1883 unsigned long convmul,
1884 unsigned long convdiv)
1886 #define TMPBUFLEN 21
1887 unsigned long *i, *min, *max, val;
1888 int vleft, first=1, neg;
1889 size_t len, left;
1890 char buf[TMPBUFLEN], *p;
1891 char __user *s = buffer;
1893 if (!table->data || !table->maxlen || !*lenp ||
1894 (*ppos && !write)) {
1895 *lenp = 0;
1896 return 0;
1899 i = (unsigned long *) table->data;
1900 min = (unsigned long *) table->extra1;
1901 max = (unsigned long *) table->extra2;
1902 vleft = table->maxlen / sizeof(unsigned long);
1903 left = *lenp;
1905 for (; left && vleft--; i++, min++, max++, first=0) {
1906 if (write) {
1907 while (left) {
1908 char c;
1909 if (get_user(c, s))
1910 return -EFAULT;
1911 if (!isspace(c))
1912 break;
1913 left--;
1914 s++;
1916 if (!left)
1917 break;
1918 neg = 0;
1919 len = left;
1920 if (len > TMPBUFLEN-1)
1921 len = TMPBUFLEN-1;
1922 if (copy_from_user(buf, s, len))
1923 return -EFAULT;
1924 buf[len] = 0;
1925 p = buf;
1926 if (*p == '-' && left > 1) {
1927 neg = 1;
1928 left--, p++;
1930 if (*p < '0' || *p > '9')
1931 break;
1932 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1933 len = p-buf;
1934 if ((len < left) && *p && !isspace(*p))
1935 break;
1936 if (neg)
1937 val = -val;
1938 s += len;
1939 left -= len;
1941 if(neg)
1942 continue;
1943 if ((min && val < *min) || (max && val > *max))
1944 continue;
1945 *i = val;
1946 } else {
1947 p = buf;
1948 if (!first)
1949 *p++ = '\t';
1950 sprintf(p, "%lu", convdiv * (*i) / convmul);
1951 len = strlen(buf);
1952 if (len > left)
1953 len = left;
1954 if(copy_to_user(s, buf, len))
1955 return -EFAULT;
1956 left -= len;
1957 s += len;
1961 if (!write && !first && left) {
1962 if(put_user('\n', s))
1963 return -EFAULT;
1964 left--, s++;
1966 if (write) {
1967 while (left) {
1968 char c;
1969 if (get_user(c, s++))
1970 return -EFAULT;
1971 if (!isspace(c))
1972 break;
1973 left--;
1976 if (write && first)
1977 return -EINVAL;
1978 *lenp -= left;
1979 *ppos += *lenp;
1980 return 0;
1981 #undef TMPBUFLEN
1985 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1986 * @table: the sysctl table
1987 * @write: %TRUE if this is a write to the sysctl file
1988 * @filp: the file structure
1989 * @buffer: the user buffer
1990 * @lenp: the size of the user buffer
1991 * @ppos: file position
1993 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1994 * values from/to the user buffer, treated as an ASCII string.
1996 * This routine will ensure the values are within the range specified by
1997 * table->extra1 (min) and table->extra2 (max).
1999 * Returns 0 on success.
2001 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2002 void __user *buffer, size_t *lenp, loff_t *ppos)
2004 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2008 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2009 * @table: the sysctl table
2010 * @write: %TRUE if this is a write to the sysctl file
2011 * @filp: the file structure
2012 * @buffer: the user buffer
2013 * @lenp: the size of the user buffer
2014 * @ppos: file position
2016 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2017 * values from/to the user buffer, treated as an ASCII string. The values
2018 * are treated as milliseconds, and converted to jiffies when they are stored.
2020 * This routine will ensure the values are within the range specified by
2021 * table->extra1 (min) and table->extra2 (max).
2023 * Returns 0 on success.
2025 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2026 struct file *filp,
2027 void __user *buffer,
2028 size_t *lenp, loff_t *ppos)
2030 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2031 lenp, ppos, HZ, 1000l);
2035 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2036 int *valp,
2037 int write, void *data)
2039 if (write) {
2040 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2041 } else {
2042 int val = *valp;
2043 unsigned long lval;
2044 if (val < 0) {
2045 *negp = -1;
2046 lval = (unsigned long)-val;
2047 } else {
2048 *negp = 0;
2049 lval = (unsigned long)val;
2051 *lvalp = lval / HZ;
2053 return 0;
2056 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2057 int *valp,
2058 int write, void *data)
2060 if (write) {
2061 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2062 } else {
2063 int val = *valp;
2064 unsigned long lval;
2065 if (val < 0) {
2066 *negp = -1;
2067 lval = (unsigned long)-val;
2068 } else {
2069 *negp = 0;
2070 lval = (unsigned long)val;
2072 *lvalp = jiffies_to_clock_t(lval);
2074 return 0;
2077 static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2078 int *valp,
2079 int write, void *data)
2081 if (write) {
2082 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2083 } else {
2084 int val = *valp;
2085 unsigned long lval;
2086 if (val < 0) {
2087 *negp = -1;
2088 lval = (unsigned long)-val;
2089 } else {
2090 *negp = 0;
2091 lval = (unsigned long)val;
2093 *lvalp = jiffies_to_msecs(lval);
2095 return 0;
2099 * proc_dointvec_jiffies - read a vector of integers as seconds
2100 * @table: the sysctl table
2101 * @write: %TRUE if this is a write to the sysctl file
2102 * @filp: the file structure
2103 * @buffer: the user buffer
2104 * @lenp: the size of the user buffer
2105 * @ppos: file position
2107 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2108 * values from/to the user buffer, treated as an ASCII string.
2109 * The values read are assumed to be in seconds, and are converted into
2110 * jiffies.
2112 * Returns 0 on success.
2114 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2115 void __user *buffer, size_t *lenp, loff_t *ppos)
2117 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2118 do_proc_dointvec_jiffies_conv,NULL);
2122 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2123 * @table: the sysctl table
2124 * @write: %TRUE if this is a write to the sysctl file
2125 * @filp: the file structure
2126 * @buffer: the user buffer
2127 * @lenp: the size of the user buffer
2128 * @ppos: pointer to the file position
2130 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2131 * values from/to the user buffer, treated as an ASCII string.
2132 * The values read are assumed to be in 1/USER_HZ seconds, and
2133 * are converted into jiffies.
2135 * Returns 0 on success.
2137 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2138 void __user *buffer, size_t *lenp, loff_t *ppos)
2140 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2141 do_proc_dointvec_userhz_jiffies_conv,NULL);
2145 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2146 * @table: the sysctl table
2147 * @write: %TRUE if this is a write to the sysctl file
2148 * @filp: the file structure
2149 * @buffer: the user buffer
2150 * @lenp: the size of the user buffer
2151 * @ppos: file position
2152 * @ppos: the current position in the file
2154 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2155 * values from/to the user buffer, treated as an ASCII string.
2156 * The values read are assumed to be in 1/1000 seconds, and
2157 * are converted into jiffies.
2159 * Returns 0 on success.
2161 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2162 void __user *buffer, size_t *lenp, loff_t *ppos)
2164 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2165 do_proc_dointvec_ms_jiffies_conv, NULL);
2168 #else /* CONFIG_PROC_FS */
2170 int proc_dostring(ctl_table *table, int write, struct file *filp,
2171 void __user *buffer, size_t *lenp, loff_t *ppos)
2173 return -ENOSYS;
2176 static int proc_doutsstring(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(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_bset(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_minmax(ctl_table *table, int write, struct file *filp,
2195 void __user *buffer, size_t *lenp, loff_t *ppos)
2197 return -ENOSYS;
2200 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2201 void __user *buffer, size_t *lenp, loff_t *ppos)
2203 return -ENOSYS;
2206 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2207 void __user *buffer, size_t *lenp, loff_t *ppos)
2209 return -ENOSYS;
2212 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2213 void __user *buffer, size_t *lenp, loff_t *ppos)
2215 return -ENOSYS;
2218 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2219 void __user *buffer, size_t *lenp, loff_t *ppos)
2221 return -ENOSYS;
2224 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2225 struct file *filp,
2226 void __user *buffer,
2227 size_t *lenp, loff_t *ppos)
2229 return -ENOSYS;
2233 #endif /* CONFIG_PROC_FS */
2237 * General sysctl support routines
2240 /* The generic string strategy routine: */
2241 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2242 void __user *oldval, size_t __user *oldlenp,
2243 void __user *newval, size_t newlen, void **context)
2245 if (!table->data || !table->maxlen)
2246 return -ENOTDIR;
2248 if (oldval && oldlenp) {
2249 size_t bufsize;
2250 if (get_user(bufsize, oldlenp))
2251 return -EFAULT;
2252 if (bufsize) {
2253 size_t len = strlen(table->data), copied;
2255 /* This shouldn't trigger for a well-formed sysctl */
2256 if (len > table->maxlen)
2257 len = table->maxlen;
2259 /* Copy up to a max of bufsize-1 bytes of the string */
2260 copied = (len >= bufsize) ? bufsize - 1 : len;
2262 if (copy_to_user(oldval, table->data, copied) ||
2263 put_user(0, (char __user *)(oldval + copied)))
2264 return -EFAULT;
2265 if (put_user(len, oldlenp))
2266 return -EFAULT;
2269 if (newval && newlen) {
2270 size_t len = newlen;
2271 if (len > table->maxlen)
2272 len = table->maxlen;
2273 if(copy_from_user(table->data, newval, len))
2274 return -EFAULT;
2275 if (len == table->maxlen)
2276 len--;
2277 ((char *) table->data)[len] = 0;
2279 return 1;
2283 * This function makes sure that all of the integers in the vector
2284 * are between the minimum and maximum values given in the arrays
2285 * table->extra1 and table->extra2, respectively.
2287 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2288 void __user *oldval, size_t __user *oldlenp,
2289 void __user *newval, size_t newlen, void **context)
2292 if (newval && newlen) {
2293 int __user *vec = (int __user *) newval;
2294 int *min = (int *) table->extra1;
2295 int *max = (int *) table->extra2;
2296 size_t length;
2297 int i;
2299 if (newlen % sizeof(int) != 0)
2300 return -EINVAL;
2302 if (!table->extra1 && !table->extra2)
2303 return 0;
2305 if (newlen > table->maxlen)
2306 newlen = table->maxlen;
2307 length = newlen / sizeof(int);
2309 for (i = 0; i < length; i++) {
2310 int value;
2311 if (get_user(value, vec + i))
2312 return -EFAULT;
2313 if (min && value < min[i])
2314 return -EINVAL;
2315 if (max && value > max[i])
2316 return -EINVAL;
2319 return 0;
2322 /* Strategy function to convert jiffies to seconds */
2323 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2324 void __user *oldval, size_t __user *oldlenp,
2325 void __user *newval, size_t newlen, void **context)
2327 if (oldval) {
2328 size_t olen;
2329 if (oldlenp) {
2330 if (get_user(olen, oldlenp))
2331 return -EFAULT;
2332 if (olen!=sizeof(int))
2333 return -EINVAL;
2335 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2336 (oldlenp && put_user(sizeof(int),oldlenp)))
2337 return -EFAULT;
2339 if (newval && newlen) {
2340 int new;
2341 if (newlen != sizeof(int))
2342 return -EINVAL;
2343 if (get_user(new, (int __user *)newval))
2344 return -EFAULT;
2345 *(int *)(table->data) = new*HZ;
2347 return 1;
2350 /* Strategy function to convert jiffies to seconds */
2351 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2352 void __user *oldval, size_t __user *oldlenp,
2353 void __user *newval, size_t newlen, void **context)
2355 if (oldval) {
2356 size_t olen;
2357 if (oldlenp) {
2358 if (get_user(olen, oldlenp))
2359 return -EFAULT;
2360 if (olen!=sizeof(int))
2361 return -EINVAL;
2363 if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
2364 (oldlenp && put_user(sizeof(int),oldlenp)))
2365 return -EFAULT;
2367 if (newval && newlen) {
2368 int new;
2369 if (newlen != sizeof(int))
2370 return -EINVAL;
2371 if (get_user(new, (int __user *)newval))
2372 return -EFAULT;
2373 *(int *)(table->data) = msecs_to_jiffies(new);
2375 return 1;
2378 #else /* CONFIG_SYSCTL */
2381 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2383 return -ENOSYS;
2386 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2387 void __user *oldval, size_t __user *oldlenp,
2388 void __user *newval, size_t newlen, void **context)
2390 return -ENOSYS;
2393 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2394 void __user *oldval, size_t __user *oldlenp,
2395 void __user *newval, size_t newlen, void **context)
2397 return -ENOSYS;
2400 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2401 void __user *oldval, size_t __user *oldlenp,
2402 void __user *newval, size_t newlen, void **context)
2404 return -ENOSYS;
2407 int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2408 void __user *oldval, size_t __user *oldlenp,
2409 void __user *newval, size_t newlen, void **context)
2411 return -ENOSYS;
2414 int proc_dostring(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(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_bset(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_minmax(ctl_table *table, int write, struct file *filp,
2433 void __user *buffer, size_t *lenp, loff_t *ppos)
2435 return -ENOSYS;
2438 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2439 void __user *buffer, size_t *lenp, loff_t *ppos)
2441 return -ENOSYS;
2444 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2445 void __user *buffer, size_t *lenp, loff_t *ppos)
2447 return -ENOSYS;
2450 int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2451 void __user *buffer, size_t *lenp, loff_t *ppos)
2453 return -ENOSYS;
2456 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2457 void __user *buffer, size_t *lenp, loff_t *ppos)
2459 return -ENOSYS;
2462 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2463 struct file *filp,
2464 void __user *buffer,
2465 size_t *lenp, loff_t *ppos)
2467 return -ENOSYS;
2470 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2471 int insert_at_head)
2473 return NULL;
2476 void unregister_sysctl_table(struct ctl_table_header * table)
2480 #endif /* CONFIG_SYSCTL */
2483 * No sense putting this after each symbol definition, twice,
2484 * exception granted :-)
2486 EXPORT_SYMBOL(proc_dointvec);
2487 EXPORT_SYMBOL(proc_dointvec_jiffies);
2488 EXPORT_SYMBOL(proc_dointvec_minmax);
2489 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2490 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2491 EXPORT_SYMBOL(proc_dostring);
2492 EXPORT_SYMBOL(proc_doulongvec_minmax);
2493 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2494 EXPORT_SYMBOL(register_sysctl_table);
2495 EXPORT_SYMBOL(sysctl_intvec);
2496 EXPORT_SYMBOL(sysctl_jiffies);
2497 EXPORT_SYMBOL(sysctl_ms_jiffies);
2498 EXPORT_SYMBOL(sysctl_string);
2499 EXPORT_SYMBOL(unregister_sysctl_table);