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 #ifdef CONFIG_CHR_DEV_SG
102 extern int sg_big_buff;
104 #ifdef CONFIG_SYSVIPC
105 extern size_t shm_ctlmax;
106 extern size_t shm_ctlall;
107 extern int shm_ctlmni;
108 extern int msg_ctlmax;
109 extern int msg_ctlmnb;
110 extern int msg_ctlmni;
111 extern int sem_ctls[];
115 extern char reboot_command [];
116 extern int stop_a_enabled;
117 extern int scons_pwroff;
121 extern int pwrsw_enabled;
122 extern int unaligned_enabled;
125 #ifdef CONFIG_ARCH_S390
126 #ifdef CONFIG_MATHEMU
127 extern int sysctl_ieee_emulation_warnings;
129 extern int sysctl_userprocess_debug;
132 extern int sysctl_hz_timer;
134 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
135 extern unsigned long powersave_nap;
136 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
137 void *buffer, size_t *lenp);
140 #ifdef CONFIG_BSD_PROCESS_ACCT
141 extern int acct_parm[];
144 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
145 ctl_table *, void **);
146 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
147 void __user *buffer, size_t *lenp);
149 static ctl_table root_table[];
150 static struct ctl_table_header root_table_header =
151 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
153 static ctl_table kern_table[];
154 static ctl_table vm_table[];
156 extern ctl_table net_table[];
158 static ctl_table proc_table[];
159 static ctl_table fs_table[];
160 static ctl_table debug_table[];
161 static ctl_table dev_table[];
162 extern ctl_table random_table[];
163 #ifdef CONFIG_UNIX98_PTYS
164 extern ctl_table pty_table[];
167 /* /proc declarations: */
169 #ifdef CONFIG_PROC_FS
171 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
172 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
173 static int proc_opensys(struct inode *, struct file *);
175 struct file_operations proc_sys_file_operations = {
176 .open = proc_opensys,
177 .read = proc_readsys,
178 .write = proc_writesys,
181 extern struct proc_dir_entry *proc_sys_root;
183 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
184 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
187 /* The default sysctl tables: */
189 static ctl_table root_table[] = {
191 .ctl_name = CTL_KERN,
192 .procname = "kernel",
211 .ctl_name = CTL_PROC,
223 .ctl_name = CTL_DEBUG,
226 .child = debug_table,
237 static ctl_table kern_table[] = {
239 .ctl_name = KERN_OSTYPE,
240 .procname = "ostype",
241 .data = system_utsname.sysname,
242 .maxlen = sizeof(system_utsname.sysname),
244 .proc_handler = &proc_doutsstring,
245 .strategy = &sysctl_string,
248 .ctl_name = KERN_OSRELEASE,
249 .procname = "osrelease",
250 .data = system_utsname.release,
251 .maxlen = sizeof(system_utsname.release),
253 .proc_handler = &proc_doutsstring,
254 .strategy = &sysctl_string,
257 .ctl_name = KERN_VERSION,
258 .procname = "version",
259 .data = system_utsname.version,
260 .maxlen = sizeof(system_utsname.version),
262 .proc_handler = &proc_doutsstring,
263 .strategy = &sysctl_string,
266 .ctl_name = KERN_NODENAME,
267 .procname = "hostname",
268 .data = system_utsname.nodename,
269 .maxlen = sizeof(system_utsname.nodename),
271 .proc_handler = &proc_doutsstring,
272 .strategy = &sysctl_string,
275 .ctl_name = KERN_DOMAINNAME,
276 .procname = "domainname",
277 .data = system_utsname.domainname,
278 .maxlen = sizeof(system_utsname.domainname),
280 .proc_handler = &proc_doutsstring,
281 .strategy = &sysctl_string,
284 .ctl_name = KERN_PANIC,
286 .data = &panic_timeout,
287 .maxlen = sizeof(int),
289 .proc_handler = &proc_dointvec,
292 .ctl_name = KERN_PANIC,
293 .procname = "exec-shield",
294 .data = &exec_shield,
295 .maxlen = sizeof(int),
297 .proc_handler = &proc_dointvec,
300 .ctl_name = KERN_PANIC,
301 .procname = "exec-shield-randomize",
302 .data = &exec_shield_randomize,
303 .maxlen = sizeof(int),
305 .proc_handler = &proc_dointvec,
308 .ctl_name = KERN_PANIC,
309 .procname = "print-fatal-signals",
310 .data = &print_fatal_signals,
311 .maxlen = sizeof(int),
313 .proc_handler = &proc_dointvec,
317 .ctl_name = KERN_PANIC,
319 .data = &vdso_enabled,
320 .maxlen = sizeof(int),
322 .proc_handler = &proc_dointvec,
326 .ctl_name = KERN_CORE_USES_PID,
327 .procname = "core_uses_pid",
328 .data = &core_uses_pid,
329 .maxlen = sizeof(int),
331 .proc_handler = &proc_dointvec,
334 .ctl_name = KERN_CORE_PATTERN,
335 .procname = "core_pattern",
336 .data = core_pattern,
339 .proc_handler = &proc_dostring,
340 .strategy = &sysctl_string,
343 .ctl_name = KERN_TAINTED,
344 .procname = "tainted",
346 .maxlen = sizeof(int),
348 .proc_handler = &proc_dointvec,
351 .ctl_name = KERN_CAP_BSET,
352 .procname = "cap-bound",
354 .maxlen = sizeof(kernel_cap_t),
356 .proc_handler = &proc_dointvec_bset,
358 #ifdef CONFIG_BLK_DEV_INITRD
360 .ctl_name = KERN_REALROOTDEV,
361 .procname = "real-root-dev",
362 .data = &real_root_dev,
363 .maxlen = sizeof(int),
365 .proc_handler = &proc_dointvec,
370 .ctl_name = KERN_SPARC_REBOOT,
371 .procname = "reboot-cmd",
372 .data = reboot_command,
375 .proc_handler = &proc_dostring,
376 .strategy = &sysctl_string,
379 .ctl_name = KERN_SPARC_STOP_A,
380 .procname = "stop-a",
381 .data = &stop_a_enabled,
382 .maxlen = sizeof (int),
384 .proc_handler = &proc_dointvec,
387 .ctl_name = KERN_SPARC_SCONS_PWROFF,
388 .procname = "scons-poweroff",
389 .data = &scons_pwroff,
390 .maxlen = sizeof (int),
392 .proc_handler = &proc_dointvec,
397 .ctl_name = KERN_HPPA_PWRSW,
398 .procname = "soft-power",
399 .data = &pwrsw_enabled,
400 .maxlen = sizeof (int),
402 .proc_handler = &proc_dointvec,
405 .ctl_name = KERN_HPPA_UNALIGNED,
406 .procname = "unaligned-trap",
407 .data = &unaligned_enabled,
408 .maxlen = sizeof (int),
410 .proc_handler = &proc_dointvec,
413 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
415 .ctl_name = KERN_PPC_POWERSAVE_NAP,
416 .procname = "powersave-nap",
417 .data = &powersave_nap,
418 .maxlen = sizeof(int),
420 .proc_handler = &proc_dointvec,
423 .ctl_name = KERN_PPC_L2CR,
426 .proc_handler = &proc_dol2crvec,
430 .ctl_name = KERN_CTLALTDEL,
431 .procname = "ctrl-alt-del",
433 .maxlen = sizeof(int),
435 .proc_handler = &proc_dointvec,
438 .ctl_name = KERN_PRINTK,
439 .procname = "printk",
440 .data = &console_loglevel,
441 .maxlen = 4*sizeof(int),
443 .proc_handler = &proc_dointvec,
447 .ctl_name = KERN_MODPROBE,
448 .procname = "modprobe",
449 .data = &modprobe_path,
450 .maxlen = KMOD_PATH_LEN,
452 .proc_handler = &proc_dostring,
453 .strategy = &sysctl_string,
456 #ifdef CONFIG_HOTPLUG
458 .ctl_name = KERN_HOTPLUG,
459 .procname = "hotplug",
460 .data = &hotplug_path,
461 .maxlen = KMOD_PATH_LEN,
463 .proc_handler = &proc_dostring,
464 .strategy = &sysctl_string,
467 #ifdef CONFIG_CHR_DEV_SG
469 .ctl_name = KERN_SG_BIG_BUFF,
470 .procname = "sg-big-buff",
471 .data = &sg_big_buff,
472 .maxlen = sizeof (int),
474 .proc_handler = &proc_dointvec,
477 #ifdef CONFIG_BSD_PROCESS_ACCT
479 .ctl_name = KERN_ACCT,
482 .maxlen = 3*sizeof(int),
484 .proc_handler = &proc_dointvec,
487 #ifdef CONFIG_SYSVIPC
489 .ctl_name = KERN_SHMMAX,
490 .procname = "shmmax",
492 .maxlen = sizeof (size_t),
494 .proc_handler = &proc_doulongvec_minmax,
497 .ctl_name = KERN_SHMALL,
498 .procname = "shmall",
500 .maxlen = sizeof (size_t),
502 .proc_handler = &proc_doulongvec_minmax,
505 .ctl_name = KERN_SHMMNI,
506 .procname = "shmmni",
508 .maxlen = sizeof (int),
510 .proc_handler = &proc_dointvec,
513 .ctl_name = KERN_MSGMAX,
514 .procname = "msgmax",
516 .maxlen = sizeof (int),
518 .proc_handler = &proc_dointvec,
521 .ctl_name = KERN_MSGMNI,
522 .procname = "msgmni",
524 .maxlen = sizeof (int),
526 .proc_handler = &proc_dointvec,
529 .ctl_name = KERN_MSGMNB,
530 .procname = "msgmnb",
532 .maxlen = sizeof (int),
534 .proc_handler = &proc_dointvec,
537 .ctl_name = KERN_SEM,
540 .maxlen = 4*sizeof (int),
542 .proc_handler = &proc_dointvec,
545 #ifdef CONFIG_MAGIC_SYSRQ
547 .ctl_name = KERN_SYSRQ,
549 .data = &sysrq_enabled,
550 .maxlen = sizeof (int),
552 .proc_handler = &proc_dointvec,
556 .ctl_name = KERN_CADPID,
557 .procname = "cad_pid",
559 .maxlen = sizeof (int),
561 .proc_handler = &proc_dointvec,
564 .ctl_name = KERN_MAX_THREADS,
565 .procname = "threads-max",
566 .data = &max_threads,
567 .maxlen = sizeof(int),
569 .proc_handler = &proc_dointvec,
572 .ctl_name = KERN_RANDOM,
573 .procname = "random",
575 .child = random_table,
577 #ifdef CONFIG_UNIX98_PTYS
579 .ctl_name = KERN_PTY,
586 .ctl_name = KERN_OVERFLOWUID,
587 .procname = "overflowuid",
588 .data = &overflowuid,
589 .maxlen = sizeof(int),
591 .proc_handler = &proc_dointvec_minmax,
592 .strategy = &sysctl_intvec,
593 .extra1 = &minolduid,
594 .extra2 = &maxolduid,
597 .ctl_name = KERN_OVERFLOWGID,
598 .procname = "overflowgid",
599 .data = &overflowgid,
600 .maxlen = sizeof(int),
602 .proc_handler = &proc_dointvec_minmax,
603 .strategy = &sysctl_intvec,
604 .extra1 = &minolduid,
605 .extra2 = &maxolduid,
607 #ifdef CONFIG_ARCH_S390
608 #ifdef CONFIG_MATHEMU
610 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
611 .procname = "ieee_emulation_warnings",
612 .data = &sysctl_ieee_emulation_warnings,
613 .maxlen = sizeof(int),
615 .proc_handler = &proc_dointvec,
618 #ifdef CONFIG_NO_IDLE_HZ
620 .ctl_name = KERN_HZ_TIMER,
621 .procname = "hz_timer",
622 .data = &sysctl_hz_timer,
623 .maxlen = sizeof(int),
625 .proc_handler = &proc_dointvec,
629 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
630 .procname = "userprocess_debug",
631 .data = &sysctl_userprocess_debug,
632 .maxlen = sizeof(int),
634 .proc_handler = &proc_dointvec,
638 .ctl_name = KERN_PIDMAX,
639 .procname = "pid_max",
641 .maxlen = sizeof (int),
643 .proc_handler = &proc_dointvec,
646 .ctl_name = KERN_PANIC_ON_OOPS,
647 .procname = "panic_on_oops",
648 .data = &panic_on_oops,
649 .maxlen = sizeof(int),
651 .proc_handler = &proc_dointvec,
654 .ctl_name = KERN_PRINTK_RATELIMIT,
655 .procname = "printk_ratelimit",
656 .data = &printk_ratelimit_jiffies,
657 .maxlen = sizeof(int),
659 .proc_handler = &proc_dointvec_jiffies,
660 .strategy = &sysctl_jiffies,
663 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
664 .procname = "printk_ratelimit_burst",
665 .data = &printk_ratelimit_burst,
666 .maxlen = sizeof(int),
668 .proc_handler = &proc_dointvec,
671 .ctl_name = KERN_NGROUPS_MAX,
672 .procname = "ngroups_max",
673 .data = &ngroups_max,
674 .maxlen = sizeof (int),
676 .proc_handler = &proc_dointvec,
681 /* Constants for minimum and maximum testing in vm_table.
682 We use these as one-element integer vectors. */
684 static int one_hundred = 100;
687 static ctl_table vm_table[] = {
689 .ctl_name = VM_OVERCOMMIT_MEMORY,
690 .procname = "overcommit_memory",
691 .data = &sysctl_overcommit_memory,
692 .maxlen = sizeof(sysctl_overcommit_memory),
694 .proc_handler = &proc_dointvec,
697 .ctl_name = VM_OVERCOMMIT_RATIO,
698 .procname = "overcommit_ratio",
699 .data = &sysctl_overcommit_ratio,
700 .maxlen = sizeof(sysctl_overcommit_ratio),
702 .proc_handler = &proc_dointvec,
705 .ctl_name = VM_PAGE_CLUSTER,
706 .procname = "page-cluster",
707 .data = &page_cluster,
708 .maxlen = sizeof(int),
710 .proc_handler = &proc_dointvec,
713 .ctl_name = VM_DIRTY_BACKGROUND,
714 .procname = "dirty_background_ratio",
715 .data = &dirty_background_ratio,
716 .maxlen = sizeof(dirty_background_ratio),
718 .proc_handler = &proc_dointvec_minmax,
719 .strategy = &sysctl_intvec,
721 .extra2 = &one_hundred,
724 .ctl_name = VM_DIRTY_RATIO,
725 .procname = "dirty_ratio",
726 .data = &vm_dirty_ratio,
727 .maxlen = sizeof(vm_dirty_ratio),
729 .proc_handler = &proc_dointvec_minmax,
730 .strategy = &sysctl_intvec,
732 .extra2 = &one_hundred,
735 .ctl_name = VM_DIRTY_WB_CS,
736 .procname = "dirty_writeback_centisecs",
737 .data = &dirty_writeback_centisecs,
738 .maxlen = sizeof(dirty_writeback_centisecs),
740 .proc_handler = &dirty_writeback_centisecs_handler,
743 .ctl_name = VM_DIRTY_EXPIRE_CS,
744 .procname = "dirty_expire_centisecs",
745 .data = &dirty_expire_centisecs,
746 .maxlen = sizeof(dirty_expire_centisecs),
748 .proc_handler = &proc_dointvec,
751 .ctl_name = VM_NR_PDFLUSH_THREADS,
752 .procname = "nr_pdflush_threads",
753 .data = &nr_pdflush_threads,
754 .maxlen = sizeof nr_pdflush_threads,
755 .mode = 0444 /* read-only*/,
756 .proc_handler = &proc_dointvec,
759 .ctl_name = VM_SWAPPINESS,
760 .procname = "swappiness",
761 .data = &vm_swappiness,
762 .maxlen = sizeof(vm_swappiness),
764 .proc_handler = &proc_dointvec_minmax,
765 .strategy = &sysctl_intvec,
767 .extra2 = &one_hundred,
769 #ifdef CONFIG_HUGETLB_PAGE
771 .ctl_name = VM_HUGETLB_PAGES,
772 .procname = "nr_hugepages",
773 .data = &max_huge_pages,
774 .maxlen = sizeof(unsigned long),
776 .proc_handler = &hugetlb_sysctl_handler,
777 .extra1 = (void *)&hugetlb_zero,
778 .extra2 = (void *)&hugetlb_infinity,
782 .ctl_name = VM_LOWER_ZONE_PROTECTION,
783 .procname = "lower_zone_protection",
784 .data = &sysctl_lower_zone_protection,
785 .maxlen = sizeof(sysctl_lower_zone_protection),
787 .proc_handler = &lower_zone_protection_sysctl_handler,
788 .strategy = &sysctl_intvec,
792 .ctl_name = VM_MIN_FREE_KBYTES,
793 .procname = "min_free_kbytes",
794 .data = &min_free_kbytes,
795 .maxlen = sizeof(min_free_kbytes),
797 .proc_handler = &min_free_kbytes_sysctl_handler,
798 .strategy = &sysctl_intvec,
802 .ctl_name = VM_MAX_MAP_COUNT,
803 .procname = "max_map_count",
804 .data = &sysctl_max_map_count,
805 .maxlen = sizeof(sysctl_max_map_count),
807 .proc_handler = &proc_dointvec
810 .ctl_name = VM_LAPTOP_MODE,
811 .procname = "laptop_mode",
812 .data = &laptop_mode,
813 .maxlen = sizeof(laptop_mode),
815 .proc_handler = &proc_dointvec,
816 .strategy = &sysctl_intvec,
820 .ctl_name = VM_BLOCK_DUMP,
821 .procname = "block_dump",
823 .maxlen = sizeof(block_dump),
825 .proc_handler = &proc_dointvec,
826 .strategy = &sysctl_intvec,
832 static ctl_table proc_table[] = {
836 static ctl_table fs_table[] = {
838 .ctl_name = FS_NRINODE,
839 .procname = "inode-nr",
840 .data = &inodes_stat,
841 .maxlen = 2*sizeof(int),
843 .proc_handler = &proc_dointvec,
846 .ctl_name = FS_STATINODE,
847 .procname = "inode-state",
848 .data = &inodes_stat,
849 .maxlen = 7*sizeof(int),
851 .proc_handler = &proc_dointvec,
854 .ctl_name = FS_NRFILE,
855 .procname = "file-nr",
857 .maxlen = 3*sizeof(int),
859 .proc_handler = &proc_dointvec,
862 .ctl_name = FS_MAXFILE,
863 .procname = "file-max",
864 .data = &files_stat.max_files,
865 .maxlen = sizeof(int),
867 .proc_handler = &proc_dointvec,
870 .ctl_name = FS_DENTRY,
871 .procname = "dentry-state",
872 .data = &dentry_stat,
873 .maxlen = 6*sizeof(int),
875 .proc_handler = &proc_dointvec,
878 .ctl_name = FS_OVERFLOWUID,
879 .procname = "overflowuid",
880 .data = &fs_overflowuid,
881 .maxlen = sizeof(int),
883 .proc_handler = &proc_dointvec_minmax,
884 .strategy = &sysctl_intvec,
885 .extra1 = &minolduid,
886 .extra2 = &maxolduid,
889 .ctl_name = FS_OVERFLOWGID,
890 .procname = "overflowgid",
891 .data = &fs_overflowgid,
892 .maxlen = sizeof(int),
894 .proc_handler = &proc_dointvec_minmax,
895 .strategy = &sysctl_intvec,
896 .extra1 = &minolduid,
897 .extra2 = &maxolduid,
900 .ctl_name = FS_LEASES,
901 .procname = "leases-enable",
902 .data = &leases_enable,
903 .maxlen = sizeof(int),
905 .proc_handler = &proc_dointvec,
908 .ctl_name = FS_DIR_NOTIFY,
909 .procname = "dir-notify-enable",
910 .data = &dir_notify_enable,
911 .maxlen = sizeof(int),
913 .proc_handler = &proc_dointvec,
916 .ctl_name = FS_LEASE_TIME,
917 .procname = "lease-break-time",
918 .data = &lease_break_time,
919 .maxlen = sizeof(int),
921 .proc_handler = &proc_dointvec,
924 .ctl_name = FS_AIO_NR,
925 .procname = "aio-nr",
927 .maxlen = sizeof(aio_nr),
929 .proc_handler = &proc_dointvec,
932 .ctl_name = FS_AIO_MAX_NR,
933 .procname = "aio-max-nr",
935 .maxlen = sizeof(aio_max_nr),
937 .proc_handler = &proc_dointvec,
942 static ctl_table debug_table[] = {
946 static ctl_table dev_table[] = {
950 extern void init_irq_proc (void);
952 void __init sysctl_init(void)
954 #ifdef CONFIG_PROC_FS
955 register_proc_table(root_table, proc_sys_root);
960 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
961 void __user *newval, size_t newlen)
963 struct list_head *tmp;
965 if (nlen <= 0 || nlen >= CTL_MAXNAME)
969 if (!oldlenp || get_user(old_len, oldlenp))
972 tmp = &root_table_header.ctl_entry;
974 struct ctl_table_header *head =
975 list_entry(tmp, struct ctl_table_header, ctl_entry);
976 void *context = NULL;
977 int error = parse_table(name, nlen, oldval, oldlenp,
978 newval, newlen, head->ctl_table,
982 if (error != -ENOTDIR)
985 } while (tmp != &root_table_header.ctl_entry);
989 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
991 struct __sysctl_args tmp;
994 if (copy_from_user(&tmp, args, sizeof(tmp)))
998 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
999 tmp.newval, tmp.newlen);
1005 * ctl_perm does NOT grant the superuser all rights automatically, because
1006 * some sysctl variables are readonly even to root.
1009 static int test_perm(int mode, int op)
1013 else if (in_egroup_p(0))
1015 if ((mode & op & 0007) == op)
1020 static inline int ctl_perm(ctl_table *table, int op)
1023 error = security_sysctl(table, op);
1026 return test_perm(table->mode, op);
1029 static int parse_table(int __user *name, int nlen,
1030 void __user *oldval, size_t __user *oldlenp,
1031 void __user *newval, size_t newlen,
1032 ctl_table *table, void **context)
1038 if (get_user(n, name))
1040 for ( ; table->ctl_name; table++) {
1041 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1044 if (ctl_perm(table, 001))
1046 if (table->strategy) {
1047 error = table->strategy(
1050 newval, newlen, context);
1056 table = table->child;
1059 error = do_sysctl_strategy(table, name, nlen,
1061 newval, newlen, context);
1068 /* Perform the actual read/write of a sysctl table entry. */
1069 int do_sysctl_strategy (ctl_table *table,
1070 int __user *name, int nlen,
1071 void __user *oldval, size_t __user *oldlenp,
1072 void __user *newval, size_t newlen, void **context)
1081 if (ctl_perm(table, op))
1084 if (table->strategy) {
1085 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1086 newval, newlen, context);
1093 /* If there is no strategy routine, or if the strategy returns
1094 * zero, proceed with automatic r/w */
1095 if (table->data && table->maxlen) {
1096 if (oldval && oldlenp) {
1097 if (get_user(len, oldlenp))
1100 if (len > table->maxlen)
1101 len = table->maxlen;
1102 if(copy_to_user(oldval, table->data, len))
1104 if(put_user(len, oldlenp))
1108 if (newval && newlen) {
1110 if (len > table->maxlen)
1111 len = table->maxlen;
1112 if(copy_from_user(table->data, newval, len))
1120 * register_sysctl_table - register a sysctl hierarchy
1121 * @table: the top-level table structure
1122 * @insert_at_head: whether the entry should be inserted in front or at the end
1124 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1125 * array. An entry with a ctl_name of 0 terminates the table.
1127 * The members of the &ctl_table structure are used as follows:
1129 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1130 * must be unique within that level of sysctl
1132 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1133 * enter a sysctl file
1135 * data - a pointer to data for use by proc_handler
1137 * maxlen - the maximum size in bytes of the data
1139 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1141 * child - a pointer to the child sysctl table if this entry is a directory, or
1144 * proc_handler - the text handler routine (described below)
1146 * strategy - the strategy routine (described below)
1148 * de - for internal use by the sysctl routines
1150 * extra1, extra2 - extra pointers usable by the proc handler routines
1152 * Leaf nodes in the sysctl tree will be represented by a single file
1153 * under /proc; non-leaf nodes will be represented by directories.
1155 * sysctl(2) can automatically manage read and write requests through
1156 * the sysctl table. The data and maxlen fields of the ctl_table
1157 * struct enable minimal validation of the values being written to be
1158 * performed, and the mode field allows minimal authentication.
1160 * More sophisticated management can be enabled by the provision of a
1161 * strategy routine with the table entry. This will be called before
1162 * any automatic read or write of the data is performed.
1164 * The strategy routine may return
1166 * < 0 - Error occurred (error is passed to user process)
1168 * 0 - OK - proceed with automatic read or write.
1170 * > 0 - OK - read or write has been done by the strategy routine, so
1171 * return immediately.
1173 * There must be a proc_handler routine for any terminal nodes
1174 * mirrored under /proc/sys (non-terminals are handled by a built-in
1175 * directory handler). Several default handlers are available to
1176 * cover common cases -
1178 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1179 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1180 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1182 * It is the handler's job to read the input buffer from user memory
1183 * and process it. The handler should return 0 on success.
1185 * This routine returns %NULL on a failure to register, and a pointer
1186 * to the table header on success.
1188 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1191 struct ctl_table_header *tmp;
1192 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1195 tmp->ctl_table = table;
1196 INIT_LIST_HEAD(&tmp->ctl_entry);
1198 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1200 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1201 #ifdef CONFIG_PROC_FS
1202 register_proc_table(table, proc_sys_root);
1208 * unregister_sysctl_table - unregister a sysctl table hierarchy
1209 * @header: the header returned from register_sysctl_table
1211 * Unregisters the sysctl table and all children. proc entries may not
1212 * actually be removed until they are no longer used by anyone.
1214 void unregister_sysctl_table(struct ctl_table_header * header)
1216 list_del(&header->ctl_entry);
1217 #ifdef CONFIG_PROC_FS
1218 unregister_proc_table(header->ctl_table, proc_sys_root);
1227 #ifdef CONFIG_PROC_FS
1229 /* Scan the sysctl entries in table and add them all into /proc */
1230 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1232 struct proc_dir_entry *de;
1236 for (; table->ctl_name; table++) {
1237 /* Can't do anything without a proc name. */
1238 if (!table->procname)
1240 /* Maybe we can't do anything with it... */
1241 if (!table->proc_handler && !table->child) {
1242 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1247 len = strlen(table->procname);
1251 if (table->proc_handler)
1255 for (de = root->subdir; de; de = de->next) {
1256 if (proc_match(len, table->procname, de))
1259 /* If the subdir exists already, de is non-NULL */
1263 de = create_proc_entry(table->procname, mode, root);
1266 de->data = (void *) table;
1267 if (table->proc_handler)
1268 de->proc_fops = &proc_sys_file_operations;
1271 if (de->mode & S_IFDIR)
1272 register_proc_table(table->child, de);
1277 * Unregister a /proc sysctl table and any subdirectories.
1279 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1281 struct proc_dir_entry *de;
1282 for (; table->ctl_name; table++) {
1283 if (!(de = table->de))
1285 if (de->mode & S_IFDIR) {
1286 if (!table->child) {
1287 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1290 unregister_proc_table(table->child, de);
1292 /* Don't unregister directories which still have entries.. */
1297 /* Don't unregister proc entries that are still being used.. */
1298 if (atomic_read(&de->count))
1302 remove_proc_entry(table->procname, root);
1306 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1307 size_t count, loff_t *ppos)
1310 struct proc_dir_entry *de;
1311 struct ctl_table *table;
1315 de = PDE(file->f_dentry->d_inode);
1316 if (!de || !de->data)
1318 table = (struct ctl_table *) de->data;
1319 if (!table || !table->proc_handler)
1321 op = (write ? 002 : 004);
1322 if (ctl_perm(table, op))
1328 * FIXME: we need to pass on ppos to the handler.
1331 error = (*table->proc_handler) (table, write, file, buf, &res);
1337 static int proc_opensys(struct inode *inode, struct file *file)
1339 if (file->f_mode & FMODE_WRITE) {
1341 * sysctl entries that are not writable,
1342 * are _NOT_ writable, capabilities or not.
1344 if (!(inode->i_mode & S_IWUSR))
1351 static ssize_t proc_readsys(struct file * file, char __user * buf,
1352 size_t count, loff_t *ppos)
1354 return do_rw_proc(0, file, buf, count, ppos);
1357 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1358 size_t count, loff_t *ppos)
1360 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1364 * proc_dostring - read a string sysctl
1365 * @table: the sysctl table
1366 * @write: %TRUE if this is a write to the sysctl file
1367 * @filp: the file structure
1368 * @buffer: the user buffer
1369 * @lenp: the size of the user buffer
1371 * Reads/writes a string from/to the user buffer. If the kernel
1372 * buffer provided is not large enough to hold the string, the
1373 * string is truncated. The copied string is %NULL-terminated.
1374 * If the string is being read by the user process, it is copied
1375 * and a newline '\n' is added. It is truncated if the buffer is
1378 * Returns 0 on success.
1380 int proc_dostring(ctl_table *table, int write, struct file *filp,
1381 void __user *buffer, size_t *lenp)
1387 if (!table->data || !table->maxlen || !*lenp ||
1388 (filp->f_pos && !write)) {
1396 while (len < *lenp) {
1397 if (get_user(c, p++))
1399 if (c == 0 || c == '\n')
1403 if (len >= table->maxlen)
1404 len = table->maxlen-1;
1405 if(copy_from_user(table->data, buffer, len))
1407 ((char *) table->data)[len] = 0;
1408 filp->f_pos += *lenp;
1410 len = strlen(table->data);
1411 if (len > table->maxlen)
1412 len = table->maxlen;
1416 if(copy_to_user(buffer, table->data, len))
1419 if(put_user('\n', ((char __user *) buffer) + len))
1430 * Special case of dostring for the UTS structure. This has locks
1431 * to observe. Should this be in kernel/sys.c ????
1434 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1435 void __user *buffer, size_t *lenp)
1440 down_read(&uts_sem);
1441 r=proc_dostring(table,0,filp,buffer,lenp);
1444 down_write(&uts_sem);
1445 r=proc_dostring(table,1,filp,buffer,lenp);
1451 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1453 int write, void *data)
1456 *valp = *negp ? -*lvalp : *lvalp;
1461 *lvalp = (unsigned long)-val;
1464 *lvalp = (unsigned long)val;
1470 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1471 void __user *buffer, size_t *lenp,
1472 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1473 int write, void *data),
1476 #define TMPBUFLEN 20
1477 int *i, vleft, first=1, neg, val;
1481 char buf[TMPBUFLEN], *p;
1482 char __user *s = buffer;
1484 if (!table->data || !table->maxlen || !*lenp ||
1485 (filp->f_pos && !write)) {
1490 i = (int *) table->data;
1491 vleft = table->maxlen / sizeof(*i);
1495 conv = do_proc_dointvec_conv;
1497 for (; left && vleft--; i++, first=0) {
1512 if (len > sizeof(buf) - 1)
1513 len = sizeof(buf) - 1;
1514 if (copy_from_user(buf, s, len))
1518 if (*p == '-' && left > 1) {
1522 if (*p < '0' || *p > '9')
1525 lval = simple_strtoul(p, &p, 0);
1528 if ((len < left) && *p && !isspace(*p))
1535 if (conv(&neg, &lval, i, 1, data))
1542 if (conv(&neg, &lval, i, 0, data))
1545 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1549 if(copy_to_user(s, buf, len))
1556 if (!write && !first && left) {
1557 if(put_user('\n', s))
1564 if (get_user(c, s++))
1574 filp->f_pos += *lenp;
1580 * proc_dointvec - read a vector of integers
1581 * @table: the sysctl table
1582 * @write: %TRUE if this is a write to the sysctl file
1583 * @filp: the file structure
1584 * @buffer: the user buffer
1585 * @lenp: the size of the user buffer
1587 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1588 * values from/to the user buffer, treated as an ASCII string.
1590 * Returns 0 on success.
1592 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1593 void __user *buffer, size_t *lenp)
1595 return do_proc_dointvec(table,write,filp,buffer,lenp,
1605 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1607 int write, void *data)
1609 int op = *(int *)data;
1611 int val = *negp ? -*lvalp : *lvalp;
1613 case OP_SET: *valp = val; break;
1614 case OP_AND: *valp &= val; break;
1615 case OP_OR: *valp |= val; break;
1616 case OP_MAX: if(*valp < val)
1619 case OP_MIN: if(*valp > val)
1627 *lvalp = (unsigned long)-val;
1630 *lvalp = (unsigned long)val;
1637 * init may raise the set.
1640 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1641 void __user *buffer, size_t *lenp)
1645 if (!capable(CAP_SYS_MODULE)) {
1649 op = (current->pid == 1) ? OP_SET : OP_AND;
1650 return do_proc_dointvec(table,write,filp,buffer,lenp,
1651 do_proc_dointvec_bset_conv,&op);
1654 struct do_proc_dointvec_minmax_conv_param {
1659 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1661 int write, void *data)
1663 struct do_proc_dointvec_minmax_conv_param *param = data;
1665 int val = *negp ? -*lvalp : *lvalp;
1666 if ((param->min && *param->min > val) ||
1667 (param->max && *param->max < val))
1674 *lvalp = (unsigned long)-val;
1677 *lvalp = (unsigned long)val;
1684 * proc_dointvec_minmax - read a vector of integers with min/max values
1685 * @table: the sysctl table
1686 * @write: %TRUE if this is a write to the sysctl file
1687 * @filp: the file structure
1688 * @buffer: the user buffer
1689 * @lenp: the size of the user buffer
1691 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1692 * values from/to the user buffer, treated as an ASCII string.
1694 * This routine will ensure the values are within the range specified by
1695 * table->extra1 (min) and table->extra2 (max).
1697 * Returns 0 on success.
1699 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1700 void __user *buffer, size_t *lenp)
1702 struct do_proc_dointvec_minmax_conv_param param = {
1703 .min = (int *) table->extra1,
1704 .max = (int *) table->extra2,
1706 return do_proc_dointvec(table, write, filp, buffer, lenp,
1707 do_proc_dointvec_minmax_conv, ¶m);
1710 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1712 void __user *buffer, size_t *lenp,
1713 unsigned long convmul,
1714 unsigned long convdiv)
1716 #define TMPBUFLEN 20
1717 unsigned long *i, *min, *max, val;
1718 int vleft, first=1, neg;
1720 char buf[TMPBUFLEN], *p;
1721 char __user *s = buffer;
1723 if (!table->data || !table->maxlen || !*lenp ||
1724 (filp->f_pos && !write)) {
1729 i = (unsigned long *) table->data;
1730 min = (unsigned long *) table->extra1;
1731 max = (unsigned long *) table->extra2;
1732 vleft = table->maxlen / sizeof(unsigned long);
1735 for (; left && vleft--; i++, min++, max++, first=0) {
1750 if (len > TMPBUFLEN-1)
1752 if (copy_from_user(buf, s, len))
1756 if (*p == '-' && left > 1) {
1760 if (*p < '0' || *p > '9')
1762 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1764 if ((len < left) && *p && !isspace(*p))
1773 if ((min && val < *min) || (max && val > *max))
1780 sprintf(p, "%lu", convdiv * (*i) / convmul);
1784 if(copy_to_user(s, buf, len))
1791 if (!write && !first && left) {
1792 if(put_user('\n', s))
1799 if (get_user(c, s++))
1809 filp->f_pos += *lenp;
1815 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1816 * @table: the sysctl table
1817 * @write: %TRUE if this is a write to the sysctl file
1818 * @filp: the file structure
1819 * @buffer: the user buffer
1820 * @lenp: the size of the user buffer
1822 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1823 * values from/to the user buffer, treated as an ASCII string.
1825 * This routine will ensure the values are within the range specified by
1826 * table->extra1 (min) and table->extra2 (max).
1828 * Returns 0 on success.
1830 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1831 void __user *buffer, size_t *lenp)
1833 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1837 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values 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. The values
1846 * are treated as milliseconds, and converted to jiffies when they are stored.
1848 * This routine will ensure the values are within the range specified by
1849 * table->extra1 (min) and table->extra2 (max).
1851 * Returns 0 on success.
1853 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1855 void __user *buffer, size_t *lenp)
1857 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1862 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1864 int write, void *data)
1867 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1873 lval = (unsigned long)-val;
1876 lval = (unsigned long)val;
1883 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1885 int write, void *data)
1888 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1894 lval = (unsigned long)-val;
1897 lval = (unsigned long)val;
1899 *lvalp = jiffies_to_clock_t(lval);
1905 * proc_dointvec_jiffies - read a vector of integers as seconds
1906 * @table: the sysctl table
1907 * @write: %TRUE if this is a write to the sysctl file
1908 * @filp: the file structure
1909 * @buffer: the user buffer
1910 * @lenp: the size of the user buffer
1912 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1913 * values from/to the user buffer, treated as an ASCII string.
1914 * The values read are assumed to be in seconds, and are converted into
1917 * Returns 0 on success.
1919 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1920 void __user *buffer, size_t *lenp)
1922 return do_proc_dointvec(table,write,filp,buffer,lenp,
1923 do_proc_dointvec_jiffies_conv,NULL);
1927 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ 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 1/USER_HZ seconds, and
1937 * are converted into jiffies.
1939 * Returns 0 on success.
1941 int proc_dointvec_userhz_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_userhz_jiffies_conv,NULL);
1948 #else /* CONFIG_PROC_FS */
1950 int proc_dostring(ctl_table *table, int write, struct file *filp,
1951 void __user *buffer, size_t *lenp)
1956 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1957 void __user *buffer, size_t *lenp)
1962 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1963 void __user *buffer, size_t *lenp)
1968 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1969 void __user *buffer, size_t *lenp)
1974 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1975 void __user *buffer, size_t *lenp)
1980 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1981 void __user *buffer, size_t *lenp)
1986 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1987 void __user *buffer, size_t *lenp)
1992 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1993 void __user *buffer, size_t *lenp)
1998 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2000 void __user *buffer, size_t *lenp)
2006 #endif /* CONFIG_PROC_FS */
2010 * General sysctl support routines
2013 /* The generic string strategy routine: */
2014 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2015 void __user *oldval, size_t __user *oldlenp,
2016 void __user *newval, size_t newlen, void **context)
2020 if (!table->data || !table->maxlen)
2023 if (oldval && oldlenp) {
2024 if (get_user(len, oldlenp))
2027 l = strlen(table->data);
2028 if (len > l) len = l;
2029 if (len >= table->maxlen)
2030 len = table->maxlen;
2031 if(copy_to_user(oldval, table->data, len))
2033 if(put_user(0, ((char __user *) oldval) + len))
2035 if(put_user(len, oldlenp))
2039 if (newval && newlen) {
2041 if (len > table->maxlen)
2042 len = table->maxlen;
2043 if(copy_from_user(table->data, newval, len))
2045 if (len == table->maxlen)
2047 ((char *) table->data)[len] = 0;
2053 * This function makes sure that all of the integers in the vector
2054 * are between the minimum and maximum values given in the arrays
2055 * table->extra1 and table->extra2, respectively.
2057 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2058 void __user *oldval, size_t __user *oldlenp,
2059 void __user *newval, size_t newlen, void **context)
2062 if (newval && newlen) {
2063 int __user *vec = (int __user *) newval;
2064 int *min = (int *) table->extra1;
2065 int *max = (int *) table->extra2;
2069 if (newlen % sizeof(int) != 0)
2072 if (!table->extra1 && !table->extra2)
2075 if (newlen > table->maxlen)
2076 newlen = table->maxlen;
2077 length = newlen / sizeof(int);
2079 for (i = 0; i < length; i++) {
2081 if (get_user(value, vec + i))
2083 if (min && value < min[i])
2085 if (max && value > max[i])
2092 /* Strategy function to convert jiffies to seconds */
2093 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2094 void __user *oldval, size_t __user *oldlenp,
2095 void __user *newval, size_t newlen, void **context)
2100 if (get_user(olen, oldlenp))
2102 if (olen!=sizeof(int))
2105 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2106 (oldlenp && put_user(sizeof(int),oldlenp)))
2109 if (newval && newlen) {
2111 if (newlen != sizeof(int))
2113 if (get_user(new, (int __user *)newval))
2115 *(int *)(table->data) = new*HZ;
2121 #else /* CONFIG_SYSCTL */
2124 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2129 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2130 void __user *oldval, size_t __user *oldlenp,
2131 void __user *newval, size_t newlen, void **context)
2136 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2137 void __user *oldval, size_t __user *oldlenp,
2138 void __user *newval, size_t newlen, void **context)
2143 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2144 void __user *oldval, size_t __user *oldlenp,
2145 void __user *newval, size_t newlen, void **context)
2150 int proc_dostring(ctl_table *table, int write, struct file *filp,
2151 void __user *buffer, size_t *lenp)
2156 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2157 void __user *buffer, size_t *lenp)
2162 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2163 void __user *buffer, size_t *lenp)
2168 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2169 void __user *buffer, size_t *lenp)
2174 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2175 void __user *buffer, size_t *lenp)
2180 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2181 void __user *buffer, size_t *lenp)
2186 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2187 void __user *buffer, size_t *lenp)
2192 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2194 void __user *buffer, size_t *lenp)
2199 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2205 void unregister_sysctl_table(struct ctl_table_header * table)
2209 #endif /* CONFIG_SYSCTL */
2212 * No sense putting this after each symbol definition, twice,
2213 * exception granted :-)
2215 EXPORT_SYMBOL(proc_dointvec);
2216 EXPORT_SYMBOL(proc_dointvec_jiffies);
2217 EXPORT_SYMBOL(proc_dointvec_minmax);
2218 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2219 EXPORT_SYMBOL(proc_dostring);
2220 EXPORT_SYMBOL(proc_doulongvec_minmax);
2221 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2222 EXPORT_SYMBOL(register_sysctl_table);
2223 EXPORT_SYMBOL(sysctl_intvec);
2224 EXPORT_SYMBOL(sysctl_jiffies);
2225 EXPORT_SYMBOL(sysctl_string);
2226 EXPORT_SYMBOL(unregister_sysctl_table);