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 int sysrq_enabled;
57 extern int core_uses_pid;
58 extern char core_pattern[];
61 extern int sysctl_lower_zone_protection;
62 extern int min_free_kbytes;
63 extern int printk_ratelimit_jiffies;
64 extern int printk_ratelimit_burst;
66 extern unsigned int vdso_enabled;
69 int exec_shield_randomize = 1;
71 static int __init setup_exec_shield(char *str)
73 get_option (&str, &exec_shield);
78 __setup("exec-shield=", setup_exec_shield);
80 static int __init setup_exec_shield_randomize(char *str)
82 get_option (&str, &exec_shield_randomize);
87 __setup("exec-shield-randomize=", setup_exec_shield_randomize);
89 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
90 static int maxolduid = 65535;
93 static int ngroups_max = NGROUPS_MAX;
96 extern char modprobe_path[];
99 extern char hotplug_path[];
101 extern char vshelper_path[];
102 #ifdef CONFIG_CHR_DEV_SG
103 extern int sg_big_buff;
105 #ifdef CONFIG_SYSVIPC
106 extern size_t shm_ctlmax;
107 extern size_t shm_ctlall;
108 extern int shm_ctlmni;
109 extern int msg_ctlmax;
110 extern int msg_ctlmnb;
111 extern int msg_ctlmni;
112 extern int sem_ctls[];
116 extern char reboot_command [];
117 extern int stop_a_enabled;
118 extern int scons_pwroff;
122 extern int pwrsw_enabled;
123 extern int unaligned_enabled;
126 #ifdef CONFIG_ARCH_S390
127 #ifdef CONFIG_MATHEMU
128 extern int sysctl_ieee_emulation_warnings;
130 extern int sysctl_userprocess_debug;
133 extern int sysctl_hz_timer;
135 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
136 extern unsigned long powersave_nap;
137 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
138 void *buffer, size_t *lenp);
141 #ifdef CONFIG_BSD_PROCESS_ACCT
142 extern int acct_parm[];
145 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
146 ctl_table *, void **);
147 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
148 void __user *buffer, size_t *lenp);
150 static ctl_table root_table[];
151 static struct ctl_table_header root_table_header =
152 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
154 static ctl_table kern_table[];
155 static ctl_table vm_table[];
157 extern ctl_table net_table[];
159 static ctl_table proc_table[];
160 static ctl_table fs_table[];
161 static ctl_table debug_table[];
162 static ctl_table dev_table[];
163 extern ctl_table random_table[];
164 #ifdef CONFIG_UNIX98_PTYS
165 extern ctl_table pty_table[];
168 /* /proc declarations: */
170 #ifdef CONFIG_PROC_FS
172 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
173 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
174 static int proc_opensys(struct inode *, struct file *);
176 struct file_operations proc_sys_file_operations = {
177 .open = proc_opensys,
178 .read = proc_readsys,
179 .write = proc_writesys,
182 extern struct proc_dir_entry *proc_sys_root;
184 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
185 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
188 /* The default sysctl tables: */
190 static ctl_table root_table[] = {
192 .ctl_name = CTL_KERN,
193 .procname = "kernel",
212 .ctl_name = CTL_PROC,
224 .ctl_name = CTL_DEBUG,
227 .child = debug_table,
238 static ctl_table kern_table[] = {
240 .ctl_name = KERN_OSTYPE,
241 .procname = "ostype",
242 .data = system_utsname.sysname,
243 .maxlen = sizeof(system_utsname.sysname),
245 .proc_handler = &proc_doutsstring,
246 .strategy = &sysctl_string,
249 .ctl_name = KERN_OSRELEASE,
250 .procname = "osrelease",
251 .data = system_utsname.release,
252 .maxlen = sizeof(system_utsname.release),
254 .proc_handler = &proc_doutsstring,
255 .strategy = &sysctl_string,
258 .ctl_name = KERN_VERSION,
259 .procname = "version",
260 .data = system_utsname.version,
261 .maxlen = sizeof(system_utsname.version),
263 .proc_handler = &proc_doutsstring,
264 .strategy = &sysctl_string,
267 .ctl_name = KERN_NODENAME,
268 .procname = "hostname",
269 .data = system_utsname.nodename,
270 .maxlen = sizeof(system_utsname.nodename),
272 .proc_handler = &proc_doutsstring,
273 .strategy = &sysctl_string,
276 .ctl_name = KERN_DOMAINNAME,
277 .procname = "domainname",
278 .data = system_utsname.domainname,
279 .maxlen = sizeof(system_utsname.domainname),
281 .proc_handler = &proc_doutsstring,
282 .strategy = &sysctl_string,
285 .ctl_name = KERN_PANIC,
287 .data = &panic_timeout,
288 .maxlen = sizeof(int),
290 .proc_handler = &proc_dointvec,
293 .ctl_name = KERN_PANIC,
294 .procname = "exec-shield",
295 .data = &exec_shield,
296 .maxlen = sizeof(int),
298 .proc_handler = &proc_dointvec,
301 .ctl_name = KERN_PANIC,
302 .procname = "exec-shield-randomize",
303 .data = &exec_shield_randomize,
304 .maxlen = sizeof(int),
306 .proc_handler = &proc_dointvec,
309 .ctl_name = KERN_PANIC,
310 .procname = "print-fatal-signals",
311 .data = &print_fatal_signals,
312 .maxlen = sizeof(int),
314 .proc_handler = &proc_dointvec,
318 .ctl_name = KERN_PANIC,
320 .data = &vdso_enabled,
321 .maxlen = sizeof(int),
323 .proc_handler = &proc_dointvec,
327 .ctl_name = KERN_CORE_USES_PID,
328 .procname = "core_uses_pid",
329 .data = &core_uses_pid,
330 .maxlen = sizeof(int),
332 .proc_handler = &proc_dointvec,
335 .ctl_name = KERN_CORE_PATTERN,
336 .procname = "core_pattern",
337 .data = core_pattern,
340 .proc_handler = &proc_dostring,
341 .strategy = &sysctl_string,
344 .ctl_name = KERN_TAINTED,
345 .procname = "tainted",
347 .maxlen = sizeof(int),
349 .proc_handler = &proc_dointvec,
352 .ctl_name = KERN_CAP_BSET,
353 .procname = "cap-bound",
355 .maxlen = sizeof(kernel_cap_t),
357 .proc_handler = &proc_dointvec_bset,
359 #ifdef CONFIG_BLK_DEV_INITRD
361 .ctl_name = KERN_REALROOTDEV,
362 .procname = "real-root-dev",
363 .data = &real_root_dev,
364 .maxlen = sizeof(int),
366 .proc_handler = &proc_dointvec,
371 .ctl_name = KERN_SPARC_REBOOT,
372 .procname = "reboot-cmd",
373 .data = reboot_command,
376 .proc_handler = &proc_dostring,
377 .strategy = &sysctl_string,
380 .ctl_name = KERN_SPARC_STOP_A,
381 .procname = "stop-a",
382 .data = &stop_a_enabled,
383 .maxlen = sizeof (int),
385 .proc_handler = &proc_dointvec,
388 .ctl_name = KERN_SPARC_SCONS_PWROFF,
389 .procname = "scons-poweroff",
390 .data = &scons_pwroff,
391 .maxlen = sizeof (int),
393 .proc_handler = &proc_dointvec,
398 .ctl_name = KERN_HPPA_PWRSW,
399 .procname = "soft-power",
400 .data = &pwrsw_enabled,
401 .maxlen = sizeof (int),
403 .proc_handler = &proc_dointvec,
406 .ctl_name = KERN_HPPA_UNALIGNED,
407 .procname = "unaligned-trap",
408 .data = &unaligned_enabled,
409 .maxlen = sizeof (int),
411 .proc_handler = &proc_dointvec,
414 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
416 .ctl_name = KERN_PPC_POWERSAVE_NAP,
417 .procname = "powersave-nap",
418 .data = &powersave_nap,
419 .maxlen = sizeof(int),
421 .proc_handler = &proc_dointvec,
424 .ctl_name = KERN_PPC_L2CR,
427 .proc_handler = &proc_dol2crvec,
431 .ctl_name = KERN_CTLALTDEL,
432 .procname = "ctrl-alt-del",
434 .maxlen = sizeof(int),
436 .proc_handler = &proc_dointvec,
439 .ctl_name = KERN_PRINTK,
440 .procname = "printk",
441 .data = &console_loglevel,
442 .maxlen = 4*sizeof(int),
444 .proc_handler = &proc_dointvec,
448 .ctl_name = KERN_MODPROBE,
449 .procname = "modprobe",
450 .data = &modprobe_path,
451 .maxlen = KMOD_PATH_LEN,
453 .proc_handler = &proc_dostring,
454 .strategy = &sysctl_string,
457 #ifdef CONFIG_HOTPLUG
459 .ctl_name = KERN_HOTPLUG,
460 .procname = "hotplug",
461 .data = &hotplug_path,
462 .maxlen = KMOD_PATH_LEN,
464 .proc_handler = &proc_dostring,
465 .strategy = &sysctl_string,
469 .ctl_name = KERN_VSHELPER,
470 .procname = "vshelper",
471 .data = &vshelper_path,
474 .proc_handler = &proc_dostring,
475 .strategy = &sysctl_string,
477 #ifdef CONFIG_CHR_DEV_SG
479 .ctl_name = KERN_SG_BIG_BUFF,
480 .procname = "sg-big-buff",
481 .data = &sg_big_buff,
482 .maxlen = sizeof (int),
484 .proc_handler = &proc_dointvec,
487 #ifdef CONFIG_BSD_PROCESS_ACCT
489 .ctl_name = KERN_ACCT,
492 .maxlen = 3*sizeof(int),
494 .proc_handler = &proc_dointvec,
497 #ifdef CONFIG_SYSVIPC
499 .ctl_name = KERN_SHMMAX,
500 .procname = "shmmax",
502 .maxlen = sizeof (size_t),
504 .proc_handler = &proc_doulongvec_minmax,
507 .ctl_name = KERN_SHMALL,
508 .procname = "shmall",
510 .maxlen = sizeof (size_t),
512 .proc_handler = &proc_doulongvec_minmax,
515 .ctl_name = KERN_SHMMNI,
516 .procname = "shmmni",
518 .maxlen = sizeof (int),
520 .proc_handler = &proc_dointvec,
523 .ctl_name = KERN_MSGMAX,
524 .procname = "msgmax",
526 .maxlen = sizeof (int),
528 .proc_handler = &proc_dointvec,
531 .ctl_name = KERN_MSGMNI,
532 .procname = "msgmni",
534 .maxlen = sizeof (int),
536 .proc_handler = &proc_dointvec,
539 .ctl_name = KERN_MSGMNB,
540 .procname = "msgmnb",
542 .maxlen = sizeof (int),
544 .proc_handler = &proc_dointvec,
547 .ctl_name = KERN_SEM,
550 .maxlen = 4*sizeof (int),
552 .proc_handler = &proc_dointvec,
555 #ifdef CONFIG_MAGIC_SYSRQ
557 .ctl_name = KERN_SYSRQ,
559 .data = &sysrq_enabled,
560 .maxlen = sizeof (int),
562 .proc_handler = &proc_dointvec,
566 .ctl_name = KERN_CADPID,
567 .procname = "cad_pid",
569 .maxlen = sizeof (int),
571 .proc_handler = &proc_dointvec,
574 .ctl_name = KERN_MAX_THREADS,
575 .procname = "threads-max",
576 .data = &max_threads,
577 .maxlen = sizeof(int),
579 .proc_handler = &proc_dointvec,
582 .ctl_name = KERN_RANDOM,
583 .procname = "random",
585 .child = random_table,
587 #ifdef CONFIG_UNIX98_PTYS
589 .ctl_name = KERN_PTY,
596 .ctl_name = KERN_OVERFLOWUID,
597 .procname = "overflowuid",
598 .data = &overflowuid,
599 .maxlen = sizeof(int),
601 .proc_handler = &proc_dointvec_minmax,
602 .strategy = &sysctl_intvec,
603 .extra1 = &minolduid,
604 .extra2 = &maxolduid,
607 .ctl_name = KERN_OVERFLOWGID,
608 .procname = "overflowgid",
609 .data = &overflowgid,
610 .maxlen = sizeof(int),
612 .proc_handler = &proc_dointvec_minmax,
613 .strategy = &sysctl_intvec,
614 .extra1 = &minolduid,
615 .extra2 = &maxolduid,
617 #ifdef CONFIG_ARCH_S390
618 #ifdef CONFIG_MATHEMU
620 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
621 .procname = "ieee_emulation_warnings",
622 .data = &sysctl_ieee_emulation_warnings,
623 .maxlen = sizeof(int),
625 .proc_handler = &proc_dointvec,
628 #ifdef CONFIG_NO_IDLE_HZ
630 .ctl_name = KERN_HZ_TIMER,
631 .procname = "hz_timer",
632 .data = &sysctl_hz_timer,
633 .maxlen = sizeof(int),
635 .proc_handler = &proc_dointvec,
639 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
640 .procname = "userprocess_debug",
641 .data = &sysctl_userprocess_debug,
642 .maxlen = sizeof(int),
644 .proc_handler = &proc_dointvec,
648 .ctl_name = KERN_PIDMAX,
649 .procname = "pid_max",
651 .maxlen = sizeof (int),
653 .proc_handler = &proc_dointvec,
656 .ctl_name = KERN_PANIC_ON_OOPS,
657 .procname = "panic_on_oops",
658 .data = &panic_on_oops,
659 .maxlen = sizeof(int),
661 .proc_handler = &proc_dointvec,
664 .ctl_name = KERN_PRINTK_RATELIMIT,
665 .procname = "printk_ratelimit",
666 .data = &printk_ratelimit_jiffies,
667 .maxlen = sizeof(int),
669 .proc_handler = &proc_dointvec_jiffies,
670 .strategy = &sysctl_jiffies,
673 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
674 .procname = "printk_ratelimit_burst",
675 .data = &printk_ratelimit_burst,
676 .maxlen = sizeof(int),
678 .proc_handler = &proc_dointvec,
681 .ctl_name = KERN_NGROUPS_MAX,
682 .procname = "ngroups_max",
683 .data = &ngroups_max,
684 .maxlen = sizeof (int),
686 .proc_handler = &proc_dointvec,
691 /* Constants for minimum and maximum testing in vm_table.
692 We use these as one-element integer vectors. */
694 static int one_hundred = 100;
697 static ctl_table vm_table[] = {
699 .ctl_name = VM_OVERCOMMIT_MEMORY,
700 .procname = "overcommit_memory",
701 .data = &sysctl_overcommit_memory,
702 .maxlen = sizeof(sysctl_overcommit_memory),
704 .proc_handler = &proc_dointvec,
707 .ctl_name = VM_OVERCOMMIT_RATIO,
708 .procname = "overcommit_ratio",
709 .data = &sysctl_overcommit_ratio,
710 .maxlen = sizeof(sysctl_overcommit_ratio),
712 .proc_handler = &proc_dointvec,
715 .ctl_name = VM_PAGE_CLUSTER,
716 .procname = "page-cluster",
717 .data = &page_cluster,
718 .maxlen = sizeof(int),
720 .proc_handler = &proc_dointvec,
723 .ctl_name = VM_DIRTY_BACKGROUND,
724 .procname = "dirty_background_ratio",
725 .data = &dirty_background_ratio,
726 .maxlen = sizeof(dirty_background_ratio),
728 .proc_handler = &proc_dointvec_minmax,
729 .strategy = &sysctl_intvec,
731 .extra2 = &one_hundred,
734 .ctl_name = VM_DIRTY_RATIO,
735 .procname = "dirty_ratio",
736 .data = &vm_dirty_ratio,
737 .maxlen = sizeof(vm_dirty_ratio),
739 .proc_handler = &proc_dointvec_minmax,
740 .strategy = &sysctl_intvec,
742 .extra2 = &one_hundred,
745 .ctl_name = VM_DIRTY_WB_CS,
746 .procname = "dirty_writeback_centisecs",
747 .data = &dirty_writeback_centisecs,
748 .maxlen = sizeof(dirty_writeback_centisecs),
750 .proc_handler = &dirty_writeback_centisecs_handler,
753 .ctl_name = VM_DIRTY_EXPIRE_CS,
754 .procname = "dirty_expire_centisecs",
755 .data = &dirty_expire_centisecs,
756 .maxlen = sizeof(dirty_expire_centisecs),
758 .proc_handler = &proc_dointvec,
761 .ctl_name = VM_NR_PDFLUSH_THREADS,
762 .procname = "nr_pdflush_threads",
763 .data = &nr_pdflush_threads,
764 .maxlen = sizeof nr_pdflush_threads,
765 .mode = 0444 /* read-only*/,
766 .proc_handler = &proc_dointvec,
769 .ctl_name = VM_SWAPPINESS,
770 .procname = "swappiness",
771 .data = &vm_swappiness,
772 .maxlen = sizeof(vm_swappiness),
774 .proc_handler = &proc_dointvec_minmax,
775 .strategy = &sysctl_intvec,
777 .extra2 = &one_hundred,
779 #ifdef CONFIG_HUGETLB_PAGE
781 .ctl_name = VM_HUGETLB_PAGES,
782 .procname = "nr_hugepages",
783 .data = &max_huge_pages,
784 .maxlen = sizeof(unsigned long),
786 .proc_handler = &hugetlb_sysctl_handler,
787 .extra1 = (void *)&hugetlb_zero,
788 .extra2 = (void *)&hugetlb_infinity,
792 .ctl_name = VM_LOWER_ZONE_PROTECTION,
793 .procname = "lower_zone_protection",
794 .data = &sysctl_lower_zone_protection,
795 .maxlen = sizeof(sysctl_lower_zone_protection),
797 .proc_handler = &lower_zone_protection_sysctl_handler,
798 .strategy = &sysctl_intvec,
802 .ctl_name = VM_MIN_FREE_KBYTES,
803 .procname = "min_free_kbytes",
804 .data = &min_free_kbytes,
805 .maxlen = sizeof(min_free_kbytes),
807 .proc_handler = &min_free_kbytes_sysctl_handler,
808 .strategy = &sysctl_intvec,
812 .ctl_name = VM_MAX_MAP_COUNT,
813 .procname = "max_map_count",
814 .data = &sysctl_max_map_count,
815 .maxlen = sizeof(sysctl_max_map_count),
817 .proc_handler = &proc_dointvec
820 .ctl_name = VM_LAPTOP_MODE,
821 .procname = "laptop_mode",
822 .data = &laptop_mode,
823 .maxlen = sizeof(laptop_mode),
825 .proc_handler = &proc_dointvec,
826 .strategy = &sysctl_intvec,
830 .ctl_name = VM_BLOCK_DUMP,
831 .procname = "block_dump",
833 .maxlen = sizeof(block_dump),
835 .proc_handler = &proc_dointvec,
836 .strategy = &sysctl_intvec,
842 static ctl_table proc_table[] = {
846 static ctl_table fs_table[] = {
848 .ctl_name = FS_NRINODE,
849 .procname = "inode-nr",
850 .data = &inodes_stat,
851 .maxlen = 2*sizeof(int),
853 .proc_handler = &proc_dointvec,
856 .ctl_name = FS_STATINODE,
857 .procname = "inode-state",
858 .data = &inodes_stat,
859 .maxlen = 7*sizeof(int),
861 .proc_handler = &proc_dointvec,
864 .ctl_name = FS_NRFILE,
865 .procname = "file-nr",
867 .maxlen = 3*sizeof(int),
869 .proc_handler = &proc_dointvec,
872 .ctl_name = FS_MAXFILE,
873 .procname = "file-max",
874 .data = &files_stat.max_files,
875 .maxlen = sizeof(int),
877 .proc_handler = &proc_dointvec,
880 .ctl_name = FS_DENTRY,
881 .procname = "dentry-state",
882 .data = &dentry_stat,
883 .maxlen = 6*sizeof(int),
885 .proc_handler = &proc_dointvec,
888 .ctl_name = FS_OVERFLOWUID,
889 .procname = "overflowuid",
890 .data = &fs_overflowuid,
891 .maxlen = sizeof(int),
893 .proc_handler = &proc_dointvec_minmax,
894 .strategy = &sysctl_intvec,
895 .extra1 = &minolduid,
896 .extra2 = &maxolduid,
899 .ctl_name = FS_OVERFLOWGID,
900 .procname = "overflowgid",
901 .data = &fs_overflowgid,
902 .maxlen = sizeof(int),
904 .proc_handler = &proc_dointvec_minmax,
905 .strategy = &sysctl_intvec,
906 .extra1 = &minolduid,
907 .extra2 = &maxolduid,
910 .ctl_name = FS_LEASES,
911 .procname = "leases-enable",
912 .data = &leases_enable,
913 .maxlen = sizeof(int),
915 .proc_handler = &proc_dointvec,
918 .ctl_name = FS_DIR_NOTIFY,
919 .procname = "dir-notify-enable",
920 .data = &dir_notify_enable,
921 .maxlen = sizeof(int),
923 .proc_handler = &proc_dointvec,
926 .ctl_name = FS_LEASE_TIME,
927 .procname = "lease-break-time",
928 .data = &lease_break_time,
929 .maxlen = sizeof(int),
931 .proc_handler = &proc_dointvec,
934 .ctl_name = FS_AIO_NR,
935 .procname = "aio-nr",
937 .maxlen = sizeof(aio_nr),
939 .proc_handler = &proc_dointvec,
942 .ctl_name = FS_AIO_MAX_NR,
943 .procname = "aio-max-nr",
945 .maxlen = sizeof(aio_max_nr),
947 .proc_handler = &proc_dointvec,
952 static ctl_table debug_table[] = {
956 static ctl_table dev_table[] = {
960 extern void init_irq_proc (void);
962 void __init sysctl_init(void)
964 #ifdef CONFIG_PROC_FS
965 register_proc_table(root_table, proc_sys_root);
970 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
971 void __user *newval, size_t newlen)
973 struct list_head *tmp;
975 if (nlen <= 0 || nlen >= CTL_MAXNAME)
979 if (!oldlenp || get_user(old_len, oldlenp))
982 tmp = &root_table_header.ctl_entry;
984 struct ctl_table_header *head =
985 list_entry(tmp, struct ctl_table_header, ctl_entry);
986 void *context = NULL;
987 int error = parse_table(name, nlen, oldval, oldlenp,
988 newval, newlen, head->ctl_table,
992 if (error != -ENOTDIR)
995 } while (tmp != &root_table_header.ctl_entry);
999 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1001 struct __sysctl_args tmp;
1004 if (copy_from_user(&tmp, args, sizeof(tmp)))
1008 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1009 tmp.newval, tmp.newlen);
1015 * ctl_perm does NOT grant the superuser all rights automatically, because
1016 * some sysctl variables are readonly even to root.
1019 static int test_perm(int mode, int op)
1023 else if (in_egroup_p(0))
1025 if ((mode & op & 0007) == op)
1030 static inline int ctl_perm(ctl_table *table, int op)
1033 error = security_sysctl(table, op);
1036 return test_perm(table->mode, op);
1039 static int parse_table(int __user *name, int nlen,
1040 void __user *oldval, size_t __user *oldlenp,
1041 void __user *newval, size_t newlen,
1042 ctl_table *table, void **context)
1048 if (get_user(n, name))
1050 for ( ; table->ctl_name; table++) {
1051 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1054 if (ctl_perm(table, 001))
1056 if (table->strategy) {
1057 error = table->strategy(
1060 newval, newlen, context);
1066 table = table->child;
1069 error = do_sysctl_strategy(table, name, nlen,
1071 newval, newlen, context);
1078 /* Perform the actual read/write of a sysctl table entry. */
1079 int do_sysctl_strategy (ctl_table *table,
1080 int __user *name, int nlen,
1081 void __user *oldval, size_t __user *oldlenp,
1082 void __user *newval, size_t newlen, void **context)
1091 if (ctl_perm(table, op))
1094 if (table->strategy) {
1095 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1096 newval, newlen, context);
1103 /* If there is no strategy routine, or if the strategy returns
1104 * zero, proceed with automatic r/w */
1105 if (table->data && table->maxlen) {
1106 if (oldval && oldlenp) {
1107 if (get_user(len, oldlenp))
1110 if (len > table->maxlen)
1111 len = table->maxlen;
1112 if(copy_to_user(oldval, table->data, len))
1114 if(put_user(len, oldlenp))
1118 if (newval && newlen) {
1120 if (len > table->maxlen)
1121 len = table->maxlen;
1122 if(copy_from_user(table->data, newval, len))
1130 * register_sysctl_table - register a sysctl hierarchy
1131 * @table: the top-level table structure
1132 * @insert_at_head: whether the entry should be inserted in front or at the end
1134 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1135 * array. An entry with a ctl_name of 0 terminates the table.
1137 * The members of the &ctl_table structure are used as follows:
1139 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1140 * must be unique within that level of sysctl
1142 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1143 * enter a sysctl file
1145 * data - a pointer to data for use by proc_handler
1147 * maxlen - the maximum size in bytes of the data
1149 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1151 * child - a pointer to the child sysctl table if this entry is a directory, or
1154 * proc_handler - the text handler routine (described below)
1156 * strategy - the strategy routine (described below)
1158 * de - for internal use by the sysctl routines
1160 * extra1, extra2 - extra pointers usable by the proc handler routines
1162 * Leaf nodes in the sysctl tree will be represented by a single file
1163 * under /proc; non-leaf nodes will be represented by directories.
1165 * sysctl(2) can automatically manage read and write requests through
1166 * the sysctl table. The data and maxlen fields of the ctl_table
1167 * struct enable minimal validation of the values being written to be
1168 * performed, and the mode field allows minimal authentication.
1170 * More sophisticated management can be enabled by the provision of a
1171 * strategy routine with the table entry. This will be called before
1172 * any automatic read or write of the data is performed.
1174 * The strategy routine may return
1176 * < 0 - Error occurred (error is passed to user process)
1178 * 0 - OK - proceed with automatic read or write.
1180 * > 0 - OK - read or write has been done by the strategy routine, so
1181 * return immediately.
1183 * There must be a proc_handler routine for any terminal nodes
1184 * mirrored under /proc/sys (non-terminals are handled by a built-in
1185 * directory handler). Several default handlers are available to
1186 * cover common cases -
1188 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1189 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1190 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1192 * It is the handler's job to read the input buffer from user memory
1193 * and process it. The handler should return 0 on success.
1195 * This routine returns %NULL on a failure to register, and a pointer
1196 * to the table header on success.
1198 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1201 struct ctl_table_header *tmp;
1202 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1205 tmp->ctl_table = table;
1206 INIT_LIST_HEAD(&tmp->ctl_entry);
1208 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1210 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1211 #ifdef CONFIG_PROC_FS
1212 register_proc_table(table, proc_sys_root);
1218 * unregister_sysctl_table - unregister a sysctl table hierarchy
1219 * @header: the header returned from register_sysctl_table
1221 * Unregisters the sysctl table and all children. proc entries may not
1222 * actually be removed until they are no longer used by anyone.
1224 void unregister_sysctl_table(struct ctl_table_header * header)
1226 list_del(&header->ctl_entry);
1227 #ifdef CONFIG_PROC_FS
1228 unregister_proc_table(header->ctl_table, proc_sys_root);
1237 #ifdef CONFIG_PROC_FS
1239 /* Scan the sysctl entries in table and add them all into /proc */
1240 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1242 struct proc_dir_entry *de;
1246 for (; table->ctl_name; table++) {
1247 /* Can't do anything without a proc name. */
1248 if (!table->procname)
1250 /* Maybe we can't do anything with it... */
1251 if (!table->proc_handler && !table->child) {
1252 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1257 len = strlen(table->procname);
1261 if (table->proc_handler)
1265 for (de = root->subdir; de; de = de->next) {
1266 if (proc_match(len, table->procname, de))
1269 /* If the subdir exists already, de is non-NULL */
1273 de = create_proc_entry(table->procname, mode, root);
1276 de->data = (void *) table;
1277 if (table->proc_handler)
1278 de->proc_fops = &proc_sys_file_operations;
1281 if (de->mode & S_IFDIR)
1282 register_proc_table(table->child, de);
1287 * Unregister a /proc sysctl table and any subdirectories.
1289 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1291 struct proc_dir_entry *de;
1292 for (; table->ctl_name; table++) {
1293 if (!(de = table->de))
1295 if (de->mode & S_IFDIR) {
1296 if (!table->child) {
1297 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1300 unregister_proc_table(table->child, de);
1302 /* Don't unregister directories which still have entries.. */
1307 /* Don't unregister proc entries that are still being used.. */
1308 if (atomic_read(&de->count))
1312 remove_proc_entry(table->procname, root);
1316 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1317 size_t count, loff_t *ppos)
1320 struct proc_dir_entry *de;
1321 struct ctl_table *table;
1325 de = PDE(file->f_dentry->d_inode);
1326 if (!de || !de->data)
1328 table = (struct ctl_table *) de->data;
1329 if (!table || !table->proc_handler)
1331 op = (write ? 002 : 004);
1332 if (ctl_perm(table, op))
1338 * FIXME: we need to pass on ppos to the handler.
1341 error = (*table->proc_handler) (table, write, file, buf, &res);
1347 static int proc_opensys(struct inode *inode, struct file *file)
1349 if (file->f_mode & FMODE_WRITE) {
1351 * sysctl entries that are not writable,
1352 * are _NOT_ writable, capabilities or not.
1354 if (!(inode->i_mode & S_IWUSR))
1361 static ssize_t proc_readsys(struct file * file, char __user * buf,
1362 size_t count, loff_t *ppos)
1364 return do_rw_proc(0, file, buf, count, ppos);
1367 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1368 size_t count, loff_t *ppos)
1370 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1374 * proc_dostring - read a string sysctl
1375 * @table: the sysctl table
1376 * @write: %TRUE if this is a write to the sysctl file
1377 * @filp: the file structure
1378 * @buffer: the user buffer
1379 * @lenp: the size of the user buffer
1381 * Reads/writes a string from/to the user buffer. If the kernel
1382 * buffer provided is not large enough to hold the string, the
1383 * string is truncated. The copied string is %NULL-terminated.
1384 * If the string is being read by the user process, it is copied
1385 * and a newline '\n' is added. It is truncated if the buffer is
1388 * Returns 0 on success.
1390 int proc_dostring(ctl_table *table, int write, struct file *filp,
1391 void __user *buffer, size_t *lenp)
1397 if (!table->data || !table->maxlen || !*lenp ||
1398 (filp->f_pos && !write)) {
1406 while (len < *lenp) {
1407 if (get_user(c, p++))
1409 if (c == 0 || c == '\n')
1413 if (len >= table->maxlen)
1414 len = table->maxlen-1;
1415 if(copy_from_user(table->data, buffer, len))
1417 ((char *) table->data)[len] = 0;
1418 filp->f_pos += *lenp;
1420 len = strlen(table->data);
1421 if (len > table->maxlen)
1422 len = table->maxlen;
1426 if(copy_to_user(buffer, table->data, len))
1429 if(put_user('\n', ((char __user *) buffer) + len))
1440 * Special case of dostring for the UTS structure. This has locks
1441 * to observe. Should this be in kernel/sys.c ????
1444 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1445 void __user *buffer, size_t *lenp)
1450 down_read(&uts_sem);
1451 r=proc_dostring(table,0,filp,buffer,lenp);
1454 down_write(&uts_sem);
1455 r=proc_dostring(table,1,filp,buffer,lenp);
1461 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1463 int write, void *data)
1466 *valp = *negp ? -*lvalp : *lvalp;
1471 *lvalp = (unsigned long)-val;
1474 *lvalp = (unsigned long)val;
1480 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1481 void __user *buffer, size_t *lenp,
1482 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1483 int write, void *data),
1486 #define TMPBUFLEN 20
1487 int *i, vleft, first=1, neg, val;
1491 char buf[TMPBUFLEN], *p;
1492 char __user *s = buffer;
1494 if (!table->data || !table->maxlen || !*lenp ||
1495 (filp->f_pos && !write)) {
1500 i = (int *) table->data;
1501 vleft = table->maxlen / sizeof(*i);
1505 conv = do_proc_dointvec_conv;
1507 for (; left && vleft--; i++, first=0) {
1522 if (len > sizeof(buf) - 1)
1523 len = sizeof(buf) - 1;
1524 if (copy_from_user(buf, s, len))
1528 if (*p == '-' && left > 1) {
1532 if (*p < '0' || *p > '9')
1535 lval = simple_strtoul(p, &p, 0);
1538 if ((len < left) && *p && !isspace(*p))
1545 if (conv(&neg, &lval, i, 1, data))
1552 if (conv(&neg, &lval, i, 0, data))
1555 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1559 if(copy_to_user(s, buf, len))
1566 if (!write && !first && left) {
1567 if(put_user('\n', s))
1574 if (get_user(c, s++))
1584 filp->f_pos += *lenp;
1590 * proc_dointvec - read a vector of integers
1591 * @table: the sysctl table
1592 * @write: %TRUE if this is a write to the sysctl file
1593 * @filp: the file structure
1594 * @buffer: the user buffer
1595 * @lenp: the size of the user buffer
1597 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1598 * values from/to the user buffer, treated as an ASCII string.
1600 * Returns 0 on success.
1602 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1603 void __user *buffer, size_t *lenp)
1605 return do_proc_dointvec(table,write,filp,buffer,lenp,
1615 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1617 int write, void *data)
1619 int op = *(int *)data;
1621 int val = *negp ? -*lvalp : *lvalp;
1623 case OP_SET: *valp = val; break;
1624 case OP_AND: *valp &= val; break;
1625 case OP_OR: *valp |= val; break;
1626 case OP_MAX: if(*valp < val)
1629 case OP_MIN: if(*valp > val)
1637 *lvalp = (unsigned long)-val;
1640 *lvalp = (unsigned long)val;
1647 * init may raise the set.
1650 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1651 void __user *buffer, size_t *lenp)
1655 if (!capable(CAP_SYS_MODULE)) {
1659 op = (current->pid == 1) ? OP_SET : OP_AND;
1660 return do_proc_dointvec(table,write,filp,buffer,lenp,
1661 do_proc_dointvec_bset_conv,&op);
1664 struct do_proc_dointvec_minmax_conv_param {
1669 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1671 int write, void *data)
1673 struct do_proc_dointvec_minmax_conv_param *param = data;
1675 int val = *negp ? -*lvalp : *lvalp;
1676 if ((param->min && *param->min > val) ||
1677 (param->max && *param->max < val))
1684 *lvalp = (unsigned long)-val;
1687 *lvalp = (unsigned long)val;
1694 * proc_dointvec_minmax - read a vector of integers with min/max values
1695 * @table: the sysctl table
1696 * @write: %TRUE if this is a write to the sysctl file
1697 * @filp: the file structure
1698 * @buffer: the user buffer
1699 * @lenp: the size of the user buffer
1701 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1702 * values from/to the user buffer, treated as an ASCII string.
1704 * This routine will ensure the values are within the range specified by
1705 * table->extra1 (min) and table->extra2 (max).
1707 * Returns 0 on success.
1709 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1710 void __user *buffer, size_t *lenp)
1712 struct do_proc_dointvec_minmax_conv_param param = {
1713 .min = (int *) table->extra1,
1714 .max = (int *) table->extra2,
1716 return do_proc_dointvec(table, write, filp, buffer, lenp,
1717 do_proc_dointvec_minmax_conv, ¶m);
1720 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1722 void __user *buffer, size_t *lenp,
1723 unsigned long convmul,
1724 unsigned long convdiv)
1726 #define TMPBUFLEN 20
1727 unsigned long *i, *min, *max, val;
1728 int vleft, first=1, neg;
1730 char buf[TMPBUFLEN], *p;
1731 char __user *s = buffer;
1733 if (!table->data || !table->maxlen || !*lenp ||
1734 (filp->f_pos && !write)) {
1739 i = (unsigned long *) table->data;
1740 min = (unsigned long *) table->extra1;
1741 max = (unsigned long *) table->extra2;
1742 vleft = table->maxlen / sizeof(unsigned long);
1745 for (; left && vleft--; i++, min++, max++, first=0) {
1760 if (len > TMPBUFLEN-1)
1762 if (copy_from_user(buf, s, len))
1766 if (*p == '-' && left > 1) {
1770 if (*p < '0' || *p > '9')
1772 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1774 if ((len < left) && *p && !isspace(*p))
1783 if ((min && val < *min) || (max && val > *max))
1790 sprintf(p, "%lu", convdiv * (*i) / convmul);
1794 if(copy_to_user(s, buf, len))
1801 if (!write && !first && left) {
1802 if(put_user('\n', s))
1809 if (get_user(c, s++))
1819 filp->f_pos += *lenp;
1825 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1826 * @table: the sysctl table
1827 * @write: %TRUE if this is a write to the sysctl file
1828 * @filp: the file structure
1829 * @buffer: the user buffer
1830 * @lenp: the size of the user buffer
1832 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1833 * values from/to the user buffer, treated as an ASCII string.
1835 * This routine will ensure the values are within the range specified by
1836 * table->extra1 (min) and table->extra2 (max).
1838 * Returns 0 on success.
1840 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1841 void __user *buffer, size_t *lenp)
1843 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1847 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1848 * @table: the sysctl table
1849 * @write: %TRUE if this is a write to the sysctl file
1850 * @filp: the file structure
1851 * @buffer: the user buffer
1852 * @lenp: the size of the user buffer
1854 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1855 * values from/to the user buffer, treated as an ASCII string. The values
1856 * are treated as milliseconds, and converted to jiffies when they are stored.
1858 * This routine will ensure the values are within the range specified by
1859 * table->extra1 (min) and table->extra2 (max).
1861 * Returns 0 on success.
1863 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1865 void __user *buffer, size_t *lenp)
1867 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1872 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1874 int write, void *data)
1877 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1883 lval = (unsigned long)-val;
1886 lval = (unsigned long)val;
1893 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1895 int write, void *data)
1898 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1904 lval = (unsigned long)-val;
1907 lval = (unsigned long)val;
1909 *lvalp = jiffies_to_clock_t(lval);
1915 * proc_dointvec_jiffies - read a vector of integers as seconds
1916 * @table: the sysctl table
1917 * @write: %TRUE if this is a write to the sysctl file
1918 * @filp: the file structure
1919 * @buffer: the user buffer
1920 * @lenp: the size of the user buffer
1922 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1923 * values from/to the user buffer, treated as an ASCII string.
1924 * The values read are assumed to be in seconds, and are converted into
1927 * Returns 0 on success.
1929 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1930 void __user *buffer, size_t *lenp)
1932 return do_proc_dointvec(table,write,filp,buffer,lenp,
1933 do_proc_dointvec_jiffies_conv,NULL);
1937 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1938 * @table: the sysctl table
1939 * @write: %TRUE if this is a write to the sysctl file
1940 * @filp: the file structure
1941 * @buffer: the user buffer
1942 * @lenp: the size of the user buffer
1944 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1945 * values from/to the user buffer, treated as an ASCII string.
1946 * The values read are assumed to be in 1/USER_HZ seconds, and
1947 * are converted into jiffies.
1949 * Returns 0 on success.
1951 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1952 void __user *buffer, size_t *lenp)
1954 return do_proc_dointvec(table,write,filp,buffer,lenp,
1955 do_proc_dointvec_userhz_jiffies_conv,NULL);
1958 #else /* CONFIG_PROC_FS */
1960 int proc_dostring(ctl_table *table, int write, struct file *filp,
1961 void __user *buffer, size_t *lenp)
1966 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1967 void __user *buffer, size_t *lenp)
1972 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1973 void __user *buffer, size_t *lenp)
1978 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1979 void __user *buffer, size_t *lenp)
1984 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1985 void __user *buffer, size_t *lenp)
1990 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1991 void __user *buffer, size_t *lenp)
1996 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1997 void __user *buffer, size_t *lenp)
2002 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2003 void __user *buffer, size_t *lenp)
2008 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2010 void __user *buffer, size_t *lenp)
2016 #endif /* CONFIG_PROC_FS */
2020 * General sysctl support routines
2023 /* The generic string strategy routine: */
2024 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2025 void __user *oldval, size_t __user *oldlenp,
2026 void __user *newval, size_t newlen, void **context)
2030 if (!table->data || !table->maxlen)
2033 if (oldval && oldlenp) {
2034 if (get_user(len, oldlenp))
2037 l = strlen(table->data);
2038 if (len > l) len = l;
2039 if (len >= table->maxlen)
2040 len = table->maxlen;
2041 if(copy_to_user(oldval, table->data, len))
2043 if(put_user(0, ((char __user *) oldval) + len))
2045 if(put_user(len, oldlenp))
2049 if (newval && newlen) {
2051 if (len > table->maxlen)
2052 len = table->maxlen;
2053 if(copy_from_user(table->data, newval, len))
2055 if (len == table->maxlen)
2057 ((char *) table->data)[len] = 0;
2063 * This function makes sure that all of the integers in the vector
2064 * are between the minimum and maximum values given in the arrays
2065 * table->extra1 and table->extra2, respectively.
2067 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2068 void __user *oldval, size_t __user *oldlenp,
2069 void __user *newval, size_t newlen, void **context)
2072 if (newval && newlen) {
2073 int __user *vec = (int __user *) newval;
2074 int *min = (int *) table->extra1;
2075 int *max = (int *) table->extra2;
2079 if (newlen % sizeof(int) != 0)
2082 if (!table->extra1 && !table->extra2)
2085 if (newlen > table->maxlen)
2086 newlen = table->maxlen;
2087 length = newlen / sizeof(int);
2089 for (i = 0; i < length; i++) {
2091 if (get_user(value, vec + i))
2093 if (min && value < min[i])
2095 if (max && value > max[i])
2102 /* Strategy function to convert jiffies to seconds */
2103 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2104 void __user *oldval, size_t __user *oldlenp,
2105 void __user *newval, size_t newlen, void **context)
2110 if (get_user(olen, oldlenp))
2112 if (olen!=sizeof(int))
2115 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2116 (oldlenp && put_user(sizeof(int),oldlenp)))
2119 if (newval && newlen) {
2121 if (newlen != sizeof(int))
2123 if (get_user(new, (int __user *)newval))
2125 *(int *)(table->data) = new*HZ;
2131 #else /* CONFIG_SYSCTL */
2134 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2139 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2140 void __user *oldval, size_t __user *oldlenp,
2141 void __user *newval, size_t newlen, void **context)
2146 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2147 void __user *oldval, size_t __user *oldlenp,
2148 void __user *newval, size_t newlen, void **context)
2153 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2154 void __user *oldval, size_t __user *oldlenp,
2155 void __user *newval, size_t newlen, void **context)
2160 int proc_dostring(ctl_table *table, int write, struct file *filp,
2161 void __user *buffer, size_t *lenp)
2166 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2167 void __user *buffer, size_t *lenp)
2172 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2173 void __user *buffer, size_t *lenp)
2178 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2179 void __user *buffer, size_t *lenp)
2184 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2185 void __user *buffer, size_t *lenp)
2190 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2191 void __user *buffer, size_t *lenp)
2196 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2197 void __user *buffer, size_t *lenp)
2202 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2204 void __user *buffer, size_t *lenp)
2209 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2215 void unregister_sysctl_table(struct ctl_table_header * table)
2219 #endif /* CONFIG_SYSCTL */
2222 * No sense putting this after each symbol definition, twice,
2223 * exception granted :-)
2225 EXPORT_SYMBOL(proc_dointvec);
2226 EXPORT_SYMBOL(proc_dointvec_jiffies);
2227 EXPORT_SYMBOL(proc_dointvec_minmax);
2228 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2229 EXPORT_SYMBOL(proc_dostring);
2230 EXPORT_SYMBOL(proc_doulongvec_minmax);
2231 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2232 EXPORT_SYMBOL(register_sysctl_table);
2233 EXPORT_SYMBOL(sysctl_intvec);
2234 EXPORT_SYMBOL(sysctl_jiffies);
2235 EXPORT_SYMBOL(sysctl_string);
2236 EXPORT_SYMBOL(unregister_sysctl_table);