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 Horn.
14 #include <linux/config.h>
15 #include <linux/malloc.h>
16 #include <linux/sysctl.h>
17 #include <linux/swapctl.h>
18 #include <linux/proc_fs.h>
19 #include <linux/ctype.h>
20 #include <linux/utsname.h>
21 #include <linux/smp_lock.h>
22 #include <linux/init.h>
24 #include <asm/uaccess.h>
26 #ifdef CONFIG_ROOT_NFS
27 #include <linux/nfs_fs.h>
30 #if defined(CONFIG_SYSCTL)
32 /* External variables not in a header file. */
33 extern int panic_timeout
;
34 extern int console_loglevel
, C_A_D
;
35 extern int bdf_prm
[], bdflush_min
[], bdflush_max
[];
36 extern int sysctl_overcommit_memory
;
37 extern int max_threads
;
38 extern int nr_queued_signals
, max_queued_signals
;
41 extern char modprobe_path
[];
43 #ifdef CONFIG_CHR_DEV_SG
44 extern int sg_big_buff
;
51 extern char reboot_command
[];
54 extern unsigned long htab_reclaim_on
, zero_paged_on
, powersave_nap
;
55 int proc_dol2crvec(ctl_table
*table
, int write
, struct file
*filp
,
56 void *buffer
, size_t *lenp
);
59 #ifdef CONFIG_BSD_PROCESS_ACCT
60 extern int acct_parm
[];
63 extern int pgt_cache_water
[];
65 static int parse_table(int *, int, void *, size_t *, void *, size_t,
66 ctl_table
*, void **);
67 static int proc_doutsstring(ctl_table
*table
, int write
, struct file
*filp
,
68 void *buffer
, size_t *lenp
);
71 static ctl_table root_table
[];
72 static struct ctl_table_header root_table_header
=
73 {root_table
, DNODE_SINGLE(&root_table_header
)};
75 static ctl_table kern_table
[];
76 static ctl_table vm_table
[];
78 extern ctl_table net_table
[];
80 static ctl_table proc_table
[];
81 static ctl_table fs_table
[];
82 static ctl_table debug_table
[];
83 static ctl_table dev_table
[];
86 /* /proc declarations: */
90 static ssize_t
proc_readsys(struct file
*, char *, size_t, loff_t
*);
91 static ssize_t
proc_writesys(struct file
*, const char *, size_t, loff_t
*);
92 static int proc_sys_permission(struct inode
*, int);
94 struct file_operations proc_sys_file_operations
=
97 proc_readsys
, /* read */
98 proc_writesys
, /* write */
103 NULL
, /* no special open code */
104 NULL
, /* no special flush code */
105 NULL
, /* no special release code */
106 NULL
/* can't fsync */
109 struct inode_operations proc_sys_inode_operations
=
111 &proc_sys_file_operations
,
122 NULL
, /* follow_link */
123 NULL
, /* get_block */
125 NULL
, /* writepage */
126 NULL
, /* flushpage */
128 proc_sys_permission
, /* permission */
130 NULL
/* revalidate */
133 extern struct proc_dir_entry proc_sys_root
;
135 static void register_proc_table(ctl_table
*, struct proc_dir_entry
*);
136 static void unregister_proc_table(ctl_table
*, struct proc_dir_entry
*);
138 extern int inodes_stat
[];
139 extern int dentry_stat
[];
141 /* The default sysctl tables: */
143 static ctl_table root_table
[] = {
144 {CTL_KERN
, "kernel", NULL
, 0, 0555, kern_table
},
145 {CTL_VM
, "vm", NULL
, 0, 0555, vm_table
},
147 {CTL_NET
, "net", NULL
, 0, 0555, net_table
},
149 {CTL_PROC
, "proc", NULL
, 0, 0555, proc_table
},
150 {CTL_FS
, "fs", NULL
, 0, 0555, fs_table
},
151 {CTL_DEBUG
, "debug", NULL
, 0, 0555, debug_table
},
152 {CTL_DEV
, "dev", NULL
, 0, 0555, dev_table
},
156 static ctl_table kern_table
[] = {
157 {KERN_OSTYPE
, "ostype", system_utsname
.sysname
, 64,
158 0444, NULL
, &proc_doutsstring
, &sysctl_string
},
159 {KERN_OSRELEASE
, "osrelease", system_utsname
.release
, 64,
160 0444, NULL
, &proc_doutsstring
, &sysctl_string
},
161 {KERN_VERSION
, "version", system_utsname
.version
, 64,
162 0444, NULL
, &proc_doutsstring
, &sysctl_string
},
163 {KERN_NODENAME
, "hostname", system_utsname
.nodename
, 64,
164 0644, NULL
, &proc_doutsstring
, &sysctl_string
},
165 {KERN_DOMAINNAME
, "domainname", system_utsname
.domainname
, 64,
166 0644, NULL
, &proc_doutsstring
, &sysctl_string
},
167 {KERN_PANIC
, "panic", &panic_timeout
, sizeof(int),
168 0644, NULL
, &proc_dointvec
},
169 #ifdef CONFIG_BLK_DEV_INITRD
170 {KERN_REALROOTDEV
, "real-root-dev", &real_root_dev
, sizeof(int),
171 0644, NULL
, &proc_dointvec
},
174 {KERN_SPARC_REBOOT
, "reboot-cmd", reboot_command
,
175 256, 0644, NULL
, &proc_dostring
, &sysctl_string
},
178 {KERN_PPC_HTABRECLAIM
, "htab-reclaim", &htab_reclaim_on
, sizeof(int),
179 0644, NULL
, &proc_dointvec
},
180 {KERN_PPC_ZEROPAGED
, "zero-paged", &zero_paged_on
, sizeof(int),
181 0644, NULL
, &proc_dointvec
},
182 {KERN_PPC_POWERSAVE_NAP
, "powersave-nap", &powersave_nap
, sizeof(int),
183 0644, NULL
, &proc_dointvec
},
184 {KERN_PPC_L2CR
, "l2cr", NULL
, 0,
185 0644, NULL
, &proc_dol2crvec
},
187 {KERN_CTLALTDEL
, "ctrl-alt-del", &C_A_D
, sizeof(int),
188 0644, NULL
, &proc_dointvec
},
189 {KERN_PRINTK
, "printk", &console_loglevel
, 4*sizeof(int),
190 0644, NULL
, &proc_dointvec
},
192 {KERN_MODPROBE
, "modprobe", &modprobe_path
, 256,
193 0644, NULL
, &proc_dostring
, &sysctl_string
},
195 #ifdef CONFIG_CHR_DEV_SG
196 {KERN_SG_BIG_BUFF
, "sg-big-buff", &sg_big_buff
, sizeof (int),
197 0444, NULL
, &proc_dointvec
},
199 #ifdef CONFIG_BSD_PROCESS_ACCT
200 {KERN_ACCT
, "acct", &acct_parm
, 3*sizeof(int),
201 0644, NULL
, &proc_dointvec
},
203 {KERN_RTSIGNR
, "rtsig-nr", &nr_queued_signals
, sizeof(int),
204 0444, NULL
, &proc_dointvec
},
205 {KERN_RTSIGMAX
, "rtsig-max", &max_queued_signals
, sizeof(int),
206 0644, NULL
, &proc_dointvec
},
207 #ifdef CONFIG_SYSVIPC
208 {KERN_SHMMAX
, "shmmax", &shmmax
, sizeof (int),
209 0644, NULL
, &proc_dointvec
},
211 {KERN_MAX_THREADS
, "threads-max", &max_threads
, sizeof(int),
212 0644, NULL
, &proc_dointvec
},
216 static ctl_table vm_table
[] = {
217 {VM_FREEPG
, "freepages",
218 &freepages
, sizeof(freepages_t
), 0644, NULL
, &proc_dointvec
},
219 {VM_BDFLUSH
, "bdflush", &bdf_prm
, 9*sizeof(int), 0600, NULL
,
220 &proc_dointvec_minmax
, &sysctl_intvec
, NULL
,
221 &bdflush_min
, &bdflush_max
},
222 {VM_OVERCOMMIT_MEMORY
, "overcommit_memory", &sysctl_overcommit_memory
,
223 sizeof(sysctl_overcommit_memory
), 0644, NULL
, &proc_dointvec
},
224 {VM_BUFFERMEM
, "buffermem",
225 &buffer_mem
, sizeof(buffer_mem_t
), 0644, NULL
, &proc_dointvec
},
226 {VM_PAGECACHE
, "pagecache",
227 &page_cache
, sizeof(buffer_mem_t
), 0644, NULL
, &proc_dointvec
},
228 {VM_PAGERDAEMON
, "kswapd",
229 &pager_daemon
, sizeof(pager_daemon_t
), 0644, NULL
, &proc_dointvec
},
230 {VM_PGT_CACHE
, "pagetable_cache",
231 &pgt_cache_water
, 2*sizeof(int), 0600, NULL
, &proc_dointvec
},
232 {VM_PAGE_CLUSTER
, "page-cluster",
233 &page_cluster
, sizeof(int), 0600, NULL
, &proc_dointvec
},
237 static ctl_table proc_table
[] = {
241 static ctl_table fs_table
[] = {
242 {FS_NRINODE
, "inode-nr", &inodes_stat
, 2*sizeof(int),
243 0444, NULL
, &proc_dointvec
},
244 {FS_STATINODE
, "inode-state", &inodes_stat
, 7*sizeof(int),
245 0444, NULL
, &proc_dointvec
},
246 {FS_MAXINODE
, "inode-max", &max_inodes
, sizeof(int),
247 0644, NULL
, &proc_dointvec
},
248 {FS_NRFILE
, "file-nr", &nr_files
, 3*sizeof(int),
249 0444, NULL
, &proc_dointvec
},
250 {FS_MAXFILE
, "file-max", &max_files
, sizeof(int),
251 0644, NULL
, &proc_dointvec
},
252 {FS_NRSUPER
, "super-nr", &nr_super_blocks
, sizeof(int),
253 0444, NULL
, &proc_dointvec
},
254 {FS_MAXSUPER
, "super-max", &max_super_blocks
, sizeof(int),
255 0644, NULL
, &proc_dointvec
},
256 {FS_NRDQUOT
, "dquot-nr", &nr_dquots
, 2*sizeof(int),
257 0444, NULL
, &proc_dointvec
},
258 {FS_MAXDQUOT
, "dquot-max", &max_dquots
, sizeof(int),
259 0644, NULL
, &proc_dointvec
},
260 {FS_DENTRY
, "dentry-state", &dentry_stat
, 6*sizeof(int),
261 0444, NULL
, &proc_dointvec
},
265 static ctl_table debug_table
[] = {
269 static ctl_table dev_table
[] = {
274 void __init
sysctl_init(void)
276 #ifdef CONFIG_PROC_FS
277 register_proc_table(root_table
, &proc_sys_root
);
282 int do_sysctl (int *name
, int nlen
,
283 void *oldval
, size_t *oldlenp
,
284 void *newval
, size_t newlen
)
287 struct ctl_table_header
*tmp
;
290 if (nlen
== 0 || nlen
>= CTL_MAXNAME
)
298 if(get_user(old_len
, oldlenp
))
301 tmp
= &root_table_header
;
304 error
= parse_table(name
, nlen
, oldval
, oldlenp
,
305 newval
, newlen
, tmp
->ctl_table
, &context
);
308 if (error
!= -ENOTDIR
)
310 tmp
= tmp
->DLIST_NEXT(ctl_entry
);
311 } while (tmp
!= &root_table_header
);
315 extern asmlinkage
int sys_sysctl(struct __sysctl_args
*args
)
317 struct __sysctl_args tmp
;
320 if(copy_from_user(&tmp
, args
, sizeof(tmp
)))
324 error
= do_sysctl(tmp
.name
, tmp
.nlen
, tmp
.oldval
, tmp
.oldlenp
,
325 tmp
.newval
, tmp
.newlen
);
330 /* Like in_group_p, but testing against egid, not fsgid */
331 static int in_egroup_p(gid_t grp
)
333 if (grp
!= current
->egid
) {
334 int i
= current
->ngroups
;
336 gid_t
*groups
= current
->groups
;
350 /* ctl_perm does NOT grant the superuser all rights automatically, because
351 some sysctl variables are readonly even to root. */
353 static int test_perm(int mode
, int op
)
357 else if (in_egroup_p(0))
359 if ((mode
& op
& 0007) == op
)
364 static inline int ctl_perm(ctl_table
*table
, int op
)
366 return test_perm(table
->mode
, op
);
369 static int parse_table(int *name
, int nlen
,
370 void *oldval
, size_t *oldlenp
,
371 void *newval
, size_t newlen
,
372 ctl_table
*table
, void **context
)
379 for ( ; table
->ctl_name
; table
++) {
383 if (n
== table
->ctl_name
||
384 table
->ctl_name
== CTL_ANY
) {
386 if (ctl_perm(table
, 001))
388 if (table
->strategy
) {
389 error
= table
->strategy(
392 newval
, newlen
, context
);
398 table
= table
->child
;
401 error
= do_sysctl_strategy(table
, name
, nlen
,
403 newval
, newlen
, context
);
410 /* Perform the actual read/write of a sysctl table entry. */
411 int do_sysctl_strategy (ctl_table
*table
,
413 void *oldval
, size_t *oldlenp
,
414 void *newval
, size_t newlen
, void **context
)
422 if (ctl_perm(table
, op
))
425 if (table
->strategy
) {
426 rc
= table
->strategy(table
, name
, nlen
, oldval
, oldlenp
,
427 newval
, newlen
, context
);
434 /* If there is no strategy routine, or if the strategy returns
435 * zero, proceed with automatic r/w */
436 if (table
->data
&& table
->maxlen
) {
437 if (oldval
&& oldlenp
) {
438 get_user(len
, oldlenp
);
440 if (len
> table
->maxlen
)
442 if(copy_to_user(oldval
, table
->data
, len
))
444 if(put_user(len
, oldlenp
))
448 if (newval
&& newlen
) {
450 if (len
> table
->maxlen
)
452 if(copy_from_user(table
->data
, newval
, len
))
459 struct ctl_table_header
*register_sysctl_table(ctl_table
* table
,
462 struct ctl_table_header
*tmp
;
463 tmp
= kmalloc(sizeof(*tmp
), GFP_KERNEL
);
466 *tmp
= ((struct ctl_table_header
) {table
, DNODE_NULL
});
468 DLIST_INSERT_AFTER(&root_table_header
, tmp
, ctl_entry
);
470 DLIST_INSERT_BEFORE(&root_table_header
, tmp
, ctl_entry
);
471 #ifdef CONFIG_PROC_FS
472 register_proc_table(table
, &proc_sys_root
);
478 * Unlink and free a ctl_table.
480 void unregister_sysctl_table(struct ctl_table_header
* header
)
482 DLIST_DELETE(header
, ctl_entry
);
483 #ifdef CONFIG_PROC_FS
484 unregister_proc_table(header
->ctl_table
, &proc_sys_root
);
493 #ifdef CONFIG_PROC_FS
495 /* Scan the sysctl entries in table and add them all into /proc */
496 static void register_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
)
498 struct proc_dir_entry
*de
;
502 for (; table
->ctl_name
; table
++) {
503 /* Can't do anything without a proc name. */
504 if (!table
->procname
)
506 /* Maybe we can't do anything with it... */
507 if (!table
->proc_handler
&& !table
->child
) {
508 printk(KERN_WARNING
"SYSCTL: Can't register %s\n",
513 len
= strlen(table
->procname
);
517 if (table
->proc_handler
)
521 for (de
= root
->subdir
; de
; de
= de
->next
) {
522 if (proc_match(len
, table
->procname
, de
))
525 /* If the subdir exists already, de is non-NULL */
529 de
= create_proc_entry(table
->procname
, mode
, root
);
532 de
->data
= (void *) table
;
533 if (table
->proc_handler
)
534 de
->ops
= &proc_sys_inode_operations
;
538 if (de
->mode
& S_IFDIR
)
539 register_proc_table(table
->child
, de
);
544 * Unregister a /proc sysctl table and any subdirectories.
546 static void unregister_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
)
548 struct proc_dir_entry
*de
;
549 for (; table
->ctl_name
; table
++) {
550 if (!(de
= table
->de
))
552 if (de
->mode
& S_IFDIR
) {
554 printk (KERN_ALERT
"Help - malformed sysctl tree on free\n");
557 unregister_proc_table(table
->child
, de
);
559 /* Don't unregister directories which still have entries.. */
564 /* Don't unregoster proc entries that are still being used.. */
568 proc_unregister(root
, de
->low_ino
);
574 static ssize_t
do_rw_proc(int write
, struct file
* file
, char * buf
,
575 size_t count
, loff_t
*ppos
)
578 struct proc_dir_entry
*de
;
579 struct ctl_table
*table
;
583 de
= (struct proc_dir_entry
*) file
->f_dentry
->d_inode
->u
.generic_ip
;
584 if (!de
|| !de
->data
)
586 table
= (struct ctl_table
*) de
->data
;
587 if (!table
|| !table
->proc_handler
)
589 op
= (write
? 002 : 004);
590 if (ctl_perm(table
, op
))
596 * FIXME: we need to pass on ppos to the handler.
599 error
= (*table
->proc_handler
) (table
, write
, file
, buf
, &res
);
605 static ssize_t
proc_readsys(struct file
* file
, char * buf
,
606 size_t count
, loff_t
*ppos
)
608 return do_rw_proc(0, file
, buf
, count
, ppos
);
611 static ssize_t
proc_writesys(struct file
* file
, const char * buf
,
612 size_t count
, loff_t
*ppos
)
614 return do_rw_proc(1, file
, (char *) buf
, count
, ppos
);
617 static int proc_sys_permission(struct inode
*inode
, int op
)
619 return test_perm(inode
->i_mode
, op
);
622 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
623 void *buffer
, size_t *lenp
)
628 if (!table
->data
|| !table
->maxlen
|| !*lenp
||
629 (filp
->f_pos
&& !write
)) {
637 while (len
< *lenp
) {
640 if (c
== 0 || c
== '\n')
644 if (len
>= table
->maxlen
)
645 len
= table
->maxlen
-1;
646 if(copy_from_user(table
->data
, buffer
, len
))
648 ((char *) table
->data
)[len
] = 0;
649 filp
->f_pos
+= *lenp
;
651 len
= strlen(table
->data
);
652 if (len
> table
->maxlen
)
657 if(copy_to_user(buffer
, table
->data
, len
))
660 if(put_user('\n', ((char *) buffer
) + len
))
671 * Special case of dostring for the UTS structure. This has locks
672 * to observe. Should this be in kernel/sys.c ????
675 static int proc_doutsstring(ctl_table
*table
, int write
, struct file
*filp
,
676 void *buffer
, size_t *lenp
)
680 r
=proc_dostring(table
,write
,filp
,buffer
,lenp
);
685 static int do_proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
686 void *buffer
, size_t *lenp
, int conv
)
688 int *i
, vleft
, first
=1, len
, left
, neg
, val
;
690 char buf
[TMPBUFLEN
], *p
;
692 if (!table
->data
|| !table
->maxlen
|| !*lenp
||
693 (filp
->f_pos
&& !write
)) {
698 i
= (int *) table
->data
;
699 vleft
= table
->maxlen
/ sizeof(int);
702 for (; left
&& vleft
--; i
++, first
=0) {
706 if(get_user(c
,(char *) buffer
))
717 if (len
> TMPBUFLEN
-1)
719 if(copy_from_user(buf
, buffer
, len
))
723 if (*p
== '-' && left
> 1) {
727 if (*p
< '0' || *p
> '9')
729 val
= simple_strtoul(p
, &p
, 0) * conv
;
731 if ((len
< left
) && *p
&& !isspace(*p
))
742 sprintf(p
, "%d", (*i
) / conv
);
746 if(copy_to_user(buffer
, buf
, len
))
753 if (!write
&& !first
&& left
) {
754 if(put_user('\n', (char *) buffer
))
772 filp
->f_pos
+= *lenp
;
776 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
777 void *buffer
, size_t *lenp
)
779 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,1);
782 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
783 void *buffer
, size_t *lenp
)
785 int *i
, *min
, *max
, vleft
, first
=1, len
, left
, neg
, val
;
787 char buf
[TMPBUFLEN
], *p
;
789 if (!table
->data
|| !table
->maxlen
|| !*lenp
||
790 (filp
->f_pos
&& !write
)) {
795 i
= (int *) table
->data
;
796 min
= (int *) table
->extra1
;
797 max
= (int *) table
->extra2
;
798 vleft
= table
->maxlen
/ sizeof(int);
801 for (; left
&& vleft
--; i
++, first
=0) {
805 if(get_user(c
, (char *) buffer
))
816 if (len
> TMPBUFLEN
-1)
818 if(copy_from_user(buf
, buffer
, len
))
822 if (*p
== '-' && left
> 1) {
826 if (*p
< '0' || *p
> '9')
828 val
= simple_strtoul(p
, &p
, 0);
830 if ((len
< left
) && *p
&& !isspace(*p
))
837 if (min
&& val
< *min
++)
839 if (max
&& val
> *max
++)
846 sprintf(p
, "%d", *i
);
850 if(copy_to_user(buffer
, buf
, len
))
857 if (!write
&& !first
&& left
) {
858 if(put_user('\n', (char *) buffer
))
876 filp
->f_pos
+= *lenp
;
880 /* Like proc_dointvec, but converts seconds to jiffies */
881 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
882 void *buffer
, size_t *lenp
)
884 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,HZ
);
887 #else /* CONFIG_PROC_FS */
889 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
890 void *buffer
, size_t *lenp
)
895 static int proc_doutsstring(ctl_table
*table
, int write
, struct file
*filp
,
896 void *buffer
, size_t *lenp
)
901 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
902 void *buffer
, size_t *lenp
)
907 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
908 void *buffer
, size_t *lenp
)
913 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
914 void *buffer
, size_t *lenp
)
919 #endif /* CONFIG_PROC_FS */
923 * General sysctl support routines
926 /* The generic string strategy routine: */
927 int sysctl_string(ctl_table
*table
, int *name
, int nlen
,
928 void *oldval
, size_t *oldlenp
,
929 void *newval
, size_t newlen
, void **context
)
933 if (!table
->data
|| !table
->maxlen
)
936 if (oldval
&& oldlenp
) {
937 if(get_user(len
, oldlenp
))
940 l
= strlen(table
->data
);
941 if (len
> l
) len
= l
;
942 if (len
>= table
->maxlen
)
944 if(copy_to_user(oldval
, table
->data
, len
))
946 if(put_user(0, ((char *) oldval
) + len
))
948 if(put_user(len
, oldlenp
))
952 if (newval
&& newlen
) {
954 if (len
> table
->maxlen
)
956 if(copy_from_user(table
->data
, newval
, len
))
958 if (len
== table
->maxlen
)
960 ((char *) table
->data
)[len
] = 0;
966 * This function makes sure that all of the integers in the vector
967 * are between the minimum and maximum values given in the arrays
968 * table->extra1 and table->extra2, respectively.
970 int sysctl_intvec(ctl_table
*table
, int *name
, int nlen
,
971 void *oldval
, size_t *oldlenp
,
972 void *newval
, size_t newlen
, void **context
)
974 int i
, length
, *vec
, *min
, *max
;
976 if (newval
&& newlen
) {
977 if (newlen
% sizeof(int) != 0)
980 if (!table
->extra1
&& !table
->extra2
)
983 if (newlen
> table
->maxlen
)
984 newlen
= table
->maxlen
;
985 length
= newlen
/ sizeof(int);
987 vec
= (int *) newval
;
988 min
= (int *) table
->extra1
;
989 max
= (int *) table
->extra2
;
991 for (i
= 0; i
< length
; i
++) {
993 get_user(value
, vec
+ i
);
994 if (min
&& value
< min
[i
])
996 if (max
&& value
> max
[i
])
1004 void *oldval
, size_t *oldlenp
, void *newval
, size_t newlen
,
1005 int rdwr
, char *data
, size_t max
)
1007 int l
= strlen(data
) + 1;
1008 if (newval
&& !rdwr
)
1010 if (newval
&& newlen
>= max
)
1014 if(get_user(old_l
, oldlenp
))
1018 if(put_user(l
, oldlenp
) || copy_to_user(oldval
, data
, l
))
1022 if(copy_from_user(data
, newval
, newlen
))
1030 void *oldval
, size_t *oldlenp
, void *newval
, size_t newlen
,
1031 int rdwr
, int *data
)
1033 if (newval
&& !rdwr
)
1035 if (newval
&& newlen
!= sizeof(int))
1039 if(get_user(old_l
, oldlenp
))
1041 if (old_l
< sizeof(int))
1043 if(put_user(sizeof(int), oldlenp
)||copy_to_user(oldval
, data
, sizeof(int)))
1047 if(copy_from_user(data
, newval
, sizeof(int)))
1053 void *oldval
, size_t *oldlenp
, void *newval
, size_t newlen
,
1054 int rdwr
, void *data
, size_t len
)
1056 if (newval
&& !rdwr
)
1058 if (newval
&& newlen
!= len
)
1062 if(get_user(old_l
, oldlenp
))
1066 if(put_user(len
, oldlenp
) || copy_to_user(oldval
, data
, len
))
1070 if(copy_from_user(data
, newval
, len
))
1076 #else /* CONFIG_SYSCTL */
1079 extern asmlinkage
int sys_sysctl(struct __sysctl_args
*args
)
1084 int sysctl_string(ctl_table
*table
, int *name
, int nlen
,
1085 void *oldval
, size_t *oldlenp
,
1086 void *newval
, size_t newlen
, void **context
)
1091 int sysctl_intvec(ctl_table
*table
, int *name
, int nlen
,
1092 void *oldval
, size_t *oldlenp
,
1093 void *newval
, size_t newlen
, void **context
)
1098 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
1099 void *buffer
, size_t *lenp
)
1104 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
1105 void *buffer
, size_t *lenp
)
1110 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
1111 void *buffer
, size_t *lenp
)
1116 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
1117 void *buffer
, size_t *lenp
)
1122 struct ctl_table_header
* register_sysctl_table(ctl_table
* table
,
1128 void unregister_sysctl_table(struct ctl_table_header
* table
)
1132 #endif /* CONFIG_SYSCTL */