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 extern unsigned int vdso_enabled;
71 int exec_shield_randomize = 1;
73 static int __init setup_exec_shield(char *str)
75 get_option (&str, &exec_shield);
80 __setup("exec-shield=", setup_exec_shield);
82 static int __init setup_exec_shield_randomize(char *str)
84 get_option (&str, &exec_shield_randomize);
89 __setup("exec-shield-randomize=", setup_exec_shield_randomize);
91 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
92 static int maxolduid = 65535;
95 static int ngroups_max = NGROUPS_MAX;
98 extern char modprobe_path[];
100 #ifdef CONFIG_HOTPLUG
101 extern char hotplug_path[];
103 #ifdef CONFIG_CHR_DEV_SG
104 extern int sg_big_buff;
106 #ifdef CONFIG_SYSVIPC
107 extern size_t shm_ctlmax;
108 extern size_t shm_ctlall;
109 extern int shm_ctlmni;
110 extern int msg_ctlmax;
111 extern int msg_ctlmnb;
112 extern int msg_ctlmni;
113 extern int sem_ctls[];
117 extern char reboot_command [];
118 extern int stop_a_enabled;
119 extern int scons_pwroff;
123 extern int pwrsw_enabled;
124 extern int unaligned_enabled;
127 #ifdef CONFIG_ARCH_S390
128 #ifdef CONFIG_MATHEMU
129 extern int sysctl_ieee_emulation_warnings;
131 extern int sysctl_userprocess_debug;
134 extern int sysctl_hz_timer;
136 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
137 extern unsigned long powersave_nap;
138 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
139 void *buffer, size_t *lenp);
142 #ifdef CONFIG_BSD_PROCESS_ACCT
143 extern int acct_parm[];
146 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
147 ctl_table *, void **);
148 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
149 void __user *buffer, size_t *lenp);
151 static ctl_table root_table[];
152 static struct ctl_table_header root_table_header =
153 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
155 static ctl_table kern_table[];
156 static ctl_table vm_table[];
158 extern ctl_table net_table[];
160 static ctl_table proc_table[];
161 static ctl_table fs_table[];
162 static ctl_table debug_table[];
163 static ctl_table dev_table[];
164 extern ctl_table random_table[];
165 #ifdef CONFIG_UNIX98_PTYS
166 extern ctl_table pty_table[];
169 /* /proc declarations: */
171 #ifdef CONFIG_PROC_FS
173 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
174 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
175 static int proc_opensys(struct inode *, struct file *);
177 struct file_operations proc_sys_file_operations = {
178 .open = proc_opensys,
179 .read = proc_readsys,
180 .write = proc_writesys,
183 extern struct proc_dir_entry *proc_sys_root;
185 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
186 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
189 /* The default sysctl tables: */
191 static ctl_table root_table[] = {
193 .ctl_name = CTL_KERN,
194 .procname = "kernel",
213 .ctl_name = CTL_PROC,
225 .ctl_name = CTL_DEBUG,
228 .child = debug_table,
239 static ctl_table kern_table[] = {
241 .ctl_name = KERN_OSTYPE,
242 .procname = "ostype",
243 .data = system_utsname.sysname,
246 .proc_handler = &proc_doutsstring,
247 .strategy = &sysctl_string,
250 .ctl_name = KERN_OSRELEASE,
251 .procname = "osrelease",
252 .data = system_utsname.release,
255 .proc_handler = &proc_doutsstring,
256 .strategy = &sysctl_string,
259 .ctl_name = KERN_VERSION,
260 .procname = "version",
261 .data = system_utsname.version,
264 .proc_handler = &proc_doutsstring,
265 .strategy = &sysctl_string,
268 .ctl_name = KERN_NODENAME,
269 .procname = "hostname",
270 .data = system_utsname.nodename,
273 .proc_handler = &proc_doutsstring,
274 .strategy = &sysctl_string,
277 .ctl_name = KERN_DOMAINNAME,
278 .procname = "domainname",
279 .data = system_utsname.domainname,
282 .proc_handler = &proc_doutsstring,
283 .strategy = &sysctl_string,
286 .ctl_name = KERN_PANIC,
288 .data = &panic_timeout,
289 .maxlen = sizeof(int),
291 .proc_handler = &proc_dointvec,
294 .ctl_name = KERN_PANIC,
295 .procname = "exec-shield",
296 .data = &exec_shield,
297 .maxlen = sizeof(int),
299 .proc_handler = &proc_dointvec,
302 .ctl_name = KERN_PANIC,
303 .procname = "exec-shield-randomize",
304 .data = &exec_shield_randomize,
305 .maxlen = sizeof(int),
307 .proc_handler = &proc_dointvec,
310 .ctl_name = KERN_PANIC,
311 .procname = "print-fatal-signals",
312 .data = &print_fatal_signals,
313 .maxlen = sizeof(int),
315 .proc_handler = &proc_dointvec,
319 .ctl_name = KERN_PANIC,
321 .data = &vdso_enabled,
322 .maxlen = sizeof(int),
324 .proc_handler = &proc_dointvec,
328 .ctl_name = KERN_CORE_USES_PID,
329 .procname = "core_uses_pid",
330 .data = &core_uses_pid,
331 .maxlen = sizeof(int),
333 .proc_handler = &proc_dointvec,
336 .ctl_name = KERN_CORE_PATTERN,
337 .procname = "core_pattern",
338 .data = core_pattern,
341 .proc_handler = &proc_dostring,
342 .strategy = &sysctl_string,
345 .ctl_name = KERN_TAINTED,
346 .procname = "tainted",
348 .maxlen = sizeof(int),
350 .proc_handler = &proc_dointvec,
353 .ctl_name = KERN_CAP_BSET,
354 .procname = "cap-bound",
356 .maxlen = sizeof(kernel_cap_t),
358 .proc_handler = &proc_dointvec_bset,
360 #ifdef CONFIG_BLK_DEV_INITRD
362 .ctl_name = KERN_REALROOTDEV,
363 .procname = "real-root-dev",
364 .data = &real_root_dev,
365 .maxlen = sizeof(int),
367 .proc_handler = &proc_dointvec,
372 .ctl_name = KERN_SPARC_REBOOT,
373 .procname = "reboot-cmd",
374 .data = reboot_command,
377 .proc_handler = &proc_dostring,
378 .strategy = &sysctl_string,
381 .ctl_name = KERN_SPARC_STOP_A,
382 .procname = "stop-a",
383 .data = &stop_a_enabled,
384 .maxlen = sizeof (int),
386 .proc_handler = &proc_dointvec,
389 .ctl_name = KERN_SPARC_SCONS_PWROFF,
390 .procname = "scons-poweroff",
391 .data = &scons_pwroff,
392 .maxlen = sizeof (int),
394 .proc_handler = &proc_dointvec,
399 .ctl_name = KERN_HPPA_PWRSW,
400 .procname = "soft-power",
401 .data = &pwrsw_enabled,
402 .maxlen = sizeof (int),
404 .proc_handler = &proc_dointvec,
407 .ctl_name = KERN_HPPA_UNALIGNED,
408 .procname = "unaligned-trap",
409 .data = &unaligned_enabled,
410 .maxlen = sizeof (int),
412 .proc_handler = &proc_dointvec,
415 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
417 .ctl_name = KERN_PPC_POWERSAVE_NAP,
418 .procname = "powersave-nap",
419 .data = &powersave_nap,
420 .maxlen = sizeof(int),
422 .proc_handler = &proc_dointvec,
425 .ctl_name = KERN_PPC_L2CR,
428 .proc_handler = &proc_dol2crvec,
432 .ctl_name = KERN_CTLALTDEL,
433 .procname = "ctrl-alt-del",
435 .maxlen = sizeof(int),
437 .proc_handler = &proc_dointvec,
440 .ctl_name = KERN_PRINTK,
441 .procname = "printk",
442 .data = &console_loglevel,
443 .maxlen = 4*sizeof(int),
445 .proc_handler = &proc_dointvec,
449 .ctl_name = KERN_MODPROBE,
450 .procname = "modprobe",
451 .data = &modprobe_path,
454 .proc_handler = &proc_dostring,
455 .strategy = &sysctl_string,
458 #ifdef CONFIG_HOTPLUG
460 .ctl_name = KERN_HOTPLUG,
461 .procname = "hotplug",
462 .data = &hotplug_path,
465 .proc_handler = &proc_dostring,
466 .strategy = &sysctl_string,
469 #ifdef CONFIG_CHR_DEV_SG
471 .ctl_name = KERN_SG_BIG_BUFF,
472 .procname = "sg-big-buff",
473 .data = &sg_big_buff,
474 .maxlen = sizeof (int),
476 .proc_handler = &proc_dointvec,
479 #ifdef CONFIG_BSD_PROCESS_ACCT
481 .ctl_name = KERN_ACCT,
484 .maxlen = 3*sizeof(int),
486 .proc_handler = &proc_dointvec,
490 .ctl_name = KERN_RTSIGNR,
491 .procname = "rtsig-nr",
492 .data = &nr_queued_signals,
493 .maxlen = sizeof(int),
495 .proc_handler = &proc_dointvec,
498 .ctl_name = KERN_RTSIGMAX,
499 .procname = "rtsig-max",
500 .data = &max_queued_signals,
501 .maxlen = sizeof(int),
503 .proc_handler = &proc_dointvec,
505 #ifdef CONFIG_SYSVIPC
507 .ctl_name = KERN_SHMMAX,
508 .procname = "shmmax",
510 .maxlen = sizeof (size_t),
512 .proc_handler = &proc_doulongvec_minmax,
515 .ctl_name = KERN_SHMALL,
516 .procname = "shmall",
518 .maxlen = sizeof (size_t),
520 .proc_handler = &proc_doulongvec_minmax,
523 .ctl_name = KERN_SHMMNI,
524 .procname = "shmmni",
526 .maxlen = sizeof (int),
528 .proc_handler = &proc_dointvec,
531 .ctl_name = KERN_MSGMAX,
532 .procname = "msgmax",
534 .maxlen = sizeof (int),
536 .proc_handler = &proc_dointvec,
539 .ctl_name = KERN_MSGMNI,
540 .procname = "msgmni",
542 .maxlen = sizeof (int),
544 .proc_handler = &proc_dointvec,
547 .ctl_name = KERN_MSGMNB,
548 .procname = "msgmnb",
550 .maxlen = sizeof (int),
552 .proc_handler = &proc_dointvec,
555 .ctl_name = KERN_SEM,
558 .maxlen = 4*sizeof (int),
560 .proc_handler = &proc_dointvec,
563 #ifdef CONFIG_MAGIC_SYSRQ
565 .ctl_name = KERN_SYSRQ,
567 .data = &sysrq_enabled,
568 .maxlen = sizeof (int),
570 .proc_handler = &proc_dointvec,
574 .ctl_name = KERN_CADPID,
575 .procname = "cad_pid",
577 .maxlen = sizeof (int),
579 .proc_handler = &proc_dointvec,
582 .ctl_name = KERN_MAX_THREADS,
583 .procname = "threads-max",
584 .data = &max_threads,
585 .maxlen = sizeof(int),
587 .proc_handler = &proc_dointvec,
590 .ctl_name = KERN_RANDOM,
591 .procname = "random",
593 .child = random_table,
595 #ifdef CONFIG_UNIX98_PTYS
597 .ctl_name = KERN_PTY,
604 .ctl_name = KERN_OVERFLOWUID,
605 .procname = "overflowuid",
606 .data = &overflowuid,
607 .maxlen = sizeof(int),
609 .proc_handler = &proc_dointvec_minmax,
610 .strategy = &sysctl_intvec,
611 .extra1 = &minolduid,
612 .extra2 = &maxolduid,
615 .ctl_name = KERN_OVERFLOWGID,
616 .procname = "overflowgid",
617 .data = &overflowgid,
618 .maxlen = sizeof(int),
620 .proc_handler = &proc_dointvec_minmax,
621 .strategy = &sysctl_intvec,
622 .extra1 = &minolduid,
623 .extra2 = &maxolduid,
625 #ifdef CONFIG_ARCH_S390
626 #ifdef CONFIG_MATHEMU
628 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
629 .procname = "ieee_emulation_warnings",
630 .data = &sysctl_ieee_emulation_warnings,
631 .maxlen = sizeof(int),
633 .proc_handler = &proc_dointvec,
636 #ifdef CONFIG_NO_IDLE_HZ
638 .ctl_name = KERN_HZ_TIMER,
639 .procname = "hz_timer",
640 .data = &sysctl_hz_timer,
641 .maxlen = sizeof(int),
643 .proc_handler = &proc_dointvec,
647 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
648 .procname = "userprocess_debug",
649 .data = &sysctl_userprocess_debug,
650 .maxlen = sizeof(int),
652 .proc_handler = &proc_dointvec,
656 .ctl_name = KERN_PIDMAX,
657 .procname = "pid_max",
659 .maxlen = sizeof (int),
661 .proc_handler = &proc_dointvec,
664 .ctl_name = KERN_PANIC_ON_OOPS,
665 .procname = "panic_on_oops",
666 .data = &panic_on_oops,
667 .maxlen = sizeof(int),
669 .proc_handler = &proc_dointvec,
672 .ctl_name = KERN_PRINTK_RATELIMIT,
673 .procname = "printk_ratelimit",
674 .data = &printk_ratelimit_jiffies,
675 .maxlen = sizeof(int),
677 .proc_handler = &proc_dointvec_jiffies,
678 .strategy = &sysctl_jiffies,
681 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
682 .procname = "printk_ratelimit_burst",
683 .data = &printk_ratelimit_burst,
684 .maxlen = sizeof(int),
686 .proc_handler = &proc_dointvec,
689 .ctl_name = KERN_NGROUPS_MAX,
690 .procname = "ngroups_max",
691 .data = &ngroups_max,
692 .maxlen = sizeof (int),
694 .proc_handler = &proc_dointvec,
699 /* Constants for minimum and maximum testing in vm_table.
700 We use these as one-element integer vectors. */
702 static int one_hundred = 100;
705 static ctl_table vm_table[] = {
707 .ctl_name = VM_OVERCOMMIT_MEMORY,
708 .procname = "overcommit_memory",
709 .data = &sysctl_overcommit_memory,
710 .maxlen = sizeof(sysctl_overcommit_memory),
712 .proc_handler = &proc_dointvec,
715 .ctl_name = VM_OVERCOMMIT_RATIO,
716 .procname = "overcommit_ratio",
717 .data = &sysctl_overcommit_ratio,
718 .maxlen = sizeof(sysctl_overcommit_ratio),
720 .proc_handler = &proc_dointvec,
723 .ctl_name = VM_PAGE_CLUSTER,
724 .procname = "page-cluster",
725 .data = &page_cluster,
726 .maxlen = sizeof(int),
728 .proc_handler = &proc_dointvec,
731 .ctl_name = VM_DIRTY_BACKGROUND,
732 .procname = "dirty_background_ratio",
733 .data = &dirty_background_ratio,
734 .maxlen = sizeof(dirty_background_ratio),
736 .proc_handler = &proc_dointvec_minmax,
737 .strategy = &sysctl_intvec,
739 .extra2 = &one_hundred,
742 .ctl_name = VM_DIRTY_RATIO,
743 .procname = "dirty_ratio",
744 .data = &vm_dirty_ratio,
745 .maxlen = sizeof(vm_dirty_ratio),
747 .proc_handler = &proc_dointvec_minmax,
748 .strategy = &sysctl_intvec,
750 .extra2 = &one_hundred,
753 .ctl_name = VM_DIRTY_WB_CS,
754 .procname = "dirty_writeback_centisecs",
755 .data = &dirty_writeback_centisecs,
756 .maxlen = sizeof(dirty_writeback_centisecs),
758 .proc_handler = &dirty_writeback_centisecs_handler,
761 .ctl_name = VM_DIRTY_EXPIRE_CS,
762 .procname = "dirty_expire_centisecs",
763 .data = &dirty_expire_centisecs,
764 .maxlen = sizeof(dirty_expire_centisecs),
766 .proc_handler = &proc_dointvec,
769 .ctl_name = VM_NR_PDFLUSH_THREADS,
770 .procname = "nr_pdflush_threads",
771 .data = &nr_pdflush_threads,
772 .maxlen = sizeof nr_pdflush_threads,
773 .mode = 0444 /* read-only*/,
774 .proc_handler = &proc_dointvec,
777 .ctl_name = VM_SWAPPINESS,
778 .procname = "swappiness",
779 .data = &vm_swappiness,
780 .maxlen = sizeof(vm_swappiness),
782 .proc_handler = &proc_dointvec_minmax,
783 .strategy = &sysctl_intvec,
785 .extra2 = &one_hundred,
787 #ifdef CONFIG_HUGETLB_PAGE
789 .ctl_name = VM_HUGETLB_PAGES,
790 .procname = "nr_hugepages",
791 .data = &max_huge_pages,
792 .maxlen = sizeof(unsigned long),
794 .proc_handler = &hugetlb_sysctl_handler,
795 .extra1 = (void *)&hugetlb_zero,
796 .extra2 = (void *)&hugetlb_infinity,
800 .ctl_name = VM_LOWER_ZONE_PROTECTION,
801 .procname = "lower_zone_protection",
802 .data = &sysctl_lower_zone_protection,
803 .maxlen = sizeof(sysctl_lower_zone_protection),
805 .proc_handler = &lower_zone_protection_sysctl_handler,
806 .strategy = &sysctl_intvec,
810 .ctl_name = VM_MIN_FREE_KBYTES,
811 .procname = "min_free_kbytes",
812 .data = &min_free_kbytes,
813 .maxlen = sizeof(min_free_kbytes),
815 .proc_handler = &min_free_kbytes_sysctl_handler,
816 .strategy = &sysctl_intvec,
820 .ctl_name = VM_MAX_MAP_COUNT,
821 .procname = "max_map_count",
822 .data = &sysctl_max_map_count,
823 .maxlen = sizeof(sysctl_max_map_count),
825 .proc_handler = &proc_dointvec
828 .ctl_name = VM_LAPTOP_MODE,
829 .procname = "laptop_mode",
830 .data = &laptop_mode,
831 .maxlen = sizeof(laptop_mode),
833 .proc_handler = &proc_dointvec,
834 .strategy = &sysctl_intvec,
838 .ctl_name = VM_BLOCK_DUMP,
839 .procname = "block_dump",
841 .maxlen = sizeof(block_dump),
843 .proc_handler = &proc_dointvec,
844 .strategy = &sysctl_intvec,
850 static ctl_table proc_table[] = {
854 static ctl_table fs_table[] = {
856 .ctl_name = FS_NRINODE,
857 .procname = "inode-nr",
858 .data = &inodes_stat,
859 .maxlen = 2*sizeof(int),
861 .proc_handler = &proc_dointvec,
864 .ctl_name = FS_STATINODE,
865 .procname = "inode-state",
866 .data = &inodes_stat,
867 .maxlen = 7*sizeof(int),
869 .proc_handler = &proc_dointvec,
872 .ctl_name = FS_NRFILE,
873 .procname = "file-nr",
875 .maxlen = 3*sizeof(int),
877 .proc_handler = &proc_dointvec,
880 .ctl_name = FS_MAXFILE,
881 .procname = "file-max",
882 .data = &files_stat.max_files,
883 .maxlen = sizeof(int),
885 .proc_handler = &proc_dointvec,
888 .ctl_name = FS_DENTRY,
889 .procname = "dentry-state",
890 .data = &dentry_stat,
891 .maxlen = 6*sizeof(int),
893 .proc_handler = &proc_dointvec,
896 .ctl_name = FS_OVERFLOWUID,
897 .procname = "overflowuid",
898 .data = &fs_overflowuid,
899 .maxlen = sizeof(int),
901 .proc_handler = &proc_dointvec_minmax,
902 .strategy = &sysctl_intvec,
903 .extra1 = &minolduid,
904 .extra2 = &maxolduid,
907 .ctl_name = FS_OVERFLOWGID,
908 .procname = "overflowgid",
909 .data = &fs_overflowgid,
910 .maxlen = sizeof(int),
912 .proc_handler = &proc_dointvec_minmax,
913 .strategy = &sysctl_intvec,
914 .extra1 = &minolduid,
915 .extra2 = &maxolduid,
918 .ctl_name = FS_LEASES,
919 .procname = "leases-enable",
920 .data = &leases_enable,
921 .maxlen = sizeof(int),
923 .proc_handler = &proc_dointvec,
926 .ctl_name = FS_DIR_NOTIFY,
927 .procname = "dir-notify-enable",
928 .data = &dir_notify_enable,
929 .maxlen = sizeof(int),
931 .proc_handler = &proc_dointvec,
934 .ctl_name = FS_LEASE_TIME,
935 .procname = "lease-break-time",
936 .data = &lease_break_time,
937 .maxlen = sizeof(int),
939 .proc_handler = &proc_dointvec,
942 .ctl_name = FS_AIO_NR,
943 .procname = "aio-nr",
945 .maxlen = sizeof(aio_nr),
947 .proc_handler = &proc_dointvec,
950 .ctl_name = FS_AIO_MAX_NR,
951 .procname = "aio-max-nr",
953 .maxlen = sizeof(aio_max_nr),
955 .proc_handler = &proc_dointvec,
960 static ctl_table debug_table[] = {
964 static ctl_table dev_table[] = {
968 extern void init_irq_proc (void);
970 void __init sysctl_init(void)
972 #ifdef CONFIG_PROC_FS
973 register_proc_table(root_table, proc_sys_root);
978 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
979 void __user *newval, size_t newlen)
981 struct list_head *tmp;
983 if (nlen <= 0 || nlen >= CTL_MAXNAME)
987 if (!oldlenp || get_user(old_len, oldlenp))
990 tmp = &root_table_header.ctl_entry;
992 struct ctl_table_header *head =
993 list_entry(tmp, struct ctl_table_header, ctl_entry);
994 void *context = NULL;
995 int error = parse_table(name, nlen, oldval, oldlenp,
996 newval, newlen, head->ctl_table,
1000 if (error != -ENOTDIR)
1003 } while (tmp != &root_table_header.ctl_entry);
1007 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1009 struct __sysctl_args tmp;
1012 if (copy_from_user(&tmp, args, sizeof(tmp)))
1016 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1017 tmp.newval, tmp.newlen);
1023 * ctl_perm does NOT grant the superuser all rights automatically, because
1024 * some sysctl variables are readonly even to root.
1027 static int test_perm(int mode, int op)
1031 else if (in_egroup_p(0))
1033 if ((mode & op & 0007) == op)
1038 static inline int ctl_perm(ctl_table *table, int op)
1041 error = security_sysctl(table, op);
1044 return test_perm(table->mode, op);
1047 static int parse_table(int __user *name, int nlen,
1048 void __user *oldval, size_t __user *oldlenp,
1049 void __user *newval, size_t newlen,
1050 ctl_table *table, void **context)
1056 if (get_user(n, name))
1058 for ( ; table->ctl_name; table++) {
1059 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1062 if (ctl_perm(table, 001))
1064 if (table->strategy) {
1065 error = table->strategy(
1068 newval, newlen, context);
1074 table = table->child;
1077 error = do_sysctl_strategy(table, name, nlen,
1079 newval, newlen, context);
1086 /* Perform the actual read/write of a sysctl table entry. */
1087 int do_sysctl_strategy (ctl_table *table,
1088 int __user *name, int nlen,
1089 void __user *oldval, size_t __user *oldlenp,
1090 void __user *newval, size_t newlen, void **context)
1099 if (ctl_perm(table, op))
1102 if (table->strategy) {
1103 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1104 newval, newlen, context);
1111 /* If there is no strategy routine, or if the strategy returns
1112 * zero, proceed with automatic r/w */
1113 if (table->data && table->maxlen) {
1114 if (oldval && oldlenp) {
1115 if (get_user(len, oldlenp))
1118 if (len > table->maxlen)
1119 len = table->maxlen;
1120 if(copy_to_user(oldval, table->data, len))
1122 if(put_user(len, oldlenp))
1126 if (newval && newlen) {
1128 if (len > table->maxlen)
1129 len = table->maxlen;
1130 if(copy_from_user(table->data, newval, len))
1138 * register_sysctl_table - register a sysctl hierarchy
1139 * @table: the top-level table structure
1140 * @insert_at_head: whether the entry should be inserted in front or at the end
1142 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1143 * array. An entry with a ctl_name of 0 terminates the table.
1145 * The members of the &ctl_table structure are used as follows:
1147 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1148 * must be unique within that level of sysctl
1150 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1151 * enter a sysctl file
1153 * data - a pointer to data for use by proc_handler
1155 * maxlen - the maximum size in bytes of the data
1157 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1159 * child - a pointer to the child sysctl table if this entry is a directory, or
1162 * proc_handler - the text handler routine (described below)
1164 * strategy - the strategy routine (described below)
1166 * de - for internal use by the sysctl routines
1168 * extra1, extra2 - extra pointers usable by the proc handler routines
1170 * Leaf nodes in the sysctl tree will be represented by a single file
1171 * under /proc; non-leaf nodes will be represented by directories.
1173 * sysctl(2) can automatically manage read and write requests through
1174 * the sysctl table. The data and maxlen fields of the ctl_table
1175 * struct enable minimal validation of the values being written to be
1176 * performed, and the mode field allows minimal authentication.
1178 * More sophisticated management can be enabled by the provision of a
1179 * strategy routine with the table entry. This will be called before
1180 * any automatic read or write of the data is performed.
1182 * The strategy routine may return
1184 * < 0 - Error occurred (error is passed to user process)
1186 * 0 - OK - proceed with automatic read or write.
1188 * > 0 - OK - read or write has been done by the strategy routine, so
1189 * return immediately.
1191 * There must be a proc_handler routine for any terminal nodes
1192 * mirrored under /proc/sys (non-terminals are handled by a built-in
1193 * directory handler). Several default handlers are available to
1194 * cover common cases -
1196 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1197 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1198 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1200 * It is the handler's job to read the input buffer from user memory
1201 * and process it. The handler should return 0 on success.
1203 * This routine returns %NULL on a failure to register, and a pointer
1204 * to the table header on success.
1206 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1209 struct ctl_table_header *tmp;
1210 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1213 tmp->ctl_table = table;
1214 INIT_LIST_HEAD(&tmp->ctl_entry);
1216 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1218 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1219 #ifdef CONFIG_PROC_FS
1220 register_proc_table(table, proc_sys_root);
1226 * unregister_sysctl_table - unregister a sysctl table hierarchy
1227 * @header: the header returned from register_sysctl_table
1229 * Unregisters the sysctl table and all children. proc entries may not
1230 * actually be removed until they are no longer used by anyone.
1232 void unregister_sysctl_table(struct ctl_table_header * header)
1234 list_del(&header->ctl_entry);
1235 #ifdef CONFIG_PROC_FS
1236 unregister_proc_table(header->ctl_table, proc_sys_root);
1245 #ifdef CONFIG_PROC_FS
1247 /* Scan the sysctl entries in table and add them all into /proc */
1248 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1250 struct proc_dir_entry *de;
1254 for (; table->ctl_name; table++) {
1255 /* Can't do anything without a proc name. */
1256 if (!table->procname)
1258 /* Maybe we can't do anything with it... */
1259 if (!table->proc_handler && !table->child) {
1260 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1265 len = strlen(table->procname);
1269 if (table->proc_handler)
1273 for (de = root->subdir; de; de = de->next) {
1274 if (proc_match(len, table->procname, de))
1277 /* If the subdir exists already, de is non-NULL */
1281 de = create_proc_entry(table->procname, mode, root);
1284 de->data = (void *) table;
1285 if (table->proc_handler)
1286 de->proc_fops = &proc_sys_file_operations;
1289 if (de->mode & S_IFDIR)
1290 register_proc_table(table->child, de);
1295 * Unregister a /proc sysctl table and any subdirectories.
1297 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1299 struct proc_dir_entry *de;
1300 for (; table->ctl_name; table++) {
1301 if (!(de = table->de))
1303 if (de->mode & S_IFDIR) {
1304 if (!table->child) {
1305 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1308 unregister_proc_table(table->child, de);
1310 /* Don't unregister directories which still have entries.. */
1315 /* Don't unregister proc entries that are still being used.. */
1316 if (atomic_read(&de->count))
1320 remove_proc_entry(table->procname, root);
1324 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1325 size_t count, loff_t *ppos)
1328 struct proc_dir_entry *de;
1329 struct ctl_table *table;
1333 de = PDE(file->f_dentry->d_inode);
1334 if (!de || !de->data)
1336 table = (struct ctl_table *) de->data;
1337 if (!table || !table->proc_handler)
1339 op = (write ? 002 : 004);
1340 if (ctl_perm(table, op))
1346 * FIXME: we need to pass on ppos to the handler.
1349 error = (*table->proc_handler) (table, write, file, buf, &res);
1355 static int proc_opensys(struct inode *inode, struct file *file)
1357 if (file->f_mode & FMODE_WRITE) {
1359 * sysctl entries that are not writable,
1360 * are _NOT_ writable, capabilities or not.
1362 if (!(inode->i_mode & S_IWUSR))
1369 static ssize_t proc_readsys(struct file * file, char __user * buf,
1370 size_t count, loff_t *ppos)
1372 return do_rw_proc(0, file, buf, count, ppos);
1375 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1376 size_t count, loff_t *ppos)
1378 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1382 * proc_dostring - read a string sysctl
1383 * @table: the sysctl table
1384 * @write: %TRUE if this is a write to the sysctl file
1385 * @filp: the file structure
1386 * @buffer: the user buffer
1387 * @lenp: the size of the user buffer
1389 * Reads/writes a string from/to the user buffer. If the kernel
1390 * buffer provided is not large enough to hold the string, the
1391 * string is truncated. The copied string is %NULL-terminated.
1392 * If the string is being read by the user process, it is copied
1393 * and a newline '\n' is added. It is truncated if the buffer is
1396 * Returns 0 on success.
1398 int proc_dostring(ctl_table *table, int write, struct file *filp,
1399 void __user *buffer, size_t *lenp)
1405 if (!table->data || !table->maxlen || !*lenp ||
1406 (filp->f_pos && !write)) {
1414 while (len < *lenp) {
1415 if (get_user(c, p++))
1417 if (c == 0 || c == '\n')
1421 if (len >= table->maxlen)
1422 len = table->maxlen-1;
1423 if(copy_from_user(table->data, buffer, len))
1425 ((char *) table->data)[len] = 0;
1426 filp->f_pos += *lenp;
1428 len = strlen(table->data);
1429 if (len > table->maxlen)
1430 len = table->maxlen;
1434 if(copy_to_user(buffer, table->data, len))
1437 if(put_user('\n', ((char __user *) buffer) + len))
1448 * Special case of dostring for the UTS structure. This has locks
1449 * to observe. Should this be in kernel/sys.c ????
1452 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1453 void __user *buffer, size_t *lenp)
1458 down_read(&uts_sem);
1459 r=proc_dostring(table,0,filp,buffer,lenp);
1462 down_write(&uts_sem);
1463 r=proc_dostring(table,1,filp,buffer,lenp);
1469 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1471 int write, void *data)
1474 *valp = *negp ? -*lvalp : *lvalp;
1479 *lvalp = (unsigned long)-val;
1482 *lvalp = (unsigned long)val;
1488 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1489 void __user *buffer, size_t *lenp,
1490 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1491 int write, void *data),
1494 #define TMPBUFLEN 20
1495 int *i, vleft, first=1, neg, val;
1499 char buf[TMPBUFLEN], *p;
1500 char __user *s = buffer;
1502 if (!table->data || !table->maxlen || !*lenp ||
1503 (filp->f_pos && !write)) {
1508 i = (int *) table->data;
1509 vleft = table->maxlen / sizeof(*i);
1513 conv = do_proc_dointvec_conv;
1515 for (; left && vleft--; i++, first=0) {
1530 if (len > sizeof(buf) - 1)
1531 len = sizeof(buf) - 1;
1532 if (copy_from_user(buf, s, len))
1536 if (*p == '-' && left > 1) {
1540 if (*p < '0' || *p > '9')
1543 lval = simple_strtoul(p, &p, 0);
1546 if ((len < left) && *p && !isspace(*p))
1553 if (conv(&neg, &lval, i, 1, data))
1560 if (conv(&neg, &lval, i, 0, data))
1563 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1567 if(copy_to_user(s, buf, len))
1574 if (!write && !first && left) {
1575 if(put_user('\n', s))
1582 if (get_user(c, s++))
1592 filp->f_pos += *lenp;
1598 * proc_dointvec - read a vector of integers
1599 * @table: the sysctl table
1600 * @write: %TRUE if this is a write to the sysctl file
1601 * @filp: the file structure
1602 * @buffer: the user buffer
1603 * @lenp: the size of the user buffer
1605 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1606 * values from/to the user buffer, treated as an ASCII string.
1608 * Returns 0 on success.
1610 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1611 void __user *buffer, size_t *lenp)
1613 return do_proc_dointvec(table,write,filp,buffer,lenp,
1623 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1625 int write, void *data)
1627 int op = *(int *)data;
1629 int val = *negp ? -*lvalp : *lvalp;
1631 case OP_SET: *valp = val; break;
1632 case OP_AND: *valp &= val; break;
1633 case OP_OR: *valp |= val; break;
1634 case OP_MAX: if(*valp < val)
1637 case OP_MIN: if(*valp > val)
1645 *lvalp = (unsigned long)-val;
1648 *lvalp = (unsigned long)val;
1655 * init may raise the set.
1658 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1659 void __user *buffer, size_t *lenp)
1663 if (!capable(CAP_SYS_MODULE)) {
1667 op = (current->pid == 1) ? OP_SET : OP_AND;
1668 return do_proc_dointvec(table,write,filp,buffer,lenp,
1669 do_proc_dointvec_bset_conv,&op);
1672 struct do_proc_dointvec_minmax_conv_param {
1677 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1679 int write, void *data)
1681 struct do_proc_dointvec_minmax_conv_param *param = data;
1683 int val = *negp ? -*lvalp : *lvalp;
1684 if ((param->min && *param->min > val) ||
1685 (param->max && *param->max < val))
1692 *lvalp = (unsigned long)-val;
1695 *lvalp = (unsigned long)val;
1702 * proc_dointvec_minmax - read a vector of integers with min/max values
1703 * @table: the sysctl table
1704 * @write: %TRUE if this is a write to the sysctl file
1705 * @filp: the file structure
1706 * @buffer: the user buffer
1707 * @lenp: the size of the user buffer
1709 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1710 * values from/to the user buffer, treated as an ASCII string.
1712 * This routine will ensure the values are within the range specified by
1713 * table->extra1 (min) and table->extra2 (max).
1715 * Returns 0 on success.
1717 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1718 void __user *buffer, size_t *lenp)
1720 struct do_proc_dointvec_minmax_conv_param param = {
1721 .min = (int *) table->extra1,
1722 .max = (int *) table->extra2,
1724 return do_proc_dointvec(table, write, filp, buffer, lenp,
1725 do_proc_dointvec_minmax_conv, ¶m);
1728 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1730 void __user *buffer, size_t *lenp,
1731 unsigned long convmul,
1732 unsigned long convdiv)
1734 #define TMPBUFLEN 20
1735 unsigned long *i, *min, *max, val;
1736 int vleft, first=1, neg;
1738 char buf[TMPBUFLEN], *p;
1739 char __user *s = buffer;
1741 if (!table->data || !table->maxlen || !*lenp ||
1742 (filp->f_pos && !write)) {
1747 i = (unsigned long *) table->data;
1748 min = (unsigned long *) table->extra1;
1749 max = (unsigned long *) table->extra2;
1750 vleft = table->maxlen / sizeof(unsigned long);
1753 for (; left && vleft--; i++, min++, max++, first=0) {
1768 if (len > TMPBUFLEN-1)
1770 if (copy_from_user(buf, s, len))
1774 if (*p == '-' && left > 1) {
1778 if (*p < '0' || *p > '9')
1780 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1782 if ((len < left) && *p && !isspace(*p))
1791 if ((min && val < *min) || (max && val > *max))
1798 sprintf(p, "%lu", convdiv * (*i) / convmul);
1802 if(copy_to_user(s, buf, len))
1809 if (!write && !first && left) {
1810 if(put_user('\n', s))
1817 if (get_user(c, s++))
1827 filp->f_pos += *lenp;
1833 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1834 * @table: the sysctl table
1835 * @write: %TRUE if this is a write to the sysctl file
1836 * @filp: the file structure
1837 * @buffer: the user buffer
1838 * @lenp: the size of the user buffer
1840 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1841 * values from/to the user buffer, treated as an ASCII string.
1843 * This routine will ensure the values are within the range specified by
1844 * table->extra1 (min) and table->extra2 (max).
1846 * Returns 0 on success.
1848 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1849 void __user *buffer, size_t *lenp)
1851 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, 1l, 1l);
1855 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1856 * @table: the sysctl table
1857 * @write: %TRUE if this is a write to the sysctl file
1858 * @filp: the file structure
1859 * @buffer: the user buffer
1860 * @lenp: the size of the user buffer
1862 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1863 * values from/to the user buffer, treated as an ASCII string. The values
1864 * are treated as milliseconds, and converted to jiffies when they are stored.
1866 * This routine will ensure the values are within the range specified by
1867 * table->extra1 (min) and table->extra2 (max).
1869 * Returns 0 on success.
1871 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1873 void __user *buffer, size_t *lenp)
1875 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1880 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1882 int write, void *data)
1885 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1891 lval = (unsigned long)-val;
1894 lval = (unsigned long)val;
1901 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1903 int write, void *data)
1906 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1912 lval = (unsigned long)-val;
1915 lval = (unsigned long)val;
1917 *lvalp = jiffies_to_clock_t(lval);
1923 * proc_dointvec_jiffies - read a vector of integers as seconds
1924 * @table: the sysctl table
1925 * @write: %TRUE if this is a write to the sysctl file
1926 * @filp: the file structure
1927 * @buffer: the user buffer
1928 * @lenp: the size of the user buffer
1930 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1931 * values from/to the user buffer, treated as an ASCII string.
1932 * The values read are assumed to be in seconds, and are converted into
1935 * Returns 0 on success.
1937 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1938 void __user *buffer, size_t *lenp)
1940 return do_proc_dointvec(table,write,filp,buffer,lenp,
1941 do_proc_dointvec_jiffies_conv,NULL);
1945 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1946 * @table: the sysctl table
1947 * @write: %TRUE if this is a write to the sysctl file
1948 * @filp: the file structure
1949 * @buffer: the user buffer
1950 * @lenp: the size of the user buffer
1952 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1953 * values from/to the user buffer, treated as an ASCII string.
1954 * The values read are assumed to be in 1/USER_HZ seconds, and
1955 * are converted into jiffies.
1957 * Returns 0 on success.
1959 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1960 void __user *buffer, size_t *lenp)
1962 return do_proc_dointvec(table,write,filp,buffer,lenp,
1963 do_proc_dointvec_userhz_jiffies_conv,NULL);
1966 #else /* CONFIG_PROC_FS */
1968 int proc_dostring(ctl_table *table, int write, struct file *filp,
1969 void *buffer, size_t *lenp)
1974 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1975 void *buffer, size_t *lenp)
1980 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1981 void *buffer, size_t *lenp)
1986 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1987 void *buffer, size_t *lenp)
1992 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1993 void *buffer, size_t *lenp)
1998 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1999 void *buffer, size_t *lenp)
2004 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2005 void *buffer, size_t *lenp)
2010 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2011 void *buffer, size_t *lenp)
2016 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2018 void *buffer, size_t *lenp)
2024 #endif /* CONFIG_PROC_FS */
2028 * General sysctl support routines
2031 /* The generic string strategy routine: */
2032 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2033 void __user *oldval, size_t __user *oldlenp,
2034 void __user *newval, size_t newlen, void **context)
2038 if (!table->data || !table->maxlen)
2041 if (oldval && oldlenp) {
2042 if (get_user(len, oldlenp))
2045 l = strlen(table->data);
2046 if (len > l) len = l;
2047 if (len >= table->maxlen)
2048 len = table->maxlen;
2049 if(copy_to_user(oldval, table->data, len))
2051 if(put_user(0, ((char __user *) oldval) + len))
2053 if(put_user(len, oldlenp))
2057 if (newval && newlen) {
2059 if (len > table->maxlen)
2060 len = table->maxlen;
2061 if(copy_from_user(table->data, newval, len))
2063 if (len == table->maxlen)
2065 ((char *) table->data)[len] = 0;
2071 * This function makes sure that all of the integers in the vector
2072 * are between the minimum and maximum values given in the arrays
2073 * table->extra1 and table->extra2, respectively.
2075 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2076 void __user *oldval, size_t __user *oldlenp,
2077 void __user *newval, size_t newlen, void **context)
2080 if (newval && newlen) {
2081 int __user *vec = (int __user *) newval;
2082 int *min = (int *) table->extra1;
2083 int *max = (int *) table->extra2;
2087 if (newlen % sizeof(int) != 0)
2090 if (!table->extra1 && !table->extra2)
2093 if (newlen > table->maxlen)
2094 newlen = table->maxlen;
2095 length = newlen / sizeof(int);
2097 for (i = 0; i < length; i++) {
2099 if (get_user(value, vec + i))
2101 if (min && value < min[i])
2103 if (max && value > max[i])
2110 /* Strategy function to convert jiffies to seconds */
2111 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2112 void __user *oldval, size_t __user *oldlenp,
2113 void __user *newval, size_t newlen, void **context)
2118 if (get_user(olen, oldlenp))
2120 if (olen!=sizeof(int))
2123 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2124 (oldlenp && put_user(sizeof(int),oldlenp)))
2127 if (newval && newlen) {
2129 if (newlen != sizeof(int))
2131 if (get_user(new, (int __user *)newval))
2133 *(int *)(table->data) = new*HZ;
2139 #else /* CONFIG_SYSCTL */
2142 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2147 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2148 void __user *oldval, size_t __user *oldlenp,
2149 void __user *newval, size_t newlen, void **context)
2154 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2155 void __user *oldval, size_t __user *oldlenp,
2156 void __user *newval, size_t newlen, void **context)
2161 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2162 void __user *oldval, size_t __user *oldlenp,
2163 void __user *newval, size_t newlen, void **context)
2168 int proc_dostring(ctl_table *table, int write, struct file *filp,
2169 void __user *buffer, size_t *lenp)
2174 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2175 void __user *buffer, size_t *lenp)
2180 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2181 void __user *buffer, size_t *lenp)
2186 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2187 void __user *buffer, size_t *lenp)
2192 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2193 void *buffer, size_t *lenp)
2198 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2199 void *buffer, size_t *lenp)
2204 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2205 void __user *buffer, size_t *lenp)
2210 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2212 void __user *buffer, size_t *lenp)
2217 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2223 void unregister_sysctl_table(struct ctl_table_header * table)
2227 #endif /* CONFIG_SYSCTL */
2230 * No sense putting this after each symbol definition, twice,
2231 * exception granted :-)
2233 EXPORT_SYMBOL(proc_dointvec);
2234 EXPORT_SYMBOL(proc_dointvec_jiffies);
2235 EXPORT_SYMBOL(proc_dointvec_minmax);
2236 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2237 EXPORT_SYMBOL(proc_dostring);
2238 EXPORT_SYMBOL(proc_doulongvec_minmax);
2239 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2240 EXPORT_SYMBOL(register_sysctl_table);
2241 EXPORT_SYMBOL(sysctl_intvec);
2242 EXPORT_SYMBOL(sysctl_jiffies);
2243 EXPORT_SYMBOL(sysctl_string);
2244 EXPORT_SYMBOL(unregister_sysctl_table);