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 atomic_t nr_queued_signals;
57 extern int max_queued_signals;
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 *buffer, size_t *lenp);
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);
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,
443 .ctl_name = KERN_RTSIGNR,
444 .procname = "rtsig-nr",
445 .data = &nr_queued_signals,
446 .maxlen = sizeof(int),
448 .proc_handler = &proc_dointvec,
451 .ctl_name = KERN_RTSIGMAX,
452 .procname = "rtsig-max",
453 .data = &max_queued_signals,
454 .maxlen = sizeof(int),
456 .proc_handler = &proc_dointvec,
458 #ifdef CONFIG_SYSVIPC
460 .ctl_name = KERN_SHMMAX,
461 .procname = "shmmax",
463 .maxlen = sizeof (size_t),
465 .proc_handler = &proc_doulongvec_minmax,
468 .ctl_name = KERN_SHMALL,
469 .procname = "shmall",
471 .maxlen = sizeof (size_t),
473 .proc_handler = &proc_doulongvec_minmax,
476 .ctl_name = KERN_SHMMNI,
477 .procname = "shmmni",
479 .maxlen = sizeof (int),
481 .proc_handler = &proc_dointvec,
484 .ctl_name = KERN_MSGMAX,
485 .procname = "msgmax",
487 .maxlen = sizeof (int),
489 .proc_handler = &proc_dointvec,
492 .ctl_name = KERN_MSGMNI,
493 .procname = "msgmni",
495 .maxlen = sizeof (int),
497 .proc_handler = &proc_dointvec,
500 .ctl_name = KERN_MSGMNB,
501 .procname = "msgmnb",
503 .maxlen = sizeof (int),
505 .proc_handler = &proc_dointvec,
508 .ctl_name = KERN_SEM,
511 .maxlen = 4*sizeof (int),
513 .proc_handler = &proc_dointvec,
516 #ifdef CONFIG_MAGIC_SYSRQ
518 .ctl_name = KERN_SYSRQ,
520 .data = &sysrq_enabled,
521 .maxlen = sizeof (int),
523 .proc_handler = &proc_dointvec,
527 .ctl_name = KERN_CADPID,
528 .procname = "cad_pid",
530 .maxlen = sizeof (int),
532 .proc_handler = &proc_dointvec,
535 .ctl_name = KERN_MAX_THREADS,
536 .procname = "threads-max",
537 .data = &max_threads,
538 .maxlen = sizeof(int),
540 .proc_handler = &proc_dointvec,
543 .ctl_name = KERN_RANDOM,
544 .procname = "random",
546 .child = random_table,
548 #ifdef CONFIG_UNIX98_PTYS
550 .ctl_name = KERN_PTY,
557 .ctl_name = KERN_OVERFLOWUID,
558 .procname = "overflowuid",
559 .data = &overflowuid,
560 .maxlen = sizeof(int),
562 .proc_handler = &proc_dointvec_minmax,
563 .strategy = &sysctl_intvec,
564 .extra1 = &minolduid,
565 .extra2 = &maxolduid,
568 .ctl_name = KERN_OVERFLOWGID,
569 .procname = "overflowgid",
570 .data = &overflowgid,
571 .maxlen = sizeof(int),
573 .proc_handler = &proc_dointvec_minmax,
574 .strategy = &sysctl_intvec,
575 .extra1 = &minolduid,
576 .extra2 = &maxolduid,
578 #ifdef CONFIG_ARCH_S390
579 #ifdef CONFIG_MATHEMU
581 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
582 .procname = "ieee_emulation_warnings",
583 .data = &sysctl_ieee_emulation_warnings,
584 .maxlen = sizeof(int),
586 .proc_handler = &proc_dointvec,
589 #ifdef CONFIG_NO_IDLE_HZ
591 .ctl_name = KERN_HZ_TIMER,
592 .procname = "hz_timer",
593 .data = &sysctl_hz_timer,
594 .maxlen = sizeof(int),
596 .proc_handler = &proc_dointvec,
600 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
601 .procname = "userprocess_debug",
602 .data = &sysctl_userprocess_debug,
603 .maxlen = sizeof(int),
605 .proc_handler = &proc_dointvec,
609 .ctl_name = KERN_PIDMAX,
610 .procname = "pid_max",
612 .maxlen = sizeof (int),
614 .proc_handler = &proc_dointvec,
617 .ctl_name = KERN_PANIC_ON_OOPS,
618 .procname = "panic_on_oops",
619 .data = &panic_on_oops,
620 .maxlen = sizeof(int),
622 .proc_handler = &proc_dointvec,
625 .ctl_name = KERN_PRINTK_RATELIMIT,
626 .procname = "printk_ratelimit",
627 .data = &printk_ratelimit_jiffies,
628 .maxlen = sizeof(int),
630 .proc_handler = &proc_dointvec_jiffies,
631 .strategy = &sysctl_jiffies,
634 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
635 .procname = "printk_ratelimit_burst",
636 .data = &printk_ratelimit_burst,
637 .maxlen = sizeof(int),
639 .proc_handler = &proc_dointvec,
642 .ctl_name = KERN_NGROUPS_MAX,
643 .procname = "ngroups_max",
644 .data = &ngroups_max,
645 .maxlen = sizeof (int),
647 .proc_handler = &proc_dointvec,
652 /* Constants for minimum and maximum testing in vm_table.
653 We use these as one-element integer vectors. */
655 static int one_hundred = 100;
658 static ctl_table vm_table[] = {
660 .ctl_name = VM_OVERCOMMIT_MEMORY,
661 .procname = "overcommit_memory",
662 .data = &sysctl_overcommit_memory,
663 .maxlen = sizeof(sysctl_overcommit_memory),
665 .proc_handler = &proc_dointvec,
668 .ctl_name = VM_OVERCOMMIT_RATIO,
669 .procname = "overcommit_ratio",
670 .data = &sysctl_overcommit_ratio,
671 .maxlen = sizeof(sysctl_overcommit_ratio),
673 .proc_handler = &proc_dointvec,
676 .ctl_name = VM_PAGE_CLUSTER,
677 .procname = "page-cluster",
678 .data = &page_cluster,
679 .maxlen = sizeof(int),
681 .proc_handler = &proc_dointvec,
684 .ctl_name = VM_DIRTY_BACKGROUND,
685 .procname = "dirty_background_ratio",
686 .data = &dirty_background_ratio,
687 .maxlen = sizeof(dirty_background_ratio),
689 .proc_handler = &proc_dointvec_minmax,
690 .strategy = &sysctl_intvec,
692 .extra2 = &one_hundred,
695 .ctl_name = VM_DIRTY_RATIO,
696 .procname = "dirty_ratio",
697 .data = &vm_dirty_ratio,
698 .maxlen = sizeof(vm_dirty_ratio),
700 .proc_handler = &proc_dointvec_minmax,
701 .strategy = &sysctl_intvec,
703 .extra2 = &one_hundred,
706 .ctl_name = VM_DIRTY_WB_CS,
707 .procname = "dirty_writeback_centisecs",
708 .data = &dirty_writeback_centisecs,
709 .maxlen = sizeof(dirty_writeback_centisecs),
711 .proc_handler = &dirty_writeback_centisecs_handler,
714 .ctl_name = VM_DIRTY_EXPIRE_CS,
715 .procname = "dirty_expire_centisecs",
716 .data = &dirty_expire_centisecs,
717 .maxlen = sizeof(dirty_expire_centisecs),
719 .proc_handler = &proc_dointvec,
722 .ctl_name = VM_NR_PDFLUSH_THREADS,
723 .procname = "nr_pdflush_threads",
724 .data = &nr_pdflush_threads,
725 .maxlen = sizeof nr_pdflush_threads,
726 .mode = 0444 /* read-only*/,
727 .proc_handler = &proc_dointvec,
730 .ctl_name = VM_SWAPPINESS,
731 .procname = "swappiness",
732 .data = &vm_swappiness,
733 .maxlen = sizeof(vm_swappiness),
735 .proc_handler = &proc_dointvec_minmax,
736 .strategy = &sysctl_intvec,
738 .extra2 = &one_hundred,
740 #ifdef CONFIG_HUGETLB_PAGE
742 .ctl_name = VM_HUGETLB_PAGES,
743 .procname = "nr_hugepages",
744 .data = &max_huge_pages,
745 .maxlen = sizeof(unsigned long),
747 .proc_handler = &hugetlb_sysctl_handler,
748 .extra1 = (void *)&hugetlb_zero,
749 .extra2 = (void *)&hugetlb_infinity,
752 .ctl_name = VM_HUGETLB_GROUP,
753 .procname = "hugetlb_shm_group",
754 .data = &sysctl_hugetlb_shm_group,
755 .maxlen = sizeof(gid_t),
757 .proc_handler = &proc_dointvec,
761 .ctl_name = VM_LOWER_ZONE_PROTECTION,
762 .procname = "lower_zone_protection",
763 .data = &sysctl_lower_zone_protection,
764 .maxlen = sizeof(sysctl_lower_zone_protection),
766 .proc_handler = &lower_zone_protection_sysctl_handler,
767 .strategy = &sysctl_intvec,
771 .ctl_name = VM_MIN_FREE_KBYTES,
772 .procname = "min_free_kbytes",
773 .data = &min_free_kbytes,
774 .maxlen = sizeof(min_free_kbytes),
776 .proc_handler = &min_free_kbytes_sysctl_handler,
777 .strategy = &sysctl_intvec,
781 .ctl_name = VM_MAX_MAP_COUNT,
782 .procname = "max_map_count",
783 .data = &sysctl_max_map_count,
784 .maxlen = sizeof(sysctl_max_map_count),
786 .proc_handler = &proc_dointvec
789 .ctl_name = VM_LAPTOP_MODE,
790 .procname = "laptop_mode",
791 .data = &laptop_mode,
792 .maxlen = sizeof(laptop_mode),
794 .proc_handler = &proc_dointvec,
795 .strategy = &sysctl_intvec,
799 .ctl_name = VM_BLOCK_DUMP,
800 .procname = "block_dump",
802 .maxlen = sizeof(block_dump),
804 .proc_handler = &proc_dointvec,
805 .strategy = &sysctl_intvec,
811 static ctl_table proc_table[] = {
815 static ctl_table fs_table[] = {
817 .ctl_name = FS_NRINODE,
818 .procname = "inode-nr",
819 .data = &inodes_stat,
820 .maxlen = 2*sizeof(int),
822 .proc_handler = &proc_dointvec,
825 .ctl_name = FS_STATINODE,
826 .procname = "inode-state",
827 .data = &inodes_stat,
828 .maxlen = 7*sizeof(int),
830 .proc_handler = &proc_dointvec,
833 .ctl_name = FS_NRFILE,
834 .procname = "file-nr",
836 .maxlen = 3*sizeof(int),
838 .proc_handler = &proc_dointvec,
841 .ctl_name = FS_MAXFILE,
842 .procname = "file-max",
843 .data = &files_stat.max_files,
844 .maxlen = sizeof(int),
846 .proc_handler = &proc_dointvec,
849 .ctl_name = FS_DENTRY,
850 .procname = "dentry-state",
851 .data = &dentry_stat,
852 .maxlen = 6*sizeof(int),
854 .proc_handler = &proc_dointvec,
857 .ctl_name = FS_OVERFLOWUID,
858 .procname = "overflowuid",
859 .data = &fs_overflowuid,
860 .maxlen = sizeof(int),
862 .proc_handler = &proc_dointvec_minmax,
863 .strategy = &sysctl_intvec,
864 .extra1 = &minolduid,
865 .extra2 = &maxolduid,
868 .ctl_name = FS_OVERFLOWGID,
869 .procname = "overflowgid",
870 .data = &fs_overflowgid,
871 .maxlen = sizeof(int),
873 .proc_handler = &proc_dointvec_minmax,
874 .strategy = &sysctl_intvec,
875 .extra1 = &minolduid,
876 .extra2 = &maxolduid,
879 .ctl_name = FS_LEASES,
880 .procname = "leases-enable",
881 .data = &leases_enable,
882 .maxlen = sizeof(int),
884 .proc_handler = &proc_dointvec,
887 .ctl_name = FS_DIR_NOTIFY,
888 .procname = "dir-notify-enable",
889 .data = &dir_notify_enable,
890 .maxlen = sizeof(int),
892 .proc_handler = &proc_dointvec,
895 .ctl_name = FS_LEASE_TIME,
896 .procname = "lease-break-time",
897 .data = &lease_break_time,
898 .maxlen = sizeof(int),
900 .proc_handler = &proc_dointvec,
903 .ctl_name = FS_AIO_NR,
904 .procname = "aio-nr",
906 .maxlen = sizeof(aio_nr),
908 .proc_handler = &proc_dointvec,
911 .ctl_name = FS_AIO_MAX_NR,
912 .procname = "aio-max-nr",
914 .maxlen = sizeof(aio_max_nr),
916 .proc_handler = &proc_dointvec,
921 static ctl_table debug_table[] = {
925 static ctl_table dev_table[] = {
929 extern void init_irq_proc (void);
931 void __init sysctl_init(void)
933 #ifdef CONFIG_PROC_FS
934 register_proc_table(root_table, proc_sys_root);
939 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
940 void __user *newval, size_t newlen)
942 struct list_head *tmp;
944 if (nlen <= 0 || nlen >= CTL_MAXNAME)
948 if (!oldlenp || get_user(old_len, oldlenp))
951 tmp = &root_table_header.ctl_entry;
953 struct ctl_table_header *head =
954 list_entry(tmp, struct ctl_table_header, ctl_entry);
955 void *context = NULL;
956 int error = parse_table(name, nlen, oldval, oldlenp,
957 newval, newlen, head->ctl_table,
961 if (error != -ENOTDIR)
964 } while (tmp != &root_table_header.ctl_entry);
968 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
970 struct __sysctl_args tmp;
973 if (copy_from_user(&tmp, args, sizeof(tmp)))
977 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
978 tmp.newval, tmp.newlen);
984 * ctl_perm does NOT grant the superuser all rights automatically, because
985 * some sysctl variables are readonly even to root.
988 static int test_perm(int mode, int op)
992 else if (in_egroup_p(0))
994 if ((mode & op & 0007) == op)
999 static inline int ctl_perm(ctl_table *table, int op)
1002 error = security_sysctl(table, op);
1005 return test_perm(table->mode, op);
1008 static int parse_table(int __user *name, int nlen,
1009 void __user *oldval, size_t __user *oldlenp,
1010 void __user *newval, size_t newlen,
1011 ctl_table *table, void **context)
1017 if (get_user(n, name))
1019 for ( ; table->ctl_name; table++) {
1020 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1023 if (ctl_perm(table, 001))
1025 if (table->strategy) {
1026 error = table->strategy(
1029 newval, newlen, context);
1035 table = table->child;
1038 error = do_sysctl_strategy(table, name, nlen,
1040 newval, newlen, context);
1047 /* Perform the actual read/write of a sysctl table entry. */
1048 int do_sysctl_strategy (ctl_table *table,
1049 int __user *name, int nlen,
1050 void __user *oldval, size_t __user *oldlenp,
1051 void __user *newval, size_t newlen, void **context)
1060 if (ctl_perm(table, op))
1063 if (table->strategy) {
1064 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1065 newval, newlen, context);
1072 /* If there is no strategy routine, or if the strategy returns
1073 * zero, proceed with automatic r/w */
1074 if (table->data && table->maxlen) {
1075 if (oldval && oldlenp) {
1076 if (get_user(len, oldlenp))
1079 if (len > table->maxlen)
1080 len = table->maxlen;
1081 if(copy_to_user(oldval, table->data, len))
1083 if(put_user(len, oldlenp))
1087 if (newval && newlen) {
1089 if (len > table->maxlen)
1090 len = table->maxlen;
1091 if(copy_from_user(table->data, newval, len))
1099 * register_sysctl_table - register a sysctl hierarchy
1100 * @table: the top-level table structure
1101 * @insert_at_head: whether the entry should be inserted in front or at the end
1103 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1104 * array. An entry with a ctl_name of 0 terminates the table.
1106 * The members of the &ctl_table structure are used as follows:
1108 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1109 * must be unique within that level of sysctl
1111 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1112 * enter a sysctl file
1114 * data - a pointer to data for use by proc_handler
1116 * maxlen - the maximum size in bytes of the data
1118 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1120 * child - a pointer to the child sysctl table if this entry is a directory, or
1123 * proc_handler - the text handler routine (described below)
1125 * strategy - the strategy routine (described below)
1127 * de - for internal use by the sysctl routines
1129 * extra1, extra2 - extra pointers usable by the proc handler routines
1131 * Leaf nodes in the sysctl tree will be represented by a single file
1132 * under /proc; non-leaf nodes will be represented by directories.
1134 * sysctl(2) can automatically manage read and write requests through
1135 * the sysctl table. The data and maxlen fields of the ctl_table
1136 * struct enable minimal validation of the values being written to be
1137 * performed, and the mode field allows minimal authentication.
1139 * More sophisticated management can be enabled by the provision of a
1140 * strategy routine with the table entry. This will be called before
1141 * any automatic read or write of the data is performed.
1143 * The strategy routine may return
1145 * < 0 - Error occurred (error is passed to user process)
1147 * 0 - OK - proceed with automatic read or write.
1149 * > 0 - OK - read or write has been done by the strategy routine, so
1150 * return immediately.
1152 * There must be a proc_handler routine for any terminal nodes
1153 * mirrored under /proc/sys (non-terminals are handled by a built-in
1154 * directory handler). Several default handlers are available to
1155 * cover common cases -
1157 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1158 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1159 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1161 * It is the handler's job to read the input buffer from user memory
1162 * and process it. The handler should return 0 on success.
1164 * This routine returns %NULL on a failure to register, and a pointer
1165 * to the table header on success.
1167 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1170 struct ctl_table_header *tmp;
1171 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1174 tmp->ctl_table = table;
1175 INIT_LIST_HEAD(&tmp->ctl_entry);
1177 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1179 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1180 #ifdef CONFIG_PROC_FS
1181 register_proc_table(table, proc_sys_root);
1187 * unregister_sysctl_table - unregister a sysctl table hierarchy
1188 * @header: the header returned from register_sysctl_table
1190 * Unregisters the sysctl table and all children. proc entries may not
1191 * actually be removed until they are no longer used by anyone.
1193 void unregister_sysctl_table(struct ctl_table_header * header)
1195 list_del(&header->ctl_entry);
1196 #ifdef CONFIG_PROC_FS
1197 unregister_proc_table(header->ctl_table, proc_sys_root);
1206 #ifdef CONFIG_PROC_FS
1208 /* Scan the sysctl entries in table and add them all into /proc */
1209 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1211 struct proc_dir_entry *de;
1215 for (; table->ctl_name; table++) {
1216 /* Can't do anything without a proc name. */
1217 if (!table->procname)
1219 /* Maybe we can't do anything with it... */
1220 if (!table->proc_handler && !table->child) {
1221 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1226 len = strlen(table->procname);
1230 if (table->proc_handler)
1234 for (de = root->subdir; de; de = de->next) {
1235 if (proc_match(len, table->procname, de))
1238 /* If the subdir exists already, de is non-NULL */
1242 de = create_proc_entry(table->procname, mode, root);
1245 de->data = (void *) table;
1246 if (table->proc_handler)
1247 de->proc_fops = &proc_sys_file_operations;
1250 if (de->mode & S_IFDIR)
1251 register_proc_table(table->child, de);
1256 * Unregister a /proc sysctl table and any subdirectories.
1258 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1260 struct proc_dir_entry *de;
1261 for (; table->ctl_name; table++) {
1262 if (!(de = table->de))
1264 if (de->mode & S_IFDIR) {
1265 if (!table->child) {
1266 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1269 unregister_proc_table(table->child, de);
1271 /* Don't unregister directories which still have entries.. */
1276 /* Don't unregister proc entries that are still being used.. */
1277 if (atomic_read(&de->count))
1281 remove_proc_entry(table->procname, root);
1285 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1286 size_t count, loff_t *ppos)
1289 struct proc_dir_entry *de;
1290 struct ctl_table *table;
1294 de = PDE(file->f_dentry->d_inode);
1295 if (!de || !de->data)
1297 table = (struct ctl_table *) de->data;
1298 if (!table || !table->proc_handler)
1300 op = (write ? 002 : 004);
1301 if (ctl_perm(table, op))
1307 * FIXME: we need to pass on ppos to the handler.
1310 error = (*table->proc_handler) (table, write, file, buf, &res);
1316 static int proc_opensys(struct inode *inode, struct file *file)
1318 if (file->f_mode & FMODE_WRITE) {
1320 * sysctl entries that are not writable,
1321 * are _NOT_ writable, capabilities or not.
1323 if (!(inode->i_mode & S_IWUSR))
1330 static ssize_t proc_readsys(struct file * file, char __user * buf,
1331 size_t count, loff_t *ppos)
1333 return do_rw_proc(0, file, buf, count, ppos);
1336 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1337 size_t count, loff_t *ppos)
1339 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1343 * proc_dostring - read a string sysctl
1344 * @table: the sysctl table
1345 * @write: %TRUE if this is a write to the sysctl file
1346 * @filp: the file structure
1347 * @buffer: the user buffer
1348 * @lenp: the size of the user buffer
1350 * Reads/writes a string from/to the user buffer. If the kernel
1351 * buffer provided is not large enough to hold the string, the
1352 * string is truncated. The copied string is %NULL-terminated.
1353 * If the string is being read by the user process, it is copied
1354 * and a newline '\n' is added. It is truncated if the buffer is
1357 * Returns 0 on success.
1359 int proc_dostring(ctl_table *table, int write, struct file *filp,
1360 void __user *buffer, size_t *lenp)
1366 if (!table->data || !table->maxlen || !*lenp ||
1367 (filp->f_pos && !write)) {
1375 while (len < *lenp) {
1376 if (get_user(c, p++))
1378 if (c == 0 || c == '\n')
1382 if (len >= table->maxlen)
1383 len = table->maxlen-1;
1384 if(copy_from_user(table->data, buffer, len))
1386 ((char *) table->data)[len] = 0;
1387 filp->f_pos += *lenp;
1389 len = strlen(table->data);
1390 if (len > table->maxlen)
1391 len = table->maxlen;
1395 if(copy_to_user(buffer, table->data, len))
1398 if(put_user('\n', ((char __user *) buffer) + len))
1409 * Special case of dostring for the UTS structure. This has locks
1410 * to observe. Should this be in kernel/sys.c ????
1413 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1414 void __user *buffer, size_t *lenp)
1419 down_read(&uts_sem);
1420 r=proc_dostring(table,0,filp,buffer,lenp);
1423 down_write(&uts_sem);
1424 r=proc_dostring(table,1,filp,buffer,lenp);
1430 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1432 int write, void *data)
1435 *valp = *negp ? -*lvalp : *lvalp;
1440 *lvalp = (unsigned long)-val;
1443 *lvalp = (unsigned long)val;
1449 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1450 void __user *buffer, size_t *lenp,
1451 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1452 int write, void *data),
1455 #define TMPBUFLEN 20
1456 int *i, vleft, first=1, neg, val;
1460 char buf[TMPBUFLEN], *p;
1461 char __user *s = buffer;
1463 if (!table->data || !table->maxlen || !*lenp ||
1464 (filp->f_pos && !write)) {
1469 i = (int *) table->data;
1470 vleft = table->maxlen / sizeof(*i);
1474 conv = do_proc_dointvec_conv;
1476 for (; left && vleft--; i++, first=0) {
1491 if (len > sizeof(buf) - 1)
1492 len = sizeof(buf) - 1;
1493 if (copy_from_user(buf, s, len))
1497 if (*p == '-' && left > 1) {
1501 if (*p < '0' || *p > '9')
1504 lval = simple_strtoul(p, &p, 0);
1507 if ((len < left) && *p && !isspace(*p))
1514 if (conv(&neg, &lval, i, 1, data))
1521 if (conv(&neg, &lval, i, 0, data))
1524 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1528 if(copy_to_user(s, buf, len))
1535 if (!write && !first && left) {
1536 if(put_user('\n', s))
1543 if (get_user(c, s++))
1553 filp->f_pos += *lenp;
1559 * proc_dointvec - read a vector of integers
1560 * @table: the sysctl table
1561 * @write: %TRUE if this is a write to the sysctl file
1562 * @filp: the file structure
1563 * @buffer: the user buffer
1564 * @lenp: the size of the user buffer
1566 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1567 * values from/to the user buffer, treated as an ASCII string.
1569 * Returns 0 on success.
1571 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1572 void __user *buffer, size_t *lenp)
1574 return do_proc_dointvec(table,write,filp,buffer,lenp,
1584 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1586 int write, void *data)
1588 int op = *(int *)data;
1590 int val = *negp ? -*lvalp : *lvalp;
1592 case OP_SET: *valp = val; break;
1593 case OP_AND: *valp &= val; break;
1594 case OP_OR: *valp |= val; break;
1595 case OP_MAX: if(*valp < val)
1598 case OP_MIN: if(*valp > val)
1606 *lvalp = (unsigned long)-val;
1609 *lvalp = (unsigned long)val;
1616 * init may raise the set.
1619 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1620 void __user *buffer, size_t *lenp)
1624 if (!capable(CAP_SYS_MODULE)) {
1628 op = (current->pid == 1) ? OP_SET : OP_AND;
1629 return do_proc_dointvec(table,write,filp,buffer,lenp,
1630 do_proc_dointvec_bset_conv,&op);
1633 struct do_proc_dointvec_minmax_conv_param {
1638 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1640 int write, void *data)
1642 struct do_proc_dointvec_minmax_conv_param *param = data;
1644 int val = *negp ? -*lvalp : *lvalp;
1645 if ((param->min && *param->min > val) ||
1646 (param->max && *param->max < val))
1653 *lvalp = (unsigned long)-val;
1656 *lvalp = (unsigned long)val;
1663 * proc_dointvec_minmax - read a vector of integers with min/max values
1664 * @table: the sysctl table
1665 * @write: %TRUE if this is a write to the sysctl file
1666 * @filp: the file structure
1667 * @buffer: the user buffer
1668 * @lenp: the size of the user buffer
1670 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1671 * values from/to the user buffer, treated as an ASCII string.
1673 * This routine will ensure the values are within the range specified by
1674 * table->extra1 (min) and table->extra2 (max).
1676 * Returns 0 on success.
1678 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1679 void __user *buffer, size_t *lenp)
1681 struct do_proc_dointvec_minmax_conv_param param = {
1682 .min = (int *) table->extra1,
1683 .max = (int *) table->extra2,
1685 return do_proc_dointvec(table, write, filp, buffer, lenp,
1686 do_proc_dointvec_minmax_conv, ¶m);
1689 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1691 void __user *buffer, size_t *lenp,
1692 unsigned long convmul,
1693 unsigned long convdiv)
1695 #define TMPBUFLEN 20
1696 unsigned long *i, *min, *max, val;
1697 int vleft, first=1, neg;
1699 char buf[TMPBUFLEN], *p;
1700 char __user *s = buffer;
1702 if (!table->data || !table->maxlen || !*lenp ||
1703 (filp->f_pos && !write)) {
1708 i = (unsigned long *) table->data;
1709 min = (unsigned long *) table->extra1;
1710 max = (unsigned long *) table->extra2;
1711 vleft = table->maxlen / sizeof(unsigned long);
1714 for (; left && vleft--; i++, min++, max++, first=0) {
1729 if (len > TMPBUFLEN-1)
1731 if (copy_from_user(buf, s, len))
1735 if (*p == '-' && left > 1) {
1739 if (*p < '0' || *p > '9')
1741 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1743 if ((len < left) && *p && !isspace(*p))
1752 if ((min && val < *min) || (max && val > *max))
1759 sprintf(p, "%lu", convdiv * (*i) / convmul);
1763 if(copy_to_user(s, buf, len))
1770 if (!write && !first && left) {
1771 if(put_user('\n', s))
1778 if (get_user(c, s++))
1788 filp->f_pos += *lenp;
1794 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1795 * @table: the sysctl table
1796 * @write: %TRUE if this is a write to the sysctl file
1797 * @filp: the file structure
1798 * @buffer: the user buffer
1799 * @lenp: the size of the user buffer
1801 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1802 * values from/to the user buffer, treated as an ASCII string.
1804 * This routine will ensure the values are within the range specified by
1805 * table->extra1 (min) and table->extra2 (max).
1807 * Returns 0 on success.
1809 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1810 void __user *buffer, size_t *lenp)
1812 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1816 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1817 * @table: the sysctl table
1818 * @write: %TRUE if this is a write to the sysctl file
1819 * @filp: the file structure
1820 * @buffer: the user buffer
1821 * @lenp: the size of the user buffer
1823 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1824 * values from/to the user buffer, treated as an ASCII string. The values
1825 * are treated as milliseconds, and converted to jiffies when they are stored.
1827 * This routine will ensure the values are within the range specified by
1828 * table->extra1 (min) and table->extra2 (max).
1830 * Returns 0 on success.
1832 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1834 void __user *buffer, size_t *lenp)
1836 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1841 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1843 int write, void *data)
1846 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1852 lval = (unsigned long)-val;
1855 lval = (unsigned long)val;
1862 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1864 int write, void *data)
1867 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1873 lval = (unsigned long)-val;
1876 lval = (unsigned long)val;
1878 *lvalp = jiffies_to_clock_t(lval);
1884 * proc_dointvec_jiffies - read a vector of integers as seconds
1885 * @table: the sysctl table
1886 * @write: %TRUE if this is a write to the sysctl file
1887 * @filp: the file structure
1888 * @buffer: the user buffer
1889 * @lenp: the size of the user buffer
1891 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1892 * values from/to the user buffer, treated as an ASCII string.
1893 * The values read are assumed to be in seconds, and are converted into
1896 * Returns 0 on success.
1898 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1899 void __user *buffer, size_t *lenp)
1901 return do_proc_dointvec(table,write,filp,buffer,lenp,
1902 do_proc_dointvec_jiffies_conv,NULL);
1906 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1907 * @table: the sysctl table
1908 * @write: %TRUE if this is a write to the sysctl file
1909 * @filp: the file structure
1910 * @buffer: the user buffer
1911 * @lenp: the size of the user buffer
1913 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1914 * values from/to the user buffer, treated as an ASCII string.
1915 * The values read are assumed to be in 1/USER_HZ seconds, and
1916 * are converted into jiffies.
1918 * Returns 0 on success.
1920 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1921 void __user *buffer, size_t *lenp)
1923 return do_proc_dointvec(table,write,filp,buffer,lenp,
1924 do_proc_dointvec_userhz_jiffies_conv,NULL);
1927 #else /* CONFIG_PROC_FS */
1929 int proc_dostring(ctl_table *table, int write, struct file *filp,
1930 void __user *buffer, size_t *lenp)
1935 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1936 void __user *buffer, size_t *lenp)
1941 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1942 void __user *buffer, size_t *lenp)
1947 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1948 void __user *buffer, size_t *lenp)
1953 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1954 void __user *buffer, size_t *lenp)
1959 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1960 void __user *buffer, size_t *lenp)
1965 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1966 void __user *buffer, size_t *lenp)
1971 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1972 void __user *buffer, size_t *lenp)
1977 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1979 void __user *buffer, size_t *lenp)
1985 #endif /* CONFIG_PROC_FS */
1989 * General sysctl support routines
1992 /* The generic string strategy routine: */
1993 int sysctl_string(ctl_table *table, int __user *name, int nlen,
1994 void __user *oldval, size_t __user *oldlenp,
1995 void __user *newval, size_t newlen, void **context)
1999 if (!table->data || !table->maxlen)
2002 if (oldval && oldlenp) {
2003 if (get_user(len, oldlenp))
2006 l = strlen(table->data);
2007 if (len > l) len = l;
2008 if (len >= table->maxlen)
2009 len = table->maxlen;
2010 if(copy_to_user(oldval, table->data, len))
2012 if(put_user(0, ((char __user *) oldval) + len))
2014 if(put_user(len, oldlenp))
2018 if (newval && newlen) {
2020 if (len > table->maxlen)
2021 len = table->maxlen;
2022 if(copy_from_user(table->data, newval, len))
2024 if (len == table->maxlen)
2026 ((char *) table->data)[len] = 0;
2032 * This function makes sure that all of the integers in the vector
2033 * are between the minimum and maximum values given in the arrays
2034 * table->extra1 and table->extra2, respectively.
2036 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2037 void __user *oldval, size_t __user *oldlenp,
2038 void __user *newval, size_t newlen, void **context)
2041 if (newval && newlen) {
2042 int __user *vec = (int __user *) newval;
2043 int *min = (int *) table->extra1;
2044 int *max = (int *) table->extra2;
2048 if (newlen % sizeof(int) != 0)
2051 if (!table->extra1 && !table->extra2)
2054 if (newlen > table->maxlen)
2055 newlen = table->maxlen;
2056 length = newlen / sizeof(int);
2058 for (i = 0; i < length; i++) {
2060 if (get_user(value, vec + i))
2062 if (min && value < min[i])
2064 if (max && value > max[i])
2071 /* Strategy function to convert jiffies to seconds */
2072 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2073 void __user *oldval, size_t __user *oldlenp,
2074 void __user *newval, size_t newlen, void **context)
2079 if (get_user(olen, oldlenp))
2081 if (olen!=sizeof(int))
2084 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2085 (oldlenp && put_user(sizeof(int),oldlenp)))
2088 if (newval && newlen) {
2090 if (newlen != sizeof(int))
2092 if (get_user(new, (int __user *)newval))
2094 *(int *)(table->data) = new*HZ;
2100 #else /* CONFIG_SYSCTL */
2103 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2108 int sysctl_string(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_intvec(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 sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2123 void __user *oldval, size_t __user *oldlenp,
2124 void __user *newval, size_t newlen, void **context)
2129 int proc_dostring(ctl_table *table, int write, struct file *filp,
2130 void __user *buffer, size_t *lenp)
2135 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2136 void __user *buffer, size_t *lenp)
2141 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2142 void __user *buffer, size_t *lenp)
2147 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2148 void __user *buffer, size_t *lenp)
2153 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2154 void __user *buffer, size_t *lenp)
2159 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2160 void __user *buffer, size_t *lenp)
2165 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2166 void __user *buffer, size_t *lenp)
2171 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2173 void __user *buffer, size_t *lenp)
2178 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2184 void unregister_sysctl_table(struct ctl_table_header * table)
2188 #endif /* CONFIG_SYSCTL */
2191 * No sense putting this after each symbol definition, twice,
2192 * exception granted :-)
2194 EXPORT_SYMBOL(proc_dointvec);
2195 EXPORT_SYMBOL(proc_dointvec_jiffies);
2196 EXPORT_SYMBOL(proc_dointvec_minmax);
2197 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2198 EXPORT_SYMBOL(proc_dostring);
2199 EXPORT_SYMBOL(proc_doulongvec_minmax);
2200 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2201 EXPORT_SYMBOL(register_sysctl_table);
2202 EXPORT_SYMBOL(sysctl_intvec);
2203 EXPORT_SYMBOL(sysctl_jiffies);
2204 EXPORT_SYMBOL(sysctl_string);
2205 EXPORT_SYMBOL(unregister_sysctl_table);