2 * sysctl.c: General linux system control interface
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
21 #include <linux/config.h>
22 #include <linux/module.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/proc_fs.h>
28 #include <linux/ctype.h>
29 #include <linux/utsname.h>
30 #include <linux/capability.h>
31 #include <linux/smp_lock.h>
32 #include <linux/init.h>
33 #include <linux/kernel.h>
34 #include <linux/sysrq.h>
35 #include <linux/highuid.h>
36 #include <linux/writeback.h>
37 #include <linux/hugetlb.h>
38 #include <linux/security.h>
39 #include <linux/initrd.h>
40 #include <linux/times.h>
41 #include <linux/limits.h>
42 #include <linux/dcache.h>
44 #include <asm/uaccess.h>
46 #ifdef CONFIG_ROOT_NFS
47 #include <linux/nfs_fs.h>
50 #if defined(CONFIG_SYSCTL)
52 /* External variables not in a header file. */
53 extern int panic_timeout;
55 extern int sysctl_overcommit_memory;
56 extern int sysctl_overcommit_ratio;
57 extern int max_threads;
58 extern int sysrq_enabled;
59 extern int core_uses_pid;
60 extern char core_pattern[];
63 extern int sysctl_lower_zone_protection;
64 extern int min_free_kbytes;
65 extern int printk_ratelimit_jiffies;
66 extern int printk_ratelimit_burst;
68 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
69 static int maxolduid = 65535;
72 static int ngroups_max = NGROUPS_MAX;
75 extern char modprobe_path[];
78 extern char hotplug_path[];
80 #ifdef CONFIG_CHR_DEV_SG
81 extern int sg_big_buff;
84 extern size_t shm_ctlmax;
85 extern size_t shm_ctlall;
86 extern int shm_ctlmni;
87 extern int msg_ctlmax;
88 extern int msg_ctlmnb;
89 extern int msg_ctlmni;
90 extern int sem_ctls[];
94 extern char reboot_command [];
95 extern int stop_a_enabled;
96 extern int scons_pwroff;
100 extern int pwrsw_enabled;
101 extern int unaligned_enabled;
104 #ifdef CONFIG_ARCH_S390
105 #ifdef CONFIG_MATHEMU
106 extern int sysctl_ieee_emulation_warnings;
108 extern int sysctl_userprocess_debug;
111 extern int sysctl_hz_timer;
113 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
114 extern unsigned long powersave_nap;
115 int proc_dol2crvec(ctl_table *table, int write, struct file *filp,
116 void __user *buffer, size_t *lenp, loff_t *ppos);
119 #ifdef CONFIG_BSD_PROCESS_ACCT
120 extern int acct_parm[];
123 static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
124 ctl_table *, void **);
125 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
126 void __user *buffer, size_t *lenp, loff_t *ppos);
128 static ctl_table root_table[];
129 static struct ctl_table_header root_table_header =
130 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
132 static ctl_table kern_table[];
133 static ctl_table vm_table[];
135 extern ctl_table net_table[];
137 static ctl_table proc_table[];
138 static ctl_table fs_table[];
139 static ctl_table debug_table[];
140 static ctl_table dev_table[];
141 extern ctl_table random_table[];
142 #ifdef CONFIG_UNIX98_PTYS
143 extern ctl_table pty_table[];
146 /* /proc declarations: */
148 #ifdef CONFIG_PROC_FS
150 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
151 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
152 static int proc_opensys(struct inode *, struct file *);
154 struct file_operations proc_sys_file_operations = {
155 .open = proc_opensys,
156 .read = proc_readsys,
157 .write = proc_writesys,
160 extern struct proc_dir_entry *proc_sys_root;
162 static void register_proc_table(ctl_table *, struct proc_dir_entry *);
163 static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
166 /* The default sysctl tables: */
168 static ctl_table root_table[] = {
170 .ctl_name = CTL_KERN,
171 .procname = "kernel",
190 .ctl_name = CTL_PROC,
202 .ctl_name = CTL_DEBUG,
205 .child = debug_table,
216 static ctl_table kern_table[] = {
218 .ctl_name = KERN_OSTYPE,
219 .procname = "ostype",
220 .data = system_utsname.sysname,
221 .maxlen = sizeof(system_utsname.sysname),
223 .proc_handler = &proc_doutsstring,
224 .strategy = &sysctl_string,
227 .ctl_name = KERN_OSRELEASE,
228 .procname = "osrelease",
229 .data = system_utsname.release,
230 .maxlen = sizeof(system_utsname.release),
232 .proc_handler = &proc_doutsstring,
233 .strategy = &sysctl_string,
236 .ctl_name = KERN_VERSION,
237 .procname = "version",
238 .data = system_utsname.version,
239 .maxlen = sizeof(system_utsname.version),
241 .proc_handler = &proc_doutsstring,
242 .strategy = &sysctl_string,
245 .ctl_name = KERN_NODENAME,
246 .procname = "hostname",
247 .data = system_utsname.nodename,
248 .maxlen = sizeof(system_utsname.nodename),
250 .proc_handler = &proc_doutsstring,
251 .strategy = &sysctl_string,
254 .ctl_name = KERN_DOMAINNAME,
255 .procname = "domainname",
256 .data = system_utsname.domainname,
257 .maxlen = sizeof(system_utsname.domainname),
259 .proc_handler = &proc_doutsstring,
260 .strategy = &sysctl_string,
263 .ctl_name = KERN_PANIC,
265 .data = &panic_timeout,
266 .maxlen = sizeof(int),
268 .proc_handler = &proc_dointvec,
271 .ctl_name = KERN_CORE_USES_PID,
272 .procname = "core_uses_pid",
273 .data = &core_uses_pid,
274 .maxlen = sizeof(int),
276 .proc_handler = &proc_dointvec,
279 .ctl_name = KERN_CORE_PATTERN,
280 .procname = "core_pattern",
281 .data = core_pattern,
284 .proc_handler = &proc_dostring,
285 .strategy = &sysctl_string,
288 .ctl_name = KERN_TAINTED,
289 .procname = "tainted",
291 .maxlen = sizeof(int),
293 .proc_handler = &proc_dointvec,
296 .ctl_name = KERN_CAP_BSET,
297 .procname = "cap-bound",
299 .maxlen = sizeof(kernel_cap_t),
301 .proc_handler = &proc_dointvec_bset,
303 #ifdef CONFIG_BLK_DEV_INITRD
305 .ctl_name = KERN_REALROOTDEV,
306 .procname = "real-root-dev",
307 .data = &real_root_dev,
308 .maxlen = sizeof(int),
310 .proc_handler = &proc_dointvec,
315 .ctl_name = KERN_SPARC_REBOOT,
316 .procname = "reboot-cmd",
317 .data = reboot_command,
320 .proc_handler = &proc_dostring,
321 .strategy = &sysctl_string,
324 .ctl_name = KERN_SPARC_STOP_A,
325 .procname = "stop-a",
326 .data = &stop_a_enabled,
327 .maxlen = sizeof (int),
329 .proc_handler = &proc_dointvec,
332 .ctl_name = KERN_SPARC_SCONS_PWROFF,
333 .procname = "scons-poweroff",
334 .data = &scons_pwroff,
335 .maxlen = sizeof (int),
337 .proc_handler = &proc_dointvec,
342 .ctl_name = KERN_HPPA_PWRSW,
343 .procname = "soft-power",
344 .data = &pwrsw_enabled,
345 .maxlen = sizeof (int),
347 .proc_handler = &proc_dointvec,
350 .ctl_name = KERN_HPPA_UNALIGNED,
351 .procname = "unaligned-trap",
352 .data = &unaligned_enabled,
353 .maxlen = sizeof (int),
355 .proc_handler = &proc_dointvec,
358 #if defined(CONFIG_PPC32) && defined(CONFIG_6xx)
360 .ctl_name = KERN_PPC_POWERSAVE_NAP,
361 .procname = "powersave-nap",
362 .data = &powersave_nap,
363 .maxlen = sizeof(int),
365 .proc_handler = &proc_dointvec,
368 .ctl_name = KERN_PPC_L2CR,
371 .proc_handler = &proc_dol2crvec,
375 .ctl_name = KERN_CTLALTDEL,
376 .procname = "ctrl-alt-del",
378 .maxlen = sizeof(int),
380 .proc_handler = &proc_dointvec,
383 .ctl_name = KERN_PRINTK,
384 .procname = "printk",
385 .data = &console_loglevel,
386 .maxlen = 4*sizeof(int),
388 .proc_handler = &proc_dointvec,
392 .ctl_name = KERN_MODPROBE,
393 .procname = "modprobe",
394 .data = &modprobe_path,
395 .maxlen = KMOD_PATH_LEN,
397 .proc_handler = &proc_dostring,
398 .strategy = &sysctl_string,
401 #ifdef CONFIG_HOTPLUG
403 .ctl_name = KERN_HOTPLUG,
404 .procname = "hotplug",
405 .data = &hotplug_path,
406 .maxlen = KMOD_PATH_LEN,
408 .proc_handler = &proc_dostring,
409 .strategy = &sysctl_string,
412 #ifdef CONFIG_CHR_DEV_SG
414 .ctl_name = KERN_SG_BIG_BUFF,
415 .procname = "sg-big-buff",
416 .data = &sg_big_buff,
417 .maxlen = sizeof (int),
419 .proc_handler = &proc_dointvec,
422 #ifdef CONFIG_BSD_PROCESS_ACCT
424 .ctl_name = KERN_ACCT,
427 .maxlen = 3*sizeof(int),
429 .proc_handler = &proc_dointvec,
432 #ifdef CONFIG_SYSVIPC
434 .ctl_name = KERN_SHMMAX,
435 .procname = "shmmax",
437 .maxlen = sizeof (size_t),
439 .proc_handler = &proc_doulongvec_minmax,
442 .ctl_name = KERN_SHMALL,
443 .procname = "shmall",
445 .maxlen = sizeof (size_t),
447 .proc_handler = &proc_doulongvec_minmax,
450 .ctl_name = KERN_SHMMNI,
451 .procname = "shmmni",
453 .maxlen = sizeof (int),
455 .proc_handler = &proc_dointvec,
458 .ctl_name = KERN_MSGMAX,
459 .procname = "msgmax",
461 .maxlen = sizeof (int),
463 .proc_handler = &proc_dointvec,
466 .ctl_name = KERN_MSGMNI,
467 .procname = "msgmni",
469 .maxlen = sizeof (int),
471 .proc_handler = &proc_dointvec,
474 .ctl_name = KERN_MSGMNB,
475 .procname = "msgmnb",
477 .maxlen = sizeof (int),
479 .proc_handler = &proc_dointvec,
482 .ctl_name = KERN_SEM,
485 .maxlen = 4*sizeof (int),
487 .proc_handler = &proc_dointvec,
490 #ifdef CONFIG_MAGIC_SYSRQ
492 .ctl_name = KERN_SYSRQ,
494 .data = &sysrq_enabled,
495 .maxlen = sizeof (int),
497 .proc_handler = &proc_dointvec,
501 .ctl_name = KERN_CADPID,
502 .procname = "cad_pid",
504 .maxlen = sizeof (int),
506 .proc_handler = &proc_dointvec,
509 .ctl_name = KERN_MAX_THREADS,
510 .procname = "threads-max",
511 .data = &max_threads,
512 .maxlen = sizeof(int),
514 .proc_handler = &proc_dointvec,
517 .ctl_name = KERN_RANDOM,
518 .procname = "random",
520 .child = random_table,
522 #ifdef CONFIG_UNIX98_PTYS
524 .ctl_name = KERN_PTY,
531 .ctl_name = KERN_OVERFLOWUID,
532 .procname = "overflowuid",
533 .data = &overflowuid,
534 .maxlen = sizeof(int),
536 .proc_handler = &proc_dointvec_minmax,
537 .strategy = &sysctl_intvec,
538 .extra1 = &minolduid,
539 .extra2 = &maxolduid,
542 .ctl_name = KERN_OVERFLOWGID,
543 .procname = "overflowgid",
544 .data = &overflowgid,
545 .maxlen = sizeof(int),
547 .proc_handler = &proc_dointvec_minmax,
548 .strategy = &sysctl_intvec,
549 .extra1 = &minolduid,
550 .extra2 = &maxolduid,
552 #ifdef CONFIG_ARCH_S390
553 #ifdef CONFIG_MATHEMU
555 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
556 .procname = "ieee_emulation_warnings",
557 .data = &sysctl_ieee_emulation_warnings,
558 .maxlen = sizeof(int),
560 .proc_handler = &proc_dointvec,
563 #ifdef CONFIG_NO_IDLE_HZ
565 .ctl_name = KERN_HZ_TIMER,
566 .procname = "hz_timer",
567 .data = &sysctl_hz_timer,
568 .maxlen = sizeof(int),
570 .proc_handler = &proc_dointvec,
574 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
575 .procname = "userprocess_debug",
576 .data = &sysctl_userprocess_debug,
577 .maxlen = sizeof(int),
579 .proc_handler = &proc_dointvec,
583 .ctl_name = KERN_PIDMAX,
584 .procname = "pid_max",
586 .maxlen = sizeof (int),
588 .proc_handler = &proc_dointvec,
591 .ctl_name = KERN_PANIC_ON_OOPS,
592 .procname = "panic_on_oops",
593 .data = &panic_on_oops,
594 .maxlen = sizeof(int),
596 .proc_handler = &proc_dointvec,
599 .ctl_name = KERN_PRINTK_RATELIMIT,
600 .procname = "printk_ratelimit",
601 .data = &printk_ratelimit_jiffies,
602 .maxlen = sizeof(int),
604 .proc_handler = &proc_dointvec_jiffies,
605 .strategy = &sysctl_jiffies,
608 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
609 .procname = "printk_ratelimit_burst",
610 .data = &printk_ratelimit_burst,
611 .maxlen = sizeof(int),
613 .proc_handler = &proc_dointvec,
616 .ctl_name = KERN_NGROUPS_MAX,
617 .procname = "ngroups_max",
618 .data = &ngroups_max,
619 .maxlen = sizeof (int),
621 .proc_handler = &proc_dointvec,
626 /* Constants for minimum and maximum testing in vm_table.
627 We use these as one-element integer vectors. */
629 static int one_hundred = 100;
632 static ctl_table vm_table[] = {
634 .ctl_name = VM_OVERCOMMIT_MEMORY,
635 .procname = "overcommit_memory",
636 .data = &sysctl_overcommit_memory,
637 .maxlen = sizeof(sysctl_overcommit_memory),
639 .proc_handler = &proc_dointvec,
642 .ctl_name = VM_OVERCOMMIT_RATIO,
643 .procname = "overcommit_ratio",
644 .data = &sysctl_overcommit_ratio,
645 .maxlen = sizeof(sysctl_overcommit_ratio),
647 .proc_handler = &proc_dointvec,
650 .ctl_name = VM_PAGE_CLUSTER,
651 .procname = "page-cluster",
652 .data = &page_cluster,
653 .maxlen = sizeof(int),
655 .proc_handler = &proc_dointvec,
658 .ctl_name = VM_DIRTY_BACKGROUND,
659 .procname = "dirty_background_ratio",
660 .data = &dirty_background_ratio,
661 .maxlen = sizeof(dirty_background_ratio),
663 .proc_handler = &proc_dointvec_minmax,
664 .strategy = &sysctl_intvec,
666 .extra2 = &one_hundred,
669 .ctl_name = VM_DIRTY_RATIO,
670 .procname = "dirty_ratio",
671 .data = &vm_dirty_ratio,
672 .maxlen = sizeof(vm_dirty_ratio),
674 .proc_handler = &proc_dointvec_minmax,
675 .strategy = &sysctl_intvec,
677 .extra2 = &one_hundred,
680 .ctl_name = VM_DIRTY_WB_CS,
681 .procname = "dirty_writeback_centisecs",
682 .data = &dirty_writeback_centisecs,
683 .maxlen = sizeof(dirty_writeback_centisecs),
685 .proc_handler = &dirty_writeback_centisecs_handler,
688 .ctl_name = VM_DIRTY_EXPIRE_CS,
689 .procname = "dirty_expire_centisecs",
690 .data = &dirty_expire_centisecs,
691 .maxlen = sizeof(dirty_expire_centisecs),
693 .proc_handler = &proc_dointvec,
696 .ctl_name = VM_NR_PDFLUSH_THREADS,
697 .procname = "nr_pdflush_threads",
698 .data = &nr_pdflush_threads,
699 .maxlen = sizeof nr_pdflush_threads,
700 .mode = 0444 /* read-only*/,
701 .proc_handler = &proc_dointvec,
704 .ctl_name = VM_SWAPPINESS,
705 .procname = "swappiness",
706 .data = &vm_swappiness,
707 .maxlen = sizeof(vm_swappiness),
709 .proc_handler = &proc_dointvec_minmax,
710 .strategy = &sysctl_intvec,
712 .extra2 = &one_hundred,
714 #ifdef CONFIG_HUGETLB_PAGE
716 .ctl_name = VM_HUGETLB_PAGES,
717 .procname = "nr_hugepages",
718 .data = &max_huge_pages,
719 .maxlen = sizeof(unsigned long),
721 .proc_handler = &hugetlb_sysctl_handler,
722 .extra1 = (void *)&hugetlb_zero,
723 .extra2 = (void *)&hugetlb_infinity,
726 .ctl_name = VM_HUGETLB_GROUP,
727 .procname = "hugetlb_shm_group",
728 .data = &sysctl_hugetlb_shm_group,
729 .maxlen = sizeof(gid_t),
731 .proc_handler = &proc_dointvec,
735 .ctl_name = VM_LOWER_ZONE_PROTECTION,
736 .procname = "lower_zone_protection",
737 .data = &sysctl_lower_zone_protection,
738 .maxlen = sizeof(sysctl_lower_zone_protection),
740 .proc_handler = &lower_zone_protection_sysctl_handler,
741 .strategy = &sysctl_intvec,
745 .ctl_name = VM_MIN_FREE_KBYTES,
746 .procname = "min_free_kbytes",
747 .data = &min_free_kbytes,
748 .maxlen = sizeof(min_free_kbytes),
750 .proc_handler = &min_free_kbytes_sysctl_handler,
751 .strategy = &sysctl_intvec,
755 .ctl_name = VM_MAX_MAP_COUNT,
756 .procname = "max_map_count",
757 .data = &sysctl_max_map_count,
758 .maxlen = sizeof(sysctl_max_map_count),
760 .proc_handler = &proc_dointvec
763 .ctl_name = VM_LAPTOP_MODE,
764 .procname = "laptop_mode",
765 .data = &laptop_mode,
766 .maxlen = sizeof(laptop_mode),
768 .proc_handler = &proc_dointvec,
769 .strategy = &sysctl_intvec,
773 .ctl_name = VM_BLOCK_DUMP,
774 .procname = "block_dump",
776 .maxlen = sizeof(block_dump),
778 .proc_handler = &proc_dointvec,
779 .strategy = &sysctl_intvec,
783 .ctl_name = VM_VFS_CACHE_PRESSURE,
784 .procname = "vfs_cache_pressure",
785 .data = &sysctl_vfs_cache_pressure,
786 .maxlen = sizeof(sysctl_vfs_cache_pressure),
788 .proc_handler = &proc_dointvec,
789 .strategy = &sysctl_intvec,
795 static ctl_table proc_table[] = {
799 static ctl_table fs_table[] = {
801 .ctl_name = FS_NRINODE,
802 .procname = "inode-nr",
803 .data = &inodes_stat,
804 .maxlen = 2*sizeof(int),
806 .proc_handler = &proc_dointvec,
809 .ctl_name = FS_STATINODE,
810 .procname = "inode-state",
811 .data = &inodes_stat,
812 .maxlen = 7*sizeof(int),
814 .proc_handler = &proc_dointvec,
817 .ctl_name = FS_NRFILE,
818 .procname = "file-nr",
820 .maxlen = 3*sizeof(int),
822 .proc_handler = &proc_dointvec,
825 .ctl_name = FS_MAXFILE,
826 .procname = "file-max",
827 .data = &files_stat.max_files,
828 .maxlen = sizeof(int),
830 .proc_handler = &proc_dointvec,
833 .ctl_name = FS_DENTRY,
834 .procname = "dentry-state",
835 .data = &dentry_stat,
836 .maxlen = 6*sizeof(int),
838 .proc_handler = &proc_dointvec,
841 .ctl_name = FS_OVERFLOWUID,
842 .procname = "overflowuid",
843 .data = &fs_overflowuid,
844 .maxlen = sizeof(int),
846 .proc_handler = &proc_dointvec_minmax,
847 .strategy = &sysctl_intvec,
848 .extra1 = &minolduid,
849 .extra2 = &maxolduid,
852 .ctl_name = FS_OVERFLOWGID,
853 .procname = "overflowgid",
854 .data = &fs_overflowgid,
855 .maxlen = sizeof(int),
857 .proc_handler = &proc_dointvec_minmax,
858 .strategy = &sysctl_intvec,
859 .extra1 = &minolduid,
860 .extra2 = &maxolduid,
863 .ctl_name = FS_LEASES,
864 .procname = "leases-enable",
865 .data = &leases_enable,
866 .maxlen = sizeof(int),
868 .proc_handler = &proc_dointvec,
871 .ctl_name = FS_DIR_NOTIFY,
872 .procname = "dir-notify-enable",
873 .data = &dir_notify_enable,
874 .maxlen = sizeof(int),
876 .proc_handler = &proc_dointvec,
879 .ctl_name = FS_LEASE_TIME,
880 .procname = "lease-break-time",
881 .data = &lease_break_time,
882 .maxlen = sizeof(int),
884 .proc_handler = &proc_dointvec,
887 .ctl_name = FS_AIO_NR,
888 .procname = "aio-nr",
890 .maxlen = sizeof(aio_nr),
892 .proc_handler = &proc_dointvec,
895 .ctl_name = FS_AIO_MAX_NR,
896 .procname = "aio-max-nr",
898 .maxlen = sizeof(aio_max_nr),
900 .proc_handler = &proc_dointvec,
905 static ctl_table debug_table[] = {
909 static ctl_table dev_table[] = {
913 extern void init_irq_proc (void);
915 void __init sysctl_init(void)
917 #ifdef CONFIG_PROC_FS
918 register_proc_table(root_table, proc_sys_root);
923 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
924 void __user *newval, size_t newlen)
926 struct list_head *tmp;
928 if (nlen <= 0 || nlen >= CTL_MAXNAME)
932 if (!oldlenp || get_user(old_len, oldlenp))
935 tmp = &root_table_header.ctl_entry;
937 struct ctl_table_header *head =
938 list_entry(tmp, struct ctl_table_header, ctl_entry);
939 void *context = NULL;
940 int error = parse_table(name, nlen, oldval, oldlenp,
941 newval, newlen, head->ctl_table,
945 if (error != -ENOTDIR)
948 } while (tmp != &root_table_header.ctl_entry);
952 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
954 struct __sysctl_args tmp;
957 if (copy_from_user(&tmp, args, sizeof(tmp)))
961 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
962 tmp.newval, tmp.newlen);
968 * ctl_perm does NOT grant the superuser all rights automatically, because
969 * some sysctl variables are readonly even to root.
972 static int test_perm(int mode, int op)
976 else if (in_egroup_p(0))
978 if ((mode & op & 0007) == op)
983 static inline int ctl_perm(ctl_table *table, int op)
986 error = security_sysctl(table, op);
989 return test_perm(table->mode, op);
992 static int parse_table(int __user *name, int nlen,
993 void __user *oldval, size_t __user *oldlenp,
994 void __user *newval, size_t newlen,
995 ctl_table *table, void **context)
1001 if (get_user(n, name))
1003 for ( ; table->ctl_name; table++) {
1004 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1007 if (ctl_perm(table, 001))
1009 if (table->strategy) {
1010 error = table->strategy(
1013 newval, newlen, context);
1019 table = table->child;
1022 error = do_sysctl_strategy(table, name, nlen,
1024 newval, newlen, context);
1031 /* Perform the actual read/write of a sysctl table entry. */
1032 int do_sysctl_strategy (ctl_table *table,
1033 int __user *name, int nlen,
1034 void __user *oldval, size_t __user *oldlenp,
1035 void __user *newval, size_t newlen, void **context)
1044 if (ctl_perm(table, op))
1047 if (table->strategy) {
1048 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1049 newval, newlen, context);
1056 /* If there is no strategy routine, or if the strategy returns
1057 * zero, proceed with automatic r/w */
1058 if (table->data && table->maxlen) {
1059 if (oldval && oldlenp) {
1060 if (get_user(len, oldlenp))
1063 if (len > table->maxlen)
1064 len = table->maxlen;
1065 if(copy_to_user(oldval, table->data, len))
1067 if(put_user(len, oldlenp))
1071 if (newval && newlen) {
1073 if (len > table->maxlen)
1074 len = table->maxlen;
1075 if(copy_from_user(table->data, newval, len))
1083 * register_sysctl_table - register a sysctl hierarchy
1084 * @table: the top-level table structure
1085 * @insert_at_head: whether the entry should be inserted in front or at the end
1087 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1088 * array. An entry with a ctl_name of 0 terminates the table.
1090 * The members of the &ctl_table structure are used as follows:
1092 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1093 * must be unique within that level of sysctl
1095 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1096 * enter a sysctl file
1098 * data - a pointer to data for use by proc_handler
1100 * maxlen - the maximum size in bytes of the data
1102 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1104 * child - a pointer to the child sysctl table if this entry is a directory, or
1107 * proc_handler - the text handler routine (described below)
1109 * strategy - the strategy routine (described below)
1111 * de - for internal use by the sysctl routines
1113 * extra1, extra2 - extra pointers usable by the proc handler routines
1115 * Leaf nodes in the sysctl tree will be represented by a single file
1116 * under /proc; non-leaf nodes will be represented by directories.
1118 * sysctl(2) can automatically manage read and write requests through
1119 * the sysctl table. The data and maxlen fields of the ctl_table
1120 * struct enable minimal validation of the values being written to be
1121 * performed, and the mode field allows minimal authentication.
1123 * More sophisticated management can be enabled by the provision of a
1124 * strategy routine with the table entry. This will be called before
1125 * any automatic read or write of the data is performed.
1127 * The strategy routine may return
1129 * < 0 - Error occurred (error is passed to user process)
1131 * 0 - OK - proceed with automatic read or write.
1133 * > 0 - OK - read or write has been done by the strategy routine, so
1134 * return immediately.
1136 * There must be a proc_handler routine for any terminal nodes
1137 * mirrored under /proc/sys (non-terminals are handled by a built-in
1138 * directory handler). Several default handlers are available to
1139 * cover common cases -
1141 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1142 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1143 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1145 * It is the handler's job to read the input buffer from user memory
1146 * and process it. The handler should return 0 on success.
1148 * This routine returns %NULL on a failure to register, and a pointer
1149 * to the table header on success.
1151 struct ctl_table_header *register_sysctl_table(ctl_table * table,
1154 struct ctl_table_header *tmp;
1155 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1158 tmp->ctl_table = table;
1159 INIT_LIST_HEAD(&tmp->ctl_entry);
1161 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1163 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1164 #ifdef CONFIG_PROC_FS
1165 register_proc_table(table, proc_sys_root);
1171 * unregister_sysctl_table - unregister a sysctl table hierarchy
1172 * @header: the header returned from register_sysctl_table
1174 * Unregisters the sysctl table and all children. proc entries may not
1175 * actually be removed until they are no longer used by anyone.
1177 void unregister_sysctl_table(struct ctl_table_header * header)
1179 list_del(&header->ctl_entry);
1180 #ifdef CONFIG_PROC_FS
1181 unregister_proc_table(header->ctl_table, proc_sys_root);
1190 #ifdef CONFIG_PROC_FS
1192 /* Scan the sysctl entries in table and add them all into /proc */
1193 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root)
1195 struct proc_dir_entry *de;
1199 for (; table->ctl_name; table++) {
1200 /* Can't do anything without a proc name. */
1201 if (!table->procname)
1203 /* Maybe we can't do anything with it... */
1204 if (!table->proc_handler && !table->child) {
1205 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1210 len = strlen(table->procname);
1214 if (table->proc_handler)
1218 for (de = root->subdir; de; de = de->next) {
1219 if (proc_match(len, table->procname, de))
1222 /* If the subdir exists already, de is non-NULL */
1226 de = create_proc_entry(table->procname, mode, root);
1229 de->data = (void *) table;
1230 if (table->proc_handler)
1231 de->proc_fops = &proc_sys_file_operations;
1234 if (de->mode & S_IFDIR)
1235 register_proc_table(table->child, de);
1240 * Unregister a /proc sysctl table and any subdirectories.
1242 static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1244 struct proc_dir_entry *de;
1245 for (; table->ctl_name; table++) {
1246 if (!(de = table->de))
1248 if (de->mode & S_IFDIR) {
1249 if (!table->child) {
1250 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1253 unregister_proc_table(table->child, de);
1255 /* Don't unregister directories which still have entries.. */
1260 /* Don't unregister proc entries that are still being used.. */
1261 if (atomic_read(&de->count))
1265 remove_proc_entry(table->procname, root);
1269 static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1270 size_t count, loff_t *ppos)
1273 struct proc_dir_entry *de;
1274 struct ctl_table *table;
1278 de = PDE(file->f_dentry->d_inode);
1279 if (!de || !de->data)
1281 table = (struct ctl_table *) de->data;
1282 if (!table || !table->proc_handler)
1284 op = (write ? 002 : 004);
1285 if (ctl_perm(table, op))
1290 error = (*table->proc_handler) (table, write, file, buf, &res, ppos);
1296 static int proc_opensys(struct inode *inode, struct file *file)
1298 if (file->f_mode & FMODE_WRITE) {
1300 * sysctl entries that are not writable,
1301 * are _NOT_ writable, capabilities or not.
1303 if (!(inode->i_mode & S_IWUSR))
1310 static ssize_t proc_readsys(struct file * file, char __user * buf,
1311 size_t count, loff_t *ppos)
1313 return do_rw_proc(0, file, buf, count, ppos);
1316 static ssize_t proc_writesys(struct file * file, const char __user * buf,
1317 size_t count, loff_t *ppos)
1319 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1323 * proc_dostring - read a string sysctl
1324 * @table: the sysctl table
1325 * @write: %TRUE if this is a write to the sysctl file
1326 * @filp: the file structure
1327 * @buffer: the user buffer
1328 * @lenp: the size of the user buffer
1330 * Reads/writes a string from/to the user buffer. If the kernel
1331 * buffer provided is not large enough to hold the string, the
1332 * string is truncated. The copied string is %NULL-terminated.
1333 * If the string is being read by the user process, it is copied
1334 * and a newline '\n' is added. It is truncated if the buffer is
1337 * Returns 0 on success.
1339 int proc_dostring(ctl_table *table, int write, struct file *filp,
1340 void __user *buffer, size_t *lenp, loff_t *ppos)
1346 if (!table->data || !table->maxlen || !*lenp ||
1347 (*ppos && !write)) {
1355 while (len < *lenp) {
1356 if (get_user(c, p++))
1358 if (c == 0 || c == '\n')
1362 if (len >= table->maxlen)
1363 len = table->maxlen-1;
1364 if(copy_from_user(table->data, buffer, len))
1366 ((char *) table->data)[len] = 0;
1369 len = strlen(table->data);
1370 if (len > table->maxlen)
1371 len = table->maxlen;
1375 if(copy_to_user(buffer, table->data, len))
1378 if(put_user('\n', ((char __user *) buffer) + len))
1389 * Special case of dostring for the UTS structure. This has locks
1390 * to observe. Should this be in kernel/sys.c ????
1393 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1394 void __user *buffer, size_t *lenp, loff_t *ppos)
1399 down_read(&uts_sem);
1400 r=proc_dostring(table,0,filp,buffer,lenp, ppos);
1403 down_write(&uts_sem);
1404 r=proc_dostring(table,1,filp,buffer,lenp, ppos);
1410 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1412 int write, void *data)
1415 *valp = *negp ? -*lvalp : *lvalp;
1420 *lvalp = (unsigned long)-val;
1423 *lvalp = (unsigned long)val;
1429 static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1430 void __user *buffer, size_t *lenp, loff_t *ppos,
1431 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1432 int write, void *data),
1435 #define TMPBUFLEN 21
1436 int *i, vleft, first=1, neg, val;
1440 char buf[TMPBUFLEN], *p;
1441 char __user *s = buffer;
1443 if (!table->data || !table->maxlen || !*lenp ||
1444 (*ppos && !write)) {
1449 i = (int *) table->data;
1450 vleft = table->maxlen / sizeof(*i);
1454 conv = do_proc_dointvec_conv;
1456 for (; left && vleft--; i++, first=0) {
1471 if (len > sizeof(buf) - 1)
1472 len = sizeof(buf) - 1;
1473 if (copy_from_user(buf, s, len))
1477 if (*p == '-' && left > 1) {
1481 if (*p < '0' || *p > '9')
1484 lval = simple_strtoul(p, &p, 0);
1487 if ((len < left) && *p && !isspace(*p))
1494 if (conv(&neg, &lval, i, 1, data))
1501 if (conv(&neg, &lval, i, 0, data))
1504 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1508 if(copy_to_user(s, buf, len))
1515 if (!write && !first && left) {
1516 if(put_user('\n', s))
1523 if (get_user(c, s++))
1539 * proc_dointvec - read a vector of integers
1540 * @table: the sysctl table
1541 * @write: %TRUE if this is a write to the sysctl file
1542 * @filp: the file structure
1543 * @buffer: the user buffer
1544 * @lenp: the size of the user buffer
1546 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1547 * values from/to the user buffer, treated as an ASCII string.
1549 * Returns 0 on success.
1551 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1552 void __user *buffer, size_t *lenp, loff_t *ppos)
1554 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1564 static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1566 int write, void *data)
1568 int op = *(int *)data;
1570 int val = *negp ? -*lvalp : *lvalp;
1572 case OP_SET: *valp = val; break;
1573 case OP_AND: *valp &= val; break;
1574 case OP_OR: *valp |= val; break;
1575 case OP_MAX: if(*valp < val)
1578 case OP_MIN: if(*valp > val)
1586 *lvalp = (unsigned long)-val;
1589 *lvalp = (unsigned long)val;
1596 * init may raise the set.
1599 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1600 void __user *buffer, size_t *lenp, loff_t *ppos)
1604 if (!capable(CAP_SYS_MODULE)) {
1608 op = (current->pid == 1) ? OP_SET : OP_AND;
1609 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1610 do_proc_dointvec_bset_conv,&op);
1613 struct do_proc_dointvec_minmax_conv_param {
1618 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1620 int write, void *data)
1622 struct do_proc_dointvec_minmax_conv_param *param = data;
1624 int val = *negp ? -*lvalp : *lvalp;
1625 if ((param->min && *param->min > val) ||
1626 (param->max && *param->max < val))
1633 *lvalp = (unsigned long)-val;
1636 *lvalp = (unsigned long)val;
1643 * proc_dointvec_minmax - read a vector of integers with min/max values
1644 * @table: the sysctl table
1645 * @write: %TRUE if this is a write to the sysctl file
1646 * @filp: the file structure
1647 * @buffer: the user buffer
1648 * @lenp: the size of the user buffer
1650 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1651 * values from/to the user buffer, treated as an ASCII string.
1653 * This routine will ensure the values are within the range specified by
1654 * table->extra1 (min) and table->extra2 (max).
1656 * Returns 0 on success.
1658 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1659 void __user *buffer, size_t *lenp, loff_t *ppos)
1661 struct do_proc_dointvec_minmax_conv_param param = {
1662 .min = (int *) table->extra1,
1663 .max = (int *) table->extra2,
1665 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
1666 do_proc_dointvec_minmax_conv, ¶m);
1669 static int do_proc_doulongvec_minmax(ctl_table *table, int write,
1671 void __user *buffer,
1672 size_t *lenp, loff_t *ppos,
1673 unsigned long convmul,
1674 unsigned long convdiv)
1676 #define TMPBUFLEN 21
1677 unsigned long *i, *min, *max, val;
1678 int vleft, first=1, neg;
1680 char buf[TMPBUFLEN], *p;
1681 char __user *s = buffer;
1683 if (!table->data || !table->maxlen || !*lenp ||
1684 (*ppos && !write)) {
1689 i = (unsigned long *) table->data;
1690 min = (unsigned long *) table->extra1;
1691 max = (unsigned long *) table->extra2;
1692 vleft = table->maxlen / sizeof(unsigned long);
1695 for (; left && vleft--; i++, min++, max++, first=0) {
1710 if (len > TMPBUFLEN-1)
1712 if (copy_from_user(buf, s, len))
1716 if (*p == '-' && left > 1) {
1720 if (*p < '0' || *p > '9')
1722 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
1724 if ((len < left) && *p && !isspace(*p))
1733 if ((min && val < *min) || (max && val > *max))
1740 sprintf(p, "%lu", convdiv * (*i) / convmul);
1744 if(copy_to_user(s, buf, len))
1751 if (!write && !first && left) {
1752 if(put_user('\n', s))
1759 if (get_user(c, s++))
1775 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1776 * @table: the sysctl table
1777 * @write: %TRUE if this is a write to the sysctl file
1778 * @filp: the file structure
1779 * @buffer: the user buffer
1780 * @lenp: the size of the user buffer
1782 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1783 * values from/to the user buffer, treated as an ASCII string.
1785 * This routine will ensure the values are within the range specified by
1786 * table->extra1 (min) and table->extra2 (max).
1788 * Returns 0 on success.
1790 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1791 void __user *buffer, size_t *lenp, loff_t *ppos)
1793 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
1797 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1798 * @table: the sysctl table
1799 * @write: %TRUE if this is a write to the sysctl file
1800 * @filp: the file structure
1801 * @buffer: the user buffer
1802 * @lenp: the size of the user buffer
1804 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1805 * values from/to the user buffer, treated as an ASCII string. The values
1806 * are treated as milliseconds, and converted to jiffies when they are stored.
1808 * This routine will ensure the values are within the range specified by
1809 * table->extra1 (min) and table->extra2 (max).
1811 * Returns 0 on success.
1813 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1815 void __user *buffer,
1816 size_t *lenp, loff_t *ppos)
1818 return do_proc_doulongvec_minmax(table, write, filp, buffer,
1819 lenp, ppos, HZ, 1000l);
1823 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
1825 int write, void *data)
1828 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1834 lval = (unsigned long)-val;
1837 lval = (unsigned long)val;
1844 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
1846 int write, void *data)
1849 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1855 lval = (unsigned long)-val;
1858 lval = (unsigned long)val;
1860 *lvalp = jiffies_to_clock_t(lval);
1866 * proc_dointvec_jiffies - read a vector of integers as seconds
1867 * @table: the sysctl table
1868 * @write: %TRUE if this is a write to the sysctl file
1869 * @filp: the file structure
1870 * @buffer: the user buffer
1871 * @lenp: the size of the user buffer
1873 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1874 * values from/to the user buffer, treated as an ASCII string.
1875 * The values read are assumed to be in seconds, and are converted into
1878 * Returns 0 on success.
1880 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1881 void __user *buffer, size_t *lenp, loff_t *ppos)
1883 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1884 do_proc_dointvec_jiffies_conv,NULL);
1888 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1889 * @table: the sysctl table
1890 * @write: %TRUE if this is a write to the sysctl file
1891 * @filp: the file structure
1892 * @buffer: the user buffer
1893 * @lenp: the size of the user buffer
1895 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1896 * values from/to the user buffer, treated as an ASCII string.
1897 * The values read are assumed to be in 1/USER_HZ seconds, and
1898 * are converted into jiffies.
1900 * Returns 0 on success.
1902 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1903 void __user *buffer, size_t *lenp, loff_t *ppos)
1905 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1906 do_proc_dointvec_userhz_jiffies_conv,NULL);
1909 #else /* CONFIG_PROC_FS */
1911 int proc_dostring(ctl_table *table, int write, struct file *filp,
1912 void __user *buffer, size_t *lenp, loff_t *ppos)
1917 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1918 void __user *buffer, size_t *lenp, loff_t *ppos)
1923 int proc_dointvec(ctl_table *table, int write, struct file *filp,
1924 void __user *buffer, size_t *lenp, loff_t *ppos)
1929 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1930 void __user *buffer, size_t *lenp, loff_t *ppos)
1935 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1936 void __user *buffer, size_t *lenp, loff_t *ppos)
1941 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
1942 void __user *buffer, size_t *lenp, loff_t *ppos)
1947 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1948 void __user *buffer, size_t *lenp, loff_t *ppos)
1953 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
1954 void __user *buffer, size_t *lenp, loff_t *ppos)
1959 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
1961 void __user *buffer,
1962 size_t *lenp, loff_t *ppos)
1968 #endif /* CONFIG_PROC_FS */
1972 * General sysctl support routines
1975 /* The generic string strategy routine: */
1976 int sysctl_string(ctl_table *table, int __user *name, int nlen,
1977 void __user *oldval, size_t __user *oldlenp,
1978 void __user *newval, size_t newlen, void **context)
1982 if (!table->data || !table->maxlen)
1985 if (oldval && oldlenp) {
1986 if (get_user(len, oldlenp))
1989 l = strlen(table->data);
1990 if (len > l) len = l;
1991 if (len >= table->maxlen)
1992 len = table->maxlen;
1993 if(copy_to_user(oldval, table->data, len))
1995 if(put_user(0, ((char __user *) oldval) + len))
1997 if(put_user(len, oldlenp))
2001 if (newval && newlen) {
2003 if (len > table->maxlen)
2004 len = table->maxlen;
2005 if(copy_from_user(table->data, newval, len))
2007 if (len == table->maxlen)
2009 ((char *) table->data)[len] = 0;
2015 * This function makes sure that all of the integers in the vector
2016 * are between the minimum and maximum values given in the arrays
2017 * table->extra1 and table->extra2, respectively.
2019 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2020 void __user *oldval, size_t __user *oldlenp,
2021 void __user *newval, size_t newlen, void **context)
2024 if (newval && newlen) {
2025 int __user *vec = (int __user *) newval;
2026 int *min = (int *) table->extra1;
2027 int *max = (int *) table->extra2;
2031 if (newlen % sizeof(int) != 0)
2034 if (!table->extra1 && !table->extra2)
2037 if (newlen > table->maxlen)
2038 newlen = table->maxlen;
2039 length = newlen / sizeof(int);
2041 for (i = 0; i < length; i++) {
2043 if (get_user(value, vec + i))
2045 if (min && value < min[i])
2047 if (max && value > max[i])
2054 /* Strategy function to convert jiffies to seconds */
2055 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2056 void __user *oldval, size_t __user *oldlenp,
2057 void __user *newval, size_t newlen, void **context)
2062 if (get_user(olen, oldlenp))
2064 if (olen!=sizeof(int))
2067 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2068 (oldlenp && put_user(sizeof(int),oldlenp)))
2071 if (newval && newlen) {
2073 if (newlen != sizeof(int))
2075 if (get_user(new, (int __user *)newval))
2077 *(int *)(table->data) = new*HZ;
2083 #else /* CONFIG_SYSCTL */
2086 asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2091 int sysctl_string(ctl_table *table, int __user *name, int nlen,
2092 void __user *oldval, size_t __user *oldlenp,
2093 void __user *newval, size_t newlen, void **context)
2098 int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2099 void __user *oldval, size_t __user *oldlenp,
2100 void __user *newval, size_t newlen, void **context)
2105 int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2106 void __user *oldval, size_t __user *oldlenp,
2107 void __user *newval, size_t newlen, void **context)
2112 int proc_dostring(ctl_table *table, int write, struct file *filp,
2113 void __user *buffer, size_t *lenp, loff_t *ppos)
2118 int proc_dointvec(ctl_table *table, int write, struct file *filp,
2119 void __user *buffer, size_t *lenp, loff_t *ppos)
2124 int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2125 void __user *buffer, size_t *lenp, loff_t *ppos)
2130 int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2131 void __user *buffer, size_t *lenp, loff_t *ppos)
2136 int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2137 void __user *buffer, size_t *lenp, loff_t *ppos)
2142 int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2143 void __user *buffer, size_t *lenp, loff_t *ppos)
2148 int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2149 void __user *buffer, size_t *lenp, loff_t *ppos)
2154 int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2156 void __user *buffer,
2157 size_t *lenp, loff_t *ppos)
2162 struct ctl_table_header * register_sysctl_table(ctl_table * table,
2168 void unregister_sysctl_table(struct ctl_table_header * table)
2172 #endif /* CONFIG_SYSCTL */
2175 * No sense putting this after each symbol definition, twice,
2176 * exception granted :-)
2178 EXPORT_SYMBOL(proc_dointvec);
2179 EXPORT_SYMBOL(proc_dointvec_jiffies);
2180 EXPORT_SYMBOL(proc_dointvec_minmax);
2181 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2182 EXPORT_SYMBOL(proc_dostring);
2183 EXPORT_SYMBOL(proc_doulongvec_minmax);
2184 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2185 EXPORT_SYMBOL(register_sysctl_table);
2186 EXPORT_SYMBOL(sysctl_intvec);
2187 EXPORT_SYMBOL(sysctl_jiffies);
2188 EXPORT_SYMBOL(sysctl_string);
2189 EXPORT_SYMBOL(unregister_sysctl_table);