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 defer_softirqs;
54 extern int panic_timeout;
56 extern int sysctl_overcommit_memory;
57 extern int sysctl_overcommit_ratio;
58 extern int max_threads;
59 extern int sysrq_enabled;
60 extern int core_uses_pid;
61 extern char core_pattern[];
64 extern int sysctl_lower_zone_protection;
65 extern int min_free_kbytes;
66 extern int printk_ratelimit_jiffies;
67 extern int printk_ratelimit_burst;
69 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
70 static int maxolduid = 65535;
73 static int ngroups_max = NGROUPS_MAX;
76 extern char modprobe_path[];
79 extern char hotplug_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_DEFER_SOFTIRQS,
273 .procname = "defer_softirqs",
274 .data = &defer_softirqs,
275 .maxlen = sizeof(int),
277 .proc_handler = &proc_dointvec,
280 .ctl_name = KERN_CORE_USES_PID,
281 .procname = "core_uses_pid",
282 .data = &core_uses_pid,
283 .maxlen = sizeof(int),
285 .proc_handler = &proc_dointvec,
288 .ctl_name = KERN_CORE_PATTERN,
289 .procname = "core_pattern",
290 .data = core_pattern,
293 .proc_handler = &proc_dostring,
294 .strategy = &sysctl_string,
297 .ctl_name = KERN_TAINTED,
298 .procname = "tainted",
300 .maxlen = sizeof(int),
302 .proc_handler = &proc_dointvec,
305 .ctl_name = KERN_CAP_BSET,
306 .procname = "cap-bound",
308 .maxlen = sizeof(kernel_cap_t),
310 .proc_handler = &proc_dointvec_bset,
312 #ifdef CONFIG_BLK_DEV_INITRD
314 .ctl_name = KERN_REALROOTDEV,
315 .procname = "real-root-dev",
316 .data = &real_root_dev,
317 .maxlen = sizeof(int),
319 .proc_handler = &proc_dointvec,
324 .ctl_name = KERN_SPARC_REBOOT,
325 .procname = "reboot-cmd",
326 .data = reboot_command,
329 .proc_handler = &proc_dostring,
330 .strategy = &sysctl_string,
333 .ctl_name = KERN_SPARC_STOP_A,
334 .procname = "stop-a",
335 .data = &stop_a_enabled,
336 .maxlen = sizeof (int),
338 .proc_handler = &proc_dointvec,
341 .ctl_name = KERN_SPARC_SCONS_PWROFF,
342 .procname = "scons-poweroff",
343 .data = &scons_pwroff,
344 .maxlen = sizeof (int),
346 .proc_handler = &proc_dointvec,
351 .ctl_name = KERN_HPPA_PWRSW,
352 .procname = "soft-power",
353 .data = &pwrsw_enabled,
354 .maxlen = sizeof (int),
356 .proc_handler = &proc_dointvec,
359 .ctl_name = KERN_HPPA_UNALIGNED,
360 .procname = "unaligned-trap",
361 .data = &unaligned_enabled,
362 .maxlen = sizeof (int),
364 .proc_handler = &proc_dointvec,
367 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
369 .ctl_name = KERN_PPC_POWERSAVE_NAP,
370 .procname = "powersave-nap",
371 .data = &powersave_nap,
372 .maxlen = sizeof(int),
374 .proc_handler = &proc_dointvec,
377 .ctl_name = KERN_PPC_L2CR,
380 .proc_handler = &proc_dol2crvec,
384 .ctl_name = KERN_CTLALTDEL,
385 .procname = "ctrl-alt-del",
387 .maxlen = sizeof(int),
389 .proc_handler = &proc_dointvec,
392 .ctl_name = KERN_PRINTK,
393 .procname = "printk",
394 .data = &console_loglevel,
395 .maxlen = 4*sizeof(int),
397 .proc_handler = &proc_dointvec,
401 .ctl_name = KERN_MODPROBE,
402 .procname = "modprobe",
403 .data = &modprobe_path,
404 .maxlen = KMOD_PATH_LEN,
406 .proc_handler = &proc_dostring,
407 .strategy = &sysctl_string,
410 #ifdef CONFIG_HOTPLUG
412 .ctl_name = KERN_HOTPLUG,
413 .procname = "hotplug",
414 .data = &hotplug_path,
415 .maxlen = KMOD_PATH_LEN,
417 .proc_handler = &proc_dostring,
418 .strategy = &sysctl_string,
421 #ifdef CONFIG_CHR_DEV_SG
423 .ctl_name = KERN_SG_BIG_BUFF,
424 .procname = "sg-big-buff",
425 .data = &sg_big_buff,
426 .maxlen = sizeof (int),
428 .proc_handler = &proc_dointvec,
431 #ifdef CONFIG_BSD_PROCESS_ACCT
433 .ctl_name = KERN_ACCT,
436 .maxlen = 3*sizeof(int),
438 .proc_handler = &proc_dointvec,
441 #ifdef CONFIG_SYSVIPC
443 .ctl_name = KERN_SHMMAX,
444 .procname = "shmmax",
446 .maxlen = sizeof (size_t),
448 .proc_handler = &proc_doulongvec_minmax,
451 .ctl_name = KERN_SHMALL,
452 .procname = "shmall",
454 .maxlen = sizeof (size_t),
456 .proc_handler = &proc_doulongvec_minmax,
459 .ctl_name = KERN_SHMMNI,
460 .procname = "shmmni",
462 .maxlen = sizeof (int),
464 .proc_handler = &proc_dointvec,
467 .ctl_name = KERN_MSGMAX,
468 .procname = "msgmax",
470 .maxlen = sizeof (int),
472 .proc_handler = &proc_dointvec,
475 .ctl_name = KERN_MSGMNI,
476 .procname = "msgmni",
478 .maxlen = sizeof (int),
480 .proc_handler = &proc_dointvec,
483 .ctl_name = KERN_MSGMNB,
484 .procname = "msgmnb",
486 .maxlen = sizeof (int),
488 .proc_handler = &proc_dointvec,
491 .ctl_name = KERN_SEM,
494 .maxlen = 4*sizeof (int),
496 .proc_handler = &proc_dointvec,
499 #ifdef CONFIG_MAGIC_SYSRQ
501 .ctl_name = KERN_SYSRQ,
503 .data = &sysrq_enabled,
504 .maxlen = sizeof (int),
506 .proc_handler = &proc_dointvec,
510 .ctl_name = KERN_CADPID,
511 .procname = "cad_pid",
513 .maxlen = sizeof (int),
515 .proc_handler = &proc_dointvec,
518 .ctl_name = KERN_MAX_THREADS,
519 .procname = "threads-max",
520 .data = &max_threads,
521 .maxlen = sizeof(int),
523 .proc_handler = &proc_dointvec,
526 .ctl_name = KERN_RANDOM,
527 .procname = "random",
529 .child = random_table,
531 #ifdef CONFIG_UNIX98_PTYS
533 .ctl_name = KERN_PTY,
540 .ctl_name = KERN_OVERFLOWUID,
541 .procname = "overflowuid",
542 .data = &overflowuid,
543 .maxlen = sizeof(int),
545 .proc_handler = &proc_dointvec_minmax,
546 .strategy = &sysctl_intvec,
547 .extra1 = &minolduid,
548 .extra2 = &maxolduid,
551 .ctl_name = KERN_OVERFLOWGID,
552 .procname = "overflowgid",
553 .data = &overflowgid,
554 .maxlen = sizeof(int),
556 .proc_handler = &proc_dointvec_minmax,
557 .strategy = &sysctl_intvec,
558 .extra1 = &minolduid,
559 .extra2 = &maxolduid,
561 #ifdef CONFIG_ARCH_S390
562 #ifdef CONFIG_MATHEMU
564 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
565 .procname = "ieee_emulation_warnings",
566 .data = &sysctl_ieee_emulation_warnings,
567 .maxlen = sizeof(int),
569 .proc_handler = &proc_dointvec,
572 #ifdef CONFIG_NO_IDLE_HZ
574 .ctl_name = KERN_HZ_TIMER,
575 .procname = "hz_timer",
576 .data = &sysctl_hz_timer,
577 .maxlen = sizeof(int),
579 .proc_handler = &proc_dointvec,
583 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
584 .procname = "userprocess_debug",
585 .data = &sysctl_userprocess_debug,
586 .maxlen = sizeof(int),
588 .proc_handler = &proc_dointvec,
592 .ctl_name = KERN_PIDMAX,
593 .procname = "pid_max",
595 .maxlen = sizeof (int),
597 .proc_handler = &proc_dointvec,
600 .ctl_name = KERN_PANIC_ON_OOPS,
601 .procname = "panic_on_oops",
602 .data = &panic_on_oops,
603 .maxlen = sizeof(int),
605 .proc_handler = &proc_dointvec,
608 .ctl_name = KERN_PRINTK_RATELIMIT,
609 .procname = "printk_ratelimit",
610 .data = &printk_ratelimit_jiffies,
611 .maxlen = sizeof(int),
613 .proc_handler = &proc_dointvec_jiffies,
614 .strategy = &sysctl_jiffies,
617 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
618 .procname = "printk_ratelimit_burst",
619 .data = &printk_ratelimit_burst,
620 .maxlen = sizeof(int),
622 .proc_handler = &proc_dointvec,
625 .ctl_name = KERN_NGROUPS_MAX,
626 .procname = "ngroups_max",
627 .data = &ngroups_max,
628 .maxlen = sizeof (int),
630 .proc_handler = &proc_dointvec,
635 /* Constants for minimum and maximum testing in vm_table.
636 We use these as one-element integer vectors. */
638 static int one_hundred = 100;
641 static ctl_table vm_table[] = {
643 .ctl_name = VM_OVERCOMMIT_MEMORY,
644 .procname = "overcommit_memory",
645 .data = &sysctl_overcommit_memory,
646 .maxlen = sizeof(sysctl_overcommit_memory),
648 .proc_handler = &proc_dointvec,
651 .ctl_name = VM_OVERCOMMIT_RATIO,
652 .procname = "overcommit_ratio",
653 .data = &sysctl_overcommit_ratio,
654 .maxlen = sizeof(sysctl_overcommit_ratio),
656 .proc_handler = &proc_dointvec,
659 .ctl_name = VM_PAGE_CLUSTER,
660 .procname = "page-cluster",
661 .data = &page_cluster,
662 .maxlen = sizeof(int),
664 .proc_handler = &proc_dointvec,
667 .ctl_name = VM_DIRTY_BACKGROUND,
668 .procname = "dirty_background_ratio",
669 .data = &dirty_background_ratio,
670 .maxlen = sizeof(dirty_background_ratio),
672 .proc_handler = &proc_dointvec_minmax,
673 .strategy = &sysctl_intvec,
675 .extra2 = &one_hundred,
678 .ctl_name = VM_DIRTY_RATIO,
679 .procname = "dirty_ratio",
680 .data = &vm_dirty_ratio,
681 .maxlen = sizeof(vm_dirty_ratio),
683 .proc_handler = &proc_dointvec_minmax,
684 .strategy = &sysctl_intvec,
686 .extra2 = &one_hundred,
689 .ctl_name = VM_DIRTY_WB_CS,
690 .procname = "dirty_writeback_centisecs",
691 .data = &dirty_writeback_centisecs,
692 .maxlen = sizeof(dirty_writeback_centisecs),
694 .proc_handler = &dirty_writeback_centisecs_handler,
697 .ctl_name = VM_DIRTY_EXPIRE_CS,
698 .procname = "dirty_expire_centisecs",
699 .data = &dirty_expire_centisecs,
700 .maxlen = sizeof(dirty_expire_centisecs),
702 .proc_handler = &proc_dointvec,
705 .ctl_name = VM_NR_PDFLUSH_THREADS,
706 .procname = "nr_pdflush_threads",
707 .data = &nr_pdflush_threads,
708 .maxlen = sizeof nr_pdflush_threads,
709 .mode = 0444 /* read-only*/,
710 .proc_handler = &proc_dointvec,
713 .ctl_name = VM_SWAPPINESS,
714 .procname = "swappiness",
715 .data = &vm_swappiness,
716 .maxlen = sizeof(vm_swappiness),
718 .proc_handler = &proc_dointvec_minmax,
719 .strategy = &sysctl_intvec,
721 .extra2 = &one_hundred,
723 #ifdef CONFIG_HUGETLB_PAGE
725 .ctl_name = VM_HUGETLB_PAGES,
726 .procname = "nr_hugepages",
727 .data = &max_huge_pages,
728 .maxlen = sizeof(unsigned long),
730 .proc_handler = &hugetlb_sysctl_handler,
731 .extra1 = (void *)&hugetlb_zero,
732 .extra2 = (void *)&hugetlb_infinity,
735 .ctl_name = VM_HUGETLB_GROUP,
736 .procname = "hugetlb_shm_group",
737 .data = &sysctl_hugetlb_shm_group,
738 .maxlen = sizeof(gid_t),
740 .proc_handler = &proc_dointvec,
744 .ctl_name = VM_LOWER_ZONE_PROTECTION,
745 .procname = "lower_zone_protection",
746 .data = &sysctl_lower_zone_protection,
747 .maxlen = sizeof(sysctl_lower_zone_protection),
749 .proc_handler = &lower_zone_protection_sysctl_handler,
750 .strategy = &sysctl_intvec,
754 .ctl_name = VM_MIN_FREE_KBYTES,
755 .procname = "min_free_kbytes",
756 .data = &min_free_kbytes,
757 .maxlen = sizeof(min_free_kbytes),
759 .proc_handler = &min_free_kbytes_sysctl_handler,
760 .strategy = &sysctl_intvec,
764 .ctl_name = VM_MAX_MAP_COUNT,
765 .procname = "max_map_count",
766 .data = &sysctl_max_map_count,
767 .maxlen = sizeof(sysctl_max_map_count),
769 .proc_handler = &proc_dointvec
772 .ctl_name = VM_LAPTOP_MODE,
773 .procname = "laptop_mode",
774 .data = &laptop_mode,
775 .maxlen = sizeof(laptop_mode),
777 .proc_handler = &proc_dointvec,
778 .strategy = &sysctl_intvec,
782 .ctl_name = VM_BLOCK_DUMP,
783 .procname = "block_dump",
785 .maxlen = sizeof(block_dump),
787 .proc_handler = &proc_dointvec,
788 .strategy = &sysctl_intvec,
792 .ctl_name = VM_VFS_CACHE_PRESSURE,
793 .procname = "vfs_cache_pressure",
794 .data = &sysctl_vfs_cache_pressure,
795 .maxlen = sizeof(sysctl_vfs_cache_pressure),
797 .proc_handler = &proc_dointvec,
798 .strategy = &sysctl_intvec,
804 static ctl_table proc_table[] = {
808 static ctl_table fs_table[] = {
810 .ctl_name = FS_NRINODE,
811 .procname = "inode-nr",
812 .data = &inodes_stat,
813 .maxlen = 2*sizeof(int),
815 .proc_handler = &proc_dointvec,
818 .ctl_name = FS_STATINODE,
819 .procname = "inode-state",
820 .data = &inodes_stat,
821 .maxlen = 7*sizeof(int),
823 .proc_handler = &proc_dointvec,
826 .ctl_name = FS_NRFILE,
827 .procname = "file-nr",
829 .maxlen = 3*sizeof(int),
831 .proc_handler = &proc_dointvec,
834 .ctl_name = FS_MAXFILE,
835 .procname = "file-max",
836 .data = &files_stat.max_files,
837 .maxlen = sizeof(int),
839 .proc_handler = &proc_dointvec,
842 .ctl_name = FS_DENTRY,
843 .procname = "dentry-state",
844 .data = &dentry_stat,
845 .maxlen = 6*sizeof(int),
847 .proc_handler = &proc_dointvec,
850 .ctl_name = FS_OVERFLOWUID,
851 .procname = "overflowuid",
852 .data = &fs_overflowuid,
853 .maxlen = sizeof(int),
855 .proc_handler = &proc_dointvec_minmax,
856 .strategy = &sysctl_intvec,
857 .extra1 = &minolduid,
858 .extra2 = &maxolduid,
861 .ctl_name = FS_OVERFLOWGID,
862 .procname = "overflowgid",
863 .data = &fs_overflowgid,
864 .maxlen = sizeof(int),
866 .proc_handler = &proc_dointvec_minmax,
867 .strategy = &sysctl_intvec,
868 .extra1 = &minolduid,
869 .extra2 = &maxolduid,
872 .ctl_name = FS_LEASES,
873 .procname = "leases-enable",
874 .data = &leases_enable,
875 .maxlen = sizeof(int),
877 .proc_handler = &proc_dointvec,
880 .ctl_name = FS_DIR_NOTIFY,
881 .procname = "dir-notify-enable",
882 .data = &dir_notify_enable,
883 .maxlen = sizeof(int),
885 .proc_handler = &proc_dointvec,
888 .ctl_name = FS_LEASE_TIME,
889 .procname = "lease-break-time",
890 .data = &lease_break_time,
891 .maxlen = sizeof(int),
893 .proc_handler = &proc_dointvec,
896 .ctl_name = FS_AIO_NR,
897 .procname = "aio-nr",
899 .maxlen = sizeof(aio_nr),
901 .proc_handler = &proc_dointvec,
904 .ctl_name = FS_AIO_MAX_NR,
905 .procname = "aio-max-nr",
907 .maxlen = sizeof(aio_max_nr),
909 .proc_handler = &proc_dointvec,
914 static ctl_table debug_table[] = {
918 static ctl_table dev_table[] = {
922 extern void init_irq_proc (void);
924 void __init sysctl_init(void)
926 #ifdef CONFIG_PROC_FS
927 register_proc_table(root_table, proc_sys_root);
932 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
933 void __user *newval, size_t newlen)
935 struct list_head *tmp;
937 if (nlen <= 0 || nlen >= CTL_MAXNAME)
941 if (!oldlenp || get_user(old_len, oldlenp))
944 tmp = &root_table_header.ctl_entry;
946 struct ctl_table_header *head =
947 list_entry(tmp, struct ctl_table_header, ctl_entry);
948 void *context = NULL;
949 int error = parse_table(name, nlen, oldval, oldlenp,
950 newval, newlen, head->ctl_table,
954 if (error != -ENOTDIR)
957 } while (tmp != &root_table_header.ctl_entry);
961 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
963 struct __sysctl_args tmp;
966 if (copy_from_user(&tmp, args, sizeof(tmp)))
970 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
971 tmp.newval, tmp.newlen);
977 * ctl_perm does NOT grant the superuser all rights automatically, because
978 * some sysctl variables are readonly even to root.
981 static int test_perm(int mode, int op)
985 else if (in_egroup_p(0))
987 if ((mode & op & 0007) == op)
992 static inline int ctl_perm(ctl_table *table, int op)
995 error = security_sysctl(table, op);
998 return test_perm(table->mode, op);
1001 static int parse_table(int __user *name, int nlen,
1002 void __user *oldval, size_t __user *oldlenp,
1003 void __user *newval, size_t newlen,
1004 ctl_table *table, void **context)
1010 if (get_user(n, name))
1012 for ( ; table->ctl_name; table++) {
1013 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1016 if (ctl_perm(table, 001))
1018 if (table->strategy) {
1019 error = table->strategy(
1022 newval, newlen, context);
1028 table = table->child;
1031 error = do_sysctl_strategy(table, name, nlen,
1033 newval, newlen, context);
1040 /* Perform the actual read/write of a sysctl table entry. */
1041 int do_sysctl_strategy (ctl_table *table,
1042 int __user *name, int nlen,
1043 void __user *oldval, size_t __user *oldlenp,
1044 void __user *newval, size_t newlen, void **context)
1053 if (ctl_perm(table, op))
1056 if (table->strategy) {
1057 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1058 newval, newlen, context);
1065 /* If there is no strategy routine, or if the strategy returns
1066 * zero, proceed with automatic r/w */
1067 if (table->data && table->maxlen) {
1068 if (oldval && oldlenp) {
1069 if (get_user(len, oldlenp))
1072 if (len > table->maxlen)
1073 len = table->maxlen;
1074 if(copy_to_user(oldval, table->data, len))
1076 if(put_user(len, oldlenp))
1080 if (newval && newlen) {
1082 if (len > table->maxlen)
1083 len = table->maxlen;
1084 if(copy_from_user(table->data, newval, len))
1092 * register_sysctl_table - register a sysctl hierarchy
1093 * @table: the top-level table structure
1094 * @insert_at_head: whether the entry should be inserted in front or at the end
1096 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1097 * array. An entry with a ctl_name of 0 terminates the table.
1099 * The members of the &ctl_table structure are used as follows:
1101 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1102 * must be unique within that level of sysctl
1104 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1105 * enter a sysctl file
1107 * data - a pointer to data for use by proc_handler
1109 * maxlen - the maximum size in bytes of the data
1111 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1113 * child - a pointer to the child sysctl table if this entry is a directory, or
1116 * proc_handler - the text handler routine (described below)
1118 * strategy - the strategy routine (described below)
1120 * de - for internal use by the sysctl routines
1122 * extra1, extra2 - extra pointers usable by the proc handler routines
1124 * Leaf nodes in the sysctl tree will be represented by a single file
1125 * under /proc; non-leaf nodes will be represented by directories.
1127 * sysctl(2) can automatically manage read and write requests through
1128 * the sysctl table. The data and maxlen fields of the ctl_table
1129 * struct enable minimal validation of the values being written to be
1130 * performed, and the mode field allows minimal authentication.
1132 * More sophisticated management can be enabled by the provision of a
1133 * strategy routine with the table entry. This will be called before
1134 * any automatic read or write of the data is performed.
1136 * The strategy routine may return
1138 * < 0 - Error occurred (error is passed to user process)
1140 * 0 - OK - proceed with automatic read or write.
1142 * > 0 - OK - read or write has been done by the strategy routine, so
1143 * return immediately.
1145 * There must be a proc_handler routine for any terminal nodes
1146 * mirrored under /proc/sys (non-terminals are handled by a built-in
1147 * directory handler). Several default handlers are available to
1148 * cover common cases -
1150 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1151 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1152 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1154 * It is the handler's job to read the input buffer from user memory
1155 * and process it. The handler should return 0 on success.
1157 * This routine returns %NULL on a failure to register, and a pointer
1158 * to the table header on success.
1160 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1163 struct ctl_table_header *tmp;
1164 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1167 tmp->ctl_table = table;
1168 INIT_LIST_HEAD(&tmp->ctl_entry);
1170 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1172 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1173 #ifdef CONFIG_PROC_FS
1174 register_proc_table(table, proc_sys_root);
1180 * unregister_sysctl_table - unregister a sysctl table hierarchy
1181 * @header: the header returned from register_sysctl_table
1183 * Unregisters the sysctl table and all children. proc entries may not
1184 * actually be removed until they are no longer used by anyone.
1186 void unregister_sysctl_table(struct ctl_table_header * header)
1188 list_del(&header->ctl_entry);
1189 #ifdef CONFIG_PROC_FS
1190 unregister_proc_table(header->ctl_table, proc_sys_root);
1199 #ifdef CONFIG_PROC_FS
1201 /* Scan the sysctl entries in table and add them all into /proc */
1202 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1204 struct proc_dir_entry *de;
1208 for (; table->ctl_name; table++) {
1209 /* Can't do anything without a proc name. */
1210 if (!table->procname)
1212 /* Maybe we can't do anything with it... */
1213 if (!table->proc_handler && !table->child) {
1214 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1219 len = strlen(table->procname);
1223 if (table->proc_handler)
1227 for (de = root->subdir; de; de = de->next) {
1228 if (proc_match(len, table->procname, de))
1231 /* If the subdir exists already, de is non-NULL */
1235 de = create_proc_entry(table->procname, mode, root);
1238 de->data = (void *) table;
1239 if (table->proc_handler)
1240 de->proc_fops = &proc_sys_file_operations;
1243 if (de->mode & S_IFDIR)
1244 register_proc_table(table->child, de);
1249 * Unregister a /proc sysctl table and any subdirectories.
1251 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1253 struct proc_dir_entry *de;
1254 for (; table->ctl_name; table++) {
1255 if (!(de = table->de))
1257 if (de->mode & S_IFDIR) {
1258 if (!table->child) {
1259 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1262 unregister_proc_table(table->child, de);
1264 /* Don't unregister directories which still have entries.. */
1269 /* Don't unregister proc entries that are still being used.. */
1270 if (atomic_read(&de->count))
1274 remove_proc_entry(table->procname, root);
1278 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1279 size_t count, loff_t *ppos)
1282 struct proc_dir_entry *de;
1283 struct ctl_table *table;
1287 de = PDE(file->f_dentry->d_inode);
1288 if (!de || !de->data)
1290 table = (struct ctl_table *) de->data;
1291 if (!table || !table->proc_handler)
1293 op = (write ? 002 : 004);
1294 if (ctl_perm(table, op))
1299 error = (*table->proc_handler) (table, write, file, buf, &res, ppos);
1305 static int proc_opensys(struct inode *inode, struct file *file)
1307 if (file->f_mode & FMODE_WRITE) {
1309 * sysctl entries that are not writable,
1310 * are _NOT_ writable, capabilities or not.
1312 if (!(inode->i_mode & S_IWUSR))
1319 static ssize_t proc_readsys(struct file * file, char __user * buf,
1320 size_t count, loff_t *ppos)
1322 return do_rw_proc(0, file, buf, count, ppos);
1325 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1326 size_t count, loff_t *ppos)
1328 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1332 * proc_dostring - read a string sysctl
1333 * @table: the sysctl table
1334 * @write: %TRUE if this is a write to the sysctl file
1335 * @filp: the file structure
1336 * @buffer: the user buffer
1337 * @lenp: the size of the user buffer
1339 * Reads/writes a string from/to the user buffer. If the kernel
1340 * buffer provided is not large enough to hold the string, the
1341 * string is truncated. The copied string is %NULL-terminated.
1342 * If the string is being read by the user process, it is copied
1343 * and a newline '\n' is added. It is truncated if the buffer is
1346 * Returns 0 on success.
1348 int proc_dostring(ctl_table *table, int write, struct file *filp,
1349 void __user *buffer, size_t *lenp, loff_t *ppos)
1355 if (!table->data || !table->maxlen || !*lenp ||
1356 (*ppos && !write)) {
1364 while (len < *lenp) {
1365 if (get_user(c, p++))
1367 if (c == 0 || c == '\n')
1371 if (len >= table->maxlen)
1372 len = table->maxlen-1;
1373 if(copy_from_user(table->data, buffer, len))
1375 ((char *) table->data)[len] = 0;
1378 len = strlen(table->data);
1379 if (len > table->maxlen)
1380 len = table->maxlen;
1384 if(copy_to_user(buffer, table->data, len))
1387 if(put_user('\n', ((char __user *) buffer) + len))
1398 * Special case of dostring for the UTS structure. This has locks
1399 * to observe. Should this be in kernel/sys.c ????
1402 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1403 void __user *buffer, size_t *lenp, loff_t *ppos)
1408 down_read(&uts_sem);
1409 r=proc_dostring(table,0,filp,buffer,lenp, ppos);
1412 down_write(&uts_sem);
1413 r=proc_dostring(table,1,filp,buffer,lenp, ppos);
1419 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1421 int write, void *data)
1424 *valp = *negp ? -*lvalp : *lvalp;
1429 *lvalp = (unsigned long)-val;
1432 *lvalp = (unsigned long)val;
1438 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1439 void __user *buffer, size_t *lenp, loff_t *ppos,
1440 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1441 int write, void *data),
1444 #define TMPBUFLEN 21
1445 int *i, vleft, first=1, neg, val;
1449 char buf[TMPBUFLEN], *p;
1450 char __user *s = buffer;
1452 if (!table->data || !table->maxlen || !*lenp ||
1453 (*ppos && !write)) {
1458 i = (int *) table->data;
1459 vleft = table->maxlen / sizeof(*i);
1463 conv = do_proc_dointvec_conv;
1465 for (; left && vleft--; i++, first=0) {
1480 if (len > sizeof(buf) - 1)
1481 len = sizeof(buf) - 1;
1482 if (copy_from_user(buf, s, len))
1486 if (*p == '-' && left > 1) {
1490 if (*p < '0' || *p > '9')
1493 lval = simple_strtoul(p, &p, 0);
1496 if ((len < left) && *p && !isspace(*p))
1503 if (conv(&neg, &lval, i, 1, data))
1510 if (conv(&neg, &lval, i, 0, data))
1513 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1517 if(copy_to_user(s, buf, len))
1524 if (!write && !first && left) {
1525 if(put_user('\n', s))
1532 if (get_user(c, s++))
1548 * proc_dointvec - read a vector of integers
1549 * @table: the sysctl table
1550 * @write: %TRUE if this is a write to the sysctl file
1551 * @filp: the file structure
1552 * @buffer: the user buffer
1553 * @lenp: the size of the user buffer
1555 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1556 * values from/to the user buffer, treated as an ASCII string.
1558 * Returns 0 on success.
1560 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1561 void __user *buffer, size_t *lenp, loff_t *ppos)
1563 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1573 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1575 int write, void *data)
1577 int op = *(int *)data;
1579 int val = *negp ? -*lvalp : *lvalp;
1581 case OP_SET: *valp = val; break;
1582 case OP_AND: *valp &= val; break;
1583 case OP_OR: *valp |= val; break;
1584 case OP_MAX: if(*valp < val)
1587 case OP_MIN: if(*valp > val)
1595 *lvalp = (unsigned long)-val;
1598 *lvalp = (unsigned long)val;
1605 * init may raise the set.
1608 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1609 void __user *buffer, size_t *lenp, loff_t *ppos)
1613 if (!capable(CAP_SYS_MODULE)) {
1617 op = (current->pid == 1) ? OP_SET : OP_AND;
1618 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1619 do_proc_dointvec_bset_conv,&op);
1622 struct do_proc_dointvec_minmax_conv_param {
1627 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1629 int write, void *data)
1631 struct do_proc_dointvec_minmax_conv_param *param = data;
1633 int val = *negp ? -*lvalp : *lvalp;
1634 if ((param->min && *param->min > val) ||
1635 (param->max && *param->max < val))
1642 *lvalp = (unsigned long)-val;
1645 *lvalp = (unsigned long)val;
1652 * proc_dointvec_minmax - read a vector of integers with min/max values
1653 * @table: the sysctl table
1654 * @write: %TRUE if this is a write to the sysctl file
1655 * @filp: the file structure
1656 * @buffer: the user buffer
1657 * @lenp: the size of the user buffer
1659 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1660 * values from/to the user buffer, treated as an ASCII string.
1662 * This routine will ensure the values are within the range specified by
1663 * table->extra1 (min) and table->extra2 (max).
1665 * Returns 0 on success.
1667 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1668 void __user *buffer, size_t *lenp, loff_t *ppos)
1670 struct do_proc_dointvec_minmax_conv_param param = {
1671 .min = (int *) table->extra1,
1672 .max = (int *) table->extra2,
1674 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
1675 do_proc_dointvec_minmax_conv, ¶m);
1678 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1680 void __user *buffer,
1681 size_t *lenp, loff_t *ppos,
1682 unsigned long convmul,
1683 unsigned long convdiv)
1685 #define TMPBUFLEN 21
1686 unsigned long *i, *min, *max, val;
1687 int vleft, first=1, neg;
1689 char buf[TMPBUFLEN], *p;
1690 char __user *s = buffer;
1692 if (!table->data || !table->maxlen || !*lenp ||
1693 (*ppos && !write)) {
1698 i = (unsigned long *) table->data;
1699 min = (unsigned long *) table->extra1;
1700 max = (unsigned long *) table->extra2;
1701 vleft = table->maxlen / sizeof(unsigned long);
1704 for (; left && vleft--; i++, min++, max++, first=0) {
1719 if (len > TMPBUFLEN-1)
1721 if (copy_from_user(buf, s, len))
1725 if (*p == '-' && left > 1) {
1729 if (*p < '0' || *p > '9')
1731 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1733 if ((len < left) && *p && !isspace(*p))
1742 if ((min && val < *min) || (max && val > *max))
1749 sprintf(p, "%lu", convdiv * (*i) / convmul);
1753 if(copy_to_user(s, buf, len))
1760 if (!write && !first && left) {
1761 if(put_user('\n', s))
1768 if (get_user(c, s++))
1784 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1785 * @table: the sysctl table
1786 * @write: %TRUE if this is a write to the sysctl file
1787 * @filp: the file structure
1788 * @buffer: the user buffer
1789 * @lenp: the size of the user buffer
1791 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1792 * values from/to the user buffer, treated as an ASCII string.
1794 * This routine will ensure the values are within the range specified by
1795 * table->extra1 (min) and table->extra2 (max).
1797 * Returns 0 on success.
1799 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1800 void __user *buffer, size_t *lenp, loff_t *ppos)
1802 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
1806 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1807 * @table: the sysctl table
1808 * @write: %TRUE if this is a write to the sysctl file
1809 * @filp: the file structure
1810 * @buffer: the user buffer
1811 * @lenp: the size of the user buffer
1813 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1814 * values from/to the user buffer, treated as an ASCII string. The values
1815 * are treated as milliseconds, and converted to jiffies when they are stored.
1817 * This routine will ensure the values are within the range specified by
1818 * table->extra1 (min) and table->extra2 (max).
1820 * Returns 0 on success.
1822 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1824 void __user *buffer,
1825 size_t *lenp, loff_t *ppos)
1827 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1828 lenp, ppos, HZ, 1000l);
1832 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1834 int write, void *data)
1837 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1843 lval = (unsigned long)-val;
1846 lval = (unsigned long)val;
1853 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1855 int write, void *data)
1858 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1864 lval = (unsigned long)-val;
1867 lval = (unsigned long)val;
1869 *lvalp = jiffies_to_clock_t(lval);
1875 * proc_dointvec_jiffies - read a vector of integers as seconds
1876 * @table: the sysctl table
1877 * @write: %TRUE if this is a write to the sysctl file
1878 * @filp: the file structure
1879 * @buffer: the user buffer
1880 * @lenp: the size of the user buffer
1882 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1883 * values from/to the user buffer, treated as an ASCII string.
1884 * The values read are assumed to be in seconds, and are converted into
1887 * Returns 0 on success.
1889 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1890 void __user *buffer, size_t *lenp, loff_t *ppos)
1892 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1893 do_proc_dointvec_jiffies_conv,NULL);
1897 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1898 * @table: the sysctl table
1899 * @write: %TRUE if this is a write to the sysctl file
1900 * @filp: the file structure
1901 * @buffer: the user buffer
1902 * @lenp: the size of the user buffer
1904 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1905 * values from/to the user buffer, treated as an ASCII string.
1906 * The values read are assumed to be in 1/USER_HZ seconds, and
1907 * are converted into jiffies.
1909 * Returns 0 on success.
1911 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1912 void __user *buffer, size_t *lenp, loff_t *ppos)
1914 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1915 do_proc_dointvec_userhz_jiffies_conv,NULL);
1918 #else /* CONFIG_PROC_FS */
1920 int proc_dostring(ctl_table *table, int write, struct file *filp,
1921 void __user *buffer, size_t *lenp, loff_t *ppos)
1926 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1927 void __user *buffer, size_t *lenp, loff_t *ppos)
1932 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1933 void __user *buffer, size_t *lenp, loff_t *ppos)
1938 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1939 void __user *buffer, size_t *lenp, loff_t *ppos)
1944 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1945 void __user *buffer, size_t *lenp, loff_t *ppos)
1950 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1951 void __user *buffer, size_t *lenp, loff_t *ppos)
1956 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1957 void __user *buffer, size_t *lenp, loff_t *ppos)
1962 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1963 void __user *buffer, size_t *lenp, loff_t *ppos)
1968 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1970 void __user *buffer,
1971 size_t *lenp, loff_t *ppos)
1977 #endif /* CONFIG_PROC_FS */
1981 * General sysctl support routines
1984 /* The generic string strategy routine: */
1985 int sysctl_string(ctl_table *table, int __user *name, int nlen,
1986 void __user *oldval, size_t __user *oldlenp,
1987 void __user *newval, size_t newlen, void **context)
1991 if (!table->data || !table->maxlen)
1994 if (oldval && oldlenp) {
1995 if (get_user(len, oldlenp))
1998 l = strlen(table->data);
1999 if (len > l) len = l;
2000 if (len >= table->maxlen)
2001 len = table->maxlen;
2002 if(copy_to_user(oldval, table->data, len))
2004 if(put_user(0, ((char __user *) oldval) + len))
2006 if(put_user(len, oldlenp))
2010 if (newval && newlen) {
2012 if (len > table->maxlen)
2013 len = table->maxlen;
2014 if(copy_from_user(table->data, newval, len))
2016 if (len == table->maxlen)
2018 ((char *) table->data)[len] = 0;
2024 * This function makes sure that all of the integers in the vector
2025 * are between the minimum and maximum values given in the arrays
2026 * table->extra1 and table->extra2, respectively.
2028 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2029 void __user *oldval, size_t __user *oldlenp,
2030 void __user *newval, size_t newlen, void **context)
2033 if (newval && newlen) {
2034 int __user *vec = (int __user *) newval;
2035 int *min = (int *) table->extra1;
2036 int *max = (int *) table->extra2;
2040 if (newlen % sizeof(int) != 0)
2043 if (!table->extra1 && !table->extra2)
2046 if (newlen > table->maxlen)
2047 newlen = table->maxlen;
2048 length = newlen / sizeof(int);
2050 for (i = 0; i < length; i++) {
2052 if (get_user(value, vec + i))
2054 if (min && value < min[i])
2056 if (max && value > max[i])
2063 /* Strategy function to convert jiffies to seconds */
2064 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2065 void __user *oldval, size_t __user *oldlenp,
2066 void __user *newval, size_t newlen, void **context)
2071 if (get_user(olen, oldlenp))
2073 if (olen!=sizeof(int))
2076 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2077 (oldlenp && put_user(sizeof(int),oldlenp)))
2080 if (newval && newlen) {
2082 if (newlen != sizeof(int))
2084 if (get_user(new, (int __user *)newval))
2086 *(int *)(table->data) = new*HZ;
2092 #else /* CONFIG_SYSCTL */
2095 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2100 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2101 void __user *oldval, size_t __user *oldlenp,
2102 void __user *newval, size_t newlen, void **context)
2107 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2108 void __user *oldval, size_t __user *oldlenp,
2109 void __user *newval, size_t newlen, void **context)
2114 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2115 void __user *oldval, size_t __user *oldlenp,
2116 void __user *newval, size_t newlen, void **context)
2121 int proc_dostring(ctl_table *table, int write, struct file *filp,
2122 void __user *buffer, size_t *lenp, loff_t *ppos)
2127 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2128 void __user *buffer, size_t *lenp, loff_t *ppos)
2133 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2134 void __user *buffer, size_t *lenp, loff_t *ppos)
2139 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2140 void __user *buffer, size_t *lenp, loff_t *ppos)
2145 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2146 void __user *buffer, size_t *lenp, loff_t *ppos)
2151 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2152 void __user *buffer, size_t *lenp, loff_t *ppos)
2157 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2158 void __user *buffer, size_t *lenp, loff_t *ppos)
2163 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2165 void __user *buffer,
2166 size_t *lenp, loff_t *ppos)
2171 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2177 void unregister_sysctl_table(struct ctl_table_header * table)
2181 #endif /* CONFIG_SYSCTL */
2184 * No sense putting this after each symbol definition, twice,
2185 * exception granted :-)
2187 EXPORT_SYMBOL(proc_dointvec);
2188 EXPORT_SYMBOL(proc_dointvec_jiffies);
2189 EXPORT_SYMBOL(proc_dointvec_minmax);
2190 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2191 EXPORT_SYMBOL(proc_dostring);
2192 EXPORT_SYMBOL(proc_doulongvec_minmax);
2193 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2194 EXPORT_SYMBOL(register_sysctl_table);
2195 EXPORT_SYMBOL(sysctl_intvec);
2196 EXPORT_SYMBOL(sysctl_jiffies);
2197 EXPORT_SYMBOL(sysctl_string);
2198 EXPORT_SYMBOL(unregister_sysctl_table);