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
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
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>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/proc_fs.h>
28 #include <linux/ctype.h>
29 #include <linux/utsname.h>
30 #include <linux/capability.h>
31 #include <linux/smp_lock.h>
32 #include <linux/init.h>
33 #include <linux/kernel.h>
34 #include <linux/sysrq.h>
35 #include <linux/highuid.h>
36 #include <linux/writeback.h>
37 #include <linux/hugetlb.h>
38 #include <linux/security.h>
39 #include <linux/initrd.h>
40 #include <linux/times.h>
41 #include <linux/limits.h>
42 #include <asm/uaccess.h>
44 #ifdef CONFIG_ROOT_NFS
45 #include <linux/nfs_fs.h>
48 #if defined(CONFIG_SYSCTL)
50 /* External variables not in a header file. */
51 extern int panic_timeout;
53 extern int sysctl_overcommit_memory;
54 extern int sysctl_overcommit_ratio;
55 extern int max_threads;
56 extern atomic_t nr_queued_signals;
57 extern int max_queued_signals;
58 extern int sysrq_enabled;
59 extern int core_uses_pid;
60 extern char core_pattern[];
63 extern int sysctl_lower_zone_protection;
64 extern int min_free_kbytes;
65 extern int printk_ratelimit_jiffies;
66 extern int printk_ratelimit_burst;
68 extern unsigned int vdso_enabled;
71 int exec_shield_randomize = 1;
73 static int __init setup_exec_shield(char *str)
75 get_option (&str, &exec_shield);
80 __setup("exec-shield=", setup_exec_shield);
82 static int __init setup_exec_shield_randomize(char *str)
84 get_option (&str, &exec_shield_randomize);
89 __setup("exec-shield-randomize=", setup_exec_shield_randomize);
91 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
92 static int maxolduid = 65535;
95 static int ngroups_max = NGROUPS_MAX;
98 extern char modprobe_path[];
100 #ifdef CONFIG_HOTPLUG
101 extern char hotplug_path[];
103 extern char vshelper_path[];
104 #ifdef CONFIG_CHR_DEV_SG
105 extern int sg_big_buff;
107 #ifdef CONFIG_SYSVIPC
108 extern size_t shm_ctlmax;
109 extern size_t shm_ctlall;
110 extern int shm_ctlmni;
111 extern int msg_ctlmax;
112 extern int msg_ctlmnb;
113 extern int msg_ctlmni;
114 extern int sem_ctls[];
118 extern char reboot_command [];
119 extern int stop_a_enabled;
120 extern int scons_pwroff;
124 extern int pwrsw_enabled;
125 extern int unaligned_enabled;
128 #ifdef CONFIG_ARCH_S390
129 #ifdef CONFIG_MATHEMU
130 extern int sysctl_ieee_emulation_warnings;
132 extern int sysctl_userprocess_debug;
135 extern int sysctl_hz_timer;
137 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
138 extern unsigned long powersave_nap;
139 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
140 void *buffer, size_t *lenp);
143 #ifdef CONFIG_BSD_PROCESS_ACCT
144 extern int acct_parm[];
147 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
148 ctl_table *, void **);
149 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
150 void __user *buffer, size_t *lenp);
152 static ctl_table root_table[];
153 static struct ctl_table_header root_table_header =
154 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
156 static ctl_table kern_table[];
157 static ctl_table vm_table[];
159 extern ctl_table net_table[];
161 static ctl_table proc_table[];
162 static ctl_table fs_table[];
163 static ctl_table debug_table[];
164 static ctl_table dev_table[];
165 extern ctl_table random_table[];
166 #ifdef CONFIG_UNIX98_PTYS
167 extern ctl_table pty_table[];
170 /* /proc declarations: */
172 #ifdef CONFIG_PROC_FS
174 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
175 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
176 static int proc_opensys(struct inode *, struct file *);
178 struct file_operations proc_sys_file_operations = {
179 .open = proc_opensys,
180 .read = proc_readsys,
181 .write = proc_writesys,
184 extern struct proc_dir_entry *proc_sys_root;
186 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
187 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
190 /* The default sysctl tables: */
192 static ctl_table root_table[] = {
194 .ctl_name = CTL_KERN,
195 .procname = "kernel",
214 .ctl_name = CTL_PROC,
226 .ctl_name = CTL_DEBUG,
229 .child = debug_table,
240 static ctl_table kern_table[] = {
242 .ctl_name = KERN_OSTYPE,
243 .procname = "ostype",
244 .data = system_utsname.sysname,
247 .proc_handler = &proc_doutsstring,
248 .strategy = &sysctl_string,
251 .ctl_name = KERN_OSRELEASE,
252 .procname = "osrelease",
253 .data = system_utsname.release,
256 .proc_handler = &proc_doutsstring,
257 .strategy = &sysctl_string,
260 .ctl_name = KERN_VERSION,
261 .procname = "version",
262 .data = system_utsname.version,
265 .proc_handler = &proc_doutsstring,
266 .strategy = &sysctl_string,
269 .ctl_name = KERN_NODENAME,
270 .procname = "hostname",
271 .data = system_utsname.nodename,
274 .proc_handler = &proc_doutsstring,
275 .strategy = &sysctl_string,
278 .ctl_name = KERN_DOMAINNAME,
279 .procname = "domainname",
280 .data = system_utsname.domainname,
283 .proc_handler = &proc_doutsstring,
284 .strategy = &sysctl_string,
287 .ctl_name = KERN_PANIC,
289 .data = &panic_timeout,
290 .maxlen = sizeof(int),
292 .proc_handler = &proc_dointvec,
295 .ctl_name = KERN_PANIC,
296 .procname = "exec-shield",
297 .data = &exec_shield,
298 .maxlen = sizeof(int),
300 .proc_handler = &proc_dointvec,
303 .ctl_name = KERN_PANIC,
304 .procname = "exec-shield-randomize",
305 .data = &exec_shield_randomize,
306 .maxlen = sizeof(int),
308 .proc_handler = &proc_dointvec,
311 .ctl_name = KERN_PANIC,
312 .procname = "print-fatal-signals",
313 .data = &print_fatal_signals,
314 .maxlen = sizeof(int),
316 .proc_handler = &proc_dointvec,
320 .ctl_name = KERN_PANIC,
322 .data = &vdso_enabled,
323 .maxlen = sizeof(int),
325 .proc_handler = &proc_dointvec,
329 .ctl_name = KERN_CORE_USES_PID,
330 .procname = "core_uses_pid",
331 .data = &core_uses_pid,
332 .maxlen = sizeof(int),
334 .proc_handler = &proc_dointvec,
337 .ctl_name = KERN_CORE_PATTERN,
338 .procname = "core_pattern",
339 .data = core_pattern,
342 .proc_handler = &proc_dostring,
343 .strategy = &sysctl_string,
346 .ctl_name = KERN_TAINTED,
347 .procname = "tainted",
349 .maxlen = sizeof(int),
351 .proc_handler = &proc_dointvec,
354 .ctl_name = KERN_CAP_BSET,
355 .procname = "cap-bound",
357 .maxlen = sizeof(kernel_cap_t),
359 .proc_handler = &proc_dointvec_bset,
361 #ifdef CONFIG_BLK_DEV_INITRD
363 .ctl_name = KERN_REALROOTDEV,
364 .procname = "real-root-dev",
365 .data = &real_root_dev,
366 .maxlen = sizeof(int),
368 .proc_handler = &proc_dointvec,
373 .ctl_name = KERN_SPARC_REBOOT,
374 .procname = "reboot-cmd",
375 .data = reboot_command,
378 .proc_handler = &proc_dostring,
379 .strategy = &sysctl_string,
382 .ctl_name = KERN_SPARC_STOP_A,
383 .procname = "stop-a",
384 .data = &stop_a_enabled,
385 .maxlen = sizeof (int),
387 .proc_handler = &proc_dointvec,
390 .ctl_name = KERN_SPARC_SCONS_PWROFF,
391 .procname = "scons-poweroff",
392 .data = &scons_pwroff,
393 .maxlen = sizeof (int),
395 .proc_handler = &proc_dointvec,
400 .ctl_name = KERN_HPPA_PWRSW,
401 .procname = "soft-power",
402 .data = &pwrsw_enabled,
403 .maxlen = sizeof (int),
405 .proc_handler = &proc_dointvec,
408 .ctl_name = KERN_HPPA_UNALIGNED,
409 .procname = "unaligned-trap",
410 .data = &unaligned_enabled,
411 .maxlen = sizeof (int),
413 .proc_handler = &proc_dointvec,
416 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
418 .ctl_name = KERN_PPC_POWERSAVE_NAP,
419 .procname = "powersave-nap",
420 .data = &powersave_nap,
421 .maxlen = sizeof(int),
423 .proc_handler = &proc_dointvec,
426 .ctl_name = KERN_PPC_L2CR,
429 .proc_handler = &proc_dol2crvec,
433 .ctl_name = KERN_CTLALTDEL,
434 .procname = "ctrl-alt-del",
436 .maxlen = sizeof(int),
438 .proc_handler = &proc_dointvec,
441 .ctl_name = KERN_PRINTK,
442 .procname = "printk",
443 .data = &console_loglevel,
444 .maxlen = 4*sizeof(int),
446 .proc_handler = &proc_dointvec,
450 .ctl_name = KERN_MODPROBE,
451 .procname = "modprobe",
452 .data = &modprobe_path,
455 .proc_handler = &proc_dostring,
456 .strategy = &sysctl_string,
459 #ifdef CONFIG_HOTPLUG
461 .ctl_name = KERN_HOTPLUG,
462 .procname = "hotplug",
463 .data = &hotplug_path,
466 .proc_handler = &proc_dostring,
467 .strategy = &sysctl_string,
471 .ctl_name = KERN_VSHELPER,
472 .procname = "vshelper",
473 .data = &vshelper_path,
476 .proc_handler = &proc_dostring,
477 .strategy = &sysctl_string,
479 #ifdef CONFIG_CHR_DEV_SG
481 .ctl_name = KERN_SG_BIG_BUFF,
482 .procname = "sg-big-buff",
483 .data = &sg_big_buff,
484 .maxlen = sizeof (int),
486 .proc_handler = &proc_dointvec,
489 #ifdef CONFIG_BSD_PROCESS_ACCT
491 .ctl_name = KERN_ACCT,
494 .maxlen = 3*sizeof(int),
496 .proc_handler = &proc_dointvec,
500 .ctl_name = KERN_RTSIGNR,
501 .procname = "rtsig-nr",
502 .data = &nr_queued_signals,
503 .maxlen = sizeof(int),
505 .proc_handler = &proc_dointvec,
508 .ctl_name = KERN_RTSIGMAX,
509 .procname = "rtsig-max",
510 .data = &max_queued_signals,
511 .maxlen = sizeof(int),
513 .proc_handler = &proc_dointvec,
515 #ifdef CONFIG_SYSVIPC
517 .ctl_name = KERN_SHMMAX,
518 .procname = "shmmax",
520 .maxlen = sizeof (size_t),
522 .proc_handler = &proc_doulongvec_minmax,
525 .ctl_name = KERN_SHMALL,
526 .procname = "shmall",
528 .maxlen = sizeof (size_t),
530 .proc_handler = &proc_doulongvec_minmax,
533 .ctl_name = KERN_SHMMNI,
534 .procname = "shmmni",
536 .maxlen = sizeof (int),
538 .proc_handler = &proc_dointvec,
541 .ctl_name = KERN_MSGMAX,
542 .procname = "msgmax",
544 .maxlen = sizeof (int),
546 .proc_handler = &proc_dointvec,
549 .ctl_name = KERN_MSGMNI,
550 .procname = "msgmni",
552 .maxlen = sizeof (int),
554 .proc_handler = &proc_dointvec,
557 .ctl_name = KERN_MSGMNB,
558 .procname = "msgmnb",
560 .maxlen = sizeof (int),
562 .proc_handler = &proc_dointvec,
565 .ctl_name = KERN_SEM,
568 .maxlen = 4*sizeof (int),
570 .proc_handler = &proc_dointvec,
573 #ifdef CONFIG_MAGIC_SYSRQ
575 .ctl_name = KERN_SYSRQ,
577 .data = &sysrq_enabled,
578 .maxlen = sizeof (int),
580 .proc_handler = &proc_dointvec,
584 .ctl_name = KERN_CADPID,
585 .procname = "cad_pid",
587 .maxlen = sizeof (int),
589 .proc_handler = &proc_dointvec,
592 .ctl_name = KERN_MAX_THREADS,
593 .procname = "threads-max",
594 .data = &max_threads,
595 .maxlen = sizeof(int),
597 .proc_handler = &proc_dointvec,
600 .ctl_name = KERN_RANDOM,
601 .procname = "random",
603 .child = random_table,
605 #ifdef CONFIG_UNIX98_PTYS
607 .ctl_name = KERN_PTY,
614 .ctl_name = KERN_OVERFLOWUID,
615 .procname = "overflowuid",
616 .data = &overflowuid,
617 .maxlen = sizeof(int),
619 .proc_handler = &proc_dointvec_minmax,
620 .strategy = &sysctl_intvec,
621 .extra1 = &minolduid,
622 .extra2 = &maxolduid,
625 .ctl_name = KERN_OVERFLOWGID,
626 .procname = "overflowgid",
627 .data = &overflowgid,
628 .maxlen = sizeof(int),
630 .proc_handler = &proc_dointvec_minmax,
631 .strategy = &sysctl_intvec,
632 .extra1 = &minolduid,
633 .extra2 = &maxolduid,
635 #ifdef CONFIG_ARCH_S390
636 #ifdef CONFIG_MATHEMU
638 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
639 .procname = "ieee_emulation_warnings",
640 .data = &sysctl_ieee_emulation_warnings,
641 .maxlen = sizeof(int),
643 .proc_handler = &proc_dointvec,
646 #ifdef CONFIG_NO_IDLE_HZ
648 .ctl_name = KERN_HZ_TIMER,
649 .procname = "hz_timer",
650 .data = &sysctl_hz_timer,
651 .maxlen = sizeof(int),
653 .proc_handler = &proc_dointvec,
657 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
658 .procname = "userprocess_debug",
659 .data = &sysctl_userprocess_debug,
660 .maxlen = sizeof(int),
662 .proc_handler = &proc_dointvec,
666 .ctl_name = KERN_PIDMAX,
667 .procname = "pid_max",
669 .maxlen = sizeof (int),
671 .proc_handler = &proc_dointvec,
674 .ctl_name = KERN_PANIC_ON_OOPS,
675 .procname = "panic_on_oops",
676 .data = &panic_on_oops,
677 .maxlen = sizeof(int),
679 .proc_handler = &proc_dointvec,
682 .ctl_name = KERN_PRINTK_RATELIMIT,
683 .procname = "printk_ratelimit",
684 .data = &printk_ratelimit_jiffies,
685 .maxlen = sizeof(int),
687 .proc_handler = &proc_dointvec_jiffies,
688 .strategy = &sysctl_jiffies,
691 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
692 .procname = "printk_ratelimit_burst",
693 .data = &printk_ratelimit_burst,
694 .maxlen = sizeof(int),
696 .proc_handler = &proc_dointvec,
699 .ctl_name = KERN_NGROUPS_MAX,
700 .procname = "ngroups_max",
701 .data = &ngroups_max,
702 .maxlen = sizeof (int),
704 .proc_handler = &proc_dointvec,
709 /* Constants for minimum and maximum testing in vm_table.
710 We use these as one-element integer vectors. */
712 static int one_hundred = 100;
715 static ctl_table vm_table[] = {
717 .ctl_name = VM_OVERCOMMIT_MEMORY,
718 .procname = "overcommit_memory",
719 .data = &sysctl_overcommit_memory,
720 .maxlen = sizeof(sysctl_overcommit_memory),
722 .proc_handler = &proc_dointvec,
725 .ctl_name = VM_OVERCOMMIT_RATIO,
726 .procname = "overcommit_ratio",
727 .data = &sysctl_overcommit_ratio,
728 .maxlen = sizeof(sysctl_overcommit_ratio),
730 .proc_handler = &proc_dointvec,
733 .ctl_name = VM_PAGE_CLUSTER,
734 .procname = "page-cluster",
735 .data = &page_cluster,
736 .maxlen = sizeof(int),
738 .proc_handler = &proc_dointvec,
741 .ctl_name = VM_DIRTY_BACKGROUND,
742 .procname = "dirty_background_ratio",
743 .data = &dirty_background_ratio,
744 .maxlen = sizeof(dirty_background_ratio),
746 .proc_handler = &proc_dointvec_minmax,
747 .strategy = &sysctl_intvec,
749 .extra2 = &one_hundred,
752 .ctl_name = VM_DIRTY_RATIO,
753 .procname = "dirty_ratio",
754 .data = &vm_dirty_ratio,
755 .maxlen = sizeof(vm_dirty_ratio),
757 .proc_handler = &proc_dointvec_minmax,
758 .strategy = &sysctl_intvec,
760 .extra2 = &one_hundred,
763 .ctl_name = VM_DIRTY_WB_CS,
764 .procname = "dirty_writeback_centisecs",
765 .data = &dirty_writeback_centisecs,
766 .maxlen = sizeof(dirty_writeback_centisecs),
768 .proc_handler = &dirty_writeback_centisecs_handler,
771 .ctl_name = VM_DIRTY_EXPIRE_CS,
772 .procname = "dirty_expire_centisecs",
773 .data = &dirty_expire_centisecs,
774 .maxlen = sizeof(dirty_expire_centisecs),
776 .proc_handler = &proc_dointvec,
779 .ctl_name = VM_NR_PDFLUSH_THREADS,
780 .procname = "nr_pdflush_threads",
781 .data = &nr_pdflush_threads,
782 .maxlen = sizeof nr_pdflush_threads,
783 .mode = 0444 /* read-only*/,
784 .proc_handler = &proc_dointvec,
787 .ctl_name = VM_SWAPPINESS,
788 .procname = "swappiness",
789 .data = &vm_swappiness,
790 .maxlen = sizeof(vm_swappiness),
792 .proc_handler = &proc_dointvec_minmax,
793 .strategy = &sysctl_intvec,
795 .extra2 = &one_hundred,
797 #ifdef CONFIG_HUGETLB_PAGE
799 .ctl_name = VM_HUGETLB_PAGES,
800 .procname = "nr_hugepages",
801 .data = &max_huge_pages,
802 .maxlen = sizeof(unsigned long),
804 .proc_handler = &hugetlb_sysctl_handler,
805 .extra1 = (void *)&hugetlb_zero,
806 .extra2 = (void *)&hugetlb_infinity,
810 .ctl_name = VM_LOWER_ZONE_PROTECTION,
811 .procname = "lower_zone_protection",
812 .data = &sysctl_lower_zone_protection,
813 .maxlen = sizeof(sysctl_lower_zone_protection),
815 .proc_handler = &lower_zone_protection_sysctl_handler,
816 .strategy = &sysctl_intvec,
820 .ctl_name = VM_MIN_FREE_KBYTES,
821 .procname = "min_free_kbytes",
822 .data = &min_free_kbytes,
823 .maxlen = sizeof(min_free_kbytes),
825 .proc_handler = &min_free_kbytes_sysctl_handler,
826 .strategy = &sysctl_intvec,
830 .ctl_name = VM_MAX_MAP_COUNT,
831 .procname = "max_map_count",
832 .data = &sysctl_max_map_count,
833 .maxlen = sizeof(sysctl_max_map_count),
835 .proc_handler = &proc_dointvec
838 .ctl_name = VM_LAPTOP_MODE,
839 .procname = "laptop_mode",
840 .data = &laptop_mode,
841 .maxlen = sizeof(laptop_mode),
843 .proc_handler = &proc_dointvec,
844 .strategy = &sysctl_intvec,
848 .ctl_name = VM_BLOCK_DUMP,
849 .procname = "block_dump",
851 .maxlen = sizeof(block_dump),
853 .proc_handler = &proc_dointvec,
854 .strategy = &sysctl_intvec,
860 static ctl_table proc_table[] = {
864 static ctl_table fs_table[] = {
866 .ctl_name = FS_NRINODE,
867 .procname = "inode-nr",
868 .data = &inodes_stat,
869 .maxlen = 2*sizeof(int),
871 .proc_handler = &proc_dointvec,
874 .ctl_name = FS_STATINODE,
875 .procname = "inode-state",
876 .data = &inodes_stat,
877 .maxlen = 7*sizeof(int),
879 .proc_handler = &proc_dointvec,
882 .ctl_name = FS_NRFILE,
883 .procname = "file-nr",
885 .maxlen = 3*sizeof(int),
887 .proc_handler = &proc_dointvec,
890 .ctl_name = FS_MAXFILE,
891 .procname = "file-max",
892 .data = &files_stat.max_files,
893 .maxlen = sizeof(int),
895 .proc_handler = &proc_dointvec,
898 .ctl_name = FS_DENTRY,
899 .procname = "dentry-state",
900 .data = &dentry_stat,
901 .maxlen = 6*sizeof(int),
903 .proc_handler = &proc_dointvec,
906 .ctl_name = FS_OVERFLOWUID,
907 .procname = "overflowuid",
908 .data = &fs_overflowuid,
909 .maxlen = sizeof(int),
911 .proc_handler = &proc_dointvec_minmax,
912 .strategy = &sysctl_intvec,
913 .extra1 = &minolduid,
914 .extra2 = &maxolduid,
917 .ctl_name = FS_OVERFLOWGID,
918 .procname = "overflowgid",
919 .data = &fs_overflowgid,
920 .maxlen = sizeof(int),
922 .proc_handler = &proc_dointvec_minmax,
923 .strategy = &sysctl_intvec,
924 .extra1 = &minolduid,
925 .extra2 = &maxolduid,
928 .ctl_name = FS_LEASES,
929 .procname = "leases-enable",
930 .data = &leases_enable,
931 .maxlen = sizeof(int),
933 .proc_handler = &proc_dointvec,
936 .ctl_name = FS_DIR_NOTIFY,
937 .procname = "dir-notify-enable",
938 .data = &dir_notify_enable,
939 .maxlen = sizeof(int),
941 .proc_handler = &proc_dointvec,
944 .ctl_name = FS_LEASE_TIME,
945 .procname = "lease-break-time",
946 .data = &lease_break_time,
947 .maxlen = sizeof(int),
949 .proc_handler = &proc_dointvec,
952 .ctl_name = FS_AIO_NR,
953 .procname = "aio-nr",
955 .maxlen = sizeof(aio_nr),
957 .proc_handler = &proc_dointvec,
960 .ctl_name = FS_AIO_MAX_NR,
961 .procname = "aio-max-nr",
963 .maxlen = sizeof(aio_max_nr),
965 .proc_handler = &proc_dointvec,
970 static ctl_table debug_table[] = {
974 static ctl_table dev_table[] = {
978 extern void init_irq_proc (void);
980 void __init sysctl_init(void)
982 #ifdef CONFIG_PROC_FS
983 register_proc_table(root_table, proc_sys_root);
988 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
989 void __user *newval, size_t newlen)
991 struct list_head *tmp;
993 if (nlen <= 0 || nlen >= CTL_MAXNAME)
997 if (!oldlenp || get_user(old_len, oldlenp))
1000 tmp = &root_table_header.ctl_entry;
1002 struct ctl_table_header *head =
1003 list_entry(tmp, struct ctl_table_header, ctl_entry);
1004 void *context = NULL;
1005 int error = parse_table(name, nlen, oldval, oldlenp,
1006 newval, newlen, head->ctl_table,
1010 if (error != -ENOTDIR)
1013 } while (tmp != &root_table_header.ctl_entry);
1017 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1019 struct __sysctl_args tmp;
1022 if (copy_from_user(&tmp, args, sizeof(tmp)))
1026 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1027 tmp.newval, tmp.newlen);
1033 * ctl_perm does NOT grant the superuser all rights automatically, because
1034 * some sysctl variables are readonly even to root.
1037 static int test_perm(int mode, int op)
1041 else if (in_egroup_p(0))
1043 if ((mode & op & 0007) == op)
1048 static inline int ctl_perm(ctl_table *table, int op)
1051 error = security_sysctl(table, op);
1054 return test_perm(table->mode, op);
1057 static int parse_table(int __user *name, int nlen,
1058 void __user *oldval, size_t __user *oldlenp,
1059 void __user *newval, size_t newlen,
1060 ctl_table *table, void **context)
1066 if (get_user(n, name))
1068 for ( ; table->ctl_name; table++) {
1069 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1072 if (ctl_perm(table, 001))
1074 if (table->strategy) {
1075 error = table->strategy(
1078 newval, newlen, context);
1084 table = table->child;
1087 error = do_sysctl_strategy(table, name, nlen,
1089 newval, newlen, context);
1096 /* Perform the actual read/write of a sysctl table entry. */
1097 int do_sysctl_strategy (ctl_table *table,
1098 int __user *name, int nlen,
1099 void __user *oldval, size_t __user *oldlenp,
1100 void __user *newval, size_t newlen, void **context)
1109 if (ctl_perm(table, op))
1112 if (table->strategy) {
1113 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1114 newval, newlen, context);
1121 /* If there is no strategy routine, or if the strategy returns
1122 * zero, proceed with automatic r/w */
1123 if (table->data && table->maxlen) {
1124 if (oldval && oldlenp) {
1125 if (get_user(len, oldlenp))
1128 if (len > table->maxlen)
1129 len = table->maxlen;
1130 if(copy_to_user(oldval, table->data, len))
1132 if(put_user(len, oldlenp))
1136 if (newval && newlen) {
1138 if (len > table->maxlen)
1139 len = table->maxlen;
1140 if(copy_from_user(table->data, newval, len))
1148 * register_sysctl_table - register a sysctl hierarchy
1149 * @table: the top-level table structure
1150 * @insert_at_head: whether the entry should be inserted in front or at the end
1152 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1153 * array. An entry with a ctl_name of 0 terminates the table.
1155 * The members of the &ctl_table structure are used as follows:
1157 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1158 * must be unique within that level of sysctl
1160 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1161 * enter a sysctl file
1163 * data - a pointer to data for use by proc_handler
1165 * maxlen - the maximum size in bytes of the data
1167 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1169 * child - a pointer to the child sysctl table if this entry is a directory, or
1172 * proc_handler - the text handler routine (described below)
1174 * strategy - the strategy routine (described below)
1176 * de - for internal use by the sysctl routines
1178 * extra1, extra2 - extra pointers usable by the proc handler routines
1180 * Leaf nodes in the sysctl tree will be represented by a single file
1181 * under /proc; non-leaf nodes will be represented by directories.
1183 * sysctl(2) can automatically manage read and write requests through
1184 * the sysctl table. The data and maxlen fields of the ctl_table
1185 * struct enable minimal validation of the values being written to be
1186 * performed, and the mode field allows minimal authentication.
1188 * More sophisticated management can be enabled by the provision of a
1189 * strategy routine with the table entry. This will be called before
1190 * any automatic read or write of the data is performed.
1192 * The strategy routine may return
1194 * < 0 - Error occurred (error is passed to user process)
1196 * 0 - OK - proceed with automatic read or write.
1198 * > 0 - OK - read or write has been done by the strategy routine, so
1199 * return immediately.
1201 * There must be a proc_handler routine for any terminal nodes
1202 * mirrored under /proc/sys (non-terminals are handled by a built-in
1203 * directory handler). Several default handlers are available to
1204 * cover common cases -
1206 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1207 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1208 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1210 * It is the handler's job to read the input buffer from user memory
1211 * and process it. The handler should return 0 on success.
1213 * This routine returns %NULL on a failure to register, and a pointer
1214 * to the table header on success.
1216 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1219 struct ctl_table_header *tmp;
1220 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1223 tmp->ctl_table = table;
1224 INIT_LIST_HEAD(&tmp->ctl_entry);
1226 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1228 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1229 #ifdef CONFIG_PROC_FS
1230 register_proc_table(table, proc_sys_root);
1236 * unregister_sysctl_table - unregister a sysctl table hierarchy
1237 * @header: the header returned from register_sysctl_table
1239 * Unregisters the sysctl table and all children. proc entries may not
1240 * actually be removed until they are no longer used by anyone.
1242 void unregister_sysctl_table(struct ctl_table_header * header)
1244 list_del(&header->ctl_entry);
1245 #ifdef CONFIG_PROC_FS
1246 unregister_proc_table(header->ctl_table, proc_sys_root);
1255 #ifdef CONFIG_PROC_FS
1257 /* Scan the sysctl entries in table and add them all into /proc */
1258 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1260 struct proc_dir_entry *de;
1264 for (; table->ctl_name; table++) {
1265 /* Can't do anything without a proc name. */
1266 if (!table->procname)
1268 /* Maybe we can't do anything with it... */
1269 if (!table->proc_handler && !table->child) {
1270 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1275 len = strlen(table->procname);
1279 if (table->proc_handler)
1283 for (de = root->subdir; de; de = de->next) {
1284 if (proc_match(len, table->procname, de))
1287 /* If the subdir exists already, de is non-NULL */
1291 de = create_proc_entry(table->procname, mode, root);
1294 de->data = (void *) table;
1295 if (table->proc_handler)
1296 de->proc_fops = &proc_sys_file_operations;
1299 if (de->mode & S_IFDIR)
1300 register_proc_table(table->child, de);
1305 * Unregister a /proc sysctl table and any subdirectories.
1307 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1309 struct proc_dir_entry *de;
1310 for (; table->ctl_name; table++) {
1311 if (!(de = table->de))
1313 if (de->mode & S_IFDIR) {
1314 if (!table->child) {
1315 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1318 unregister_proc_table(table->child, de);
1320 /* Don't unregister directories which still have entries.. */
1325 /* Don't unregister proc entries that are still being used.. */
1326 if (atomic_read(&de->count))
1330 remove_proc_entry(table->procname, root);
1334 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1335 size_t count, loff_t *ppos)
1338 struct proc_dir_entry *de;
1339 struct ctl_table *table;
1343 de = PDE(file->f_dentry->d_inode);
1344 if (!de || !de->data)
1346 table = (struct ctl_table *) de->data;
1347 if (!table || !table->proc_handler)
1349 op = (write ? 002 : 004);
1350 if (ctl_perm(table, op))
1356 * FIXME: we need to pass on ppos to the handler.
1359 error = (*table->proc_handler) (table, write, file, buf, &res);
1365 static int proc_opensys(struct inode *inode, struct file *file)
1367 if (file->f_mode & FMODE_WRITE) {
1369 * sysctl entries that are not writable,
1370 * are _NOT_ writable, capabilities or not.
1372 if (!(inode->i_mode & S_IWUSR))
1379 static ssize_t proc_readsys(struct file * file, char __user * buf,
1380 size_t count, loff_t *ppos)
1382 return do_rw_proc(0, file, buf, count, ppos);
1385 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1386 size_t count, loff_t *ppos)
1388 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1392 * proc_dostring - read a string sysctl
1393 * @table: the sysctl table
1394 * @write: %TRUE if this is a write to the sysctl file
1395 * @filp: the file structure
1396 * @buffer: the user buffer
1397 * @lenp: the size of the user buffer
1399 * Reads/writes a string from/to the user buffer. If the kernel
1400 * buffer provided is not large enough to hold the string, the
1401 * string is truncated. The copied string is %NULL-terminated.
1402 * If the string is being read by the user process, it is copied
1403 * and a newline '\n' is added. It is truncated if the buffer is
1406 * Returns 0 on success.
1408 int proc_dostring(ctl_table *table, int write, struct file *filp,
1409 void __user *buffer, size_t *lenp)
1415 if (!table->data || !table->maxlen || !*lenp ||
1416 (filp->f_pos && !write)) {
1424 while (len < *lenp) {
1425 if (get_user(c, p++))
1427 if (c == 0 || c == '\n')
1431 if (len >= table->maxlen)
1432 len = table->maxlen-1;
1433 if(copy_from_user(table->data, buffer, len))
1435 ((char *) table->data)[len] = 0;
1436 filp->f_pos += *lenp;
1438 len = strlen(table->data);
1439 if (len > table->maxlen)
1440 len = table->maxlen;
1444 if(copy_to_user(buffer, table->data, len))
1447 if(put_user('\n', ((char __user *) buffer) + len))
1458 * Special case of dostring for the UTS structure. This has locks
1459 * to observe. Should this be in kernel/sys.c ????
1462 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1463 void __user *buffer, size_t *lenp)
1468 down_read(&uts_sem);
1469 r=proc_dostring(table,0,filp,buffer,lenp);
1472 down_write(&uts_sem);
1473 r=proc_dostring(table,1,filp,buffer,lenp);
1479 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1481 int write, void *data)
1484 *valp = *negp ? -*lvalp : *lvalp;
1489 *lvalp = (unsigned long)-val;
1492 *lvalp = (unsigned long)val;
1498 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1499 void __user *buffer, size_t *lenp,
1500 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1501 int write, void *data),
1504 #define TMPBUFLEN 20
1505 int *i, vleft, first=1, neg, val;
1509 char buf[TMPBUFLEN], *p;
1510 char __user *s = buffer;
1512 if (!table->data || !table->maxlen || !*lenp ||
1513 (filp->f_pos && !write)) {
1518 i = (int *) table->data;
1519 vleft = table->maxlen / sizeof(*i);
1523 conv = do_proc_dointvec_conv;
1525 for (; left && vleft--; i++, first=0) {
1540 if (len > sizeof(buf) - 1)
1541 len = sizeof(buf) - 1;
1542 if (copy_from_user(buf, s, len))
1546 if (*p == '-' && left > 1) {
1550 if (*p < '0' || *p > '9')
1553 lval = simple_strtoul(p, &p, 0);
1556 if ((len < left) && *p && !isspace(*p))
1563 if (conv(&neg, &lval, i, 1, data))
1570 if (conv(&neg, &lval, i, 0, data))
1573 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1577 if(copy_to_user(s, buf, len))
1584 if (!write && !first && left) {
1585 if(put_user('\n', s))
1592 if (get_user(c, s++))
1602 filp->f_pos += *lenp;
1608 * proc_dointvec - read a vector of integers
1609 * @table: the sysctl table
1610 * @write: %TRUE if this is a write to the sysctl file
1611 * @filp: the file structure
1612 * @buffer: the user buffer
1613 * @lenp: the size of the user buffer
1615 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1616 * values from/to the user buffer, treated as an ASCII string.
1618 * Returns 0 on success.
1620 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1621 void __user *buffer, size_t *lenp)
1623 return do_proc_dointvec(table,write,filp,buffer,lenp,
1633 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1635 int write, void *data)
1637 int op = *(int *)data;
1639 int val = *negp ? -*lvalp : *lvalp;
1641 case OP_SET: *valp = val; break;
1642 case OP_AND: *valp &= val; break;
1643 case OP_OR: *valp |= val; break;
1644 case OP_MAX: if(*valp < val)
1647 case OP_MIN: if(*valp > val)
1655 *lvalp = (unsigned long)-val;
1658 *lvalp = (unsigned long)val;
1665 * init may raise the set.
1668 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1669 void __user *buffer, size_t *lenp)
1673 if (!capable(CAP_SYS_MODULE)) {
1677 op = (current->pid == 1) ? OP_SET : OP_AND;
1678 return do_proc_dointvec(table,write,filp,buffer,lenp,
1679 do_proc_dointvec_bset_conv,&op);
1682 struct do_proc_dointvec_minmax_conv_param {
1687 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1689 int write, void *data)
1691 struct do_proc_dointvec_minmax_conv_param *param = data;
1693 int val = *negp ? -*lvalp : *lvalp;
1694 if ((param->min && *param->min > val) ||
1695 (param->max && *param->max < val))
1702 *lvalp = (unsigned long)-val;
1705 *lvalp = (unsigned long)val;
1712 * proc_dointvec_minmax - read a vector of integers with min/max values
1713 * @table: the sysctl table
1714 * @write: %TRUE if this is a write to the sysctl file
1715 * @filp: the file structure
1716 * @buffer: the user buffer
1717 * @lenp: the size of the user buffer
1719 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1720 * values from/to the user buffer, treated as an ASCII string.
1722 * This routine will ensure the values are within the range specified by
1723 * table->extra1 (min) and table->extra2 (max).
1725 * Returns 0 on success.
1727 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1728 void __user *buffer, size_t *lenp)
1730 struct do_proc_dointvec_minmax_conv_param param = {
1731 .min = (int *) table->extra1,
1732 .max = (int *) table->extra2,
1734 return do_proc_dointvec(table, write, filp, buffer, lenp,
1735 do_proc_dointvec_minmax_conv, ¶m);
1738 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1740 void __user *buffer, size_t *lenp,
1741 unsigned long convmul,
1742 unsigned long convdiv)
1744 #define TMPBUFLEN 20
1745 unsigned long *i, *min, *max, val;
1746 int vleft, first=1, neg;
1748 char buf[TMPBUFLEN], *p;
1749 char __user *s = buffer;
1751 if (!table->data || !table->maxlen || !*lenp ||
1752 (filp->f_pos && !write)) {
1757 i = (unsigned long *) table->data;
1758 min = (unsigned long *) table->extra1;
1759 max = (unsigned long *) table->extra2;
1760 vleft = table->maxlen / sizeof(unsigned long);
1763 for (; left && vleft--; i++, min++, max++, first=0) {
1778 if (len > TMPBUFLEN-1)
1780 if (copy_from_user(buf, s, len))
1784 if (*p == '-' && left > 1) {
1788 if (*p < '0' || *p > '9')
1790 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1792 if ((len < left) && *p && !isspace(*p))
1801 if ((min && val < *min) || (max && val > *max))
1808 sprintf(p, "%lu", convdiv * (*i) / convmul);
1812 if(copy_to_user(s, buf, len))
1819 if (!write && !first && left) {
1820 if(put_user('\n', s))
1827 if (get_user(c, s++))
1837 filp->f_pos += *lenp;
1843 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1844 * @table: the sysctl table
1845 * @write: %TRUE if this is a write to the sysctl file
1846 * @filp: the file structure
1847 * @buffer: the user buffer
1848 * @lenp: the size of the user buffer
1850 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1851 * values from/to the user buffer, treated as an ASCII string.
1853 * This routine will ensure the values are within the range specified by
1854 * table->extra1 (min) and table->extra2 (max).
1856 * Returns 0 on success.
1858 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1859 void __user *buffer, size_t *lenp)
1861 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1865 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1866 * @table: the sysctl table
1867 * @write: %TRUE if this is a write to the sysctl file
1868 * @filp: the file structure
1869 * @buffer: the user buffer
1870 * @lenp: the size of the user buffer
1872 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1873 * values from/to the user buffer, treated as an ASCII string. The values
1874 * are treated as milliseconds, and converted to jiffies when they are stored.
1876 * This routine will ensure the values are within the range specified by
1877 * table->extra1 (min) and table->extra2 (max).
1879 * Returns 0 on success.
1881 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1883 void __user *buffer, size_t *lenp)
1885 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1890 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1892 int write, void *data)
1895 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1901 lval = (unsigned long)-val;
1904 lval = (unsigned long)val;
1911 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1913 int write, void *data)
1916 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1922 lval = (unsigned long)-val;
1925 lval = (unsigned long)val;
1927 *lvalp = jiffies_to_clock_t(lval);
1933 * proc_dointvec_jiffies - read a vector of integers as seconds
1934 * @table: the sysctl table
1935 * @write: %TRUE if this is a write to the sysctl file
1936 * @filp: the file structure
1937 * @buffer: the user buffer
1938 * @lenp: the size of the user buffer
1940 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1941 * values from/to the user buffer, treated as an ASCII string.
1942 * The values read are assumed to be in seconds, and are converted into
1945 * Returns 0 on success.
1947 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1948 void __user *buffer, size_t *lenp)
1950 return do_proc_dointvec(table,write,filp,buffer,lenp,
1951 do_proc_dointvec_jiffies_conv,NULL);
1955 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1956 * @table: the sysctl table
1957 * @write: %TRUE if this is a write to the sysctl file
1958 * @filp: the file structure
1959 * @buffer: the user buffer
1960 * @lenp: the size of the user buffer
1962 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1963 * values from/to the user buffer, treated as an ASCII string.
1964 * The values read are assumed to be in 1/USER_HZ seconds, and
1965 * are converted into jiffies.
1967 * Returns 0 on success.
1969 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1970 void __user *buffer, size_t *lenp)
1972 return do_proc_dointvec(table,write,filp,buffer,lenp,
1973 do_proc_dointvec_userhz_jiffies_conv,NULL);
1976 #else /* CONFIG_PROC_FS */
1978 int proc_dostring(ctl_table *table, int write, struct file *filp,
1979 void *buffer, size_t *lenp)
1984 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1985 void *buffer, size_t *lenp)
1990 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1991 void *buffer, size_t *lenp)
1996 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1997 void *buffer, size_t *lenp)
2002 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2003 void *buffer, size_t *lenp)
2008 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2009 void *buffer, size_t *lenp)
2014 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2015 void *buffer, size_t *lenp)
2020 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2021 void *buffer, size_t *lenp)
2026 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2028 void *buffer, size_t *lenp)
2034 #endif /* CONFIG_PROC_FS */
2038 * General sysctl support routines
2041 /* The generic string strategy routine: */
2042 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2043 void __user *oldval, size_t __user *oldlenp,
2044 void __user *newval, size_t newlen, void **context)
2048 if (!table->data || !table->maxlen)
2051 if (oldval && oldlenp) {
2052 if (get_user(len, oldlenp))
2055 l = strlen(table->data);
2056 if (len > l) len = l;
2057 if (len >= table->maxlen)
2058 len = table->maxlen;
2059 if(copy_to_user(oldval, table->data, len))
2061 if(put_user(0, ((char __user *) oldval) + len))
2063 if(put_user(len, oldlenp))
2067 if (newval && newlen) {
2069 if (len > table->maxlen)
2070 len = table->maxlen;
2071 if(copy_from_user(table->data, newval, len))
2073 if (len == table->maxlen)
2075 ((char *) table->data)[len] = 0;
2081 * This function makes sure that all of the integers in the vector
2082 * are between the minimum and maximum values given in the arrays
2083 * table->extra1 and table->extra2, respectively.
2085 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2086 void __user *oldval, size_t __user *oldlenp,
2087 void __user *newval, size_t newlen, void **context)
2090 if (newval && newlen) {
2091 int __user *vec = (int __user *) newval;
2092 int *min = (int *) table->extra1;
2093 int *max = (int *) table->extra2;
2097 if (newlen % sizeof(int) != 0)
2100 if (!table->extra1 && !table->extra2)
2103 if (newlen > table->maxlen)
2104 newlen = table->maxlen;
2105 length = newlen / sizeof(int);
2107 for (i = 0; i < length; i++) {
2109 if (get_user(value, vec + i))
2111 if (min && value < min[i])
2113 if (max && value > max[i])
2120 /* Strategy function to convert jiffies to seconds */
2121 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2122 void __user *oldval, size_t __user *oldlenp,
2123 void __user *newval, size_t newlen, void **context)
2128 if (get_user(olen, oldlenp))
2130 if (olen!=sizeof(int))
2133 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2134 (oldlenp && put_user(sizeof(int),oldlenp)))
2137 if (newval && newlen) {
2139 if (newlen != sizeof(int))
2141 if (get_user(new, (int __user *)newval))
2143 *(int *)(table->data) = new*HZ;
2149 #else /* CONFIG_SYSCTL */
2152 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2157 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2158 void __user *oldval, size_t __user *oldlenp,
2159 void __user *newval, size_t newlen, void **context)
2164 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2165 void __user *oldval, size_t __user *oldlenp,
2166 void __user *newval, size_t newlen, void **context)
2171 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2172 void __user *oldval, size_t __user *oldlenp,
2173 void __user *newval, size_t newlen, void **context)
2178 int proc_dostring(ctl_table *table, int write, struct file *filp,
2179 void __user *buffer, size_t *lenp)
2184 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2185 void __user *buffer, size_t *lenp)
2190 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2191 void __user *buffer, size_t *lenp)
2196 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2197 void __user *buffer, size_t *lenp)
2202 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2203 void *buffer, size_t *lenp)
2208 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2209 void *buffer, size_t *lenp)
2214 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2215 void __user *buffer, size_t *lenp)
2220 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2222 void __user *buffer, size_t *lenp)
2227 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2233 void unregister_sysctl_table(struct ctl_table_header * table)
2237 #endif /* CONFIG_SYSCTL */
2240 * No sense putting this after each symbol definition, twice,
2241 * exception granted :-)
2243 EXPORT_SYMBOL(proc_dointvec);
2244 EXPORT_SYMBOL(proc_dointvec_jiffies);
2245 EXPORT_SYMBOL(proc_dointvec_minmax);
2246 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2247 EXPORT_SYMBOL(proc_dostring);
2248 EXPORT_SYMBOL(proc_doulongvec_minmax);
2249 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2250 EXPORT_SYMBOL(register_sysctl_table);
2251 EXPORT_SYMBOL(sysctl_intvec);
2252 EXPORT_SYMBOL(sysctl_jiffies);
2253 EXPORT_SYMBOL(sysctl_string);
2254 EXPORT_SYMBOL(unregister_sysctl_table);