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 <linux/dcache.h>
44 #include <asm/uaccess.h>
46 #ifdef CONFIG_ROOT_NFS
47 #include <linux/nfs_fs.h>
50 #if defined(CONFIG_SYSCTL)
52 /* External variables not in a header file. */
53 extern int panic_timeout;
55 extern int sysctl_overcommit_memory;
56 extern int sysctl_overcommit_ratio;
57 extern int max_threads;
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,
245 .maxlen = sizeof(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,
254 .maxlen = sizeof(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,
263 .maxlen = sizeof(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,
272 .maxlen = sizeof(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,
281 .maxlen = sizeof(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,
453 .maxlen = KMOD_PATH_LEN,
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,
464 .maxlen = KMOD_PATH_LEN,
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,
499 #ifdef CONFIG_SYSVIPC
501 .ctl_name = KERN_SHMMAX,
502 .procname = "shmmax",
504 .maxlen = sizeof (size_t),
506 .proc_handler = &proc_doulongvec_minmax,
509 .ctl_name = KERN_SHMALL,
510 .procname = "shmall",
512 .maxlen = sizeof (size_t),
514 .proc_handler = &proc_doulongvec_minmax,
517 .ctl_name = KERN_SHMMNI,
518 .procname = "shmmni",
520 .maxlen = sizeof (int),
522 .proc_handler = &proc_dointvec,
525 .ctl_name = KERN_MSGMAX,
526 .procname = "msgmax",
528 .maxlen = sizeof (int),
530 .proc_handler = &proc_dointvec,
533 .ctl_name = KERN_MSGMNI,
534 .procname = "msgmni",
536 .maxlen = sizeof (int),
538 .proc_handler = &proc_dointvec,
541 .ctl_name = KERN_MSGMNB,
542 .procname = "msgmnb",
544 .maxlen = sizeof (int),
546 .proc_handler = &proc_dointvec,
549 .ctl_name = KERN_SEM,
552 .maxlen = 4*sizeof (int),
554 .proc_handler = &proc_dointvec,
557 #ifdef CONFIG_MAGIC_SYSRQ
559 .ctl_name = KERN_SYSRQ,
561 .data = &sysrq_enabled,
562 .maxlen = sizeof (int),
564 .proc_handler = &proc_dointvec,
568 .ctl_name = KERN_CADPID,
569 .procname = "cad_pid",
571 .maxlen = sizeof (int),
573 .proc_handler = &proc_dointvec,
576 .ctl_name = KERN_MAX_THREADS,
577 .procname = "threads-max",
578 .data = &max_threads,
579 .maxlen = sizeof(int),
581 .proc_handler = &proc_dointvec,
584 .ctl_name = KERN_RANDOM,
585 .procname = "random",
587 .child = random_table,
589 #ifdef CONFIG_UNIX98_PTYS
591 .ctl_name = KERN_PTY,
598 .ctl_name = KERN_OVERFLOWUID,
599 .procname = "overflowuid",
600 .data = &overflowuid,
601 .maxlen = sizeof(int),
603 .proc_handler = &proc_dointvec_minmax,
604 .strategy = &sysctl_intvec,
605 .extra1 = &minolduid,
606 .extra2 = &maxolduid,
609 .ctl_name = KERN_OVERFLOWGID,
610 .procname = "overflowgid",
611 .data = &overflowgid,
612 .maxlen = sizeof(int),
614 .proc_handler = &proc_dointvec_minmax,
615 .strategy = &sysctl_intvec,
616 .extra1 = &minolduid,
617 .extra2 = &maxolduid,
619 #ifdef CONFIG_ARCH_S390
620 #ifdef CONFIG_MATHEMU
622 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
623 .procname = "ieee_emulation_warnings",
624 .data = &sysctl_ieee_emulation_warnings,
625 .maxlen = sizeof(int),
627 .proc_handler = &proc_dointvec,
630 #ifdef CONFIG_NO_IDLE_HZ
632 .ctl_name = KERN_HZ_TIMER,
633 .procname = "hz_timer",
634 .data = &sysctl_hz_timer,
635 .maxlen = sizeof(int),
637 .proc_handler = &proc_dointvec,
641 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
642 .procname = "userprocess_debug",
643 .data = &sysctl_userprocess_debug,
644 .maxlen = sizeof(int),
646 .proc_handler = &proc_dointvec,
650 .ctl_name = KERN_PIDMAX,
651 .procname = "pid_max",
653 .maxlen = sizeof (int),
655 .proc_handler = &proc_dointvec,
658 .ctl_name = KERN_PANIC_ON_OOPS,
659 .procname = "panic_on_oops",
660 .data = &panic_on_oops,
661 .maxlen = sizeof(int),
663 .proc_handler = &proc_dointvec,
666 .ctl_name = KERN_PRINTK_RATELIMIT,
667 .procname = "printk_ratelimit",
668 .data = &printk_ratelimit_jiffies,
669 .maxlen = sizeof(int),
671 .proc_handler = &proc_dointvec_jiffies,
672 .strategy = &sysctl_jiffies,
675 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
676 .procname = "printk_ratelimit_burst",
677 .data = &printk_ratelimit_burst,
678 .maxlen = sizeof(int),
680 .proc_handler = &proc_dointvec,
683 .ctl_name = KERN_NGROUPS_MAX,
684 .procname = "ngroups_max",
685 .data = &ngroups_max,
686 .maxlen = sizeof (int),
688 .proc_handler = &proc_dointvec,
693 /* Constants for minimum and maximum testing in vm_table.
694 We use these as one-element integer vectors. */
696 static int one_hundred = 100;
699 static ctl_table vm_table[] = {
701 .ctl_name = VM_OVERCOMMIT_MEMORY,
702 .procname = "overcommit_memory",
703 .data = &sysctl_overcommit_memory,
704 .maxlen = sizeof(sysctl_overcommit_memory),
706 .proc_handler = &proc_dointvec,
709 .ctl_name = VM_OVERCOMMIT_RATIO,
710 .procname = "overcommit_ratio",
711 .data = &sysctl_overcommit_ratio,
712 .maxlen = sizeof(sysctl_overcommit_ratio),
714 .proc_handler = &proc_dointvec,
717 .ctl_name = VM_PAGE_CLUSTER,
718 .procname = "page-cluster",
719 .data = &page_cluster,
720 .maxlen = sizeof(int),
722 .proc_handler = &proc_dointvec,
725 .ctl_name = VM_DIRTY_BACKGROUND,
726 .procname = "dirty_background_ratio",
727 .data = &dirty_background_ratio,
728 .maxlen = sizeof(dirty_background_ratio),
730 .proc_handler = &proc_dointvec_minmax,
731 .strategy = &sysctl_intvec,
733 .extra2 = &one_hundred,
736 .ctl_name = VM_DIRTY_RATIO,
737 .procname = "dirty_ratio",
738 .data = &vm_dirty_ratio,
739 .maxlen = sizeof(vm_dirty_ratio),
741 .proc_handler = &proc_dointvec_minmax,
742 .strategy = &sysctl_intvec,
744 .extra2 = &one_hundred,
747 .ctl_name = VM_DIRTY_WB_CS,
748 .procname = "dirty_writeback_centisecs",
749 .data = &dirty_writeback_centisecs,
750 .maxlen = sizeof(dirty_writeback_centisecs),
752 .proc_handler = &dirty_writeback_centisecs_handler,
755 .ctl_name = VM_DIRTY_EXPIRE_CS,
756 .procname = "dirty_expire_centisecs",
757 .data = &dirty_expire_centisecs,
758 .maxlen = sizeof(dirty_expire_centisecs),
760 .proc_handler = &proc_dointvec,
763 .ctl_name = VM_NR_PDFLUSH_THREADS,
764 .procname = "nr_pdflush_threads",
765 .data = &nr_pdflush_threads,
766 .maxlen = sizeof nr_pdflush_threads,
767 .mode = 0444 /* read-only*/,
768 .proc_handler = &proc_dointvec,
771 .ctl_name = VM_SWAPPINESS,
772 .procname = "swappiness",
773 .data = &vm_swappiness,
774 .maxlen = sizeof(vm_swappiness),
776 .proc_handler = &proc_dointvec_minmax,
777 .strategy = &sysctl_intvec,
779 .extra2 = &one_hundred,
781 #ifdef CONFIG_HUGETLB_PAGE
783 .ctl_name = VM_HUGETLB_PAGES,
784 .procname = "nr_hugepages",
785 .data = &max_huge_pages,
786 .maxlen = sizeof(unsigned long),
788 .proc_handler = &hugetlb_sysctl_handler,
789 .extra1 = (void *)&hugetlb_zero,
790 .extra2 = (void *)&hugetlb_infinity,
794 .ctl_name = VM_LOWER_ZONE_PROTECTION,
795 .procname = "lower_zone_protection",
796 .data = &sysctl_lower_zone_protection,
797 .maxlen = sizeof(sysctl_lower_zone_protection),
799 .proc_handler = &lower_zone_protection_sysctl_handler,
800 .strategy = &sysctl_intvec,
804 .ctl_name = VM_MIN_FREE_KBYTES,
805 .procname = "min_free_kbytes",
806 .data = &min_free_kbytes,
807 .maxlen = sizeof(min_free_kbytes),
809 .proc_handler = &min_free_kbytes_sysctl_handler,
810 .strategy = &sysctl_intvec,
814 .ctl_name = VM_MAX_MAP_COUNT,
815 .procname = "max_map_count",
816 .data = &sysctl_max_map_count,
817 .maxlen = sizeof(sysctl_max_map_count),
819 .proc_handler = &proc_dointvec
822 .ctl_name = VM_LAPTOP_MODE,
823 .procname = "laptop_mode",
824 .data = &laptop_mode,
825 .maxlen = sizeof(laptop_mode),
827 .proc_handler = &proc_dointvec,
828 .strategy = &sysctl_intvec,
832 .ctl_name = VM_BLOCK_DUMP,
833 .procname = "block_dump",
835 .maxlen = sizeof(block_dump),
837 .proc_handler = &proc_dointvec,
838 .strategy = &sysctl_intvec,
842 .ctl_name = VM_VFS_CACHE_PRESSURE,
843 .procname = "vfs_cache_pressure",
844 .data = &sysctl_vfs_cache_pressure,
845 .maxlen = sizeof(sysctl_vfs_cache_pressure),
847 .proc_handler = &proc_dointvec,
848 .strategy = &sysctl_intvec,
854 static ctl_table proc_table[] = {
858 static ctl_table fs_table[] = {
860 .ctl_name = FS_NRINODE,
861 .procname = "inode-nr",
862 .data = &inodes_stat,
863 .maxlen = 2*sizeof(int),
865 .proc_handler = &proc_dointvec,
868 .ctl_name = FS_STATINODE,
869 .procname = "inode-state",
870 .data = &inodes_stat,
871 .maxlen = 7*sizeof(int),
873 .proc_handler = &proc_dointvec,
876 .ctl_name = FS_NRFILE,
877 .procname = "file-nr",
879 .maxlen = 3*sizeof(int),
881 .proc_handler = &proc_dointvec,
884 .ctl_name = FS_MAXFILE,
885 .procname = "file-max",
886 .data = &files_stat.max_files,
887 .maxlen = sizeof(int),
889 .proc_handler = &proc_dointvec,
892 .ctl_name = FS_DENTRY,
893 .procname = "dentry-state",
894 .data = &dentry_stat,
895 .maxlen = 6*sizeof(int),
897 .proc_handler = &proc_dointvec,
900 .ctl_name = FS_OVERFLOWUID,
901 .procname = "overflowuid",
902 .data = &fs_overflowuid,
903 .maxlen = sizeof(int),
905 .proc_handler = &proc_dointvec_minmax,
906 .strategy = &sysctl_intvec,
907 .extra1 = &minolduid,
908 .extra2 = &maxolduid,
911 .ctl_name = FS_OVERFLOWGID,
912 .procname = "overflowgid",
913 .data = &fs_overflowgid,
914 .maxlen = sizeof(int),
916 .proc_handler = &proc_dointvec_minmax,
917 .strategy = &sysctl_intvec,
918 .extra1 = &minolduid,
919 .extra2 = &maxolduid,
922 .ctl_name = FS_LEASES,
923 .procname = "leases-enable",
924 .data = &leases_enable,
925 .maxlen = sizeof(int),
927 .proc_handler = &proc_dointvec,
930 .ctl_name = FS_DIR_NOTIFY,
931 .procname = "dir-notify-enable",
932 .data = &dir_notify_enable,
933 .maxlen = sizeof(int),
935 .proc_handler = &proc_dointvec,
938 .ctl_name = FS_LEASE_TIME,
939 .procname = "lease-break-time",
940 .data = &lease_break_time,
941 .maxlen = sizeof(int),
943 .proc_handler = &proc_dointvec,
946 .ctl_name = FS_AIO_NR,
947 .procname = "aio-nr",
949 .maxlen = sizeof(aio_nr),
951 .proc_handler = &proc_dointvec,
954 .ctl_name = FS_AIO_MAX_NR,
955 .procname = "aio-max-nr",
957 .maxlen = sizeof(aio_max_nr),
959 .proc_handler = &proc_dointvec,
964 static ctl_table debug_table[] = {
968 static ctl_table dev_table[] = {
972 extern void init_irq_proc (void);
974 void __init sysctl_init(void)
976 #ifdef CONFIG_PROC_FS
977 register_proc_table(root_table, proc_sys_root);
982 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
983 void __user *newval, size_t newlen)
985 struct list_head *tmp;
987 if (nlen <= 0 || nlen >= CTL_MAXNAME)
991 if (!oldlenp || get_user(old_len, oldlenp))
994 tmp = &root_table_header.ctl_entry;
996 struct ctl_table_header *head =
997 list_entry(tmp, struct ctl_table_header, ctl_entry);
998 void *context = NULL;
999 int error = parse_table(name, nlen, oldval, oldlenp,
1000 newval, newlen, head->ctl_table,
1004 if (error != -ENOTDIR)
1007 } while (tmp != &root_table_header.ctl_entry);
1011 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1013 struct __sysctl_args tmp;
1016 if (copy_from_user(&tmp, args, sizeof(tmp)))
1020 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1021 tmp.newval, tmp.newlen);
1027 * ctl_perm does NOT grant the superuser all rights automatically, because
1028 * some sysctl variables are readonly even to root.
1031 static int test_perm(int mode, int op)
1035 else if (in_egroup_p(0))
1037 if ((mode & op & 0007) == op)
1042 static inline int ctl_perm(ctl_table *table, int op)
1045 error = security_sysctl(table, op);
1048 return test_perm(table->mode, op);
1051 static int parse_table(int __user *name, int nlen,
1052 void __user *oldval, size_t __user *oldlenp,
1053 void __user *newval, size_t newlen,
1054 ctl_table *table, void **context)
1060 if (get_user(n, name))
1062 for ( ; table->ctl_name; table++) {
1063 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1066 if (ctl_perm(table, 001))
1068 if (table->strategy) {
1069 error = table->strategy(
1072 newval, newlen, context);
1078 table = table->child;
1081 error = do_sysctl_strategy(table, name, nlen,
1083 newval, newlen, context);
1090 /* Perform the actual read/write of a sysctl table entry. */
1091 int do_sysctl_strategy (ctl_table *table,
1092 int __user *name, int nlen,
1093 void __user *oldval, size_t __user *oldlenp,
1094 void __user *newval, size_t newlen, void **context)
1103 if (ctl_perm(table, op))
1106 if (table->strategy) {
1107 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1108 newval, newlen, context);
1115 /* If there is no strategy routine, or if the strategy returns
1116 * zero, proceed with automatic r/w */
1117 if (table->data && table->maxlen) {
1118 if (oldval && oldlenp) {
1119 if (get_user(len, oldlenp))
1122 if (len > table->maxlen)
1123 len = table->maxlen;
1124 if(copy_to_user(oldval, table->data, len))
1126 if(put_user(len, oldlenp))
1130 if (newval && newlen) {
1132 if (len > table->maxlen)
1133 len = table->maxlen;
1134 if(copy_from_user(table->data, newval, len))
1142 * register_sysctl_table - register a sysctl hierarchy
1143 * @table: the top-level table structure
1144 * @insert_at_head: whether the entry should be inserted in front or at the end
1146 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1147 * array. An entry with a ctl_name of 0 terminates the table.
1149 * The members of the &ctl_table structure are used as follows:
1151 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1152 * must be unique within that level of sysctl
1154 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1155 * enter a sysctl file
1157 * data - a pointer to data for use by proc_handler
1159 * maxlen - the maximum size in bytes of the data
1161 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1163 * child - a pointer to the child sysctl table if this entry is a directory, or
1166 * proc_handler - the text handler routine (described below)
1168 * strategy - the strategy routine (described below)
1170 * de - for internal use by the sysctl routines
1172 * extra1, extra2 - extra pointers usable by the proc handler routines
1174 * Leaf nodes in the sysctl tree will be represented by a single file
1175 * under /proc; non-leaf nodes will be represented by directories.
1177 * sysctl(2) can automatically manage read and write requests through
1178 * the sysctl table. The data and maxlen fields of the ctl_table
1179 * struct enable minimal validation of the values being written to be
1180 * performed, and the mode field allows minimal authentication.
1182 * More sophisticated management can be enabled by the provision of a
1183 * strategy routine with the table entry. This will be called before
1184 * any automatic read or write of the data is performed.
1186 * The strategy routine may return
1188 * < 0 - Error occurred (error is passed to user process)
1190 * 0 - OK - proceed with automatic read or write.
1192 * > 0 - OK - read or write has been done by the strategy routine, so
1193 * return immediately.
1195 * There must be a proc_handler routine for any terminal nodes
1196 * mirrored under /proc/sys (non-terminals are handled by a built-in
1197 * directory handler). Several default handlers are available to
1198 * cover common cases -
1200 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1201 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1202 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1204 * It is the handler's job to read the input buffer from user memory
1205 * and process it. The handler should return 0 on success.
1207 * This routine returns %NULL on a failure to register, and a pointer
1208 * to the table header on success.
1210 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1213 struct ctl_table_header *tmp;
1214 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1217 tmp->ctl_table = table;
1218 INIT_LIST_HEAD(&tmp->ctl_entry);
1220 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1222 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1223 #ifdef CONFIG_PROC_FS
1224 register_proc_table(table, proc_sys_root);
1230 * unregister_sysctl_table - unregister a sysctl table hierarchy
1231 * @header: the header returned from register_sysctl_table
1233 * Unregisters the sysctl table and all children. proc entries may not
1234 * actually be removed until they are no longer used by anyone.
1236 void unregister_sysctl_table(struct ctl_table_header * header)
1238 list_del(&header->ctl_entry);
1239 #ifdef CONFIG_PROC_FS
1240 unregister_proc_table(header->ctl_table, proc_sys_root);
1249 #ifdef CONFIG_PROC_FS
1251 /* Scan the sysctl entries in table and add them all into /proc */
1252 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1254 struct proc_dir_entry *de;
1258 for (; table->ctl_name; table++) {
1259 /* Can't do anything without a proc name. */
1260 if (!table->procname)
1262 /* Maybe we can't do anything with it... */
1263 if (!table->proc_handler && !table->child) {
1264 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1269 len = strlen(table->procname);
1273 if (table->proc_handler)
1277 for (de = root->subdir; de; de = de->next) {
1278 if (proc_match(len, table->procname, de))
1281 /* If the subdir exists already, de is non-NULL */
1285 de = create_proc_entry(table->procname, mode, root);
1288 de->data = (void *) table;
1289 if (table->proc_handler)
1290 de->proc_fops = &proc_sys_file_operations;
1293 if (de->mode & S_IFDIR)
1294 register_proc_table(table->child, de);
1299 * Unregister a /proc sysctl table and any subdirectories.
1301 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1303 struct proc_dir_entry *de;
1304 for (; table->ctl_name; table++) {
1305 if (!(de = table->de))
1307 if (de->mode & S_IFDIR) {
1308 if (!table->child) {
1309 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1312 unregister_proc_table(table->child, de);
1314 /* Don't unregister directories which still have entries.. */
1319 /* Don't unregister proc entries that are still being used.. */
1320 if (atomic_read(&de->count))
1324 remove_proc_entry(table->procname, root);
1328 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1329 size_t count, loff_t *ppos)
1332 struct proc_dir_entry *de;
1333 struct ctl_table *table;
1337 de = PDE(file->f_dentry->d_inode);
1338 if (!de || !de->data)
1340 table = (struct ctl_table *) de->data;
1341 if (!table || !table->proc_handler)
1343 op = (write ? 002 : 004);
1344 if (ctl_perm(table, op))
1350 * FIXME: we need to pass on ppos to the handler.
1353 error = (*table->proc_handler) (table, write, file, buf, &res);
1359 static int proc_opensys(struct inode *inode, struct file *file)
1361 if (file->f_mode & FMODE_WRITE) {
1363 * sysctl entries that are not writable,
1364 * are _NOT_ writable, capabilities or not.
1366 if (!(inode->i_mode & S_IWUSR))
1373 static ssize_t proc_readsys(struct file * file, char __user * buf,
1374 size_t count, loff_t *ppos)
1376 return do_rw_proc(0, file, buf, count, ppos);
1379 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1380 size_t count, loff_t *ppos)
1382 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1386 * proc_dostring - read a string sysctl
1387 * @table: the sysctl table
1388 * @write: %TRUE if this is a write to the sysctl file
1389 * @filp: the file structure
1390 * @buffer: the user buffer
1391 * @lenp: the size of the user buffer
1393 * Reads/writes a string from/to the user buffer. If the kernel
1394 * buffer provided is not large enough to hold the string, the
1395 * string is truncated. The copied string is %NULL-terminated.
1396 * If the string is being read by the user process, it is copied
1397 * and a newline '\n' is added. It is truncated if the buffer is
1400 * Returns 0 on success.
1402 int proc_dostring(ctl_table *table, int write, struct file *filp,
1403 void __user *buffer, size_t *lenp)
1409 if (!table->data || !table->maxlen || !*lenp ||
1410 (filp->f_pos && !write)) {
1418 while (len < *lenp) {
1419 if (get_user(c, p++))
1421 if (c == 0 || c == '\n')
1425 if (len >= table->maxlen)
1426 len = table->maxlen-1;
1427 if(copy_from_user(table->data, buffer, len))
1429 ((char *) table->data)[len] = 0;
1430 filp->f_pos += *lenp;
1432 len = strlen(table->data);
1433 if (len > table->maxlen)
1434 len = table->maxlen;
1438 if(copy_to_user(buffer, table->data, len))
1441 if(put_user('\n', ((char __user *) buffer) + len))
1452 * Special case of dostring for the UTS structure. This has locks
1453 * to observe. Should this be in kernel/sys.c ????
1456 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1457 void __user *buffer, size_t *lenp)
1462 down_read(&uts_sem);
1463 r=proc_dostring(table,0,filp,buffer,lenp);
1466 down_write(&uts_sem);
1467 r=proc_dostring(table,1,filp,buffer,lenp);
1473 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1475 int write, void *data)
1478 *valp = *negp ? -*lvalp : *lvalp;
1483 *lvalp = (unsigned long)-val;
1486 *lvalp = (unsigned long)val;
1492 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1493 void __user *buffer, size_t *lenp,
1494 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1495 int write, void *data),
1498 #define TMPBUFLEN 20
1499 int *i, vleft, first=1, neg, val;
1503 char buf[TMPBUFLEN], *p;
1504 char __user *s = buffer;
1506 if (!table->data || !table->maxlen || !*lenp ||
1507 (filp->f_pos && !write)) {
1512 i = (int *) table->data;
1513 vleft = table->maxlen / sizeof(*i);
1517 conv = do_proc_dointvec_conv;
1519 for (; left && vleft--; i++, first=0) {
1534 if (len > sizeof(buf) - 1)
1535 len = sizeof(buf) - 1;
1536 if (copy_from_user(buf, s, len))
1540 if (*p == '-' && left > 1) {
1544 if (*p < '0' || *p > '9')
1547 lval = simple_strtoul(p, &p, 0);
1550 if ((len < left) && *p && !isspace(*p))
1557 if (conv(&neg, &lval, i, 1, data))
1564 if (conv(&neg, &lval, i, 0, data))
1567 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1571 if(copy_to_user(s, buf, len))
1578 if (!write && !first && left) {
1579 if(put_user('\n', s))
1586 if (get_user(c, s++))
1596 filp->f_pos += *lenp;
1602 * proc_dointvec - read a vector of integers
1603 * @table: the sysctl table
1604 * @write: %TRUE if this is a write to the sysctl file
1605 * @filp: the file structure
1606 * @buffer: the user buffer
1607 * @lenp: the size of the user buffer
1609 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1610 * values from/to the user buffer, treated as an ASCII string.
1612 * Returns 0 on success.
1614 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1615 void __user *buffer, size_t *lenp)
1617 return do_proc_dointvec(table,write,filp,buffer,lenp,
1627 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1629 int write, void *data)
1631 int op = *(int *)data;
1633 int val = *negp ? -*lvalp : *lvalp;
1635 case OP_SET: *valp = val; break;
1636 case OP_AND: *valp &= val; break;
1637 case OP_OR: *valp |= val; break;
1638 case OP_MAX: if(*valp < val)
1641 case OP_MIN: if(*valp > val)
1649 *lvalp = (unsigned long)-val;
1652 *lvalp = (unsigned long)val;
1659 * init may raise the set.
1662 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1663 void __user *buffer, size_t *lenp)
1667 if (!capable(CAP_SYS_MODULE)) {
1671 op = (current->pid == 1) ? OP_SET : OP_AND;
1672 return do_proc_dointvec(table,write,filp,buffer,lenp,
1673 do_proc_dointvec_bset_conv,&op);
1676 struct do_proc_dointvec_minmax_conv_param {
1681 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1683 int write, void *data)
1685 struct do_proc_dointvec_minmax_conv_param *param = data;
1687 int val = *negp ? -*lvalp : *lvalp;
1688 if ((param->min && *param->min > val) ||
1689 (param->max && *param->max < val))
1696 *lvalp = (unsigned long)-val;
1699 *lvalp = (unsigned long)val;
1706 * proc_dointvec_minmax - read a vector of integers with min/max values
1707 * @table: the sysctl table
1708 * @write: %TRUE if this is a write to the sysctl file
1709 * @filp: the file structure
1710 * @buffer: the user buffer
1711 * @lenp: the size of the user buffer
1713 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1714 * values from/to the user buffer, treated as an ASCII string.
1716 * This routine will ensure the values are within the range specified by
1717 * table->extra1 (min) and table->extra2 (max).
1719 * Returns 0 on success.
1721 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1722 void __user *buffer, size_t *lenp)
1724 struct do_proc_dointvec_minmax_conv_param param = {
1725 .min = (int *) table->extra1,
1726 .max = (int *) table->extra2,
1728 return do_proc_dointvec(table, write, filp, buffer, lenp,
1729 do_proc_dointvec_minmax_conv, ¶m);
1732 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1734 void __user *buffer, size_t *lenp,
1735 unsigned long convmul,
1736 unsigned long convdiv)
1738 #define TMPBUFLEN 20
1739 unsigned long *i, *min, *max, val;
1740 int vleft, first=1, neg;
1742 char buf[TMPBUFLEN], *p;
1743 char __user *s = buffer;
1745 if (!table->data || !table->maxlen || !*lenp ||
1746 (filp->f_pos && !write)) {
1751 i = (unsigned long *) table->data;
1752 min = (unsigned long *) table->extra1;
1753 max = (unsigned long *) table->extra2;
1754 vleft = table->maxlen / sizeof(unsigned long);
1757 for (; left && vleft--; i++, min++, max++, first=0) {
1772 if (len > TMPBUFLEN-1)
1774 if (copy_from_user(buf, s, len))
1778 if (*p == '-' && left > 1) {
1782 if (*p < '0' || *p > '9')
1784 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1786 if ((len < left) && *p && !isspace(*p))
1795 if ((min && val < *min) || (max && val > *max))
1802 sprintf(p, "%lu", convdiv * (*i) / convmul);
1806 if(copy_to_user(s, buf, len))
1813 if (!write && !first && left) {
1814 if(put_user('\n', s))
1821 if (get_user(c, s++))
1831 filp->f_pos += *lenp;
1837 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1838 * @table: the sysctl table
1839 * @write: %TRUE if this is a write to the sysctl file
1840 * @filp: the file structure
1841 * @buffer: the user buffer
1842 * @lenp: the size of the user buffer
1844 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1845 * values from/to the user buffer, treated as an ASCII string.
1847 * This routine will ensure the values are within the range specified by
1848 * table->extra1 (min) and table->extra2 (max).
1850 * Returns 0 on success.
1852 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1853 void __user *buffer, size_t *lenp)
1855 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1859 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1860 * @table: the sysctl table
1861 * @write: %TRUE if this is a write to the sysctl file
1862 * @filp: the file structure
1863 * @buffer: the user buffer
1864 * @lenp: the size of the user buffer
1866 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1867 * values from/to the user buffer, treated as an ASCII string. The values
1868 * are treated as milliseconds, and converted to jiffies when they are stored.
1870 * This routine will ensure the values are within the range specified by
1871 * table->extra1 (min) and table->extra2 (max).
1873 * Returns 0 on success.
1875 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1877 void __user *buffer, size_t *lenp)
1879 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1884 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1886 int write, void *data)
1889 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1895 lval = (unsigned long)-val;
1898 lval = (unsigned long)val;
1905 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1907 int write, void *data)
1910 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1916 lval = (unsigned long)-val;
1919 lval = (unsigned long)val;
1921 *lvalp = jiffies_to_clock_t(lval);
1927 * proc_dointvec_jiffies - read a vector of integers as seconds
1928 * @table: the sysctl table
1929 * @write: %TRUE if this is a write to the sysctl file
1930 * @filp: the file structure
1931 * @buffer: the user buffer
1932 * @lenp: the size of the user buffer
1934 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1935 * values from/to the user buffer, treated as an ASCII string.
1936 * The values read are assumed to be in seconds, and are converted into
1939 * Returns 0 on success.
1941 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1942 void __user *buffer, size_t *lenp)
1944 return do_proc_dointvec(table,write,filp,buffer,lenp,
1945 do_proc_dointvec_jiffies_conv,NULL);
1949 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1950 * @table: the sysctl table
1951 * @write: %TRUE if this is a write to the sysctl file
1952 * @filp: the file structure
1953 * @buffer: the user buffer
1954 * @lenp: the size of the user buffer
1956 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1957 * values from/to the user buffer, treated as an ASCII string.
1958 * The values read are assumed to be in 1/USER_HZ seconds, and
1959 * are converted into jiffies.
1961 * Returns 0 on success.
1963 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1964 void __user *buffer, size_t *lenp)
1966 return do_proc_dointvec(table,write,filp,buffer,lenp,
1967 do_proc_dointvec_userhz_jiffies_conv,NULL);
1970 #else /* CONFIG_PROC_FS */
1972 int proc_dostring(ctl_table *table, int write, struct file *filp,
1973 void __user *buffer, size_t *lenp)
1978 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1979 void __user *buffer, size_t *lenp)
1984 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1985 void __user *buffer, size_t *lenp)
1990 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1991 void __user *buffer, size_t *lenp)
1996 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1997 void __user *buffer, size_t *lenp)
2002 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2003 void __user *buffer, size_t *lenp)
2008 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2009 void __user *buffer, size_t *lenp)
2014 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2015 void __user *buffer, size_t *lenp)
2020 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2022 void __user *buffer, size_t *lenp)
2028 #endif /* CONFIG_PROC_FS */
2032 * General sysctl support routines
2035 /* The generic string strategy routine: */
2036 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2037 void __user *oldval, size_t __user *oldlenp,
2038 void __user *newval, size_t newlen, void **context)
2042 if (!table->data || !table->maxlen)
2045 if (oldval && oldlenp) {
2046 if (get_user(len, oldlenp))
2049 l = strlen(table->data);
2050 if (len > l) len = l;
2051 if (len >= table->maxlen)
2052 len = table->maxlen;
2053 if(copy_to_user(oldval, table->data, len))
2055 if(put_user(0, ((char __user *) oldval) + len))
2057 if(put_user(len, oldlenp))
2061 if (newval && newlen) {
2063 if (len > table->maxlen)
2064 len = table->maxlen;
2065 if(copy_from_user(table->data, newval, len))
2067 if (len == table->maxlen)
2069 ((char *) table->data)[len] = 0;
2075 * This function makes sure that all of the integers in the vector
2076 * are between the minimum and maximum values given in the arrays
2077 * table->extra1 and table->extra2, respectively.
2079 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2080 void __user *oldval, size_t __user *oldlenp,
2081 void __user *newval, size_t newlen, void **context)
2084 if (newval && newlen) {
2085 int __user *vec = (int __user *) newval;
2086 int *min = (int *) table->extra1;
2087 int *max = (int *) table->extra2;
2091 if (newlen % sizeof(int) != 0)
2094 if (!table->extra1 && !table->extra2)
2097 if (newlen > table->maxlen)
2098 newlen = table->maxlen;
2099 length = newlen / sizeof(int);
2101 for (i = 0; i < length; i++) {
2103 if (get_user(value, vec + i))
2105 if (min && value < min[i])
2107 if (max && value > max[i])
2114 /* Strategy function to convert jiffies to seconds */
2115 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2116 void __user *oldval, size_t __user *oldlenp,
2117 void __user *newval, size_t newlen, void **context)
2122 if (get_user(olen, oldlenp))
2124 if (olen!=sizeof(int))
2127 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2128 (oldlenp && put_user(sizeof(int),oldlenp)))
2131 if (newval && newlen) {
2133 if (newlen != sizeof(int))
2135 if (get_user(new, (int __user *)newval))
2137 *(int *)(table->data) = new*HZ;
2143 #else /* CONFIG_SYSCTL */
2146 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2151 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2152 void __user *oldval, size_t __user *oldlenp,
2153 void __user *newval, size_t newlen, void **context)
2158 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2159 void __user *oldval, size_t __user *oldlenp,
2160 void __user *newval, size_t newlen, void **context)
2165 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2166 void __user *oldval, size_t __user *oldlenp,
2167 void __user *newval, size_t newlen, void **context)
2172 int proc_dostring(ctl_table *table, int write, struct file *filp,
2173 void __user *buffer, size_t *lenp)
2178 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2179 void __user *buffer, size_t *lenp)
2184 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2185 void __user *buffer, size_t *lenp)
2190 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2191 void __user *buffer, size_t *lenp)
2196 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2197 void __user *buffer, size_t *lenp)
2202 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2203 void __user *buffer, size_t *lenp)
2208 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2209 void __user *buffer, size_t *lenp)
2214 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2216 void __user *buffer, size_t *lenp)
2221 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2227 void unregister_sysctl_table(struct ctl_table_header * table)
2231 #endif /* CONFIG_SYSCTL */
2234 * No sense putting this after each symbol definition, twice,
2235 * exception granted :-)
2237 EXPORT_SYMBOL(proc_dointvec);
2238 EXPORT_SYMBOL(proc_dointvec_jiffies);
2239 EXPORT_SYMBOL(proc_dointvec_minmax);
2240 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2241 EXPORT_SYMBOL(proc_dostring);
2242 EXPORT_SYMBOL(proc_doulongvec_minmax);
2243 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2244 EXPORT_SYMBOL(register_sysctl_table);
2245 EXPORT_SYMBOL(sysctl_intvec);
2246 EXPORT_SYMBOL(sysctl_jiffies);
2247 EXPORT_SYMBOL(sysctl_string);
2248 EXPORT_SYMBOL(unregister_sysctl_table);