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/sched.h>
17 #include <linux/sysctl.h>
18 #include <linux/swapctl.h>
19 #include <linux/proc_fs.h>
20 #include <linux/malloc.h>
21 #include <linux/stat.h>
22 #include <linux/ctype.h>
23 #include <linux/utsname.h>
24 #include <linux/swapctl.h>
25 #include <linux/smp.h>
26 #include <linux/smp_lock.h>
27 #include <linux/init.h>
30 #include <asm/bitops.h>
31 #include <asm/uaccess.h>
33 #ifdef CONFIG_ROOT_NFS
34 #include <linux/nfs_fs.h>
37 #if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
39 /* External variables not in a header file. */
40 extern int panic_timeout
;
41 extern int console_loglevel
, C_A_D
, swapout_interval
;
42 extern int bdf_prm
[], bdflush_min
[], bdflush_max
[];
43 extern char binfmt_java_interpreter
[], binfmt_java_appletviewer
[];
44 extern int sysctl_overcommit_memory
;
46 extern char modprobe_path
[];
48 #ifdef CONFIG_CHR_DEV_SG
49 extern int sg_big_buff
;
53 extern char reboot_command
[];
56 extern unsigned long htab_reclaim_on
, zero_paged_on
, powersave_nap
;
59 extern int pgt_cache_water
[];
61 static int parse_table(int *, int, void *, size_t *, void *, size_t,
62 ctl_table
*, void **);
63 static int proc_doutsstring(ctl_table
*table
, int write
, struct file
*filp
,
64 void *buffer
, size_t *lenp
);
67 static ctl_table root_table
[];
68 static struct ctl_table_header root_table_header
=
69 {root_table
, DNODE_SINGLE(&root_table_header
)};
71 static ctl_table kern_table
[];
72 static ctl_table vm_table
[];
73 extern ctl_table net_table
[];
74 static ctl_table proc_table
[];
75 static ctl_table fs_table
[];
76 static ctl_table debug_table
[];
77 static ctl_table dev_table
[];
80 /* /proc declarations: */
84 static ssize_t
proc_readsys(struct file
*, char *, size_t, loff_t
*);
85 static ssize_t
proc_writesys(struct file
*, const char *, size_t, loff_t
*);
86 static int proc_sys_permission(struct inode
*, int);
88 struct file_operations proc_sys_file_operations
=
91 proc_readsys
, /* read */
92 proc_writesys
, /* write */
97 NULL
, /* no special open code */
98 NULL
, /* no special flush code */
99 NULL
, /* no special release code */
100 NULL
/* can't fsync */
103 struct inode_operations proc_sys_inode_operations
=
105 &proc_sys_file_operations
,
116 NULL
, /* follow_link */
118 NULL
, /* writepage */
124 extern struct proc_dir_entry proc_sys_root
;
126 extern int inodes_stat
[];
127 extern int dentry_stat
[];
128 static void register_proc_table(ctl_table
*, struct proc_dir_entry
*);
129 static void unregister_proc_table(ctl_table
*, struct proc_dir_entry
*);
132 /* The default sysctl tables: */
134 static ctl_table root_table
[] = {
135 {CTL_KERN
, "kernel", NULL
, 0, 0555, kern_table
},
136 {CTL_VM
, "vm", NULL
, 0, 0555, vm_table
},
137 {CTL_NET
, "net", NULL
, 0, 0555, net_table
},
138 {CTL_PROC
, "proc", NULL
, 0, 0555, proc_table
},
139 {CTL_FS
, "fs", NULL
, 0, 0555, fs_table
},
140 {CTL_DEBUG
, "debug", NULL
, 0, 0555, debug_table
},
141 {CTL_DEV
, "dev", NULL
, 0, 0555, dev_table
},
145 static ctl_table kern_table
[] = {
146 {KERN_OSTYPE
, "ostype", system_utsname
.sysname
, 64,
147 0444, NULL
, &proc_doutsstring
, &sysctl_string
},
148 {KERN_OSRELEASE
, "osrelease", system_utsname
.release
, 64,
149 0444, NULL
, &proc_doutsstring
, &sysctl_string
},
150 {KERN_VERSION
, "version", system_utsname
.version
, 64,
151 0444, NULL
, &proc_doutsstring
, &sysctl_string
},
152 {KERN_NODENAME
, "hostname", system_utsname
.nodename
, 64,
153 0644, NULL
, &proc_doutsstring
, &sysctl_string
},
154 {KERN_DOMAINNAME
, "domainname", system_utsname
.domainname
, 64,
155 0644, NULL
, &proc_doutsstring
, &sysctl_string
},
156 {KERN_PANIC
, "panic", &panic_timeout
, sizeof(int),
157 0644, NULL
, &proc_dointvec
},
158 #ifdef CONFIG_BLK_DEV_INITRD
159 {KERN_REALROOTDEV
, "real-root-dev", &real_root_dev
, sizeof(int),
160 0644, NULL
, &proc_dointvec
},
162 #ifdef CONFIG_BINFMT_JAVA
163 {KERN_JAVA_INTERPRETER
, "java-interpreter", binfmt_java_interpreter
,
164 64, 0644, NULL
, &proc_dostring
, &sysctl_string
},
165 {KERN_JAVA_APPLETVIEWER
, "java-appletviewer", binfmt_java_appletviewer
,
166 64, 0644, NULL
, &proc_dostring
, &sysctl_string
},
169 {KERN_SPARC_REBOOT
, "reboot-cmd", reboot_command
,
170 256, 0644, NULL
, &proc_dostring
, &sysctl_string
},
173 {KERN_PPC_HTABRECLAIM
, "htab-reclaim", &htab_reclaim_on
, sizeof(int),
174 0644, NULL
, &proc_dointvec
},
175 {KERN_PPC_ZEROPAGED
, "zero-paged", &zero_paged_on
, sizeof(int),
176 0644, NULL
, &proc_dointvec
},
177 {KERN_PPC_POWERSAVE_NAP
, "powersave-nap", &powersave_nap
, sizeof(int),
178 0644, NULL
, &proc_dointvec
},
180 {KERN_CTLALTDEL
, "ctrl-alt-del", &C_A_D
, sizeof(int),
181 0644, NULL
, &proc_dointvec
},
182 {KERN_PRINTK
, "printk", &console_loglevel
, 4*sizeof(int),
183 0644, NULL
, &proc_dointvec
},
185 {KERN_MODPROBE
, "modprobe", &modprobe_path
, 256,
186 0644, NULL
, &proc_dostring
, &sysctl_string
},
188 #ifdef CONFIG_CHR_DEV_SG
189 {KERN_SG_BIG_BUFF
, "sg-big-buff", &sg_big_buff
, sizeof (int),
190 0444, NULL
, &proc_dointvec
},
195 static ctl_table vm_table
[] = {
196 {VM_SWAPCTL
, "swapctl",
197 &swap_control
, sizeof(swap_control_t
), 0644, NULL
, &proc_dointvec
},
198 {VM_SWAPOUT
, "swapout_interval",
199 &swapout_interval
, sizeof(int), 0644, NULL
, &proc_dointvec
},
200 {VM_FREEPG
, "freepages",
201 &freepages
, sizeof(freepages_t
), 0644, NULL
, &proc_dointvec
},
202 {VM_BDFLUSH
, "bdflush", &bdf_prm
, 9*sizeof(int), 0600, NULL
,
203 &proc_dointvec_minmax
, &sysctl_intvec
, NULL
,
204 &bdflush_min
, &bdflush_max
},
205 {VM_OVERCOMMIT_MEMORY
, "overcommit_memory", &sysctl_overcommit_memory
,
206 sizeof(sysctl_overcommit_memory
), 0644, NULL
, &proc_dointvec
},
207 {VM_BUFFERMEM
, "buffermem",
208 &buffer_mem
, sizeof(buffer_mem_t
), 0644, NULL
, &proc_dointvec
},
209 {VM_PAGECACHE
, "pagecache",
210 &page_cache
, sizeof(buffer_mem_t
), 0644, NULL
, &proc_dointvec
},
211 {VM_PAGERDAEMON
, "kswapd",
212 &pager_daemon
, sizeof(pager_daemon_t
), 0644, NULL
, &proc_dointvec
},
213 {VM_PGT_CACHE
, "pagetable_cache",
214 &pgt_cache_water
, 2*sizeof(int), 0600, NULL
, &proc_dointvec
},
218 static ctl_table proc_table
[] = {
222 static ctl_table fs_table
[] = {
223 {FS_NRINODE
, "inode-nr", &inodes_stat
, 2*sizeof(int),
224 0444, NULL
, &proc_dointvec
},
225 {FS_STATINODE
, "inode-state", &inodes_stat
, 7*sizeof(int),
226 0444, NULL
, &proc_dointvec
},
227 {FS_MAXINODE
, "inode-max", &max_inodes
, sizeof(int),
228 0644, NULL
, &proc_dointvec
},
229 {FS_NRFILE
, "file-nr", &nr_files
, 3*sizeof(int),
230 0444, NULL
, &proc_dointvec
},
231 {FS_MAXFILE
, "file-max", &max_files
, sizeof(int),
232 0644, NULL
, &proc_dointvec
},
233 {FS_NRSUPER
, "super-nr", &nr_super_blocks
, sizeof(int),
234 0444, NULL
, &proc_dointvec
},
235 {FS_MAXSUPER
, "super-max", &max_super_blocks
, sizeof(int),
236 0644, NULL
, &proc_dointvec
},
237 {FS_NRDQUOT
, "dquot-nr", &nr_dquots
, 2*sizeof(int),
238 0444, NULL
, &proc_dointvec
},
239 {FS_MAXDQUOT
, "dquot-max", &max_dquots
, sizeof(int),
240 0644, NULL
, &proc_dointvec
},
241 {FS_DENTRY
, "dentry-state", &dentry_stat
, 6*sizeof(int),
242 0444, NULL
, &proc_dointvec
},
246 static ctl_table debug_table
[] = {
250 static ctl_table dev_table
[] = {
255 void __init
sysctl_init(void)
257 #ifdef CONFIG_PROC_FS
258 register_proc_table(root_table
, &proc_sys_root
);
263 int do_sysctl (int *name
, int nlen
,
264 void *oldval
, size_t *oldlenp
,
265 void *newval
, size_t newlen
)
268 struct ctl_table_header
*tmp
;
271 if (nlen
== 0 || nlen
>= CTL_MAXNAME
)
279 if(get_user(old_len
, oldlenp
))
282 tmp
= &root_table_header
;
285 error
= parse_table(name
, nlen
, oldval
, oldlenp
,
286 newval
, newlen
, tmp
->ctl_table
, &context
);
289 if (error
!= -ENOTDIR
)
291 tmp
= tmp
->DLIST_NEXT(ctl_entry
);
292 } while (tmp
!= &root_table_header
);
296 extern asmlinkage
int sys_sysctl(struct __sysctl_args
*args
)
298 struct __sysctl_args tmp
;
301 if(copy_from_user(&tmp
, args
, sizeof(tmp
)))
305 error
= do_sysctl(tmp
.name
, tmp
.nlen
, tmp
.oldval
, tmp
.oldlenp
,
306 tmp
.newval
, tmp
.newlen
);
311 /* Like in_group_p, but testing against egid, not fsgid */
312 static int in_egroup_p(gid_t grp
)
314 if (grp
!= current
->egid
) {
315 int i
= current
->ngroups
;
317 gid_t
*groups
= current
->groups
;
331 /* ctl_perm does NOT grant the superuser all rights automatically, because
332 some sysctl variables are readonly even to root. */
334 static int test_perm(int mode
, int op
)
338 else if (in_egroup_p(0))
340 if ((mode
& op
& 0007) == op
)
345 static inline int ctl_perm(ctl_table
*table
, int op
)
347 return test_perm(table
->mode
, op
);
350 static int parse_table(int *name
, int nlen
,
351 void *oldval
, size_t *oldlenp
,
352 void *newval
, size_t newlen
,
353 ctl_table
*table
, void **context
)
360 for ( ; table
->ctl_name
; table
++) {
364 if (n
== table
->ctl_name
||
365 table
->ctl_name
== CTL_ANY
) {
367 if (ctl_perm(table
, 001))
369 if (table
->strategy
) {
370 error
= table
->strategy(
373 newval
, newlen
, context
);
379 table
= table
->child
;
382 error
= do_sysctl_strategy(table
, name
, nlen
,
384 newval
, newlen
, context
);
391 /* Perform the actual read/write of a sysctl table entry. */
392 int do_sysctl_strategy (ctl_table
*table
,
394 void *oldval
, size_t *oldlenp
,
395 void *newval
, size_t newlen
, void **context
)
403 if (ctl_perm(table
, op
))
406 if (table
->strategy
) {
407 rc
= table
->strategy(table
, name
, nlen
, oldval
, oldlenp
,
408 newval
, newlen
, context
);
415 /* If there is no strategy routine, or if the strategy returns
416 * zero, proceed with automatic r/w */
417 if (table
->data
&& table
->maxlen
) {
418 if (oldval
&& oldlenp
) {
419 get_user(len
, oldlenp
);
421 if (len
> table
->maxlen
)
423 if(copy_to_user(oldval
, table
->data
, len
))
425 if(put_user(len
, oldlenp
))
429 if (newval
&& newlen
) {
431 if (len
> table
->maxlen
)
433 if(copy_from_user(table
->data
, newval
, len
))
440 struct ctl_table_header
*register_sysctl_table(ctl_table
* table
,
443 struct ctl_table_header
*tmp
;
444 tmp
= kmalloc(sizeof(*tmp
), GFP_KERNEL
);
447 *tmp
= ((struct ctl_table_header
) {table
, DNODE_NULL
});
449 DLIST_INSERT_AFTER(&root_table_header
, tmp
, ctl_entry
);
451 DLIST_INSERT_BEFORE(&root_table_header
, tmp
, ctl_entry
);
452 #ifdef CONFIG_PROC_FS
453 register_proc_table(table
, &proc_sys_root
);
459 * Unlink and free a ctl_table.
461 void unregister_sysctl_table(struct ctl_table_header
* header
)
463 DLIST_DELETE(header
, ctl_entry
);
464 #ifdef CONFIG_PROC_FS
465 unregister_proc_table(header
->ctl_table
, &proc_sys_root
);
474 #ifdef CONFIG_PROC_FS
476 /* Scan the sysctl entries in table and add them all into /proc */
477 static void register_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
)
479 struct proc_dir_entry
*de
;
483 for (; table
->ctl_name
; table
++) {
484 /* Can't do anything without a proc name. */
485 if (!table
->procname
)
487 /* Maybe we can't do anything with it... */
488 if (!table
->proc_handler
&& !table
->child
) {
489 printk(KERN_WARNING
"SYSCTL: Can't register %s\n",
494 len
= strlen(table
->procname
);
498 if (table
->proc_handler
)
502 for (de
= root
->subdir
; de
; de
= de
->next
) {
503 if (proc_match(len
, table
->procname
, de
))
506 /* If the subdir exists already, de is non-NULL */
510 de
= create_proc_entry(table
->procname
, mode
, root
);
513 de
->data
= (void *) table
;
514 if (table
->proc_handler
)
515 de
->ops
= &proc_sys_inode_operations
;
519 if (de
->mode
& S_IFDIR
)
520 register_proc_table(table
->child
, de
);
525 * Unregister a /proc sysctl table and any subdirectories.
527 static void unregister_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
)
529 struct proc_dir_entry
*de
;
530 for (; table
->ctl_name
; table
++) {
531 if (!(de
= table
->de
))
533 if (de
->mode
& S_IFDIR
) {
535 printk (KERN_ALERT
"Help - malformed sysctl tree on free\n");
538 unregister_proc_table(table
->child
, de
);
540 /* Don't unregister proc directories which still have
542 if (!((de
->mode
& S_IFDIR
) && de
->subdir
)) {
543 proc_unregister(root
, de
->low_ino
);
550 static ssize_t
do_rw_proc(int write
, struct file
* file
, char * buf
,
551 size_t count
, loff_t
*ppos
)
554 struct proc_dir_entry
*de
;
555 struct ctl_table
*table
;
559 de
= (struct proc_dir_entry
*) file
->f_dentry
->d_inode
->u
.generic_ip
;
560 if (!de
|| !de
->data
)
562 table
= (struct ctl_table
*) de
->data
;
563 if (!table
|| !table
->proc_handler
)
565 op
= (write
? 002 : 004);
566 if (ctl_perm(table
, op
))
572 * FIXME: we need to pass on ppos to the handler.
575 error
= (*table
->proc_handler
) (table
, write
, file
, buf
, &res
);
581 static ssize_t
proc_readsys(struct file
* file
, char * buf
,
582 size_t count
, loff_t
*ppos
)
584 return do_rw_proc(0, file
, buf
, count
, ppos
);
587 static ssize_t
proc_writesys(struct file
* file
, const char * buf
,
588 size_t count
, loff_t
*ppos
)
590 return do_rw_proc(1, file
, (char *) buf
, count
, ppos
);
593 static int proc_sys_permission(struct inode
*inode
, int op
)
595 return test_perm(inode
->i_mode
, op
);
598 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
599 void *buffer
, size_t *lenp
)
604 if (!table
->data
|| !table
->maxlen
|| !*lenp
||
605 (filp
->f_pos
&& !write
)) {
613 while (len
< *lenp
) {
616 if (c
== 0 || c
== '\n')
620 if (len
>= table
->maxlen
)
621 len
= table
->maxlen
-1;
622 if(copy_from_user(table
->data
, buffer
, len
))
624 ((char *) table
->data
)[len
] = 0;
625 filp
->f_pos
+= *lenp
;
627 len
= strlen(table
->data
);
628 if (len
> table
->maxlen
)
633 if(copy_to_user(buffer
, table
->data
, len
))
636 if(put_user('\n', ((char *) buffer
) + len
))
647 * Special case of dostring for the UTS structure. This has locks
648 * to observe. Should this be in kernel/sys.c ????
651 static int proc_doutsstring(ctl_table
*table
, int write
, struct file
*filp
,
652 void *buffer
, size_t *lenp
)
656 r
=proc_dostring(table
,write
,filp
,buffer
,lenp
);
661 static int do_proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
662 void *buffer
, size_t *lenp
, int conv
)
664 int *i
, vleft
, first
=1, len
, left
, neg
, val
;
666 char buf
[TMPBUFLEN
], *p
;
668 if (!table
->data
|| !table
->maxlen
|| !*lenp
||
669 (filp
->f_pos
&& !write
)) {
674 i
= (int *) table
->data
;
675 vleft
= table
->maxlen
/ sizeof(int);
678 for (; left
&& vleft
--; i
++, first
=0) {
682 if(get_user(c
,(char *) buffer
))
693 if (len
> TMPBUFLEN
-1)
695 if(copy_from_user(buf
, buffer
, len
))
699 if (*p
== '-' && left
> 1) {
703 if (*p
< '0' || *p
> '9')
705 val
= simple_strtoul(p
, &p
, 0) * conv
;
707 if ((len
< left
) && *p
&& !isspace(*p
))
718 sprintf(p
, "%d", (*i
) / conv
);
722 if(copy_to_user(buffer
, buf
, len
))
729 if (!write
&& !first
&& left
) {
730 if(put_user('\n', (char *) buffer
))
748 filp
->f_pos
+= *lenp
;
752 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
753 void *buffer
, size_t *lenp
)
755 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,1);
758 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
759 void *buffer
, size_t *lenp
)
761 int *i
, *min
, *max
, vleft
, first
=1, len
, left
, neg
, val
;
763 char buf
[TMPBUFLEN
], *p
;
765 if (!table
->data
|| !table
->maxlen
|| !*lenp
||
766 (filp
->f_pos
&& !write
)) {
771 i
= (int *) table
->data
;
772 min
= (int *) table
->extra1
;
773 max
= (int *) table
->extra2
;
774 vleft
= table
->maxlen
/ sizeof(int);
777 for (; left
&& vleft
--; i
++, first
=0) {
781 if(get_user(c
, (char *) buffer
))
792 if (len
> TMPBUFLEN
-1)
794 if(copy_from_user(buf
, buffer
, len
))
798 if (*p
== '-' && left
> 1) {
802 if (*p
< '0' || *p
> '9')
804 val
= simple_strtoul(p
, &p
, 0);
806 if ((len
< left
) && *p
&& !isspace(*p
))
813 if (min
&& val
< *min
++)
815 if (max
&& val
> *max
++)
822 sprintf(p
, "%d", *i
);
826 if(copy_to_user(buffer
, buf
, len
))
833 if (!write
&& !first
&& left
) {
834 if(put_user('\n', (char *) buffer
))
852 filp
->f_pos
+= *lenp
;
856 /* Like proc_dointvec, but converts seconds to jiffies */
857 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
858 void *buffer
, size_t *lenp
)
860 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,HZ
);
863 #else /* CONFIG_PROC_FS */
865 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
866 void *buffer
, size_t *lenp
)
871 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
872 void *buffer
, size_t *lenp
)
877 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
878 void *buffer
, size_t *lenp
)
883 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
884 void *buffer
, size_t *lenp
)
889 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
890 void *buffer
, size_t *lenp
)
895 #endif /* CONFIG_PROC_FS */
899 * General sysctl support routines
902 /* The generic string strategy routine: */
903 int sysctl_string(ctl_table
*table
, int *name
, int nlen
,
904 void *oldval
, size_t *oldlenp
,
905 void *newval
, size_t newlen
, void **context
)
909 if (!table
->data
|| !table
->maxlen
)
912 if (oldval
&& oldlenp
) {
913 if(get_user(len
, oldlenp
))
916 l
= strlen(table
->data
);
917 if (len
> l
) len
= l
;
918 if (len
>= table
->maxlen
)
920 if(copy_to_user(oldval
, table
->data
, len
))
922 if(put_user(0, ((char *) oldval
) + len
))
924 if(put_user(len
, oldlenp
))
928 if (newval
&& newlen
) {
930 if (len
> table
->maxlen
)
932 if(copy_from_user(table
->data
, newval
, len
))
934 if (len
== table
->maxlen
)
936 ((char *) table
->data
)[len
] = 0;
942 * This function makes sure that all of the integers in the vector
943 * are between the minimum and maximum values given in the arrays
944 * table->extra1 and table->extra2, respectively.
946 int sysctl_intvec(ctl_table
*table
, int *name
, int nlen
,
947 void *oldval
, size_t *oldlenp
,
948 void *newval
, size_t newlen
, void **context
)
950 int i
, length
, *vec
, *min
, *max
;
952 if (newval
&& newlen
) {
953 if (newlen
% sizeof(int) != 0)
956 if (!table
->extra1
&& !table
->extra2
)
959 if (newlen
> table
->maxlen
)
960 newlen
= table
->maxlen
;
961 length
= newlen
/ sizeof(int);
963 vec
= (int *) newval
;
964 min
= (int *) table
->extra1
;
965 max
= (int *) table
->extra2
;
967 for (i
= 0; i
< length
; i
++) {
969 get_user(value
, vec
+ i
);
970 if (min
&& value
< min
[i
])
972 if (max
&& value
> max
[i
])
980 void *oldval
, size_t *oldlenp
, void *newval
, size_t newlen
,
981 int rdwr
, char *data
, size_t max
)
983 int l
= strlen(data
) + 1;
986 if (newval
&& newlen
>= max
)
990 if(get_user(old_l
, oldlenp
))
994 if(put_user(l
, oldlenp
) || copy_to_user(oldval
, data
, l
))
998 if(copy_from_user(data
, newval
, newlen
))
1006 void *oldval
, size_t *oldlenp
, void *newval
, size_t newlen
,
1007 int rdwr
, int *data
)
1009 if (newval
&& !rdwr
)
1011 if (newval
&& newlen
!= sizeof(int))
1015 if(get_user(old_l
, oldlenp
))
1017 if (old_l
< sizeof(int))
1019 if(put_user(sizeof(int), oldlenp
)||copy_to_user(oldval
, data
, sizeof(int)))
1023 if(copy_from_user(data
, newval
, sizeof(int)))
1029 void *oldval
, size_t *oldlenp
, void *newval
, size_t newlen
,
1030 int rdwr
, void *data
, size_t len
)
1032 if (newval
&& !rdwr
)
1034 if (newval
&& newlen
!= len
)
1038 if(get_user(old_l
, oldlenp
))
1042 if(put_user(len
, oldlenp
) || copy_to_user(oldval
, data
, len
))
1046 if(copy_from_user(data
, newval
, len
))
1052 #else /* CONFIG_PROC_FS && CONFIG_SYSCTL */
1055 extern asmlinkage
int sys_sysctl(struct __sysctl_args
*args
)
1060 int sysctl_string(ctl_table
*table
, int *name
, int nlen
,
1061 void *oldval
, size_t *oldlenp
,
1062 void *newval
, size_t newlen
, void **context
)
1067 int sysctl_intvec(ctl_table
*table
, int *name
, int nlen
,
1068 void *oldval
, size_t *oldlenp
,
1069 void *newval
, size_t newlen
, void **context
)
1074 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
1075 void *buffer
, size_t *lenp
)
1080 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
1081 void *buffer
, size_t *lenp
)
1086 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
1087 void *buffer
, size_t *lenp
)
1092 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
1093 void *buffer
, size_t *lenp
)
1098 struct ctl_table_header
* register_sysctl_table(ctl_table
* table
,
1104 void unregister_sysctl_table(struct ctl_table_header
* table
)
1108 #endif /* CONFIG_PROC_FS && CONFIG_SYSCTL */