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 #ifdef CONFIG_CHR_DEV_SG
104 extern int sg_big_buff;
106 #ifdef CONFIG_SYSVIPC
107 extern size_t shm_ctlmax;
108 extern size_t shm_ctlall;
109 extern int shm_ctlmni;
110 extern int msg_ctlmax;
111 extern int msg_ctlmnb;
112 extern int msg_ctlmni;
113 extern int sem_ctls[];
117 extern char reboot_command [];
118 extern int stop_a_enabled;
119 extern int scons_pwroff;
123 extern int pwrsw_enabled;
124 extern int unaligned_enabled;
127 #ifdef CONFIG_ARCH_S390
128 #ifdef CONFIG_MATHEMU
129 extern int sysctl_ieee_emulation_warnings;
131 extern int sysctl_userprocess_debug;
134 extern int sysctl_hz_timer;
136 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
137 extern unsigned long powersave_nap;
138 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
139 void *buffer, size_t *lenp);
142 #ifdef CONFIG_BSD_PROCESS_ACCT
143 extern int acct_parm[];
146 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
147 ctl_table *, void **);
148 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
149 void __user *buffer, size_t *lenp);
151 static ctl_table root_table[];
152 static struct ctl_table_header root_table_header =
153 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
155 static ctl_table kern_table[];
156 static ctl_table vm_table[];
158 extern ctl_table net_table[];
160 static ctl_table proc_table[];
161 static ctl_table fs_table[];
162 static ctl_table debug_table[];
163 static ctl_table dev_table[];
164 extern ctl_table random_table[];
165 #ifdef CONFIG_UNIX98_PTYS
166 extern ctl_table pty_table[];
169 /* /proc declarations: */
171 #ifdef CONFIG_PROC_FS
173 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
174 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
175 static int proc_opensys(struct inode *, struct file *);
177 struct file_operations proc_sys_file_operations = {
178 .open = proc_opensys,
179 .read = proc_readsys,
180 .write = proc_writesys,
183 extern struct proc_dir_entry *proc_sys_root;
185 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
186 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
189 /* The default sysctl tables: */
191 static ctl_table root_table[] = {
193 .ctl_name = CTL_KERN,
194 .procname = "kernel",
213 .ctl_name = CTL_PROC,
225 .ctl_name = CTL_DEBUG,
228 .child = debug_table,
239 static ctl_table kern_table[] = {
241 .ctl_name = KERN_OSTYPE,
242 .procname = "ostype",
243 .data = system_utsname.sysname,
244 .maxlen = sizeof(system_utsname.sysname),
246 .proc_handler = &proc_doutsstring,
247 .strategy = &sysctl_string,
250 .ctl_name = KERN_OSRELEASE,
251 .procname = "osrelease",
252 .data = system_utsname.release,
253 .maxlen = sizeof(system_utsname.release),
255 .proc_handler = &proc_doutsstring,
256 .strategy = &sysctl_string,
259 .ctl_name = KERN_VERSION,
260 .procname = "version",
261 .data = system_utsname.version,
262 .maxlen = sizeof(system_utsname.version),
264 .proc_handler = &proc_doutsstring,
265 .strategy = &sysctl_string,
268 .ctl_name = KERN_NODENAME,
269 .procname = "hostname",
270 .data = system_utsname.nodename,
271 .maxlen = sizeof(system_utsname.nodename),
273 .proc_handler = &proc_doutsstring,
274 .strategy = &sysctl_string,
277 .ctl_name = KERN_DOMAINNAME,
278 .procname = "domainname",
279 .data = system_utsname.domainname,
280 .maxlen = sizeof(system_utsname.domainname),
282 .proc_handler = &proc_doutsstring,
283 .strategy = &sysctl_string,
286 .ctl_name = KERN_PANIC,
288 .data = &panic_timeout,
289 .maxlen = sizeof(int),
291 .proc_handler = &proc_dointvec,
294 .ctl_name = KERN_PANIC,
295 .procname = "exec-shield",
296 .data = &exec_shield,
297 .maxlen = sizeof(int),
299 .proc_handler = &proc_dointvec,
302 .ctl_name = KERN_PANIC,
303 .procname = "exec-shield-randomize",
304 .data = &exec_shield_randomize,
305 .maxlen = sizeof(int),
307 .proc_handler = &proc_dointvec,
310 .ctl_name = KERN_PANIC,
311 .procname = "print-fatal-signals",
312 .data = &print_fatal_signals,
313 .maxlen = sizeof(int),
315 .proc_handler = &proc_dointvec,
319 .ctl_name = KERN_PANIC,
321 .data = &vdso_enabled,
322 .maxlen = sizeof(int),
324 .proc_handler = &proc_dointvec,
328 .ctl_name = KERN_CORE_USES_PID,
329 .procname = "core_uses_pid",
330 .data = &core_uses_pid,
331 .maxlen = sizeof(int),
333 .proc_handler = &proc_dointvec,
336 .ctl_name = KERN_CORE_PATTERN,
337 .procname = "core_pattern",
338 .data = core_pattern,
341 .proc_handler = &proc_dostring,
342 .strategy = &sysctl_string,
345 .ctl_name = KERN_TAINTED,
346 .procname = "tainted",
348 .maxlen = sizeof(int),
350 .proc_handler = &proc_dointvec,
353 .ctl_name = KERN_CAP_BSET,
354 .procname = "cap-bound",
356 .maxlen = sizeof(kernel_cap_t),
358 .proc_handler = &proc_dointvec_bset,
360 #ifdef CONFIG_BLK_DEV_INITRD
362 .ctl_name = KERN_REALROOTDEV,
363 .procname = "real-root-dev",
364 .data = &real_root_dev,
365 .maxlen = sizeof(int),
367 .proc_handler = &proc_dointvec,
372 .ctl_name = KERN_SPARC_REBOOT,
373 .procname = "reboot-cmd",
374 .data = reboot_command,
377 .proc_handler = &proc_dostring,
378 .strategy = &sysctl_string,
381 .ctl_name = KERN_SPARC_STOP_A,
382 .procname = "stop-a",
383 .data = &stop_a_enabled,
384 .maxlen = sizeof (int),
386 .proc_handler = &proc_dointvec,
389 .ctl_name = KERN_SPARC_SCONS_PWROFF,
390 .procname = "scons-poweroff",
391 .data = &scons_pwroff,
392 .maxlen = sizeof (int),
394 .proc_handler = &proc_dointvec,
399 .ctl_name = KERN_HPPA_PWRSW,
400 .procname = "soft-power",
401 .data = &pwrsw_enabled,
402 .maxlen = sizeof (int),
404 .proc_handler = &proc_dointvec,
407 .ctl_name = KERN_HPPA_UNALIGNED,
408 .procname = "unaligned-trap",
409 .data = &unaligned_enabled,
410 .maxlen = sizeof (int),
412 .proc_handler = &proc_dointvec,
415 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
417 .ctl_name = KERN_PPC_POWERSAVE_NAP,
418 .procname = "powersave-nap",
419 .data = &powersave_nap,
420 .maxlen = sizeof(int),
422 .proc_handler = &proc_dointvec,
425 .ctl_name = KERN_PPC_L2CR,
428 .proc_handler = &proc_dol2crvec,
432 .ctl_name = KERN_CTLALTDEL,
433 .procname = "ctrl-alt-del",
435 .maxlen = sizeof(int),
437 .proc_handler = &proc_dointvec,
440 .ctl_name = KERN_PRINTK,
441 .procname = "printk",
442 .data = &console_loglevel,
443 .maxlen = 4*sizeof(int),
445 .proc_handler = &proc_dointvec,
449 .ctl_name = KERN_MODPROBE,
450 .procname = "modprobe",
451 .data = &modprobe_path,
452 .maxlen = KMOD_PATH_LEN,
454 .proc_handler = &proc_dostring,
455 .strategy = &sysctl_string,
458 #ifdef CONFIG_HOTPLUG
460 .ctl_name = KERN_HOTPLUG,
461 .procname = "hotplug",
462 .data = &hotplug_path,
463 .maxlen = KMOD_PATH_LEN,
465 .proc_handler = &proc_dostring,
466 .strategy = &sysctl_string,
469 #ifdef CONFIG_CHR_DEV_SG
471 .ctl_name = KERN_SG_BIG_BUFF,
472 .procname = "sg-big-buff",
473 .data = &sg_big_buff,
474 .maxlen = sizeof (int),
476 .proc_handler = &proc_dointvec,
479 #ifdef CONFIG_BSD_PROCESS_ACCT
481 .ctl_name = KERN_ACCT,
484 .maxlen = 3*sizeof(int),
486 .proc_handler = &proc_dointvec,
489 #ifdef CONFIG_SYSVIPC
491 .ctl_name = KERN_SHMMAX,
492 .procname = "shmmax",
494 .maxlen = sizeof (size_t),
496 .proc_handler = &proc_doulongvec_minmax,
499 .ctl_name = KERN_SHMALL,
500 .procname = "shmall",
502 .maxlen = sizeof (size_t),
504 .proc_handler = &proc_doulongvec_minmax,
507 .ctl_name = KERN_SHMMNI,
508 .procname = "shmmni",
510 .maxlen = sizeof (int),
512 .proc_handler = &proc_dointvec,
515 .ctl_name = KERN_MSGMAX,
516 .procname = "msgmax",
518 .maxlen = sizeof (int),
520 .proc_handler = &proc_dointvec,
523 .ctl_name = KERN_MSGMNI,
524 .procname = "msgmni",
526 .maxlen = sizeof (int),
528 .proc_handler = &proc_dointvec,
531 .ctl_name = KERN_MSGMNB,
532 .procname = "msgmnb",
534 .maxlen = sizeof (int),
536 .proc_handler = &proc_dointvec,
539 .ctl_name = KERN_SEM,
542 .maxlen = 4*sizeof (int),
544 .proc_handler = &proc_dointvec,
547 #ifdef CONFIG_MAGIC_SYSRQ
549 .ctl_name = KERN_SYSRQ,
551 .data = &sysrq_enabled,
552 .maxlen = sizeof (int),
554 .proc_handler = &proc_dointvec,
558 .ctl_name = KERN_CADPID,
559 .procname = "cad_pid",
561 .maxlen = sizeof (int),
563 .proc_handler = &proc_dointvec,
566 .ctl_name = KERN_MAX_THREADS,
567 .procname = "threads-max",
568 .data = &max_threads,
569 .maxlen = sizeof(int),
571 .proc_handler = &proc_dointvec,
574 .ctl_name = KERN_RANDOM,
575 .procname = "random",
577 .child = random_table,
579 #ifdef CONFIG_UNIX98_PTYS
581 .ctl_name = KERN_PTY,
588 .ctl_name = KERN_OVERFLOWUID,
589 .procname = "overflowuid",
590 .data = &overflowuid,
591 .maxlen = sizeof(int),
593 .proc_handler = &proc_dointvec_minmax,
594 .strategy = &sysctl_intvec,
595 .extra1 = &minolduid,
596 .extra2 = &maxolduid,
599 .ctl_name = KERN_OVERFLOWGID,
600 .procname = "overflowgid",
601 .data = &overflowgid,
602 .maxlen = sizeof(int),
604 .proc_handler = &proc_dointvec_minmax,
605 .strategy = &sysctl_intvec,
606 .extra1 = &minolduid,
607 .extra2 = &maxolduid,
609 #ifdef CONFIG_ARCH_S390
610 #ifdef CONFIG_MATHEMU
612 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
613 .procname = "ieee_emulation_warnings",
614 .data = &sysctl_ieee_emulation_warnings,
615 .maxlen = sizeof(int),
617 .proc_handler = &proc_dointvec,
620 #ifdef CONFIG_NO_IDLE_HZ
622 .ctl_name = KERN_HZ_TIMER,
623 .procname = "hz_timer",
624 .data = &sysctl_hz_timer,
625 .maxlen = sizeof(int),
627 .proc_handler = &proc_dointvec,
631 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
632 .procname = "userprocess_debug",
633 .data = &sysctl_userprocess_debug,
634 .maxlen = sizeof(int),
636 .proc_handler = &proc_dointvec,
640 .ctl_name = KERN_PIDMAX,
641 .procname = "pid_max",
643 .maxlen = sizeof (int),
645 .proc_handler = &proc_dointvec,
648 .ctl_name = KERN_PANIC_ON_OOPS,
649 .procname = "panic_on_oops",
650 .data = &panic_on_oops,
651 .maxlen = sizeof(int),
653 .proc_handler = &proc_dointvec,
656 .ctl_name = KERN_PRINTK_RATELIMIT,
657 .procname = "printk_ratelimit",
658 .data = &printk_ratelimit_jiffies,
659 .maxlen = sizeof(int),
661 .proc_handler = &proc_dointvec_jiffies,
662 .strategy = &sysctl_jiffies,
665 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
666 .procname = "printk_ratelimit_burst",
667 .data = &printk_ratelimit_burst,
668 .maxlen = sizeof(int),
670 .proc_handler = &proc_dointvec,
673 .ctl_name = KERN_NGROUPS_MAX,
674 .procname = "ngroups_max",
675 .data = &ngroups_max,
676 .maxlen = sizeof (int),
678 .proc_handler = &proc_dointvec,
683 /* Constants for minimum and maximum testing in vm_table.
684 We use these as one-element integer vectors. */
686 static int one_hundred = 100;
689 static ctl_table vm_table[] = {
691 .ctl_name = VM_OVERCOMMIT_MEMORY,
692 .procname = "overcommit_memory",
693 .data = &sysctl_overcommit_memory,
694 .maxlen = sizeof(sysctl_overcommit_memory),
696 .proc_handler = &proc_dointvec,
699 .ctl_name = VM_OVERCOMMIT_RATIO,
700 .procname = "overcommit_ratio",
701 .data = &sysctl_overcommit_ratio,
702 .maxlen = sizeof(sysctl_overcommit_ratio),
704 .proc_handler = &proc_dointvec,
707 .ctl_name = VM_PAGE_CLUSTER,
708 .procname = "page-cluster",
709 .data = &page_cluster,
710 .maxlen = sizeof(int),
712 .proc_handler = &proc_dointvec,
715 .ctl_name = VM_DIRTY_BACKGROUND,
716 .procname = "dirty_background_ratio",
717 .data = &dirty_background_ratio,
718 .maxlen = sizeof(dirty_background_ratio),
720 .proc_handler = &proc_dointvec_minmax,
721 .strategy = &sysctl_intvec,
723 .extra2 = &one_hundred,
726 .ctl_name = VM_DIRTY_RATIO,
727 .procname = "dirty_ratio",
728 .data = &vm_dirty_ratio,
729 .maxlen = sizeof(vm_dirty_ratio),
731 .proc_handler = &proc_dointvec_minmax,
732 .strategy = &sysctl_intvec,
734 .extra2 = &one_hundred,
737 .ctl_name = VM_DIRTY_WB_CS,
738 .procname = "dirty_writeback_centisecs",
739 .data = &dirty_writeback_centisecs,
740 .maxlen = sizeof(dirty_writeback_centisecs),
742 .proc_handler = &dirty_writeback_centisecs_handler,
745 .ctl_name = VM_DIRTY_EXPIRE_CS,
746 .procname = "dirty_expire_centisecs",
747 .data = &dirty_expire_centisecs,
748 .maxlen = sizeof(dirty_expire_centisecs),
750 .proc_handler = &proc_dointvec,
753 .ctl_name = VM_NR_PDFLUSH_THREADS,
754 .procname = "nr_pdflush_threads",
755 .data = &nr_pdflush_threads,
756 .maxlen = sizeof nr_pdflush_threads,
757 .mode = 0444 /* read-only*/,
758 .proc_handler = &proc_dointvec,
761 .ctl_name = VM_SWAPPINESS,
762 .procname = "swappiness",
763 .data = &vm_swappiness,
764 .maxlen = sizeof(vm_swappiness),
766 .proc_handler = &proc_dointvec_minmax,
767 .strategy = &sysctl_intvec,
769 .extra2 = &one_hundred,
771 #ifdef CONFIG_HUGETLB_PAGE
773 .ctl_name = VM_HUGETLB_PAGES,
774 .procname = "nr_hugepages",
775 .data = &max_huge_pages,
776 .maxlen = sizeof(unsigned long),
778 .proc_handler = &hugetlb_sysctl_handler,
779 .extra1 = (void *)&hugetlb_zero,
780 .extra2 = (void *)&hugetlb_infinity,
784 .ctl_name = VM_LOWER_ZONE_PROTECTION,
785 .procname = "lower_zone_protection",
786 .data = &sysctl_lower_zone_protection,
787 .maxlen = sizeof(sysctl_lower_zone_protection),
789 .proc_handler = &lower_zone_protection_sysctl_handler,
790 .strategy = &sysctl_intvec,
794 .ctl_name = VM_MIN_FREE_KBYTES,
795 .procname = "min_free_kbytes",
796 .data = &min_free_kbytes,
797 .maxlen = sizeof(min_free_kbytes),
799 .proc_handler = &min_free_kbytes_sysctl_handler,
800 .strategy = &sysctl_intvec,
804 .ctl_name = VM_MAX_MAP_COUNT,
805 .procname = "max_map_count",
806 .data = &sysctl_max_map_count,
807 .maxlen = sizeof(sysctl_max_map_count),
809 .proc_handler = &proc_dointvec
812 .ctl_name = VM_LAPTOP_MODE,
813 .procname = "laptop_mode",
814 .data = &laptop_mode,
815 .maxlen = sizeof(laptop_mode),
817 .proc_handler = &proc_dointvec,
818 .strategy = &sysctl_intvec,
822 .ctl_name = VM_BLOCK_DUMP,
823 .procname = "block_dump",
825 .maxlen = sizeof(block_dump),
827 .proc_handler = &proc_dointvec,
828 .strategy = &sysctl_intvec,
832 .ctl_name = VM_VFS_CACHE_PRESSURE,
833 .procname = "vfs_cache_pressure",
834 .data = &sysctl_vfs_cache_pressure,
835 .maxlen = sizeof(sysctl_vfs_cache_pressure),
837 .proc_handler = &proc_dointvec,
838 .strategy = &sysctl_intvec,
844 static ctl_table proc_table[] = {
848 static ctl_table fs_table[] = {
850 .ctl_name = FS_NRINODE,
851 .procname = "inode-nr",
852 .data = &inodes_stat,
853 .maxlen = 2*sizeof(int),
855 .proc_handler = &proc_dointvec,
858 .ctl_name = FS_STATINODE,
859 .procname = "inode-state",
860 .data = &inodes_stat,
861 .maxlen = 7*sizeof(int),
863 .proc_handler = &proc_dointvec,
866 .ctl_name = FS_NRFILE,
867 .procname = "file-nr",
869 .maxlen = 3*sizeof(int),
871 .proc_handler = &proc_dointvec,
874 .ctl_name = FS_MAXFILE,
875 .procname = "file-max",
876 .data = &files_stat.max_files,
877 .maxlen = sizeof(int),
879 .proc_handler = &proc_dointvec,
882 .ctl_name = FS_DENTRY,
883 .procname = "dentry-state",
884 .data = &dentry_stat,
885 .maxlen = 6*sizeof(int),
887 .proc_handler = &proc_dointvec,
890 .ctl_name = FS_OVERFLOWUID,
891 .procname = "overflowuid",
892 .data = &fs_overflowuid,
893 .maxlen = sizeof(int),
895 .proc_handler = &proc_dointvec_minmax,
896 .strategy = &sysctl_intvec,
897 .extra1 = &minolduid,
898 .extra2 = &maxolduid,
901 .ctl_name = FS_OVERFLOWGID,
902 .procname = "overflowgid",
903 .data = &fs_overflowgid,
904 .maxlen = sizeof(int),
906 .proc_handler = &proc_dointvec_minmax,
907 .strategy = &sysctl_intvec,
908 .extra1 = &minolduid,
909 .extra2 = &maxolduid,
912 .ctl_name = FS_LEASES,
913 .procname = "leases-enable",
914 .data = &leases_enable,
915 .maxlen = sizeof(int),
917 .proc_handler = &proc_dointvec,
920 .ctl_name = FS_DIR_NOTIFY,
921 .procname = "dir-notify-enable",
922 .data = &dir_notify_enable,
923 .maxlen = sizeof(int),
925 .proc_handler = &proc_dointvec,
928 .ctl_name = FS_LEASE_TIME,
929 .procname = "lease-break-time",
930 .data = &lease_break_time,
931 .maxlen = sizeof(int),
933 .proc_handler = &proc_dointvec,
936 .ctl_name = FS_AIO_NR,
937 .procname = "aio-nr",
939 .maxlen = sizeof(aio_nr),
941 .proc_handler = &proc_dointvec,
944 .ctl_name = FS_AIO_MAX_NR,
945 .procname = "aio-max-nr",
947 .maxlen = sizeof(aio_max_nr),
949 .proc_handler = &proc_dointvec,
954 static ctl_table debug_table[] = {
958 static ctl_table dev_table[] = {
962 extern void init_irq_proc (void);
964 void __init sysctl_init(void)
966 #ifdef CONFIG_PROC_FS
967 register_proc_table(root_table, proc_sys_root);
972 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
973 void __user *newval, size_t newlen)
975 struct list_head *tmp;
977 if (nlen <= 0 || nlen >= CTL_MAXNAME)
981 if (!oldlenp || get_user(old_len, oldlenp))
984 tmp = &root_table_header.ctl_entry;
986 struct ctl_table_header *head =
987 list_entry(tmp, struct ctl_table_header, ctl_entry);
988 void *context = NULL;
989 int error = parse_table(name, nlen, oldval, oldlenp,
990 newval, newlen, head->ctl_table,
994 if (error != -ENOTDIR)
997 } while (tmp != &root_table_header.ctl_entry);
1001 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1003 struct __sysctl_args tmp;
1006 if (copy_from_user(&tmp, args, sizeof(tmp)))
1010 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1011 tmp.newval, tmp.newlen);
1017 * ctl_perm does NOT grant the superuser all rights automatically, because
1018 * some sysctl variables are readonly even to root.
1021 static int test_perm(int mode, int op)
1025 else if (in_egroup_p(0))
1027 if ((mode & op & 0007) == op)
1032 static inline int ctl_perm(ctl_table *table, int op)
1035 error = security_sysctl(table, op);
1038 return test_perm(table->mode, op);
1041 static int parse_table(int __user *name, int nlen,
1042 void __user *oldval, size_t __user *oldlenp,
1043 void __user *newval, size_t newlen,
1044 ctl_table *table, void **context)
1050 if (get_user(n, name))
1052 for ( ; table->ctl_name; table++) {
1053 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1056 if (ctl_perm(table, 001))
1058 if (table->strategy) {
1059 error = table->strategy(
1062 newval, newlen, context);
1068 table = table->child;
1071 error = do_sysctl_strategy(table, name, nlen,
1073 newval, newlen, context);
1080 /* Perform the actual read/write of a sysctl table entry. */
1081 int do_sysctl_strategy (ctl_table *table,
1082 int __user *name, int nlen,
1083 void __user *oldval, size_t __user *oldlenp,
1084 void __user *newval, size_t newlen, void **context)
1093 if (ctl_perm(table, op))
1096 if (table->strategy) {
1097 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1098 newval, newlen, context);
1105 /* If there is no strategy routine, or if the strategy returns
1106 * zero, proceed with automatic r/w */
1107 if (table->data && table->maxlen) {
1108 if (oldval && oldlenp) {
1109 if (get_user(len, oldlenp))
1112 if (len > table->maxlen)
1113 len = table->maxlen;
1114 if(copy_to_user(oldval, table->data, len))
1116 if(put_user(len, oldlenp))
1120 if (newval && newlen) {
1122 if (len > table->maxlen)
1123 len = table->maxlen;
1124 if(copy_from_user(table->data, newval, len))
1132 * register_sysctl_table - register a sysctl hierarchy
1133 * @table: the top-level table structure
1134 * @insert_at_head: whether the entry should be inserted in front or at the end
1136 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1137 * array. An entry with a ctl_name of 0 terminates the table.
1139 * The members of the &ctl_table structure are used as follows:
1141 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1142 * must be unique within that level of sysctl
1144 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1145 * enter a sysctl file
1147 * data - a pointer to data for use by proc_handler
1149 * maxlen - the maximum size in bytes of the data
1151 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1153 * child - a pointer to the child sysctl table if this entry is a directory, or
1156 * proc_handler - the text handler routine (described below)
1158 * strategy - the strategy routine (described below)
1160 * de - for internal use by the sysctl routines
1162 * extra1, extra2 - extra pointers usable by the proc handler routines
1164 * Leaf nodes in the sysctl tree will be represented by a single file
1165 * under /proc; non-leaf nodes will be represented by directories.
1167 * sysctl(2) can automatically manage read and write requests through
1168 * the sysctl table. The data and maxlen fields of the ctl_table
1169 * struct enable minimal validation of the values being written to be
1170 * performed, and the mode field allows minimal authentication.
1172 * More sophisticated management can be enabled by the provision of a
1173 * strategy routine with the table entry. This will be called before
1174 * any automatic read or write of the data is performed.
1176 * The strategy routine may return
1178 * < 0 - Error occurred (error is passed to user process)
1180 * 0 - OK - proceed with automatic read or write.
1182 * > 0 - OK - read or write has been done by the strategy routine, so
1183 * return immediately.
1185 * There must be a proc_handler routine for any terminal nodes
1186 * mirrored under /proc/sys (non-terminals are handled by a built-in
1187 * directory handler). Several default handlers are available to
1188 * cover common cases -
1190 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1191 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1192 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1194 * It is the handler's job to read the input buffer from user memory
1195 * and process it. The handler should return 0 on success.
1197 * This routine returns %NULL on a failure to register, and a pointer
1198 * to the table header on success.
1200 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1203 struct ctl_table_header *tmp;
1204 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1207 tmp->ctl_table = table;
1208 INIT_LIST_HEAD(&tmp->ctl_entry);
1210 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1212 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1213 #ifdef CONFIG_PROC_FS
1214 register_proc_table(table, proc_sys_root);
1220 * unregister_sysctl_table - unregister a sysctl table hierarchy
1221 * @header: the header returned from register_sysctl_table
1223 * Unregisters the sysctl table and all children. proc entries may not
1224 * actually be removed until they are no longer used by anyone.
1226 void unregister_sysctl_table(struct ctl_table_header * header)
1228 list_del(&header->ctl_entry);
1229 #ifdef CONFIG_PROC_FS
1230 unregister_proc_table(header->ctl_table, proc_sys_root);
1239 #ifdef CONFIG_PROC_FS
1241 /* Scan the sysctl entries in table and add them all into /proc */
1242 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1244 struct proc_dir_entry *de;
1248 for (; table->ctl_name; table++) {
1249 /* Can't do anything without a proc name. */
1250 if (!table->procname)
1252 /* Maybe we can't do anything with it... */
1253 if (!table->proc_handler && !table->child) {
1254 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1259 len = strlen(table->procname);
1263 if (table->proc_handler)
1267 for (de = root->subdir; de; de = de->next) {
1268 if (proc_match(len, table->procname, de))
1271 /* If the subdir exists already, de is non-NULL */
1275 de = create_proc_entry(table->procname, mode, root);
1278 de->data = (void *) table;
1279 if (table->proc_handler)
1280 de->proc_fops = &proc_sys_file_operations;
1283 if (de->mode & S_IFDIR)
1284 register_proc_table(table->child, de);
1289 * Unregister a /proc sysctl table and any subdirectories.
1291 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1293 struct proc_dir_entry *de;
1294 for (; table->ctl_name; table++) {
1295 if (!(de = table->de))
1297 if (de->mode & S_IFDIR) {
1298 if (!table->child) {
1299 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1302 unregister_proc_table(table->child, de);
1304 /* Don't unregister directories which still have entries.. */
1309 /* Don't unregister proc entries that are still being used.. */
1310 if (atomic_read(&de->count))
1314 remove_proc_entry(table->procname, root);
1318 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1319 size_t count, loff_t *ppos)
1322 struct proc_dir_entry *de;
1323 struct ctl_table *table;
1327 de = PDE(file->f_dentry->d_inode);
1328 if (!de || !de->data)
1330 table = (struct ctl_table *) de->data;
1331 if (!table || !table->proc_handler)
1333 op = (write ? 002 : 004);
1334 if (ctl_perm(table, op))
1340 * FIXME: we need to pass on ppos to the handler.
1343 error = (*table->proc_handler) (table, write, file, buf, &res);
1349 static int proc_opensys(struct inode *inode, struct file *file)
1351 if (file->f_mode & FMODE_WRITE) {
1353 * sysctl entries that are not writable,
1354 * are _NOT_ writable, capabilities or not.
1356 if (!(inode->i_mode & S_IWUSR))
1363 static ssize_t proc_readsys(struct file * file, char __user * buf,
1364 size_t count, loff_t *ppos)
1366 return do_rw_proc(0, file, buf, count, ppos);
1369 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1370 size_t count, loff_t *ppos)
1372 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1376 * proc_dostring - read a string sysctl
1377 * @table: the sysctl table
1378 * @write: %TRUE if this is a write to the sysctl file
1379 * @filp: the file structure
1380 * @buffer: the user buffer
1381 * @lenp: the size of the user buffer
1383 * Reads/writes a string from/to the user buffer. If the kernel
1384 * buffer provided is not large enough to hold the string, the
1385 * string is truncated. The copied string is %NULL-terminated.
1386 * If the string is being read by the user process, it is copied
1387 * and a newline '\n' is added. It is truncated if the buffer is
1390 * Returns 0 on success.
1392 int proc_dostring(ctl_table *table, int write, struct file *filp,
1393 void __user *buffer, size_t *lenp)
1399 if (!table->data || !table->maxlen || !*lenp ||
1400 (filp->f_pos && !write)) {
1408 while (len < *lenp) {
1409 if (get_user(c, p++))
1411 if (c == 0 || c == '\n')
1415 if (len >= table->maxlen)
1416 len = table->maxlen-1;
1417 if(copy_from_user(table->data, buffer, len))
1419 ((char *) table->data)[len] = 0;
1420 filp->f_pos += *lenp;
1422 len = strlen(table->data);
1423 if (len > table->maxlen)
1424 len = table->maxlen;
1428 if(copy_to_user(buffer, table->data, len))
1431 if(put_user('\n', ((char __user *) buffer) + len))
1442 * Special case of dostring for the UTS structure. This has locks
1443 * to observe. Should this be in kernel/sys.c ????
1446 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1447 void __user *buffer, size_t *lenp)
1452 down_read(&uts_sem);
1453 r=proc_dostring(table,0,filp,buffer,lenp);
1456 down_write(&uts_sem);
1457 r=proc_dostring(table,1,filp,buffer,lenp);
1463 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1465 int write, void *data)
1468 *valp = *negp ? -*lvalp : *lvalp;
1473 *lvalp = (unsigned long)-val;
1476 *lvalp = (unsigned long)val;
1482 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1483 void __user *buffer, size_t *lenp,
1484 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1485 int write, void *data),
1488 #define TMPBUFLEN 20
1489 int *i, vleft, first=1, neg, val;
1493 char buf[TMPBUFLEN], *p;
1494 char __user *s = buffer;
1496 if (!table->data || !table->maxlen || !*lenp ||
1497 (filp->f_pos && !write)) {
1502 i = (int *) table->data;
1503 vleft = table->maxlen / sizeof(*i);
1507 conv = do_proc_dointvec_conv;
1509 for (; left && vleft--; i++, first=0) {
1524 if (len > sizeof(buf) - 1)
1525 len = sizeof(buf) - 1;
1526 if (copy_from_user(buf, s, len))
1530 if (*p == '-' && left > 1) {
1534 if (*p < '0' || *p > '9')
1537 lval = simple_strtoul(p, &p, 0);
1540 if ((len < left) && *p && !isspace(*p))
1547 if (conv(&neg, &lval, i, 1, data))
1554 if (conv(&neg, &lval, i, 0, data))
1557 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1561 if(copy_to_user(s, buf, len))
1568 if (!write && !first && left) {
1569 if(put_user('\n', s))
1576 if (get_user(c, s++))
1586 filp->f_pos += *lenp;
1592 * proc_dointvec - read a vector of integers
1593 * @table: the sysctl table
1594 * @write: %TRUE if this is a write to the sysctl file
1595 * @filp: the file structure
1596 * @buffer: the user buffer
1597 * @lenp: the size of the user buffer
1599 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1600 * values from/to the user buffer, treated as an ASCII string.
1602 * Returns 0 on success.
1604 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1605 void __user *buffer, size_t *lenp)
1607 return do_proc_dointvec(table,write,filp,buffer,lenp,
1617 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1619 int write, void *data)
1621 int op = *(int *)data;
1623 int val = *negp ? -*lvalp : *lvalp;
1625 case OP_SET: *valp = val; break;
1626 case OP_AND: *valp &= val; break;
1627 case OP_OR: *valp |= val; break;
1628 case OP_MAX: if(*valp < val)
1631 case OP_MIN: if(*valp > val)
1639 *lvalp = (unsigned long)-val;
1642 *lvalp = (unsigned long)val;
1649 * init may raise the set.
1652 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1653 void __user *buffer, size_t *lenp)
1657 if (!capable(CAP_SYS_MODULE)) {
1661 op = (current->pid == 1) ? OP_SET : OP_AND;
1662 return do_proc_dointvec(table,write,filp,buffer,lenp,
1663 do_proc_dointvec_bset_conv,&op);
1666 struct do_proc_dointvec_minmax_conv_param {
1671 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1673 int write, void *data)
1675 struct do_proc_dointvec_minmax_conv_param *param = data;
1677 int val = *negp ? -*lvalp : *lvalp;
1678 if ((param->min && *param->min > val) ||
1679 (param->max && *param->max < val))
1686 *lvalp = (unsigned long)-val;
1689 *lvalp = (unsigned long)val;
1696 * proc_dointvec_minmax - read a vector of integers with min/max values
1697 * @table: the sysctl table
1698 * @write: %TRUE if this is a write to the sysctl file
1699 * @filp: the file structure
1700 * @buffer: the user buffer
1701 * @lenp: the size of the user buffer
1703 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1704 * values from/to the user buffer, treated as an ASCII string.
1706 * This routine will ensure the values are within the range specified by
1707 * table->extra1 (min) and table->extra2 (max).
1709 * Returns 0 on success.
1711 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1712 void __user *buffer, size_t *lenp)
1714 struct do_proc_dointvec_minmax_conv_param param = {
1715 .min = (int *) table->extra1,
1716 .max = (int *) table->extra2,
1718 return do_proc_dointvec(table, write, filp, buffer, lenp,
1719 do_proc_dointvec_minmax_conv, ¶m);
1722 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1724 void __user *buffer, size_t *lenp,
1725 unsigned long convmul,
1726 unsigned long convdiv)
1728 #define TMPBUFLEN 20
1729 unsigned long *i, *min, *max, val;
1730 int vleft, first=1, neg;
1732 char buf[TMPBUFLEN], *p;
1733 char __user *s = buffer;
1735 if (!table->data || !table->maxlen || !*lenp ||
1736 (filp->f_pos && !write)) {
1741 i = (unsigned long *) table->data;
1742 min = (unsigned long *) table->extra1;
1743 max = (unsigned long *) table->extra2;
1744 vleft = table->maxlen / sizeof(unsigned long);
1747 for (; left && vleft--; i++, min++, max++, first=0) {
1762 if (len > TMPBUFLEN-1)
1764 if (copy_from_user(buf, s, len))
1768 if (*p == '-' && left > 1) {
1772 if (*p < '0' || *p > '9')
1774 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1776 if ((len < left) && *p && !isspace(*p))
1785 if ((min && val < *min) || (max && val > *max))
1792 sprintf(p, "%lu", convdiv * (*i) / convmul);
1796 if(copy_to_user(s, buf, len))
1803 if (!write && !first && left) {
1804 if(put_user('\n', s))
1811 if (get_user(c, s++))
1821 filp->f_pos += *lenp;
1827 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1828 * @table: the sysctl table
1829 * @write: %TRUE if this is a write to the sysctl file
1830 * @filp: the file structure
1831 * @buffer: the user buffer
1832 * @lenp: the size of the user buffer
1834 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1835 * values from/to the user buffer, treated as an ASCII string.
1837 * This routine will ensure the values are within the range specified by
1838 * table->extra1 (min) and table->extra2 (max).
1840 * Returns 0 on success.
1842 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1843 void __user *buffer, size_t *lenp)
1845 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1849 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1850 * @table: the sysctl table
1851 * @write: %TRUE if this is a write to the sysctl file
1852 * @filp: the file structure
1853 * @buffer: the user buffer
1854 * @lenp: the size of the user buffer
1856 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1857 * values from/to the user buffer, treated as an ASCII string. The values
1858 * are treated as milliseconds, and converted to jiffies when they are stored.
1860 * This routine will ensure the values are within the range specified by
1861 * table->extra1 (min) and table->extra2 (max).
1863 * Returns 0 on success.
1865 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1867 void __user *buffer, size_t *lenp)
1869 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1874 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1876 int write, void *data)
1879 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1885 lval = (unsigned long)-val;
1888 lval = (unsigned long)val;
1895 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1897 int write, void *data)
1900 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1906 lval = (unsigned long)-val;
1909 lval = (unsigned long)val;
1911 *lvalp = jiffies_to_clock_t(lval);
1917 * proc_dointvec_jiffies - read a vector of integers as seconds
1918 * @table: the sysctl table
1919 * @write: %TRUE if this is a write to the sysctl file
1920 * @filp: the file structure
1921 * @buffer: the user buffer
1922 * @lenp: the size of the user buffer
1924 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1925 * values from/to the user buffer, treated as an ASCII string.
1926 * The values read are assumed to be in seconds, and are converted into
1929 * Returns 0 on success.
1931 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1932 void __user *buffer, size_t *lenp)
1934 return do_proc_dointvec(table,write,filp,buffer,lenp,
1935 do_proc_dointvec_jiffies_conv,NULL);
1939 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1940 * @table: the sysctl table
1941 * @write: %TRUE if this is a write to the sysctl file
1942 * @filp: the file structure
1943 * @buffer: the user buffer
1944 * @lenp: the size of the user buffer
1946 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1947 * values from/to the user buffer, treated as an ASCII string.
1948 * The values read are assumed to be in 1/USER_HZ seconds, and
1949 * are converted into jiffies.
1951 * Returns 0 on success.
1953 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1954 void __user *buffer, size_t *lenp)
1956 return do_proc_dointvec(table,write,filp,buffer,lenp,
1957 do_proc_dointvec_userhz_jiffies_conv,NULL);
1960 #else /* CONFIG_PROC_FS */
1962 int proc_dostring(ctl_table *table, int write, struct file *filp,
1963 void __user *buffer, size_t *lenp)
1968 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1969 void __user *buffer, size_t *lenp)
1974 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1975 void __user *buffer, size_t *lenp)
1980 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1981 void __user *buffer, size_t *lenp)
1986 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1987 void __user *buffer, size_t *lenp)
1992 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1993 void __user *buffer, size_t *lenp)
1998 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1999 void __user *buffer, size_t *lenp)
2004 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2005 void __user *buffer, size_t *lenp)
2010 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2012 void __user *buffer, size_t *lenp)
2018 #endif /* CONFIG_PROC_FS */
2022 * General sysctl support routines
2025 /* The generic string strategy routine: */
2026 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2027 void __user *oldval, size_t __user *oldlenp,
2028 void __user *newval, size_t newlen, void **context)
2032 if (!table->data || !table->maxlen)
2035 if (oldval && oldlenp) {
2036 if (get_user(len, oldlenp))
2039 l = strlen(table->data);
2040 if (len > l) len = l;
2041 if (len >= table->maxlen)
2042 len = table->maxlen;
2043 if(copy_to_user(oldval, table->data, len))
2045 if(put_user(0, ((char __user *) oldval) + len))
2047 if(put_user(len, oldlenp))
2051 if (newval && newlen) {
2053 if (len > table->maxlen)
2054 len = table->maxlen;
2055 if(copy_from_user(table->data, newval, len))
2057 if (len == table->maxlen)
2059 ((char *) table->data)[len] = 0;
2065 * This function makes sure that all of the integers in the vector
2066 * are between the minimum and maximum values given in the arrays
2067 * table->extra1 and table->extra2, respectively.
2069 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2070 void __user *oldval, size_t __user *oldlenp,
2071 void __user *newval, size_t newlen, void **context)
2074 if (newval && newlen) {
2075 int __user *vec = (int __user *) newval;
2076 int *min = (int *) table->extra1;
2077 int *max = (int *) table->extra2;
2081 if (newlen % sizeof(int) != 0)
2084 if (!table->extra1 && !table->extra2)
2087 if (newlen > table->maxlen)
2088 newlen = table->maxlen;
2089 length = newlen / sizeof(int);
2091 for (i = 0; i < length; i++) {
2093 if (get_user(value, vec + i))
2095 if (min && value < min[i])
2097 if (max && value > max[i])
2104 /* Strategy function to convert jiffies to seconds */
2105 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2106 void __user *oldval, size_t __user *oldlenp,
2107 void __user *newval, size_t newlen, void **context)
2112 if (get_user(olen, oldlenp))
2114 if (olen!=sizeof(int))
2117 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2118 (oldlenp && put_user(sizeof(int),oldlenp)))
2121 if (newval && newlen) {
2123 if (newlen != sizeof(int))
2125 if (get_user(new, (int __user *)newval))
2127 *(int *)(table->data) = new*HZ;
2133 #else /* CONFIG_SYSCTL */
2136 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2141 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2142 void __user *oldval, size_t __user *oldlenp,
2143 void __user *newval, size_t newlen, void **context)
2148 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2149 void __user *oldval, size_t __user *oldlenp,
2150 void __user *newval, size_t newlen, void **context)
2155 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2156 void __user *oldval, size_t __user *oldlenp,
2157 void __user *newval, size_t newlen, void **context)
2162 int proc_dostring(ctl_table *table, int write, struct file *filp,
2163 void __user *buffer, size_t *lenp)
2168 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2169 void __user *buffer, size_t *lenp)
2174 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2175 void __user *buffer, size_t *lenp)
2180 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2181 void __user *buffer, size_t *lenp)
2186 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2187 void __user *buffer, size_t *lenp)
2192 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2193 void __user *buffer, size_t *lenp)
2198 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2199 void __user *buffer, size_t *lenp)
2204 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2206 void __user *buffer, size_t *lenp)
2211 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2217 void unregister_sysctl_table(struct ctl_table_header * table)
2221 #endif /* CONFIG_SYSCTL */
2224 * No sense putting this after each symbol definition, twice,
2225 * exception granted :-)
2227 EXPORT_SYMBOL(proc_dointvec);
2228 EXPORT_SYMBOL(proc_dointvec_jiffies);
2229 EXPORT_SYMBOL(proc_dointvec_minmax);
2230 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2231 EXPORT_SYMBOL(proc_dostring);
2232 EXPORT_SYMBOL(proc_doulongvec_minmax);
2233 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2234 EXPORT_SYMBOL(register_sysctl_table);
2235 EXPORT_SYMBOL(sysctl_intvec);
2236 EXPORT_SYMBOL(sysctl_jiffies);
2237 EXPORT_SYMBOL(sysctl_string);
2238 EXPORT_SYMBOL(unregister_sysctl_table);