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/module.h>
23 #include <linux/swap.h>
24 #include <linux/slab.h>
25 #include <linux/sysctl.h>
26 #include <linux/proc_fs.h>
27 #include <linux/capability.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/kobject.h>
35 #include <linux/net.h>
36 #include <linux/sysrq.h>
37 #include <linux/highuid.h>
38 #include <linux/writeback.h>
39 #include <linux/hugetlb.h>
40 #include <linux/security.h>
41 #include <linux/initrd.h>
42 #include <linux/times.h>
43 #include <linux/limits.h>
44 #include <linux/dcache.h>
45 #include <linux/syscalls.h>
46 #include <linux/nfs_fs.h>
47 #include <linux/acpi.h>
49 #include <asm/uaccess.h>
50 #include <asm/processor.h>
52 extern int proc_nr_files(ctl_table
*table
, int write
, struct file
*filp
,
53 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
57 #include <asm/stacktrace.h>
60 #if defined(CONFIG_SYSCTL)
62 /* External variables not in a header file. */
64 extern int sysctl_overcommit_memory
;
65 extern int sysctl_overcommit_ratio
;
66 extern int sysctl_panic_on_oom
;
67 extern int max_threads
;
68 extern int sysrq_enabled
;
69 extern int core_uses_pid
;
70 extern int suid_dumpable
;
71 extern char core_pattern
[];
73 extern int min_free_kbytes
;
74 extern int printk_ratelimit_jiffies
;
75 extern int printk_ratelimit_burst
;
76 extern int pid_max_min
, pid_max_max
;
77 extern int sysctl_drop_caches
;
78 extern int percpu_pagelist_fraction
;
79 extern int compat_log
;
81 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
82 static int maxolduid
= 65535;
84 static int min_percpu_pagelist_fract
= 8;
86 static int ngroups_max
= NGROUPS_MAX
;
89 extern char modprobe_path
[];
91 #ifdef CONFIG_CHR_DEV_SG
92 extern int sg_big_buff
;
95 static int proc_do_ipc_string(ctl_table
*table
, int write
, struct file
*filp
,
96 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
100 extern char reboot_command
[];
101 extern int stop_a_enabled
;
102 extern int scons_pwroff
;
106 extern int pwrsw_enabled
;
107 extern int unaligned_enabled
;
111 #ifdef CONFIG_MATHEMU
112 extern int sysctl_ieee_emulation_warnings
;
114 extern int sysctl_userprocess_debug
;
115 extern int spin_retry
;
118 extern int sysctl_hz_timer
;
120 #ifdef CONFIG_BSD_PROCESS_ACCT
121 extern int acct_parm
[];
125 extern int no_unaligned_warning
;
128 #ifdef CONFIG_RT_MUTEXES
129 extern int max_lock_depth
;
132 #ifdef CONFIG_SYSCTL_SYSCALL
133 static int parse_table(int __user
*, int, void __user
*, size_t __user
*,
134 void __user
*, size_t, ctl_table
*, void **);
137 static int proc_do_uts_string(ctl_table
*table
, int write
, struct file
*filp
,
138 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
140 #ifdef CONFIG_PROC_SYSCTL
141 static int proc_do_cad_pid(ctl_table
*table
, int write
, struct file
*filp
,
142 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
145 static ctl_table root_table
[];
146 static struct ctl_table_header root_table_header
=
147 { root_table
, LIST_HEAD_INIT(root_table_header
.ctl_entry
) };
149 static ctl_table kern_table
[];
150 static ctl_table vm_table
[];
151 static ctl_table fs_table
[];
152 static ctl_table debug_table
[];
153 static ctl_table dev_table
[];
154 extern ctl_table random_table
[];
155 #ifdef CONFIG_UNIX98_PTYS
156 extern ctl_table pty_table
[];
158 #ifdef CONFIG_INOTIFY_USER
159 extern ctl_table inotify_table
[];
162 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
163 int sysctl_legacy_va_layout
;
166 /* /proc declarations: */
168 #ifdef CONFIG_PROC_SYSCTL
170 static ssize_t
proc_readsys(struct file
*, char __user
*, size_t, loff_t
*);
171 static ssize_t
proc_writesys(struct file
*, const char __user
*, size_t, loff_t
*);
172 static int proc_opensys(struct inode
*, struct file
*);
174 struct file_operations proc_sys_file_operations
= {
175 .open
= proc_opensys
,
176 .read
= proc_readsys
,
177 .write
= proc_writesys
,
180 extern struct proc_dir_entry
*proc_sys_root
;
182 static void register_proc_table(ctl_table
*, struct proc_dir_entry
*, void *);
183 static void unregister_proc_table(ctl_table
*, struct proc_dir_entry
*);
186 /* The default sysctl tables: */
188 static ctl_table root_table
[] = {
190 .ctl_name
= CTL_KERN
,
191 .procname
= "kernel",
216 .ctl_name
= CTL_DEBUG
,
219 .child
= debug_table
,
231 static ctl_table kern_table
[] = {
232 #ifndef CONFIG_UTS_NS
234 .ctl_name
= KERN_OSTYPE
,
235 .procname
= "ostype",
236 .data
= init_uts_ns
.name
.sysname
,
237 .maxlen
= sizeof(init_uts_ns
.name
.sysname
),
239 .proc_handler
= &proc_do_uts_string
,
240 .strategy
= &sysctl_string
,
243 .ctl_name
= KERN_OSRELEASE
,
244 .procname
= "osrelease",
245 .data
= init_uts_ns
.name
.release
,
246 .maxlen
= sizeof(init_uts_ns
.name
.release
),
248 .proc_handler
= &proc_do_uts_string
,
249 .strategy
= &sysctl_string
,
252 .ctl_name
= KERN_VERSION
,
253 .procname
= "version",
254 .data
= init_uts_ns
.name
.version
,
255 .maxlen
= sizeof(init_uts_ns
.name
.version
),
257 .proc_handler
= &proc_do_uts_string
,
258 .strategy
= &sysctl_string
,
261 .ctl_name
= KERN_NODENAME
,
262 .procname
= "hostname",
263 .data
= init_uts_ns
.name
.nodename
,
264 .maxlen
= sizeof(init_uts_ns
.name
.nodename
),
266 .proc_handler
= &proc_do_uts_string
,
267 .strategy
= &sysctl_string
,
270 .ctl_name
= KERN_DOMAINNAME
,
271 .procname
= "domainname",
272 .data
= init_uts_ns
.name
.domainname
,
273 .maxlen
= sizeof(init_uts_ns
.name
.domainname
),
275 .proc_handler
= &proc_do_uts_string
,
276 .strategy
= &sysctl_string
,
278 #else /* !CONFIG_UTS_NS */
280 .ctl_name
= KERN_OSTYPE
,
281 .procname
= "ostype",
283 /* could maybe use __NEW_UTS_LEN here? */
284 .maxlen
= FIELD_SIZEOF(struct new_utsname
, sysname
),
286 .proc_handler
= &proc_do_uts_string
,
287 .strategy
= &sysctl_string
,
290 .ctl_name
= KERN_OSRELEASE
,
291 .procname
= "osrelease",
293 .maxlen
= FIELD_SIZEOF(struct new_utsname
, release
),
295 .proc_handler
= &proc_do_uts_string
,
296 .strategy
= &sysctl_string
,
299 .ctl_name
= KERN_VERSION
,
300 .procname
= "version",
302 .maxlen
= FIELD_SIZEOF(struct new_utsname
, version
),
304 .proc_handler
= &proc_do_uts_string
,
305 .strategy
= &sysctl_string
,
308 .ctl_name
= KERN_NODENAME
,
309 .procname
= "hostname",
311 .maxlen
= FIELD_SIZEOF(struct new_utsname
, nodename
),
313 .proc_handler
= &proc_do_uts_string
,
314 .strategy
= &sysctl_string
,
317 .ctl_name
= KERN_DOMAINNAME
,
318 .procname
= "domainname",
320 .maxlen
= FIELD_SIZEOF(struct new_utsname
, domainname
),
322 .proc_handler
= &proc_do_uts_string
,
323 .strategy
= &sysctl_string
,
325 #endif /* !CONFIG_UTS_NS */
327 .ctl_name
= KERN_PANIC
,
329 .data
= &panic_timeout
,
330 .maxlen
= sizeof(int),
332 .proc_handler
= &proc_dointvec
,
335 .ctl_name
= KERN_CORE_USES_PID
,
336 .procname
= "core_uses_pid",
337 .data
= &core_uses_pid
,
338 .maxlen
= sizeof(int),
340 .proc_handler
= &proc_dointvec
,
343 .ctl_name
= KERN_CORE_PATTERN
,
344 .procname
= "core_pattern",
345 .data
= core_pattern
,
348 .proc_handler
= &proc_dostring
,
349 .strategy
= &sysctl_string
,
352 .ctl_name
= KERN_TAINTED
,
353 .procname
= "tainted",
355 .maxlen
= sizeof(int),
357 .proc_handler
= &proc_dointvec
,
360 .ctl_name
= KERN_CAP_BSET
,
361 .procname
= "cap-bound",
363 .maxlen
= sizeof(kernel_cap_t
),
365 .proc_handler
= &proc_dointvec_bset
,
367 #ifdef CONFIG_BLK_DEV_INITRD
369 .ctl_name
= KERN_REALROOTDEV
,
370 .procname
= "real-root-dev",
371 .data
= &real_root_dev
,
372 .maxlen
= sizeof(int),
374 .proc_handler
= &proc_dointvec
,
379 .ctl_name
= KERN_SPARC_REBOOT
,
380 .procname
= "reboot-cmd",
381 .data
= reboot_command
,
384 .proc_handler
= &proc_dostring
,
385 .strategy
= &sysctl_string
,
388 .ctl_name
= KERN_SPARC_STOP_A
,
389 .procname
= "stop-a",
390 .data
= &stop_a_enabled
,
391 .maxlen
= sizeof (int),
393 .proc_handler
= &proc_dointvec
,
396 .ctl_name
= KERN_SPARC_SCONS_PWROFF
,
397 .procname
= "scons-poweroff",
398 .data
= &scons_pwroff
,
399 .maxlen
= sizeof (int),
401 .proc_handler
= &proc_dointvec
,
406 .ctl_name
= KERN_HPPA_PWRSW
,
407 .procname
= "soft-power",
408 .data
= &pwrsw_enabled
,
409 .maxlen
= sizeof (int),
411 .proc_handler
= &proc_dointvec
,
414 .ctl_name
= KERN_HPPA_UNALIGNED
,
415 .procname
= "unaligned-trap",
416 .data
= &unaligned_enabled
,
417 .maxlen
= sizeof (int),
419 .proc_handler
= &proc_dointvec
,
423 .ctl_name
= KERN_CTLALTDEL
,
424 .procname
= "ctrl-alt-del",
426 .maxlen
= sizeof(int),
428 .proc_handler
= &proc_dointvec
,
431 .ctl_name
= KERN_PRINTK
,
432 .procname
= "printk",
433 .data
= &console_loglevel
,
434 .maxlen
= 4*sizeof(int),
436 .proc_handler
= &proc_dointvec
,
440 .ctl_name
= KERN_MODPROBE
,
441 .procname
= "modprobe",
442 .data
= &modprobe_path
,
443 .maxlen
= KMOD_PATH_LEN
,
445 .proc_handler
= &proc_dostring
,
446 .strategy
= &sysctl_string
,
449 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
451 .ctl_name
= KERN_HOTPLUG
,
452 .procname
= "hotplug",
453 .data
= &uevent_helper
,
454 .maxlen
= UEVENT_HELPER_PATH_LEN
,
456 .proc_handler
= &proc_dostring
,
457 .strategy
= &sysctl_string
,
460 #ifdef CONFIG_CHR_DEV_SG
462 .ctl_name
= KERN_SG_BIG_BUFF
,
463 .procname
= "sg-big-buff",
464 .data
= &sg_big_buff
,
465 .maxlen
= sizeof (int),
467 .proc_handler
= &proc_dointvec
,
470 #ifdef CONFIG_BSD_PROCESS_ACCT
472 .ctl_name
= KERN_ACCT
,
475 .maxlen
= 3*sizeof(int),
477 .proc_handler
= &proc_dointvec
,
480 #ifdef CONFIG_SYSVIPC
482 .ctl_name
= KERN_SHMMAX
,
483 .procname
= "shmmax",
485 .maxlen
= sizeof (size_t),
487 .proc_handler
= &proc_do_ipc_string
,
490 .ctl_name
= KERN_SHMALL
,
491 .procname
= "shmall",
493 .maxlen
= sizeof (size_t),
495 .proc_handler
= &proc_do_ipc_string
,
498 .ctl_name
= KERN_SHMMNI
,
499 .procname
= "shmmni",
501 .maxlen
= sizeof (int),
503 .proc_handler
= &proc_do_ipc_string
,
506 .ctl_name
= KERN_MSGMAX
,
507 .procname
= "msgmax",
509 .maxlen
= sizeof (int),
511 .proc_handler
= &proc_do_ipc_string
,
514 .ctl_name
= KERN_MSGMNI
,
515 .procname
= "msgmni",
517 .maxlen
= sizeof (int),
519 .proc_handler
= &proc_do_ipc_string
,
522 .ctl_name
= KERN_MSGMNB
,
523 .procname
= "msgmnb",
525 .maxlen
= sizeof (int),
527 .proc_handler
= &proc_do_ipc_string
,
530 .ctl_name
= KERN_SEM
,
533 .maxlen
= 4*sizeof (int),
535 .proc_handler
= &proc_do_ipc_string
,
538 #ifdef CONFIG_MAGIC_SYSRQ
540 .ctl_name
= KERN_SYSRQ
,
542 .data
= &sysrq_enabled
,
543 .maxlen
= sizeof (int),
545 .proc_handler
= &proc_dointvec
,
548 #ifdef CONFIG_PROC_SYSCTL
550 .ctl_name
= KERN_CADPID
,
551 .procname
= "cad_pid",
553 .maxlen
= sizeof (int),
555 .proc_handler
= &proc_do_cad_pid
,
559 .ctl_name
= KERN_MAX_THREADS
,
560 .procname
= "threads-max",
561 .data
= &max_threads
,
562 .maxlen
= sizeof(int),
564 .proc_handler
= &proc_dointvec
,
567 .ctl_name
= KERN_RANDOM
,
568 .procname
= "random",
570 .child
= random_table
,
572 #ifdef CONFIG_UNIX98_PTYS
574 .ctl_name
= KERN_PTY
,
581 .ctl_name
= KERN_OVERFLOWUID
,
582 .procname
= "overflowuid",
583 .data
= &overflowuid
,
584 .maxlen
= sizeof(int),
586 .proc_handler
= &proc_dointvec_minmax
,
587 .strategy
= &sysctl_intvec
,
588 .extra1
= &minolduid
,
589 .extra2
= &maxolduid
,
592 .ctl_name
= KERN_OVERFLOWGID
,
593 .procname
= "overflowgid",
594 .data
= &overflowgid
,
595 .maxlen
= sizeof(int),
597 .proc_handler
= &proc_dointvec_minmax
,
598 .strategy
= &sysctl_intvec
,
599 .extra1
= &minolduid
,
600 .extra2
= &maxolduid
,
603 #ifdef CONFIG_MATHEMU
605 .ctl_name
= KERN_IEEE_EMULATION_WARNINGS
,
606 .procname
= "ieee_emulation_warnings",
607 .data
= &sysctl_ieee_emulation_warnings
,
608 .maxlen
= sizeof(int),
610 .proc_handler
= &proc_dointvec
,
613 #ifdef CONFIG_NO_IDLE_HZ
615 .ctl_name
= KERN_HZ_TIMER
,
616 .procname
= "hz_timer",
617 .data
= &sysctl_hz_timer
,
618 .maxlen
= sizeof(int),
620 .proc_handler
= &proc_dointvec
,
624 .ctl_name
= KERN_S390_USER_DEBUG_LOGGING
,
625 .procname
= "userprocess_debug",
626 .data
= &sysctl_userprocess_debug
,
627 .maxlen
= sizeof(int),
629 .proc_handler
= &proc_dointvec
,
633 .ctl_name
= KERN_PIDMAX
,
634 .procname
= "pid_max",
636 .maxlen
= sizeof (int),
638 .proc_handler
= &proc_dointvec_minmax
,
639 .strategy
= sysctl_intvec
,
640 .extra1
= &pid_max_min
,
641 .extra2
= &pid_max_max
,
644 .ctl_name
= KERN_PANIC_ON_OOPS
,
645 .procname
= "panic_on_oops",
646 .data
= &panic_on_oops
,
647 .maxlen
= sizeof(int),
649 .proc_handler
= &proc_dointvec
,
652 .ctl_name
= KERN_PRINTK_RATELIMIT
,
653 .procname
= "printk_ratelimit",
654 .data
= &printk_ratelimit_jiffies
,
655 .maxlen
= sizeof(int),
657 .proc_handler
= &proc_dointvec_jiffies
,
658 .strategy
= &sysctl_jiffies
,
661 .ctl_name
= KERN_PRINTK_RATELIMIT_BURST
,
662 .procname
= "printk_ratelimit_burst",
663 .data
= &printk_ratelimit_burst
,
664 .maxlen
= sizeof(int),
666 .proc_handler
= &proc_dointvec
,
669 .ctl_name
= KERN_NGROUPS_MAX
,
670 .procname
= "ngroups_max",
671 .data
= &ngroups_max
,
672 .maxlen
= sizeof (int),
674 .proc_handler
= &proc_dointvec
,
676 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
678 .ctl_name
= KERN_UNKNOWN_NMI_PANIC
,
679 .procname
= "unknown_nmi_panic",
680 .data
= &unknown_nmi_panic
,
681 .maxlen
= sizeof (int),
683 .proc_handler
= &proc_dointvec
,
686 .ctl_name
= KERN_NMI_WATCHDOG
,
687 .procname
= "nmi_watchdog",
688 .data
= &nmi_watchdog_enabled
,
689 .maxlen
= sizeof (int),
691 .proc_handler
= &proc_nmi_enabled
,
694 #if defined(CONFIG_X86)
696 .ctl_name
= KERN_PANIC_ON_NMI
,
697 .procname
= "panic_on_unrecovered_nmi",
698 .data
= &panic_on_unrecovered_nmi
,
699 .maxlen
= sizeof(int),
701 .proc_handler
= &proc_dointvec
,
704 .ctl_name
= KERN_BOOTLOADER_TYPE
,
705 .procname
= "bootloader_type",
706 .data
= &bootloader_type
,
707 .maxlen
= sizeof (int),
709 .proc_handler
= &proc_dointvec
,
712 .ctl_name
= CTL_UNNUMBERED
,
713 .procname
= "kstack_depth_to_print",
714 .data
= &kstack_depth_to_print
,
715 .maxlen
= sizeof(int),
717 .proc_handler
= &proc_dointvec
,
720 #if defined(CONFIG_MMU)
722 .ctl_name
= KERN_RANDOMIZE
,
723 .procname
= "randomize_va_space",
724 .data
= &randomize_va_space
,
725 .maxlen
= sizeof(int),
727 .proc_handler
= &proc_dointvec
,
730 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
732 .ctl_name
= KERN_SPIN_RETRY
,
733 .procname
= "spin_retry",
735 .maxlen
= sizeof (int),
737 .proc_handler
= &proc_dointvec
,
740 #ifdef CONFIG_ACPI_SLEEP
742 .ctl_name
= KERN_ACPI_VIDEO_FLAGS
,
743 .procname
= "acpi_video_flags",
744 .data
= &acpi_video_flags
,
745 .maxlen
= sizeof (unsigned long),
747 .proc_handler
= &proc_doulongvec_minmax
,
752 .ctl_name
= KERN_IA64_UNALIGNED
,
753 .procname
= "ignore-unaligned-usertrap",
754 .data
= &no_unaligned_warning
,
755 .maxlen
= sizeof (int),
757 .proc_handler
= &proc_dointvec
,
762 .ctl_name
= KERN_COMPAT_LOG
,
763 .procname
= "compat-log",
765 .maxlen
= sizeof (int),
767 .proc_handler
= &proc_dointvec
,
770 #ifdef CONFIG_RT_MUTEXES
772 .ctl_name
= KERN_MAX_LOCK_DEPTH
,
773 .procname
= "max_lock_depth",
774 .data
= &max_lock_depth
,
775 .maxlen
= sizeof(int),
777 .proc_handler
= &proc_dointvec
,
784 /* Constants for minimum and maximum testing in vm_table.
785 We use these as one-element integer vectors. */
787 static int one_hundred
= 100;
790 static ctl_table vm_table
[] = {
792 .ctl_name
= VM_OVERCOMMIT_MEMORY
,
793 .procname
= "overcommit_memory",
794 .data
= &sysctl_overcommit_memory
,
795 .maxlen
= sizeof(sysctl_overcommit_memory
),
797 .proc_handler
= &proc_dointvec
,
800 .ctl_name
= VM_PANIC_ON_OOM
,
801 .procname
= "panic_on_oom",
802 .data
= &sysctl_panic_on_oom
,
803 .maxlen
= sizeof(sysctl_panic_on_oom
),
805 .proc_handler
= &proc_dointvec
,
808 .ctl_name
= VM_OVERCOMMIT_RATIO
,
809 .procname
= "overcommit_ratio",
810 .data
= &sysctl_overcommit_ratio
,
811 .maxlen
= sizeof(sysctl_overcommit_ratio
),
813 .proc_handler
= &proc_dointvec
,
816 .ctl_name
= VM_PAGE_CLUSTER
,
817 .procname
= "page-cluster",
818 .data
= &page_cluster
,
819 .maxlen
= sizeof(int),
821 .proc_handler
= &proc_dointvec
,
824 .ctl_name
= VM_DIRTY_BACKGROUND
,
825 .procname
= "dirty_background_ratio",
826 .data
= &dirty_background_ratio
,
827 .maxlen
= sizeof(dirty_background_ratio
),
829 .proc_handler
= &proc_dointvec_minmax
,
830 .strategy
= &sysctl_intvec
,
832 .extra2
= &one_hundred
,
835 .ctl_name
= VM_DIRTY_RATIO
,
836 .procname
= "dirty_ratio",
837 .data
= &vm_dirty_ratio
,
838 .maxlen
= sizeof(vm_dirty_ratio
),
840 .proc_handler
= &proc_dointvec_minmax
,
841 .strategy
= &sysctl_intvec
,
843 .extra2
= &one_hundred
,
846 .ctl_name
= VM_DIRTY_WB_CS
,
847 .procname
= "dirty_writeback_centisecs",
848 .data
= &dirty_writeback_interval
,
849 .maxlen
= sizeof(dirty_writeback_interval
),
851 .proc_handler
= &dirty_writeback_centisecs_handler
,
854 .ctl_name
= VM_DIRTY_EXPIRE_CS
,
855 .procname
= "dirty_expire_centisecs",
856 .data
= &dirty_expire_interval
,
857 .maxlen
= sizeof(dirty_expire_interval
),
859 .proc_handler
= &proc_dointvec_userhz_jiffies
,
862 .ctl_name
= VM_NR_PDFLUSH_THREADS
,
863 .procname
= "nr_pdflush_threads",
864 .data
= &nr_pdflush_threads
,
865 .maxlen
= sizeof nr_pdflush_threads
,
866 .mode
= 0444 /* read-only*/,
867 .proc_handler
= &proc_dointvec
,
870 .ctl_name
= VM_SWAPPINESS
,
871 .procname
= "swappiness",
872 .data
= &vm_swappiness
,
873 .maxlen
= sizeof(vm_swappiness
),
875 .proc_handler
= &proc_dointvec_minmax
,
876 .strategy
= &sysctl_intvec
,
878 .extra2
= &one_hundred
,
880 #ifdef CONFIG_HUGETLB_PAGE
882 .ctl_name
= VM_HUGETLB_PAGES
,
883 .procname
= "nr_hugepages",
884 .data
= &max_huge_pages
,
885 .maxlen
= sizeof(unsigned long),
887 .proc_handler
= &hugetlb_sysctl_handler
,
888 .extra1
= (void *)&hugetlb_zero
,
889 .extra2
= (void *)&hugetlb_infinity
,
892 .ctl_name
= VM_HUGETLB_GROUP
,
893 .procname
= "hugetlb_shm_group",
894 .data
= &sysctl_hugetlb_shm_group
,
895 .maxlen
= sizeof(gid_t
),
897 .proc_handler
= &proc_dointvec
,
901 .ctl_name
= VM_LOWMEM_RESERVE_RATIO
,
902 .procname
= "lowmem_reserve_ratio",
903 .data
= &sysctl_lowmem_reserve_ratio
,
904 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
906 .proc_handler
= &lowmem_reserve_ratio_sysctl_handler
,
907 .strategy
= &sysctl_intvec
,
910 .ctl_name
= VM_DROP_PAGECACHE
,
911 .procname
= "drop_caches",
912 .data
= &sysctl_drop_caches
,
913 .maxlen
= sizeof(int),
915 .proc_handler
= drop_caches_sysctl_handler
,
916 .strategy
= &sysctl_intvec
,
919 .ctl_name
= VM_MIN_FREE_KBYTES
,
920 .procname
= "min_free_kbytes",
921 .data
= &min_free_kbytes
,
922 .maxlen
= sizeof(min_free_kbytes
),
924 .proc_handler
= &min_free_kbytes_sysctl_handler
,
925 .strategy
= &sysctl_intvec
,
929 .ctl_name
= VM_PERCPU_PAGELIST_FRACTION
,
930 .procname
= "percpu_pagelist_fraction",
931 .data
= &percpu_pagelist_fraction
,
932 .maxlen
= sizeof(percpu_pagelist_fraction
),
934 .proc_handler
= &percpu_pagelist_fraction_sysctl_handler
,
935 .strategy
= &sysctl_intvec
,
936 .extra1
= &min_percpu_pagelist_fract
,
940 .ctl_name
= VM_MAX_MAP_COUNT
,
941 .procname
= "max_map_count",
942 .data
= &sysctl_max_map_count
,
943 .maxlen
= sizeof(sysctl_max_map_count
),
945 .proc_handler
= &proc_dointvec
949 .ctl_name
= VM_LAPTOP_MODE
,
950 .procname
= "laptop_mode",
951 .data
= &laptop_mode
,
952 .maxlen
= sizeof(laptop_mode
),
954 .proc_handler
= &proc_dointvec_jiffies
,
955 .strategy
= &sysctl_jiffies
,
958 .ctl_name
= VM_BLOCK_DUMP
,
959 .procname
= "block_dump",
961 .maxlen
= sizeof(block_dump
),
963 .proc_handler
= &proc_dointvec
,
964 .strategy
= &sysctl_intvec
,
968 .ctl_name
= VM_VFS_CACHE_PRESSURE
,
969 .procname
= "vfs_cache_pressure",
970 .data
= &sysctl_vfs_cache_pressure
,
971 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
973 .proc_handler
= &proc_dointvec
,
974 .strategy
= &sysctl_intvec
,
977 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
979 .ctl_name
= VM_LEGACY_VA_LAYOUT
,
980 .procname
= "legacy_va_layout",
981 .data
= &sysctl_legacy_va_layout
,
982 .maxlen
= sizeof(sysctl_legacy_va_layout
),
984 .proc_handler
= &proc_dointvec
,
985 .strategy
= &sysctl_intvec
,
991 .ctl_name
= VM_SWAP_TOKEN_TIMEOUT
,
992 .procname
= "swap_token_timeout",
993 .data
= &swap_token_default_timeout
,
994 .maxlen
= sizeof(swap_token_default_timeout
),
996 .proc_handler
= &proc_dointvec_jiffies
,
997 .strategy
= &sysctl_jiffies
,
1002 .ctl_name
= VM_ZONE_RECLAIM_MODE
,
1003 .procname
= "zone_reclaim_mode",
1004 .data
= &zone_reclaim_mode
,
1005 .maxlen
= sizeof(zone_reclaim_mode
),
1007 .proc_handler
= &proc_dointvec
,
1008 .strategy
= &sysctl_intvec
,
1012 .ctl_name
= VM_MIN_UNMAPPED
,
1013 .procname
= "min_unmapped_ratio",
1014 .data
= &sysctl_min_unmapped_ratio
,
1015 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1017 .proc_handler
= &sysctl_min_unmapped_ratio_sysctl_handler
,
1018 .strategy
= &sysctl_intvec
,
1020 .extra2
= &one_hundred
,
1023 .ctl_name
= VM_MIN_SLAB
,
1024 .procname
= "min_slab_ratio",
1025 .data
= &sysctl_min_slab_ratio
,
1026 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1028 .proc_handler
= &sysctl_min_slab_ratio_sysctl_handler
,
1029 .strategy
= &sysctl_intvec
,
1031 .extra2
= &one_hundred
,
1034 #ifdef CONFIG_X86_32
1036 .ctl_name
= VM_VDSO_ENABLED
,
1037 .procname
= "vdso_enabled",
1038 .data
= &vdso_enabled
,
1039 .maxlen
= sizeof(vdso_enabled
),
1041 .proc_handler
= &proc_dointvec
,
1042 .strategy
= &sysctl_intvec
,
1049 static ctl_table fs_table
[] = {
1051 .ctl_name
= FS_NRINODE
,
1052 .procname
= "inode-nr",
1053 .data
= &inodes_stat
,
1054 .maxlen
= 2*sizeof(int),
1056 .proc_handler
= &proc_dointvec
,
1059 .ctl_name
= FS_STATINODE
,
1060 .procname
= "inode-state",
1061 .data
= &inodes_stat
,
1062 .maxlen
= 7*sizeof(int),
1064 .proc_handler
= &proc_dointvec
,
1067 .ctl_name
= FS_NRFILE
,
1068 .procname
= "file-nr",
1069 .data
= &files_stat
,
1070 .maxlen
= 3*sizeof(int),
1072 .proc_handler
= &proc_nr_files
,
1075 .ctl_name
= FS_MAXFILE
,
1076 .procname
= "file-max",
1077 .data
= &files_stat
.max_files
,
1078 .maxlen
= sizeof(int),
1080 .proc_handler
= &proc_dointvec
,
1083 .ctl_name
= FS_DENTRY
,
1084 .procname
= "dentry-state",
1085 .data
= &dentry_stat
,
1086 .maxlen
= 6*sizeof(int),
1088 .proc_handler
= &proc_dointvec
,
1091 .ctl_name
= FS_OVERFLOWUID
,
1092 .procname
= "overflowuid",
1093 .data
= &fs_overflowuid
,
1094 .maxlen
= sizeof(int),
1096 .proc_handler
= &proc_dointvec_minmax
,
1097 .strategy
= &sysctl_intvec
,
1098 .extra1
= &minolduid
,
1099 .extra2
= &maxolduid
,
1102 .ctl_name
= FS_OVERFLOWGID
,
1103 .procname
= "overflowgid",
1104 .data
= &fs_overflowgid
,
1105 .maxlen
= sizeof(int),
1107 .proc_handler
= &proc_dointvec_minmax
,
1108 .strategy
= &sysctl_intvec
,
1109 .extra1
= &minolduid
,
1110 .extra2
= &maxolduid
,
1113 .ctl_name
= FS_LEASES
,
1114 .procname
= "leases-enable",
1115 .data
= &leases_enable
,
1116 .maxlen
= sizeof(int),
1118 .proc_handler
= &proc_dointvec
,
1120 #ifdef CONFIG_DNOTIFY
1122 .ctl_name
= FS_DIR_NOTIFY
,
1123 .procname
= "dir-notify-enable",
1124 .data
= &dir_notify_enable
,
1125 .maxlen
= sizeof(int),
1127 .proc_handler
= &proc_dointvec
,
1132 .ctl_name
= FS_LEASE_TIME
,
1133 .procname
= "lease-break-time",
1134 .data
= &lease_break_time
,
1135 .maxlen
= sizeof(int),
1137 .proc_handler
= &proc_dointvec
,
1140 .ctl_name
= FS_AIO_NR
,
1141 .procname
= "aio-nr",
1143 .maxlen
= sizeof(aio_nr
),
1145 .proc_handler
= &proc_doulongvec_minmax
,
1148 .ctl_name
= FS_AIO_MAX_NR
,
1149 .procname
= "aio-max-nr",
1150 .data
= &aio_max_nr
,
1151 .maxlen
= sizeof(aio_max_nr
),
1153 .proc_handler
= &proc_doulongvec_minmax
,
1155 #ifdef CONFIG_INOTIFY_USER
1157 .ctl_name
= FS_INOTIFY
,
1158 .procname
= "inotify",
1160 .child
= inotify_table
,
1165 .ctl_name
= KERN_SETUID_DUMPABLE
,
1166 .procname
= "suid_dumpable",
1167 .data
= &suid_dumpable
,
1168 .maxlen
= sizeof(int),
1170 .proc_handler
= &proc_dointvec
,
1175 static ctl_table debug_table
[] = {
1179 static ctl_table dev_table
[] = {
1183 extern void init_irq_proc (void);
1185 static DEFINE_SPINLOCK(sysctl_lock
);
1187 /* called under sysctl_lock */
1188 static int use_table(struct ctl_table_header
*p
)
1190 if (unlikely(p
->unregistering
))
1196 /* called under sysctl_lock */
1197 static void unuse_table(struct ctl_table_header
*p
)
1200 if (unlikely(p
->unregistering
))
1201 complete(p
->unregistering
);
1204 /* called under sysctl_lock, will reacquire if has to wait */
1205 static void start_unregistering(struct ctl_table_header
*p
)
1208 * if p->used is 0, nobody will ever touch that entry again;
1209 * we'll eliminate all paths to it before dropping sysctl_lock
1211 if (unlikely(p
->used
)) {
1212 struct completion wait
;
1213 init_completion(&wait
);
1214 p
->unregistering
= &wait
;
1215 spin_unlock(&sysctl_lock
);
1216 wait_for_completion(&wait
);
1217 spin_lock(&sysctl_lock
);
1220 * do not remove from the list until nobody holds it; walking the
1221 * list in do_sysctl() relies on that.
1223 list_del_init(&p
->ctl_entry
);
1226 void __init
sysctl_init(void)
1228 #ifdef CONFIG_PROC_SYSCTL
1229 register_proc_table(root_table
, proc_sys_root
, &root_table_header
);
1234 #ifdef CONFIG_SYSCTL_SYSCALL
1235 int do_sysctl(int __user
*name
, int nlen
, void __user
*oldval
, size_t __user
*oldlenp
,
1236 void __user
*newval
, size_t newlen
)
1238 struct list_head
*tmp
;
1239 int error
= -ENOTDIR
;
1241 if (nlen
<= 0 || nlen
>= CTL_MAXNAME
)
1245 if (!oldlenp
|| get_user(old_len
, oldlenp
))
1248 spin_lock(&sysctl_lock
);
1249 tmp
= &root_table_header
.ctl_entry
;
1251 struct ctl_table_header
*head
=
1252 list_entry(tmp
, struct ctl_table_header
, ctl_entry
);
1253 void *context
= NULL
;
1255 if (!use_table(head
))
1258 spin_unlock(&sysctl_lock
);
1260 error
= parse_table(name
, nlen
, oldval
, oldlenp
,
1261 newval
, newlen
, head
->ctl_table
,
1265 spin_lock(&sysctl_lock
);
1267 if (error
!= -ENOTDIR
)
1269 } while ((tmp
= tmp
->next
) != &root_table_header
.ctl_entry
);
1270 spin_unlock(&sysctl_lock
);
1274 asmlinkage
long sys_sysctl(struct __sysctl_args __user
*args
)
1276 struct __sysctl_args tmp
;
1279 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
1283 error
= do_sysctl(tmp
.name
, tmp
.nlen
, tmp
.oldval
, tmp
.oldlenp
,
1284 tmp
.newval
, tmp
.newlen
);
1288 #endif /* CONFIG_SYSCTL_SYSCALL */
1291 * ctl_perm does NOT grant the superuser all rights automatically, because
1292 * some sysctl variables are readonly even to root.
1295 static int test_perm(int mode
, int op
)
1299 else if (in_egroup_p(0))
1301 if ((mode
& op
& 0007) == op
)
1306 static inline int ctl_perm(ctl_table
*table
, int op
)
1309 error
= security_sysctl(table
, op
);
1312 return test_perm(table
->mode
, op
);
1315 #ifdef CONFIG_SYSCTL_SYSCALL
1316 static int parse_table(int __user
*name
, int nlen
,
1317 void __user
*oldval
, size_t __user
*oldlenp
,
1318 void __user
*newval
, size_t newlen
,
1319 ctl_table
*table
, void **context
)
1325 if (get_user(n
, name
))
1327 for ( ; table
->ctl_name
|| table
->procname
; table
++) {
1328 if (!table
->ctl_name
)
1330 if (n
== table
->ctl_name
|| table
->ctl_name
== CTL_ANY
) {
1333 if (ctl_perm(table
, 001))
1335 if (table
->strategy
) {
1336 error
= table
->strategy(
1339 newval
, newlen
, context
);
1345 table
= table
->child
;
1348 error
= do_sysctl_strategy(table
, name
, nlen
,
1350 newval
, newlen
, context
);
1357 /* Perform the actual read/write of a sysctl table entry. */
1358 int do_sysctl_strategy (ctl_table
*table
,
1359 int __user
*name
, int nlen
,
1360 void __user
*oldval
, size_t __user
*oldlenp
,
1361 void __user
*newval
, size_t newlen
, void **context
)
1370 if (ctl_perm(table
, op
))
1373 if (table
->strategy
) {
1374 rc
= table
->strategy(table
, name
, nlen
, oldval
, oldlenp
,
1375 newval
, newlen
, context
);
1382 /* If there is no strategy routine, or if the strategy returns
1383 * zero, proceed with automatic r/w */
1384 if (table
->data
&& table
->maxlen
) {
1385 if (oldval
&& oldlenp
) {
1386 if (get_user(len
, oldlenp
))
1389 if (len
> table
->maxlen
)
1390 len
= table
->maxlen
;
1391 if(copy_to_user(oldval
, table
->data
, len
))
1393 if(put_user(len
, oldlenp
))
1397 if (newval
&& newlen
) {
1399 if (len
> table
->maxlen
)
1400 len
= table
->maxlen
;
1401 if(copy_from_user(table
->data
, newval
, len
))
1407 #endif /* CONFIG_SYSCTL_SYSCALL */
1410 * register_sysctl_table - register a sysctl hierarchy
1411 * @table: the top-level table structure
1412 * @insert_at_head: whether the entry should be inserted in front or at the end
1414 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1415 * array. An entry with a ctl_name of 0 terminates the table.
1417 * The members of the &ctl_table structure are used as follows:
1419 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1420 * must be unique within that level of sysctl
1422 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1423 * enter a sysctl file
1425 * data - a pointer to data for use by proc_handler
1427 * maxlen - the maximum size in bytes of the data
1429 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1431 * child - a pointer to the child sysctl table if this entry is a directory, or
1434 * proc_handler - the text handler routine (described below)
1436 * strategy - the strategy routine (described below)
1438 * de - for internal use by the sysctl routines
1440 * extra1, extra2 - extra pointers usable by the proc handler routines
1442 * Leaf nodes in the sysctl tree will be represented by a single file
1443 * under /proc; non-leaf nodes will be represented by directories.
1445 * sysctl(2) can automatically manage read and write requests through
1446 * the sysctl table. The data and maxlen fields of the ctl_table
1447 * struct enable minimal validation of the values being written to be
1448 * performed, and the mode field allows minimal authentication.
1450 * More sophisticated management can be enabled by the provision of a
1451 * strategy routine with the table entry. This will be called before
1452 * any automatic read or write of the data is performed.
1454 * The strategy routine may return
1456 * < 0 - Error occurred (error is passed to user process)
1458 * 0 - OK - proceed with automatic read or write.
1460 * > 0 - OK - read or write has been done by the strategy routine, so
1461 * return immediately.
1463 * There must be a proc_handler routine for any terminal nodes
1464 * mirrored under /proc/sys (non-terminals are handled by a built-in
1465 * directory handler). Several default handlers are available to
1466 * cover common cases -
1468 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1469 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1470 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1472 * It is the handler's job to read the input buffer from user memory
1473 * and process it. The handler should return 0 on success.
1475 * This routine returns %NULL on a failure to register, and a pointer
1476 * to the table header on success.
1478 struct ctl_table_header
*register_sysctl_table(ctl_table
* table
,
1481 struct ctl_table_header
*tmp
;
1482 tmp
= kmalloc(sizeof(struct ctl_table_header
), GFP_KERNEL
);
1485 tmp
->ctl_table
= table
;
1486 INIT_LIST_HEAD(&tmp
->ctl_entry
);
1488 tmp
->unregistering
= NULL
;
1489 spin_lock(&sysctl_lock
);
1491 list_add(&tmp
->ctl_entry
, &root_table_header
.ctl_entry
);
1493 list_add_tail(&tmp
->ctl_entry
, &root_table_header
.ctl_entry
);
1494 spin_unlock(&sysctl_lock
);
1495 #ifdef CONFIG_PROC_SYSCTL
1496 register_proc_table(table
, proc_sys_root
, tmp
);
1502 * unregister_sysctl_table - unregister a sysctl table hierarchy
1503 * @header: the header returned from register_sysctl_table
1505 * Unregisters the sysctl table and all children. proc entries may not
1506 * actually be removed until they are no longer used by anyone.
1508 void unregister_sysctl_table(struct ctl_table_header
* header
)
1511 spin_lock(&sysctl_lock
);
1512 start_unregistering(header
);
1513 #ifdef CONFIG_PROC_SYSCTL
1514 unregister_proc_table(header
->ctl_table
, proc_sys_root
);
1516 spin_unlock(&sysctl_lock
);
1520 #else /* !CONFIG_SYSCTL */
1521 struct ctl_table_header
* register_sysctl_table(ctl_table
* table
,
1527 void unregister_sysctl_table(struct ctl_table_header
* table
)
1531 #endif /* CONFIG_SYSCTL */
1537 #ifdef CONFIG_PROC_SYSCTL
1539 /* Scan the sysctl entries in table and add them all into /proc */
1540 static void register_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
, void *set
)
1542 struct proc_dir_entry
*de
;
1546 for (; table
->ctl_name
|| table
->procname
; table
++) {
1547 /* Can't do anything without a proc name. */
1548 if (!table
->procname
)
1550 /* Maybe we can't do anything with it... */
1551 if (!table
->proc_handler
&& !table
->child
) {
1552 printk(KERN_WARNING
"SYSCTL: Can't register %s\n",
1557 len
= strlen(table
->procname
);
1561 if (table
->proc_handler
)
1565 for (de
= root
->subdir
; de
; de
= de
->next
) {
1566 if (proc_match(len
, table
->procname
, de
))
1569 /* If the subdir exists already, de is non-NULL */
1573 de
= create_proc_entry(table
->procname
, mode
, root
);
1577 de
->data
= (void *) table
;
1578 if (table
->proc_handler
)
1579 de
->proc_fops
= &proc_sys_file_operations
;
1582 if (de
->mode
& S_IFDIR
)
1583 register_proc_table(table
->child
, de
, set
);
1588 * Unregister a /proc sysctl table and any subdirectories.
1590 static void unregister_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
)
1592 struct proc_dir_entry
*de
;
1593 for (; table
->ctl_name
|| table
->procname
; table
++) {
1594 if (!(de
= table
->de
))
1596 if (de
->mode
& S_IFDIR
) {
1597 if (!table
->child
) {
1598 printk (KERN_ALERT
"Help - malformed sysctl tree on free\n");
1601 unregister_proc_table(table
->child
, de
);
1603 /* Don't unregister directories which still have entries.. */
1609 * In any case, mark the entry as goner; we'll keep it
1610 * around if it's busy, but we'll know to do nothing with
1611 * its fields. We are under sysctl_lock here.
1615 /* Don't unregister proc entries that are still being used.. */
1616 if (atomic_read(&de
->count
))
1620 remove_proc_entry(table
->procname
, root
);
1624 static ssize_t
do_rw_proc(int write
, struct file
* file
, char __user
* buf
,
1625 size_t count
, loff_t
*ppos
)
1628 struct proc_dir_entry
*de
= PDE(file
->f_dentry
->d_inode
);
1629 struct ctl_table
*table
;
1631 ssize_t error
= -ENOTDIR
;
1633 spin_lock(&sysctl_lock
);
1634 if (de
&& de
->data
&& use_table(de
->set
)) {
1636 * at that point we know that sysctl was not unregistered
1637 * and won't be until we finish
1639 spin_unlock(&sysctl_lock
);
1640 table
= (struct ctl_table
*) de
->data
;
1641 if (!table
|| !table
->proc_handler
)
1644 op
= (write
? 002 : 004);
1645 if (ctl_perm(table
, op
))
1648 /* careful: calling conventions are nasty here */
1650 error
= (*table
->proc_handler
)(table
, write
, file
,
1655 spin_lock(&sysctl_lock
);
1656 unuse_table(de
->set
);
1658 spin_unlock(&sysctl_lock
);
1662 static int proc_opensys(struct inode
*inode
, struct file
*file
)
1664 if (file
->f_mode
& FMODE_WRITE
) {
1666 * sysctl entries that are not writable,
1667 * are _NOT_ writable, capabilities or not.
1669 if (!(inode
->i_mode
& S_IWUSR
))
1676 static ssize_t
proc_readsys(struct file
* file
, char __user
* buf
,
1677 size_t count
, loff_t
*ppos
)
1679 return do_rw_proc(0, file
, buf
, count
, ppos
);
1682 static ssize_t
proc_writesys(struct file
* file
, const char __user
* buf
,
1683 size_t count
, loff_t
*ppos
)
1685 return do_rw_proc(1, file
, (char __user
*) buf
, count
, ppos
);
1688 static int _proc_do_string(void* data
, int maxlen
, int write
,
1689 struct file
*filp
, void __user
*buffer
,
1690 size_t *lenp
, loff_t
*ppos
)
1696 if (!data
|| !maxlen
|| !*lenp
||
1697 (*ppos
&& !write
)) {
1705 while (len
< *lenp
) {
1706 if (get_user(c
, p
++))
1708 if (c
== 0 || c
== '\n')
1714 if(copy_from_user(data
, buffer
, len
))
1716 ((char *) data
)[len
] = 0;
1725 if(copy_to_user(buffer
, data
, len
))
1728 if(put_user('\n', ((char __user
*) buffer
) + len
))
1739 * proc_dostring - read a string sysctl
1740 * @table: the sysctl table
1741 * @write: %TRUE if this is a write to the sysctl file
1742 * @filp: the file structure
1743 * @buffer: the user buffer
1744 * @lenp: the size of the user buffer
1745 * @ppos: file position
1747 * Reads/writes a string from/to the user buffer. If the kernel
1748 * buffer provided is not large enough to hold the string, the
1749 * string is truncated. The copied string is %NULL-terminated.
1750 * If the string is being read by the user process, it is copied
1751 * and a newline '\n' is added. It is truncated if the buffer is
1754 * Returns 0 on success.
1756 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
1757 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1759 return _proc_do_string(table
->data
, table
->maxlen
, write
, filp
,
1760 buffer
, lenp
, ppos
);
1764 * Special case of dostring for the UTS structure. This has locks
1765 * to observe. Should this be in kernel/sys.c ????
1768 #ifndef CONFIG_UTS_NS
1769 static int proc_do_uts_string(ctl_table
*table
, int write
, struct file
*filp
,
1770 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1775 down_read(&uts_sem
);
1776 r
=proc_dostring(table
,0,filp
,buffer
,lenp
, ppos
);
1779 down_write(&uts_sem
);
1780 r
=proc_dostring(table
,1,filp
,buffer
,lenp
, ppos
);
1785 #else /* !CONFIG_UTS_NS */
1786 static int proc_do_uts_string(ctl_table
*table
, int write
, struct file
*filp
,
1787 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1790 struct uts_namespace
* uts_ns
= current
->nsproxy
->uts_ns
;
1793 switch (table
->ctl_name
) {
1795 which
= uts_ns
->name
.sysname
;
1798 which
= uts_ns
->name
.nodename
;
1800 case KERN_OSRELEASE
:
1801 which
= uts_ns
->name
.release
;
1804 which
= uts_ns
->name
.version
;
1806 case KERN_DOMAINNAME
:
1807 which
= uts_ns
->name
.domainname
;
1815 down_read(&uts_sem
);
1816 r
=_proc_do_string(which
,table
->maxlen
,0,filp
,buffer
,lenp
, ppos
);
1819 down_write(&uts_sem
);
1820 r
=_proc_do_string(which
,table
->maxlen
,1,filp
,buffer
,lenp
, ppos
);
1826 #endif /* !CONFIG_UTS_NS */
1828 static int do_proc_dointvec_conv(int *negp
, unsigned long *lvalp
,
1830 int write
, void *data
)
1833 *valp
= *negp
? -*lvalp
: *lvalp
;
1838 *lvalp
= (unsigned long)-val
;
1841 *lvalp
= (unsigned long)val
;
1847 static int __do_proc_dointvec(void *tbl_data
, ctl_table
*table
,
1848 int write
, struct file
*filp
, void __user
*buffer
,
1849 size_t *lenp
, loff_t
*ppos
,
1850 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
1851 int write
, void *data
),
1854 #define TMPBUFLEN 21
1855 int *i
, vleft
, first
=1, neg
, val
;
1859 char buf
[TMPBUFLEN
], *p
;
1860 char __user
*s
= buffer
;
1862 if (!tbl_data
|| !table
->maxlen
|| !*lenp
||
1863 (*ppos
&& !write
)) {
1868 i
= (int *) tbl_data
;
1869 vleft
= table
->maxlen
/ sizeof(*i
);
1873 conv
= do_proc_dointvec_conv
;
1875 for (; left
&& vleft
--; i
++, first
=0) {
1890 if (len
> sizeof(buf
) - 1)
1891 len
= sizeof(buf
) - 1;
1892 if (copy_from_user(buf
, s
, len
))
1896 if (*p
== '-' && left
> 1) {
1900 if (*p
< '0' || *p
> '9')
1903 lval
= simple_strtoul(p
, &p
, 0);
1906 if ((len
< left
) && *p
&& !isspace(*p
))
1913 if (conv(&neg
, &lval
, i
, 1, data
))
1920 if (conv(&neg
, &lval
, i
, 0, data
))
1923 sprintf(p
, "%s%lu", neg
? "-" : "", lval
);
1927 if(copy_to_user(s
, buf
, len
))
1934 if (!write
&& !first
&& left
) {
1935 if(put_user('\n', s
))
1942 if (get_user(c
, s
++))
1957 static int do_proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
1958 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
1959 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
1960 int write
, void *data
),
1963 return __do_proc_dointvec(table
->data
, table
, write
, filp
,
1964 buffer
, lenp
, ppos
, conv
, data
);
1968 * proc_dointvec - read a vector of integers
1969 * @table: the sysctl table
1970 * @write: %TRUE if this is a write to the sysctl file
1971 * @filp: the file structure
1972 * @buffer: the user buffer
1973 * @lenp: the size of the user buffer
1974 * @ppos: file position
1976 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1977 * values from/to the user buffer, treated as an ASCII string.
1979 * Returns 0 on success.
1981 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
1982 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1984 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
1994 static int do_proc_dointvec_bset_conv(int *negp
, unsigned long *lvalp
,
1996 int write
, void *data
)
1998 int op
= *(int *)data
;
2000 int val
= *negp
? -*lvalp
: *lvalp
;
2002 case OP_SET
: *valp
= val
; break;
2003 case OP_AND
: *valp
&= val
; break;
2004 case OP_OR
: *valp
|= val
; break;
2005 case OP_MAX
: if(*valp
< val
)
2008 case OP_MIN
: if(*valp
> val
)
2016 *lvalp
= (unsigned long)-val
;
2019 *lvalp
= (unsigned long)val
;
2026 * init may raise the set.
2029 int proc_dointvec_bset(ctl_table
*table
, int write
, struct file
*filp
,
2030 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2034 if (!capable(CAP_SYS_MODULE
)) {
2038 op
= is_init(current
) ? OP_SET
: OP_AND
;
2039 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
2040 do_proc_dointvec_bset_conv
,&op
);
2043 struct do_proc_dointvec_minmax_conv_param
{
2048 static int do_proc_dointvec_minmax_conv(int *negp
, unsigned long *lvalp
,
2050 int write
, void *data
)
2052 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2054 int val
= *negp
? -*lvalp
: *lvalp
;
2055 if ((param
->min
&& *param
->min
> val
) ||
2056 (param
->max
&& *param
->max
< val
))
2063 *lvalp
= (unsigned long)-val
;
2066 *lvalp
= (unsigned long)val
;
2073 * proc_dointvec_minmax - read a vector of integers with min/max values
2074 * @table: the sysctl table
2075 * @write: %TRUE if this is a write to the sysctl file
2076 * @filp: the file structure
2077 * @buffer: the user buffer
2078 * @lenp: the size of the user buffer
2079 * @ppos: file position
2081 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2082 * values from/to the user buffer, treated as an ASCII string.
2084 * This routine will ensure the values are within the range specified by
2085 * table->extra1 (min) and table->extra2 (max).
2087 * Returns 0 on success.
2089 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2090 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2092 struct do_proc_dointvec_minmax_conv_param param
= {
2093 .min
= (int *) table
->extra1
,
2094 .max
= (int *) table
->extra2
,
2096 return do_proc_dointvec(table
, write
, filp
, buffer
, lenp
, ppos
,
2097 do_proc_dointvec_minmax_conv
, ¶m
);
2100 static int __do_proc_doulongvec_minmax(void *data
, ctl_table
*table
, int write
,
2102 void __user
*buffer
,
2103 size_t *lenp
, loff_t
*ppos
,
2104 unsigned long convmul
,
2105 unsigned long convdiv
)
2107 #define TMPBUFLEN 21
2108 unsigned long *i
, *min
, *max
, val
;
2109 int vleft
, first
=1, neg
;
2111 char buf
[TMPBUFLEN
], *p
;
2112 char __user
*s
= buffer
;
2114 if (!data
|| !table
->maxlen
|| !*lenp
||
2115 (*ppos
&& !write
)) {
2120 i
= (unsigned long *) data
;
2121 min
= (unsigned long *) table
->extra1
;
2122 max
= (unsigned long *) table
->extra2
;
2123 vleft
= table
->maxlen
/ sizeof(unsigned long);
2126 for (; left
&& vleft
--; i
++, min
++, max
++, first
=0) {
2141 if (len
> TMPBUFLEN
-1)
2143 if (copy_from_user(buf
, s
, len
))
2147 if (*p
== '-' && left
> 1) {
2151 if (*p
< '0' || *p
> '9')
2153 val
= simple_strtoul(p
, &p
, 0) * convmul
/ convdiv
;
2155 if ((len
< left
) && *p
&& !isspace(*p
))
2164 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2171 sprintf(p
, "%lu", convdiv
* (*i
) / convmul
);
2175 if(copy_to_user(s
, buf
, len
))
2182 if (!write
&& !first
&& left
) {
2183 if(put_user('\n', s
))
2190 if (get_user(c
, s
++))
2205 static int do_proc_doulongvec_minmax(ctl_table
*table
, int write
,
2207 void __user
*buffer
,
2208 size_t *lenp
, loff_t
*ppos
,
2209 unsigned long convmul
,
2210 unsigned long convdiv
)
2212 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2213 filp
, buffer
, lenp
, ppos
, convmul
, convdiv
);
2217 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2218 * @table: the sysctl table
2219 * @write: %TRUE if this is a write to the sysctl file
2220 * @filp: the file structure
2221 * @buffer: the user buffer
2222 * @lenp: the size of the user buffer
2223 * @ppos: file position
2225 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2226 * values from/to the user buffer, treated as an ASCII string.
2228 * This routine will ensure the values are within the range specified by
2229 * table->extra1 (min) and table->extra2 (max).
2231 * Returns 0 on success.
2233 int proc_doulongvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2234 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2236 return do_proc_doulongvec_minmax(table
, write
, filp
, buffer
, lenp
, ppos
, 1l, 1l);
2240 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2241 * @table: the sysctl table
2242 * @write: %TRUE if this is a write to the sysctl file
2243 * @filp: the file structure
2244 * @buffer: the user buffer
2245 * @lenp: the size of the user buffer
2246 * @ppos: file position
2248 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2249 * values from/to the user buffer, treated as an ASCII string. The values
2250 * are treated as milliseconds, and converted to jiffies when they are stored.
2252 * This routine will ensure the values are within the range specified by
2253 * table->extra1 (min) and table->extra2 (max).
2255 * Returns 0 on success.
2257 int proc_doulongvec_ms_jiffies_minmax(ctl_table
*table
, int write
,
2259 void __user
*buffer
,
2260 size_t *lenp
, loff_t
*ppos
)
2262 return do_proc_doulongvec_minmax(table
, write
, filp
, buffer
,
2263 lenp
, ppos
, HZ
, 1000l);
2267 static int do_proc_dointvec_jiffies_conv(int *negp
, unsigned long *lvalp
,
2269 int write
, void *data
)
2272 if (*lvalp
> LONG_MAX
/ HZ
)
2274 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2280 lval
= (unsigned long)-val
;
2283 lval
= (unsigned long)val
;
2290 static int do_proc_dointvec_userhz_jiffies_conv(int *negp
, unsigned long *lvalp
,
2292 int write
, void *data
)
2295 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2297 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2303 lval
= (unsigned long)-val
;
2306 lval
= (unsigned long)val
;
2308 *lvalp
= jiffies_to_clock_t(lval
);
2313 static int do_proc_dointvec_ms_jiffies_conv(int *negp
, unsigned long *lvalp
,
2315 int write
, void *data
)
2318 *valp
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2324 lval
= (unsigned long)-val
;
2327 lval
= (unsigned long)val
;
2329 *lvalp
= jiffies_to_msecs(lval
);
2335 * proc_dointvec_jiffies - read a vector of integers as seconds
2336 * @table: the sysctl table
2337 * @write: %TRUE if this is a write to the sysctl file
2338 * @filp: the file structure
2339 * @buffer: the user buffer
2340 * @lenp: the size of the user buffer
2341 * @ppos: file position
2343 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2344 * values from/to the user buffer, treated as an ASCII string.
2345 * The values read are assumed to be in seconds, and are converted into
2348 * Returns 0 on success.
2350 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2351 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2353 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
2354 do_proc_dointvec_jiffies_conv
,NULL
);
2358 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2359 * @table: the sysctl table
2360 * @write: %TRUE if this is a write to the sysctl file
2361 * @filp: the file structure
2362 * @buffer: the user buffer
2363 * @lenp: the size of the user buffer
2364 * @ppos: pointer to the file position
2366 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2367 * values from/to the user buffer, treated as an ASCII string.
2368 * The values read are assumed to be in 1/USER_HZ seconds, and
2369 * are converted into jiffies.
2371 * Returns 0 on success.
2373 int proc_dointvec_userhz_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2374 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2376 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
2377 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2381 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2382 * @table: the sysctl table
2383 * @write: %TRUE if this is a write to the sysctl file
2384 * @filp: the file structure
2385 * @buffer: the user buffer
2386 * @lenp: the size of the user buffer
2387 * @ppos: file position
2388 * @ppos: the current position in the file
2390 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2391 * values from/to the user buffer, treated as an ASCII string.
2392 * The values read are assumed to be in 1/1000 seconds, and
2393 * are converted into jiffies.
2395 * Returns 0 on success.
2397 int proc_dointvec_ms_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2398 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2400 return do_proc_dointvec(table
, write
, filp
, buffer
, lenp
, ppos
,
2401 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2404 #ifdef CONFIG_SYSVIPC
2405 static int proc_do_ipc_string(ctl_table
*table
, int write
, struct file
*filp
,
2406 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2409 struct ipc_namespace
*ns
;
2411 ns
= current
->nsproxy
->ipc_ns
;
2413 switch (table
->ctl_name
) {
2415 data
= &ns
->shm_ctlmax
;
2418 data
= &ns
->shm_ctlall
;
2421 data
= &ns
->shm_ctlmni
;
2424 data
= &ns
->msg_ctlmax
;
2427 data
= &ns
->msg_ctlmni
;
2430 data
= &ns
->msg_ctlmnb
;
2433 data
= &ns
->sem_ctls
;
2439 return __do_proc_dointvec(data
, table
, write
, filp
, buffer
,
2440 lenp
, ppos
, NULL
, NULL
);
2442 return __do_proc_doulongvec_minmax(data
, table
, write
, filp
, buffer
,
2443 lenp
, ppos
, 1l, 1l);
2447 static int proc_do_cad_pid(ctl_table
*table
, int write
, struct file
*filp
,
2448 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2450 struct pid
*new_pid
;
2454 tmp
= pid_nr(cad_pid
);
2456 r
= __do_proc_dointvec(&tmp
, table
, write
, filp
, buffer
,
2457 lenp
, ppos
, NULL
, NULL
);
2461 new_pid
= find_get_pid(tmp
);
2465 put_pid(xchg(&cad_pid
, new_pid
));
2469 #else /* CONFIG_PROC_FS */
2471 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
2472 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2477 static int proc_do_uts_string(ctl_table
*table
, int write
, struct file
*filp
,
2478 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2483 #ifdef CONFIG_SYSVIPC
2484 static int proc_do_ipc_string(ctl_table
*table
, int write
, struct file
*filp
,
2485 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2491 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
2492 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2497 int proc_dointvec_bset(ctl_table
*table
, int write
, struct file
*filp
,
2498 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2503 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2504 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2509 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2510 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2515 int proc_dointvec_userhz_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2516 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2521 int proc_dointvec_ms_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2522 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2527 int proc_doulongvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2528 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2533 int proc_doulongvec_ms_jiffies_minmax(ctl_table
*table
, int write
,
2535 void __user
*buffer
,
2536 size_t *lenp
, loff_t
*ppos
)
2542 #endif /* CONFIG_PROC_FS */
2545 #ifdef CONFIG_SYSCTL_SYSCALL
2547 * General sysctl support routines
2550 /* The generic string strategy routine: */
2551 int sysctl_string(ctl_table
*table
, int __user
*name
, int nlen
,
2552 void __user
*oldval
, size_t __user
*oldlenp
,
2553 void __user
*newval
, size_t newlen
, void **context
)
2555 if (!table
->data
|| !table
->maxlen
)
2558 if (oldval
&& oldlenp
) {
2560 if (get_user(bufsize
, oldlenp
))
2563 size_t len
= strlen(table
->data
), copied
;
2565 /* This shouldn't trigger for a well-formed sysctl */
2566 if (len
> table
->maxlen
)
2567 len
= table
->maxlen
;
2569 /* Copy up to a max of bufsize-1 bytes of the string */
2570 copied
= (len
>= bufsize
) ? bufsize
- 1 : len
;
2572 if (copy_to_user(oldval
, table
->data
, copied
) ||
2573 put_user(0, (char __user
*)(oldval
+ copied
)))
2575 if (put_user(len
, oldlenp
))
2579 if (newval
&& newlen
) {
2580 size_t len
= newlen
;
2581 if (len
> table
->maxlen
)
2582 len
= table
->maxlen
;
2583 if(copy_from_user(table
->data
, newval
, len
))
2585 if (len
== table
->maxlen
)
2587 ((char *) table
->data
)[len
] = 0;
2593 * This function makes sure that all of the integers in the vector
2594 * are between the minimum and maximum values given in the arrays
2595 * table->extra1 and table->extra2, respectively.
2597 int sysctl_intvec(ctl_table
*table
, int __user
*name
, int nlen
,
2598 void __user
*oldval
, size_t __user
*oldlenp
,
2599 void __user
*newval
, size_t newlen
, void **context
)
2602 if (newval
&& newlen
) {
2603 int __user
*vec
= (int __user
*) newval
;
2604 int *min
= (int *) table
->extra1
;
2605 int *max
= (int *) table
->extra2
;
2609 if (newlen
% sizeof(int) != 0)
2612 if (!table
->extra1
&& !table
->extra2
)
2615 if (newlen
> table
->maxlen
)
2616 newlen
= table
->maxlen
;
2617 length
= newlen
/ sizeof(int);
2619 for (i
= 0; i
< length
; i
++) {
2621 if (get_user(value
, vec
+ i
))
2623 if (min
&& value
< min
[i
])
2625 if (max
&& value
> max
[i
])
2632 /* Strategy function to convert jiffies to seconds */
2633 int sysctl_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2634 void __user
*oldval
, size_t __user
*oldlenp
,
2635 void __user
*newval
, size_t newlen
, void **context
)
2640 if (get_user(olen
, oldlenp
))
2642 if (olen
!=sizeof(int))
2645 if (put_user(*(int *)(table
->data
)/HZ
, (int __user
*)oldval
) ||
2646 (oldlenp
&& put_user(sizeof(int),oldlenp
)))
2649 if (newval
&& newlen
) {
2651 if (newlen
!= sizeof(int))
2653 if (get_user(new, (int __user
*)newval
))
2655 *(int *)(table
->data
) = new*HZ
;
2660 /* Strategy function to convert jiffies to seconds */
2661 int sysctl_ms_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2662 void __user
*oldval
, size_t __user
*oldlenp
,
2663 void __user
*newval
, size_t newlen
, void **context
)
2668 if (get_user(olen
, oldlenp
))
2670 if (olen
!=sizeof(int))
2673 if (put_user(jiffies_to_msecs(*(int *)(table
->data
)), (int __user
*)oldval
) ||
2674 (oldlenp
&& put_user(sizeof(int),oldlenp
)))
2677 if (newval
&& newlen
) {
2679 if (newlen
!= sizeof(int))
2681 if (get_user(new, (int __user
*)newval
))
2683 *(int *)(table
->data
) = msecs_to_jiffies(new);
2688 #else /* CONFIG_SYSCTL_SYSCALL */
2691 asmlinkage
long sys_sysctl(struct __sysctl_args __user
*args
)
2693 static int msg_count
;
2694 struct __sysctl_args tmp
;
2695 int name
[CTL_MAXNAME
];
2698 /* Read in the sysctl name for better debug message logging */
2699 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
2701 if (tmp
.nlen
<= 0 || tmp
.nlen
>= CTL_MAXNAME
)
2703 for (i
= 0; i
< tmp
.nlen
; i
++)
2704 if (get_user(name
[i
], tmp
.name
+ i
))
2707 /* Ignore accesses to kernel.version */
2708 if ((tmp
.nlen
== 2) && (name
[0] == CTL_KERN
) && (name
[1] == KERN_VERSION
))
2711 if (msg_count
< 5) {
2714 "warning: process `%s' used the removed sysctl "
2715 "system call with ", current
->comm
);
2716 for (i
= 0; i
< tmp
.nlen
; i
++)
2717 printk("%d.", name
[i
]);
2724 int sysctl_string(ctl_table
*table
, int __user
*name
, int nlen
,
2725 void __user
*oldval
, size_t __user
*oldlenp
,
2726 void __user
*newval
, size_t newlen
, void **context
)
2731 int sysctl_intvec(ctl_table
*table
, int __user
*name
, int nlen
,
2732 void __user
*oldval
, size_t __user
*oldlenp
,
2733 void __user
*newval
, size_t newlen
, void **context
)
2738 int sysctl_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2739 void __user
*oldval
, size_t __user
*oldlenp
,
2740 void __user
*newval
, size_t newlen
, void **context
)
2745 int sysctl_ms_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2746 void __user
*oldval
, size_t __user
*oldlenp
,
2747 void __user
*newval
, size_t newlen
, void **context
)
2752 #endif /* CONFIG_SYSCTL_SYSCALL */
2755 * No sense putting this after each symbol definition, twice,
2756 * exception granted :-)
2758 EXPORT_SYMBOL(proc_dointvec
);
2759 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2760 EXPORT_SYMBOL(proc_dointvec_minmax
);
2761 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2762 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2763 EXPORT_SYMBOL(proc_dostring
);
2764 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2765 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);
2766 EXPORT_SYMBOL(register_sysctl_table
);
2767 EXPORT_SYMBOL(sysctl_intvec
);
2768 EXPORT_SYMBOL(sysctl_jiffies
);
2769 EXPORT_SYMBOL(sysctl_ms_jiffies
);
2770 EXPORT_SYMBOL(sysctl_string
);
2771 EXPORT_SYMBOL(unregister_sysctl_table
);