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 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
69 static int maxolduid = 65535;
72 static int ngroups_max = NGROUPS_MAX;
75 extern char modprobe_path[];
78 extern char hotplug_path[];
80 extern char vshelper_path[];
81 #ifdef CONFIG_CHR_DEV_SG
82 extern int sg_big_buff;
85 extern size_t shm_ctlmax;
86 extern size_t shm_ctlall;
87 extern int shm_ctlmni;
88 extern int msg_ctlmax;
89 extern int msg_ctlmnb;
90 extern int msg_ctlmni;
91 extern int sem_ctls[];
95 extern char reboot_command [];
96 extern int stop_a_enabled;
97 extern int scons_pwroff;
101 extern int pwrsw_enabled;
102 extern int unaligned_enabled;
105 #ifdef CONFIG_ARCH_S390
106 #ifdef CONFIG_MATHEMU
107 extern int sysctl_ieee_emulation_warnings;
109 extern int sysctl_userprocess_debug;
112 extern int sysctl_hz_timer;
114 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
115 extern unsigned long powersave_nap;
116 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
117 void __user *buffer, size_t *lenp, loff_t *ppos);
120 #ifdef CONFIG_BSD_PROCESS_ACCT
121 extern int acct_parm[];
124 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
125 ctl_table *, void **);
126 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
127 void __user *buffer, size_t *lenp, loff_t *ppos);
129 static ctl_table root_table[];
130 static struct ctl_table_header root_table_header =
131 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
133 static ctl_table kern_table[];
134 static ctl_table vm_table[];
136 extern ctl_table net_table[];
138 static ctl_table proc_table[];
139 static ctl_table fs_table[];
140 static ctl_table debug_table[];
141 static ctl_table dev_table[];
142 extern ctl_table random_table[];
143 #ifdef CONFIG_UNIX98_PTYS
144 extern ctl_table pty_table[];
147 /* /proc declarations: */
149 #ifdef CONFIG_PROC_FS
151 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
152 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
153 static int proc_opensys(struct inode *, struct file *);
155 struct file_operations proc_sys_file_operations = {
156 .open = proc_opensys,
157 .read = proc_readsys,
158 .write = proc_writesys,
161 extern struct proc_dir_entry *proc_sys_root;
163 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
164 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
167 /* The default sysctl tables: */
169 static ctl_table root_table[] = {
171 .ctl_name = CTL_KERN,
172 .procname = "kernel",
191 .ctl_name = CTL_PROC,
203 .ctl_name = CTL_DEBUG,
206 .child = debug_table,
217 static ctl_table kern_table[] = {
219 .ctl_name = KERN_OSTYPE,
220 .procname = "ostype",
221 .data = system_utsname.sysname,
222 .maxlen = sizeof(system_utsname.sysname),
224 .proc_handler = &proc_doutsstring,
225 .strategy = &sysctl_string,
228 .ctl_name = KERN_OSRELEASE,
229 .procname = "osrelease",
230 .data = system_utsname.release,
231 .maxlen = sizeof(system_utsname.release),
233 .proc_handler = &proc_doutsstring,
234 .strategy = &sysctl_string,
237 .ctl_name = KERN_VERSION,
238 .procname = "version",
239 .data = system_utsname.version,
240 .maxlen = sizeof(system_utsname.version),
242 .proc_handler = &proc_doutsstring,
243 .strategy = &sysctl_string,
246 .ctl_name = KERN_NODENAME,
247 .procname = "hostname",
248 .data = system_utsname.nodename,
249 .maxlen = sizeof(system_utsname.nodename),
251 .proc_handler = &proc_doutsstring,
252 .strategy = &sysctl_string,
255 .ctl_name = KERN_DOMAINNAME,
256 .procname = "domainname",
257 .data = system_utsname.domainname,
258 .maxlen = sizeof(system_utsname.domainname),
260 .proc_handler = &proc_doutsstring,
261 .strategy = &sysctl_string,
264 .ctl_name = KERN_PANIC,
266 .data = &panic_timeout,
267 .maxlen = sizeof(int),
269 .proc_handler = &proc_dointvec,
272 .ctl_name = KERN_CORE_USES_PID,
273 .procname = "core_uses_pid",
274 .data = &core_uses_pid,
275 .maxlen = sizeof(int),
277 .proc_handler = &proc_dointvec,
280 .ctl_name = KERN_CORE_PATTERN,
281 .procname = "core_pattern",
282 .data = core_pattern,
285 .proc_handler = &proc_dostring,
286 .strategy = &sysctl_string,
289 .ctl_name = KERN_TAINTED,
290 .procname = "tainted",
292 .maxlen = sizeof(int),
294 .proc_handler = &proc_dointvec,
297 .ctl_name = KERN_CAP_BSET,
298 .procname = "cap-bound",
300 .maxlen = sizeof(kernel_cap_t),
302 .proc_handler = &proc_dointvec_bset,
304 #ifdef CONFIG_BLK_DEV_INITRD
306 .ctl_name = KERN_REALROOTDEV,
307 .procname = "real-root-dev",
308 .data = &real_root_dev,
309 .maxlen = sizeof(int),
311 .proc_handler = &proc_dointvec,
316 .ctl_name = KERN_SPARC_REBOOT,
317 .procname = "reboot-cmd",
318 .data = reboot_command,
321 .proc_handler = &proc_dostring,
322 .strategy = &sysctl_string,
325 .ctl_name = KERN_SPARC_STOP_A,
326 .procname = "stop-a",
327 .data = &stop_a_enabled,
328 .maxlen = sizeof (int),
330 .proc_handler = &proc_dointvec,
333 .ctl_name = KERN_SPARC_SCONS_PWROFF,
334 .procname = "scons-poweroff",
335 .data = &scons_pwroff,
336 .maxlen = sizeof (int),
338 .proc_handler = &proc_dointvec,
343 .ctl_name = KERN_HPPA_PWRSW,
344 .procname = "soft-power",
345 .data = &pwrsw_enabled,
346 .maxlen = sizeof (int),
348 .proc_handler = &proc_dointvec,
351 .ctl_name = KERN_HPPA_UNALIGNED,
352 .procname = "unaligned-trap",
353 .data = &unaligned_enabled,
354 .maxlen = sizeof (int),
356 .proc_handler = &proc_dointvec,
359 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
361 .ctl_name = KERN_PPC_POWERSAVE_NAP,
362 .procname = "powersave-nap",
363 .data = &powersave_nap,
364 .maxlen = sizeof(int),
366 .proc_handler = &proc_dointvec,
369 .ctl_name = KERN_PPC_L2CR,
372 .proc_handler = &proc_dol2crvec,
376 .ctl_name = KERN_CTLALTDEL,
377 .procname = "ctrl-alt-del",
379 .maxlen = sizeof(int),
381 .proc_handler = &proc_dointvec,
384 .ctl_name = KERN_PRINTK,
385 .procname = "printk",
386 .data = &console_loglevel,
387 .maxlen = 4*sizeof(int),
389 .proc_handler = &proc_dointvec,
393 .ctl_name = KERN_MODPROBE,
394 .procname = "modprobe",
395 .data = &modprobe_path,
396 .maxlen = KMOD_PATH_LEN,
398 .proc_handler = &proc_dostring,
399 .strategy = &sysctl_string,
402 #ifdef CONFIG_HOTPLUG
404 .ctl_name = KERN_HOTPLUG,
405 .procname = "hotplug",
406 .data = &hotplug_path,
407 .maxlen = KMOD_PATH_LEN,
409 .proc_handler = &proc_dostring,
410 .strategy = &sysctl_string,
414 .ctl_name = KERN_VSHELPER,
415 .procname = "vshelper",
416 .data = &vshelper_path,
419 .proc_handler = &proc_dostring,
420 .strategy = &sysctl_string,
422 #ifdef CONFIG_CHR_DEV_SG
424 .ctl_name = KERN_SG_BIG_BUFF,
425 .procname = "sg-big-buff",
426 .data = &sg_big_buff,
427 .maxlen = sizeof (int),
429 .proc_handler = &proc_dointvec,
432 #ifdef CONFIG_BSD_PROCESS_ACCT
434 .ctl_name = KERN_ACCT,
437 .maxlen = 3*sizeof(int),
439 .proc_handler = &proc_dointvec,
442 #ifdef CONFIG_SYSVIPC
444 .ctl_name = KERN_SHMMAX,
445 .procname = "shmmax",
447 .maxlen = sizeof (size_t),
449 .proc_handler = &proc_doulongvec_minmax,
452 .ctl_name = KERN_SHMALL,
453 .procname = "shmall",
455 .maxlen = sizeof (size_t),
457 .proc_handler = &proc_doulongvec_minmax,
460 .ctl_name = KERN_SHMMNI,
461 .procname = "shmmni",
463 .maxlen = sizeof (int),
465 .proc_handler = &proc_dointvec,
468 .ctl_name = KERN_MSGMAX,
469 .procname = "msgmax",
471 .maxlen = sizeof (int),
473 .proc_handler = &proc_dointvec,
476 .ctl_name = KERN_MSGMNI,
477 .procname = "msgmni",
479 .maxlen = sizeof (int),
481 .proc_handler = &proc_dointvec,
484 .ctl_name = KERN_MSGMNB,
485 .procname = "msgmnb",
487 .maxlen = sizeof (int),
489 .proc_handler = &proc_dointvec,
492 .ctl_name = KERN_SEM,
495 .maxlen = 4*sizeof (int),
497 .proc_handler = &proc_dointvec,
500 #ifdef CONFIG_MAGIC_SYSRQ
502 .ctl_name = KERN_SYSRQ,
504 .data = &sysrq_enabled,
505 .maxlen = sizeof (int),
507 .proc_handler = &proc_dointvec,
511 .ctl_name = KERN_CADPID,
512 .procname = "cad_pid",
514 .maxlen = sizeof (int),
516 .proc_handler = &proc_dointvec,
519 .ctl_name = KERN_MAX_THREADS,
520 .procname = "threads-max",
521 .data = &max_threads,
522 .maxlen = sizeof(int),
524 .proc_handler = &proc_dointvec,
527 .ctl_name = KERN_RANDOM,
528 .procname = "random",
530 .child = random_table,
532 #ifdef CONFIG_UNIX98_PTYS
534 .ctl_name = KERN_PTY,
541 .ctl_name = KERN_OVERFLOWUID,
542 .procname = "overflowuid",
543 .data = &overflowuid,
544 .maxlen = sizeof(int),
546 .proc_handler = &proc_dointvec_minmax,
547 .strategy = &sysctl_intvec,
548 .extra1 = &minolduid,
549 .extra2 = &maxolduid,
552 .ctl_name = KERN_OVERFLOWGID,
553 .procname = "overflowgid",
554 .data = &overflowgid,
555 .maxlen = sizeof(int),
557 .proc_handler = &proc_dointvec_minmax,
558 .strategy = &sysctl_intvec,
559 .extra1 = &minolduid,
560 .extra2 = &maxolduid,
562 #ifdef CONFIG_ARCH_S390
563 #ifdef CONFIG_MATHEMU
565 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
566 .procname = "ieee_emulation_warnings",
567 .data = &sysctl_ieee_emulation_warnings,
568 .maxlen = sizeof(int),
570 .proc_handler = &proc_dointvec,
573 #ifdef CONFIG_NO_IDLE_HZ
575 .ctl_name = KERN_HZ_TIMER,
576 .procname = "hz_timer",
577 .data = &sysctl_hz_timer,
578 .maxlen = sizeof(int),
580 .proc_handler = &proc_dointvec,
584 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
585 .procname = "userprocess_debug",
586 .data = &sysctl_userprocess_debug,
587 .maxlen = sizeof(int),
589 .proc_handler = &proc_dointvec,
593 .ctl_name = KERN_PIDMAX,
594 .procname = "pid_max",
596 .maxlen = sizeof (int),
598 .proc_handler = &proc_dointvec,
601 .ctl_name = KERN_PANIC_ON_OOPS,
602 .procname = "panic_on_oops",
603 .data = &panic_on_oops,
604 .maxlen = sizeof(int),
606 .proc_handler = &proc_dointvec,
609 .ctl_name = KERN_PRINTK_RATELIMIT,
610 .procname = "printk_ratelimit",
611 .data = &printk_ratelimit_jiffies,
612 .maxlen = sizeof(int),
614 .proc_handler = &proc_dointvec_jiffies,
615 .strategy = &sysctl_jiffies,
618 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
619 .procname = "printk_ratelimit_burst",
620 .data = &printk_ratelimit_burst,
621 .maxlen = sizeof(int),
623 .proc_handler = &proc_dointvec,
626 .ctl_name = KERN_NGROUPS_MAX,
627 .procname = "ngroups_max",
628 .data = &ngroups_max,
629 .maxlen = sizeof (int),
631 .proc_handler = &proc_dointvec,
636 /* Constants for minimum and maximum testing in vm_table.
637 We use these as one-element integer vectors. */
639 static int one_hundred = 100;
642 static ctl_table vm_table[] = {
644 .ctl_name = VM_OVERCOMMIT_MEMORY,
645 .procname = "overcommit_memory",
646 .data = &sysctl_overcommit_memory,
647 .maxlen = sizeof(sysctl_overcommit_memory),
649 .proc_handler = &proc_dointvec,
652 .ctl_name = VM_OVERCOMMIT_RATIO,
653 .procname = "overcommit_ratio",
654 .data = &sysctl_overcommit_ratio,
655 .maxlen = sizeof(sysctl_overcommit_ratio),
657 .proc_handler = &proc_dointvec,
660 .ctl_name = VM_PAGE_CLUSTER,
661 .procname = "page-cluster",
662 .data = &page_cluster,
663 .maxlen = sizeof(int),
665 .proc_handler = &proc_dointvec,
668 .ctl_name = VM_DIRTY_BACKGROUND,
669 .procname = "dirty_background_ratio",
670 .data = &dirty_background_ratio,
671 .maxlen = sizeof(dirty_background_ratio),
673 .proc_handler = &proc_dointvec_minmax,
674 .strategy = &sysctl_intvec,
676 .extra2 = &one_hundred,
679 .ctl_name = VM_DIRTY_RATIO,
680 .procname = "dirty_ratio",
681 .data = &vm_dirty_ratio,
682 .maxlen = sizeof(vm_dirty_ratio),
684 .proc_handler = &proc_dointvec_minmax,
685 .strategy = &sysctl_intvec,
687 .extra2 = &one_hundred,
690 .ctl_name = VM_DIRTY_WB_CS,
691 .procname = "dirty_writeback_centisecs",
692 .data = &dirty_writeback_centisecs,
693 .maxlen = sizeof(dirty_writeback_centisecs),
695 .proc_handler = &dirty_writeback_centisecs_handler,
698 .ctl_name = VM_DIRTY_EXPIRE_CS,
699 .procname = "dirty_expire_centisecs",
700 .data = &dirty_expire_centisecs,
701 .maxlen = sizeof(dirty_expire_centisecs),
703 .proc_handler = &proc_dointvec,
706 .ctl_name = VM_NR_PDFLUSH_THREADS,
707 .procname = "nr_pdflush_threads",
708 .data = &nr_pdflush_threads,
709 .maxlen = sizeof nr_pdflush_threads,
710 .mode = 0444 /* read-only*/,
711 .proc_handler = &proc_dointvec,
714 .ctl_name = VM_SWAPPINESS,
715 .procname = "swappiness",
716 .data = &vm_swappiness,
717 .maxlen = sizeof(vm_swappiness),
719 .proc_handler = &proc_dointvec_minmax,
720 .strategy = &sysctl_intvec,
722 .extra2 = &one_hundred,
724 #ifdef CONFIG_HUGETLB_PAGE
726 .ctl_name = VM_HUGETLB_PAGES,
727 .procname = "nr_hugepages",
728 .data = &max_huge_pages,
729 .maxlen = sizeof(unsigned long),
731 .proc_handler = &hugetlb_sysctl_handler,
732 .extra1 = (void *)&hugetlb_zero,
733 .extra2 = (void *)&hugetlb_infinity,
736 .ctl_name = VM_HUGETLB_GROUP,
737 .procname = "hugetlb_shm_group",
738 .data = &sysctl_hugetlb_shm_group,
739 .maxlen = sizeof(gid_t),
741 .proc_handler = &proc_dointvec,
745 .ctl_name = VM_LOWER_ZONE_PROTECTION,
746 .procname = "lower_zone_protection",
747 .data = &sysctl_lower_zone_protection,
748 .maxlen = sizeof(sysctl_lower_zone_protection),
750 .proc_handler = &lower_zone_protection_sysctl_handler,
751 .strategy = &sysctl_intvec,
755 .ctl_name = VM_MIN_FREE_KBYTES,
756 .procname = "min_free_kbytes",
757 .data = &min_free_kbytes,
758 .maxlen = sizeof(min_free_kbytes),
760 .proc_handler = &min_free_kbytes_sysctl_handler,
761 .strategy = &sysctl_intvec,
765 .ctl_name = VM_MAX_MAP_COUNT,
766 .procname = "max_map_count",
767 .data = &sysctl_max_map_count,
768 .maxlen = sizeof(sysctl_max_map_count),
770 .proc_handler = &proc_dointvec
773 .ctl_name = VM_LAPTOP_MODE,
774 .procname = "laptop_mode",
775 .data = &laptop_mode,
776 .maxlen = sizeof(laptop_mode),
778 .proc_handler = &proc_dointvec,
779 .strategy = &sysctl_intvec,
783 .ctl_name = VM_BLOCK_DUMP,
784 .procname = "block_dump",
786 .maxlen = sizeof(block_dump),
788 .proc_handler = &proc_dointvec,
789 .strategy = &sysctl_intvec,
793 .ctl_name = VM_VFS_CACHE_PRESSURE,
794 .procname = "vfs_cache_pressure",
795 .data = &sysctl_vfs_cache_pressure,
796 .maxlen = sizeof(sysctl_vfs_cache_pressure),
798 .proc_handler = &proc_dointvec,
799 .strategy = &sysctl_intvec,
805 static ctl_table proc_table[] = {
809 static ctl_table fs_table[] = {
811 .ctl_name = FS_NRINODE,
812 .procname = "inode-nr",
813 .data = &inodes_stat,
814 .maxlen = 2*sizeof(int),
816 .proc_handler = &proc_dointvec,
819 .ctl_name = FS_STATINODE,
820 .procname = "inode-state",
821 .data = &inodes_stat,
822 .maxlen = 7*sizeof(int),
824 .proc_handler = &proc_dointvec,
827 .ctl_name = FS_NRFILE,
828 .procname = "file-nr",
830 .maxlen = 3*sizeof(int),
832 .proc_handler = &proc_dointvec,
835 .ctl_name = FS_MAXFILE,
836 .procname = "file-max",
837 .data = &files_stat.max_files,
838 .maxlen = sizeof(int),
840 .proc_handler = &proc_dointvec,
843 .ctl_name = FS_DENTRY,
844 .procname = "dentry-state",
845 .data = &dentry_stat,
846 .maxlen = 6*sizeof(int),
848 .proc_handler = &proc_dointvec,
851 .ctl_name = FS_OVERFLOWUID,
852 .procname = "overflowuid",
853 .data = &fs_overflowuid,
854 .maxlen = sizeof(int),
856 .proc_handler = &proc_dointvec_minmax,
857 .strategy = &sysctl_intvec,
858 .extra1 = &minolduid,
859 .extra2 = &maxolduid,
862 .ctl_name = FS_OVERFLOWGID,
863 .procname = "overflowgid",
864 .data = &fs_overflowgid,
865 .maxlen = sizeof(int),
867 .proc_handler = &proc_dointvec_minmax,
868 .strategy = &sysctl_intvec,
869 .extra1 = &minolduid,
870 .extra2 = &maxolduid,
873 .ctl_name = FS_LEASES,
874 .procname = "leases-enable",
875 .data = &leases_enable,
876 .maxlen = sizeof(int),
878 .proc_handler = &proc_dointvec,
881 .ctl_name = FS_DIR_NOTIFY,
882 .procname = "dir-notify-enable",
883 .data = &dir_notify_enable,
884 .maxlen = sizeof(int),
886 .proc_handler = &proc_dointvec,
889 .ctl_name = FS_LEASE_TIME,
890 .procname = "lease-break-time",
891 .data = &lease_break_time,
892 .maxlen = sizeof(int),
894 .proc_handler = &proc_dointvec,
897 .ctl_name = FS_AIO_NR,
898 .procname = "aio-nr",
900 .maxlen = sizeof(aio_nr),
902 .proc_handler = &proc_dointvec,
905 .ctl_name = FS_AIO_MAX_NR,
906 .procname = "aio-max-nr",
908 .maxlen = sizeof(aio_max_nr),
910 .proc_handler = &proc_dointvec,
915 static ctl_table debug_table[] = {
919 static ctl_table dev_table[] = {
923 extern void init_irq_proc (void);
925 void __init sysctl_init(void)
927 #ifdef CONFIG_PROC_FS
928 register_proc_table(root_table, proc_sys_root);
933 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
934 void __user *newval, size_t newlen)
936 struct list_head *tmp;
938 if (nlen <= 0 || nlen >= CTL_MAXNAME)
942 if (!oldlenp || get_user(old_len, oldlenp))
945 tmp = &root_table_header.ctl_entry;
947 struct ctl_table_header *head =
948 list_entry(tmp, struct ctl_table_header, ctl_entry);
949 void *context = NULL;
950 int error = parse_table(name, nlen, oldval, oldlenp,
951 newval, newlen, head->ctl_table,
955 if (error != -ENOTDIR)
958 } while (tmp != &root_table_header.ctl_entry);
962 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
964 struct __sysctl_args tmp;
967 if (copy_from_user(&tmp, args, sizeof(tmp)))
971 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
972 tmp.newval, tmp.newlen);
978 * ctl_perm does NOT grant the superuser all rights automatically, because
979 * some sysctl variables are readonly even to root.
982 static int test_perm(int mode, int op)
986 else if (in_egroup_p(0))
988 if ((mode & op & 0007) == op)
993 static inline int ctl_perm(ctl_table *table, int op)
996 error = security_sysctl(table, op);
999 return test_perm(table->mode, op);
1002 static int parse_table(int __user *name, int nlen,
1003 void __user *oldval, size_t __user *oldlenp,
1004 void __user *newval, size_t newlen,
1005 ctl_table *table, void **context)
1011 if (get_user(n, name))
1013 for ( ; table->ctl_name; table++) {
1014 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1017 if (ctl_perm(table, 001))
1019 if (table->strategy) {
1020 error = table->strategy(
1023 newval, newlen, context);
1029 table = table->child;
1032 error = do_sysctl_strategy(table, name, nlen,
1034 newval, newlen, context);
1041 /* Perform the actual read/write of a sysctl table entry. */
1042 int do_sysctl_strategy (ctl_table *table,
1043 int __user *name, int nlen,
1044 void __user *oldval, size_t __user *oldlenp,
1045 void __user *newval, size_t newlen, void **context)
1054 if (ctl_perm(table, op))
1057 if (table->strategy) {
1058 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1059 newval, newlen, context);
1066 /* If there is no strategy routine, or if the strategy returns
1067 * zero, proceed with automatic r/w */
1068 if (table->data && table->maxlen) {
1069 if (oldval && oldlenp) {
1070 if (get_user(len, oldlenp))
1073 if (len > table->maxlen)
1074 len = table->maxlen;
1075 if(copy_to_user(oldval, table->data, len))
1077 if(put_user(len, oldlenp))
1081 if (newval && newlen) {
1083 if (len > table->maxlen)
1084 len = table->maxlen;
1085 if(copy_from_user(table->data, newval, len))
1093 * register_sysctl_table - register a sysctl hierarchy
1094 * @table: the top-level table structure
1095 * @insert_at_head: whether the entry should be inserted in front or at the end
1097 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1098 * array. An entry with a ctl_name of 0 terminates the table.
1100 * The members of the &ctl_table structure are used as follows:
1102 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1103 * must be unique within that level of sysctl
1105 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1106 * enter a sysctl file
1108 * data - a pointer to data for use by proc_handler
1110 * maxlen - the maximum size in bytes of the data
1112 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1114 * child - a pointer to the child sysctl table if this entry is a directory, or
1117 * proc_handler - the text handler routine (described below)
1119 * strategy - the strategy routine (described below)
1121 * de - for internal use by the sysctl routines
1123 * extra1, extra2 - extra pointers usable by the proc handler routines
1125 * Leaf nodes in the sysctl tree will be represented by a single file
1126 * under /proc; non-leaf nodes will be represented by directories.
1128 * sysctl(2) can automatically manage read and write requests through
1129 * the sysctl table. The data and maxlen fields of the ctl_table
1130 * struct enable minimal validation of the values being written to be
1131 * performed, and the mode field allows minimal authentication.
1133 * More sophisticated management can be enabled by the provision of a
1134 * strategy routine with the table entry. This will be called before
1135 * any automatic read or write of the data is performed.
1137 * The strategy routine may return
1139 * < 0 - Error occurred (error is passed to user process)
1141 * 0 - OK - proceed with automatic read or write.
1143 * > 0 - OK - read or write has been done by the strategy routine, so
1144 * return immediately.
1146 * There must be a proc_handler routine for any terminal nodes
1147 * mirrored under /proc/sys (non-terminals are handled by a built-in
1148 * directory handler). Several default handlers are available to
1149 * cover common cases -
1151 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1152 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1153 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1155 * It is the handler's job to read the input buffer from user memory
1156 * and process it. The handler should return 0 on success.
1158 * This routine returns %NULL on a failure to register, and a pointer
1159 * to the table header on success.
1161 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1164 struct ctl_table_header *tmp;
1165 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1168 tmp->ctl_table = table;
1169 INIT_LIST_HEAD(&tmp->ctl_entry);
1171 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1173 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1174 #ifdef CONFIG_PROC_FS
1175 register_proc_table(table, proc_sys_root);
1181 * unregister_sysctl_table - unregister a sysctl table hierarchy
1182 * @header: the header returned from register_sysctl_table
1184 * Unregisters the sysctl table and all children. proc entries may not
1185 * actually be removed until they are no longer used by anyone.
1187 void unregister_sysctl_table(struct ctl_table_header * header)
1189 list_del(&header->ctl_entry);
1190 #ifdef CONFIG_PROC_FS
1191 unregister_proc_table(header->ctl_table, proc_sys_root);
1200 #ifdef CONFIG_PROC_FS
1202 /* Scan the sysctl entries in table and add them all into /proc */
1203 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1205 struct proc_dir_entry *de;
1209 for (; table->ctl_name; table++) {
1210 /* Can't do anything without a proc name. */
1211 if (!table->procname)
1213 /* Maybe we can't do anything with it... */
1214 if (!table->proc_handler && !table->child) {
1215 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1220 len = strlen(table->procname);
1224 if (table->proc_handler)
1228 for (de = root->subdir; de; de = de->next) {
1229 if (proc_match(len, table->procname, de))
1232 /* If the subdir exists already, de is non-NULL */
1236 de = create_proc_entry(table->procname, mode, root);
1239 de->data = (void *) table;
1240 if (table->proc_handler)
1241 de->proc_fops = &proc_sys_file_operations;
1244 if (de->mode & S_IFDIR)
1245 register_proc_table(table->child, de);
1250 * Unregister a /proc sysctl table and any subdirectories.
1252 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1254 struct proc_dir_entry *de;
1255 for (; table->ctl_name; table++) {
1256 if (!(de = table->de))
1258 if (de->mode & S_IFDIR) {
1259 if (!table->child) {
1260 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1263 unregister_proc_table(table->child, de);
1265 /* Don't unregister directories which still have entries.. */
1270 /* Don't unregister proc entries that are still being used.. */
1271 if (atomic_read(&de->count))
1275 remove_proc_entry(table->procname, root);
1279 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1280 size_t count, loff_t *ppos)
1283 struct proc_dir_entry *de;
1284 struct ctl_table *table;
1288 de = PDE(file->f_dentry->d_inode);
1289 if (!de || !de->data)
1291 table = (struct ctl_table *) de->data;
1292 if (!table || !table->proc_handler)
1294 op = (write ? 002 : 004);
1295 if (ctl_perm(table, op))
1300 error = (*table->proc_handler) (table, write, file, buf, &res, ppos);
1306 static int proc_opensys(struct inode *inode, struct file *file)
1308 if (file->f_mode & FMODE_WRITE) {
1310 * sysctl entries that are not writable,
1311 * are _NOT_ writable, capabilities or not.
1313 if (!(inode->i_mode & S_IWUSR))
1320 static ssize_t proc_readsys(struct file * file, char __user * buf,
1321 size_t count, loff_t *ppos)
1323 return do_rw_proc(0, file, buf, count, ppos);
1326 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1327 size_t count, loff_t *ppos)
1329 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1333 * proc_dostring - read a string sysctl
1334 * @table: the sysctl table
1335 * @write: %TRUE if this is a write to the sysctl file
1336 * @filp: the file structure
1337 * @buffer: the user buffer
1338 * @lenp: the size of the user buffer
1340 * Reads/writes a string from/to the user buffer. If the kernel
1341 * buffer provided is not large enough to hold the string, the
1342 * string is truncated. The copied string is %NULL-terminated.
1343 * If the string is being read by the user process, it is copied
1344 * and a newline '\n' is added. It is truncated if the buffer is
1347 * Returns 0 on success.
1349 int proc_dostring(ctl_table *table, int write, struct file *filp,
1350 void __user *buffer, size_t *lenp, loff_t *ppos)
1356 if (!table->data || !table->maxlen || !*lenp ||
1357 (*ppos && !write)) {
1365 while (len < *lenp) {
1366 if (get_user(c, p++))
1368 if (c == 0 || c == '\n')
1372 if (len >= table->maxlen)
1373 len = table->maxlen-1;
1374 if(copy_from_user(table->data, buffer, len))
1376 ((char *) table->data)[len] = 0;
1379 len = strlen(table->data);
1380 if (len > table->maxlen)
1381 len = table->maxlen;
1385 if(copy_to_user(buffer, table->data, len))
1388 if(put_user('\n', ((char __user *) buffer) + len))
1399 * Special case of dostring for the UTS structure. This has locks
1400 * to observe. Should this be in kernel/sys.c ????
1403 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1404 void __user *buffer, size_t *lenp, loff_t *ppos)
1409 down_read(&uts_sem);
1410 r=proc_dostring(table,0,filp,buffer,lenp, ppos);
1413 down_write(&uts_sem);
1414 r=proc_dostring(table,1,filp,buffer,lenp, ppos);
1420 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1422 int write, void *data)
1425 *valp = *negp ? -*lvalp : *lvalp;
1430 *lvalp = (unsigned long)-val;
1433 *lvalp = (unsigned long)val;
1439 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1440 void __user *buffer, size_t *lenp, loff_t *ppos,
1441 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1442 int write, void *data),
1445 #define TMPBUFLEN 21
1446 int *i, vleft, first=1, neg, val;
1450 char buf[TMPBUFLEN], *p;
1451 char __user *s = buffer;
1453 if (!table->data || !table->maxlen || !*lenp ||
1454 (*ppos && !write)) {
1459 i = (int *) table->data;
1460 vleft = table->maxlen / sizeof(*i);
1464 conv = do_proc_dointvec_conv;
1466 for (; left && vleft--; i++, first=0) {
1481 if (len > sizeof(buf) - 1)
1482 len = sizeof(buf) - 1;
1483 if (copy_from_user(buf, s, len))
1487 if (*p == '-' && left > 1) {
1491 if (*p < '0' || *p > '9')
1494 lval = simple_strtoul(p, &p, 0);
1497 if ((len < left) && *p && !isspace(*p))
1504 if (conv(&neg, &lval, i, 1, data))
1511 if (conv(&neg, &lval, i, 0, data))
1514 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1518 if(copy_to_user(s, buf, len))
1525 if (!write && !first && left) {
1526 if(put_user('\n', s))
1533 if (get_user(c, s++))
1549 * proc_dointvec - read a vector of integers
1550 * @table: the sysctl table
1551 * @write: %TRUE if this is a write to the sysctl file
1552 * @filp: the file structure
1553 * @buffer: the user buffer
1554 * @lenp: the size of the user buffer
1556 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1557 * values from/to the user buffer, treated as an ASCII string.
1559 * Returns 0 on success.
1561 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1562 void __user *buffer, size_t *lenp, loff_t *ppos)
1564 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1574 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1576 int write, void *data)
1578 int op = *(int *)data;
1580 int val = *negp ? -*lvalp : *lvalp;
1582 case OP_SET: *valp = val; break;
1583 case OP_AND: *valp &= val; break;
1584 case OP_OR: *valp |= val; break;
1585 case OP_MAX: if(*valp < val)
1588 case OP_MIN: if(*valp > val)
1596 *lvalp = (unsigned long)-val;
1599 *lvalp = (unsigned long)val;
1606 * init may raise the set.
1609 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1610 void __user *buffer, size_t *lenp, loff_t *ppos)
1614 if (!capable(CAP_SYS_MODULE)) {
1618 op = (current->pid == 1) ? OP_SET : OP_AND;
1619 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1620 do_proc_dointvec_bset_conv,&op);
1623 struct do_proc_dointvec_minmax_conv_param {
1628 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1630 int write, void *data)
1632 struct do_proc_dointvec_minmax_conv_param *param = data;
1634 int val = *negp ? -*lvalp : *lvalp;
1635 if ((param->min && *param->min > val) ||
1636 (param->max && *param->max < val))
1643 *lvalp = (unsigned long)-val;
1646 *lvalp = (unsigned long)val;
1653 * proc_dointvec_minmax - read a vector of integers with min/max values
1654 * @table: the sysctl table
1655 * @write: %TRUE if this is a write to the sysctl file
1656 * @filp: the file structure
1657 * @buffer: the user buffer
1658 * @lenp: the size of the user buffer
1660 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1661 * values from/to the user buffer, treated as an ASCII string.
1663 * This routine will ensure the values are within the range specified by
1664 * table->extra1 (min) and table->extra2 (max).
1666 * Returns 0 on success.
1668 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1669 void __user *buffer, size_t *lenp, loff_t *ppos)
1671 struct do_proc_dointvec_minmax_conv_param param = {
1672 .min = (int *) table->extra1,
1673 .max = (int *) table->extra2,
1675 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
1676 do_proc_dointvec_minmax_conv, ¶m);
1679 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1681 void __user *buffer,
1682 size_t *lenp, loff_t *ppos,
1683 unsigned long convmul,
1684 unsigned long convdiv)
1686 #define TMPBUFLEN 21
1687 unsigned long *i, *min, *max, val;
1688 int vleft, first=1, neg;
1690 char buf[TMPBUFLEN], *p;
1691 char __user *s = buffer;
1693 if (!table->data || !table->maxlen || !*lenp ||
1694 (*ppos && !write)) {
1699 i = (unsigned long *) table->data;
1700 min = (unsigned long *) table->extra1;
1701 max = (unsigned long *) table->extra2;
1702 vleft = table->maxlen / sizeof(unsigned long);
1705 for (; left && vleft--; i++, min++, max++, first=0) {
1720 if (len > TMPBUFLEN-1)
1722 if (copy_from_user(buf, s, len))
1726 if (*p == '-' && left > 1) {
1730 if (*p < '0' || *p > '9')
1732 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1734 if ((len < left) && *p && !isspace(*p))
1743 if ((min && val < *min) || (max && val > *max))
1750 sprintf(p, "%lu", convdiv * (*i) / convmul);
1754 if(copy_to_user(s, buf, len))
1761 if (!write && !first && left) {
1762 if(put_user('\n', s))
1769 if (get_user(c, s++))
1785 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1786 * @table: the sysctl table
1787 * @write: %TRUE if this is a write to the sysctl file
1788 * @filp: the file structure
1789 * @buffer: the user buffer
1790 * @lenp: the size of the user buffer
1792 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1793 * values from/to the user buffer, treated as an ASCII string.
1795 * This routine will ensure the values are within the range specified by
1796 * table->extra1 (min) and table->extra2 (max).
1798 * Returns 0 on success.
1800 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1801 void __user *buffer, size_t *lenp, loff_t *ppos)
1803 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
1807 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1808 * @table: the sysctl table
1809 * @write: %TRUE if this is a write to the sysctl file
1810 * @filp: the file structure
1811 * @buffer: the user buffer
1812 * @lenp: the size of the user buffer
1814 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1815 * values from/to the user buffer, treated as an ASCII string. The values
1816 * are treated as milliseconds, and converted to jiffies when they are stored.
1818 * This routine will ensure the values are within the range specified by
1819 * table->extra1 (min) and table->extra2 (max).
1821 * Returns 0 on success.
1823 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1825 void __user *buffer,
1826 size_t *lenp, loff_t *ppos)
1828 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1829 lenp, ppos, HZ, 1000l);
1833 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1835 int write, void *data)
1838 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1844 lval = (unsigned long)-val;
1847 lval = (unsigned long)val;
1854 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1856 int write, void *data)
1859 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1865 lval = (unsigned long)-val;
1868 lval = (unsigned long)val;
1870 *lvalp = jiffies_to_clock_t(lval);
1876 * proc_dointvec_jiffies - read a vector of integers as seconds
1877 * @table: the sysctl table
1878 * @write: %TRUE if this is a write to the sysctl file
1879 * @filp: the file structure
1880 * @buffer: the user buffer
1881 * @lenp: the size of the user buffer
1883 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1884 * values from/to the user buffer, treated as an ASCII string.
1885 * The values read are assumed to be in seconds, and are converted into
1888 * Returns 0 on success.
1890 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1891 void __user *buffer, size_t *lenp, loff_t *ppos)
1893 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1894 do_proc_dointvec_jiffies_conv,NULL);
1898 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1899 * @table: the sysctl table
1900 * @write: %TRUE if this is a write to the sysctl file
1901 * @filp: the file structure
1902 * @buffer: the user buffer
1903 * @lenp: the size of the user buffer
1905 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1906 * values from/to the user buffer, treated as an ASCII string.
1907 * The values read are assumed to be in 1/USER_HZ seconds, and
1908 * are converted into jiffies.
1910 * Returns 0 on success.
1912 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1913 void __user *buffer, size_t *lenp, loff_t *ppos)
1915 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1916 do_proc_dointvec_userhz_jiffies_conv,NULL);
1919 #else /* CONFIG_PROC_FS */
1921 int proc_dostring(ctl_table *table, int write, struct file *filp,
1922 void __user *buffer, size_t *lenp, loff_t *ppos)
1927 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1928 void __user *buffer, size_t *lenp, loff_t *ppos)
1933 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1934 void __user *buffer, size_t *lenp, loff_t *ppos)
1939 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1940 void __user *buffer, size_t *lenp, loff_t *ppos)
1945 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1946 void __user *buffer, size_t *lenp, loff_t *ppos)
1951 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1952 void __user *buffer, size_t *lenp, loff_t *ppos)
1957 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1958 void __user *buffer, size_t *lenp, loff_t *ppos)
1963 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1964 void __user *buffer, size_t *lenp, loff_t *ppos)
1969 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1971 void __user *buffer,
1972 size_t *lenp, loff_t *ppos)
1978 #endif /* CONFIG_PROC_FS */
1982 * General sysctl support routines
1985 /* The generic string strategy routine: */
1986 int sysctl_string(ctl_table *table, int __user *name, int nlen,
1987 void __user *oldval, size_t __user *oldlenp,
1988 void __user *newval, size_t newlen, void **context)
1992 if (!table->data || !table->maxlen)
1995 if (oldval && oldlenp) {
1996 if (get_user(len, oldlenp))
1999 l = strlen(table->data);
2000 if (len > l) len = l;
2001 if (len >= table->maxlen)
2002 len = table->maxlen;
2003 if(copy_to_user(oldval, table->data, len))
2005 if(put_user(0, ((char __user *) oldval) + len))
2007 if(put_user(len, oldlenp))
2011 if (newval && newlen) {
2013 if (len > table->maxlen)
2014 len = table->maxlen;
2015 if(copy_from_user(table->data, newval, len))
2017 if (len == table->maxlen)
2019 ((char *) table->data)[len] = 0;
2025 * This function makes sure that all of the integers in the vector
2026 * are between the minimum and maximum values given in the arrays
2027 * table->extra1 and table->extra2, respectively.
2029 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2030 void __user *oldval, size_t __user *oldlenp,
2031 void __user *newval, size_t newlen, void **context)
2034 if (newval && newlen) {
2035 int __user *vec = (int __user *) newval;
2036 int *min = (int *) table->extra1;
2037 int *max = (int *) table->extra2;
2041 if (newlen % sizeof(int) != 0)
2044 if (!table->extra1 && !table->extra2)
2047 if (newlen > table->maxlen)
2048 newlen = table->maxlen;
2049 length = newlen / sizeof(int);
2051 for (i = 0; i < length; i++) {
2053 if (get_user(value, vec + i))
2055 if (min && value < min[i])
2057 if (max && value > max[i])
2064 /* Strategy function to convert jiffies to seconds */
2065 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2066 void __user *oldval, size_t __user *oldlenp,
2067 void __user *newval, size_t newlen, void **context)
2072 if (get_user(olen, oldlenp))
2074 if (olen!=sizeof(int))
2077 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2078 (oldlenp && put_user(sizeof(int),oldlenp)))
2081 if (newval && newlen) {
2083 if (newlen != sizeof(int))
2085 if (get_user(new, (int __user *)newval))
2087 *(int *)(table->data) = new*HZ;
2093 #else /* CONFIG_SYSCTL */
2096 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2101 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2102 void __user *oldval, size_t __user *oldlenp,
2103 void __user *newval, size_t newlen, void **context)
2108 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2109 void __user *oldval, size_t __user *oldlenp,
2110 void __user *newval, size_t newlen, void **context)
2115 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2116 void __user *oldval, size_t __user *oldlenp,
2117 void __user *newval, size_t newlen, void **context)
2122 int proc_dostring(ctl_table *table, int write, struct file *filp,
2123 void __user *buffer, size_t *lenp, loff_t *ppos)
2128 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2129 void __user *buffer, size_t *lenp, loff_t *ppos)
2134 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2135 void __user *buffer, size_t *lenp, loff_t *ppos)
2140 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2141 void __user *buffer, size_t *lenp, loff_t *ppos)
2146 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2147 void __user *buffer, size_t *lenp, loff_t *ppos)
2152 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2153 void __user *buffer, size_t *lenp, loff_t *ppos)
2158 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2159 void __user *buffer, size_t *lenp, loff_t *ppos)
2164 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2166 void __user *buffer,
2167 size_t *lenp, loff_t *ppos)
2172 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2178 void unregister_sysctl_table(struct ctl_table_header * table)
2182 #endif /* CONFIG_SYSCTL */
2185 * No sense putting this after each symbol definition, twice,
2186 * exception granted :-)
2188 EXPORT_SYMBOL(proc_dointvec);
2189 EXPORT_SYMBOL(proc_dointvec_jiffies);
2190 EXPORT_SYMBOL(proc_dointvec_minmax);
2191 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2192 EXPORT_SYMBOL(proc_dostring);
2193 EXPORT_SYMBOL(proc_doulongvec_minmax);
2194 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2195 EXPORT_SYMBOL(register_sysctl_table);
2196 EXPORT_SYMBOL(sysctl_intvec);
2197 EXPORT_SYMBOL(sysctl_jiffies);
2198 EXPORT_SYMBOL(sysctl_string);
2199 EXPORT_SYMBOL(unregister_sysctl_table);