diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-02-14 03:34:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-14 11:09:59 -0500 |
commit | a5494dcd8b92dce64317f2f7dd0d62747c54980b (patch) | |
tree | bdf0a29aecd3c043bc0478e6fa2e8a2b950f1b96 /kernel/sysctl.c | |
parent | 39732acd968a007036ff3c504f1e6748024ef548 (diff) |
[PATCH] sysctl: move SYSV IPC sysctls to their own file
This is just a simple cleanup to keep kernel/sysctl.c from getting to crowded
with special cases, and by keeping all of the ipc logic to together it makes
the code a little more readable.
[gcoady.lk@gmail.com: build fix]
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Serge E. Hallyn <serue@us.ibm.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Kirill Korotaev <dev@sw.ru>
Signed-off-by: Grant Coady <gcoady.lk@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r-- | kernel/sysctl.c | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index eff1d36c0687..ca376e733ce4 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -90,12 +90,6 @@ extern char modprobe_path[]; | |||
90 | #ifdef CONFIG_CHR_DEV_SG | 90 | #ifdef CONFIG_CHR_DEV_SG |
91 | extern int sg_big_buff; | 91 | extern int sg_big_buff; |
92 | #endif | 92 | #endif |
93 | #ifdef CONFIG_SYSVIPC | ||
94 | static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp, | ||
95 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
96 | static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, | ||
97 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
98 | #endif | ||
99 | 93 | ||
100 | #ifdef __sparc__ | 94 | #ifdef __sparc__ |
101 | extern char reboot_command []; | 95 | extern char reboot_command []; |
@@ -135,11 +129,6 @@ static int parse_table(int __user *, int, void __user *, size_t __user *, | |||
135 | void __user *, size_t, ctl_table *); | 129 | void __user *, size_t, ctl_table *); |
136 | #endif | 130 | #endif |
137 | 131 | ||
138 | #ifdef CONFIG_SYSVIPC | ||
139 | static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen, | ||
140 | void __user *oldval, size_t __user *oldlenp, | ||
141 | void __user *newval, size_t newlen); | ||
142 | #endif | ||
143 | 132 | ||
144 | #ifdef CONFIG_PROC_SYSCTL | 133 | #ifdef CONFIG_PROC_SYSCTL |
145 | static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, | 134 | static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, |
@@ -169,17 +158,6 @@ extern ctl_table inotify_table[]; | |||
169 | int sysctl_legacy_va_layout; | 158 | int sysctl_legacy_va_layout; |
170 | #endif | 159 | #endif |
171 | 160 | ||
172 | #ifdef CONFIG_SYSVIPC | ||
173 | static void *get_ipc(ctl_table *table, int write) | ||
174 | { | ||
175 | char *which = table->data; | ||
176 | struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; | ||
177 | which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns; | ||
178 | return which; | ||
179 | } | ||
180 | #else | ||
181 | #define get_ipc(T,W) ((T)->data) | ||
182 | #endif | ||
183 | 161 | ||
184 | /* /proc declarations: */ | 162 | /* /proc declarations: */ |
185 | 163 | ||
@@ -403,71 +381,6 @@ static ctl_table kern_table[] = { | |||
403 | .proc_handler = &proc_dointvec, | 381 | .proc_handler = &proc_dointvec, |
404 | }, | 382 | }, |
405 | #endif | 383 | #endif |
406 | #ifdef CONFIG_SYSVIPC | ||
407 | { | ||
408 | .ctl_name = KERN_SHMMAX, | ||
409 | .procname = "shmmax", | ||
410 | .data = &init_ipc_ns.shm_ctlmax, | ||
411 | .maxlen = sizeof (init_ipc_ns.shm_ctlmax), | ||
412 | .mode = 0644, | ||
413 | .proc_handler = &proc_ipc_doulongvec_minmax, | ||
414 | .strategy = sysctl_ipc_data, | ||
415 | }, | ||
416 | { | ||
417 | .ctl_name = KERN_SHMALL, | ||
418 | .procname = "shmall", | ||
419 | .data = &init_ipc_ns.shm_ctlall, | ||
420 | .maxlen = sizeof (init_ipc_ns.shm_ctlall), | ||
421 | .mode = 0644, | ||
422 | .proc_handler = &proc_ipc_doulongvec_minmax, | ||
423 | .strategy = sysctl_ipc_data, | ||
424 | }, | ||
425 | { | ||
426 | .ctl_name = KERN_SHMMNI, | ||
427 | .procname = "shmmni", | ||
428 | .data = &init_ipc_ns.shm_ctlmni, | ||
429 | .maxlen = sizeof (init_ipc_ns.shm_ctlmni), | ||
430 | .mode = 0644, | ||
431 | .proc_handler = &proc_ipc_dointvec, | ||
432 | .strategy = sysctl_ipc_data, | ||
433 | }, | ||
434 | { | ||
435 | .ctl_name = KERN_MSGMAX, | ||
436 | .procname = "msgmax", | ||
437 | .data = &init_ipc_ns.msg_ctlmax, | ||
438 | .maxlen = sizeof (init_ipc_ns.msg_ctlmax), | ||
439 | .mode = 0644, | ||
440 | .proc_handler = &proc_ipc_dointvec, | ||
441 | .strategy = sysctl_ipc_data, | ||
442 | }, | ||
443 | { | ||
444 | .ctl_name = KERN_MSGMNI, | ||
445 | .procname = "msgmni", | ||
446 | .data = &init_ipc_ns.msg_ctlmni, | ||
447 | .maxlen = sizeof (init_ipc_ns.msg_ctlmni), | ||
448 | .mode = 0644, | ||
449 | .proc_handler = &proc_ipc_dointvec, | ||
450 | .strategy = sysctl_ipc_data, | ||
451 | }, | ||
452 | { | ||
453 | .ctl_name = KERN_MSGMNB, | ||
454 | .procname = "msgmnb", | ||
455 | .data = &init_ipc_ns.msg_ctlmnb, | ||
456 | .maxlen = sizeof (init_ipc_ns.msg_ctlmnb), | ||
457 | .mode = 0644, | ||
458 | .proc_handler = &proc_ipc_dointvec, | ||
459 | .strategy = sysctl_ipc_data, | ||
460 | }, | ||
461 | { | ||
462 | .ctl_name = KERN_SEM, | ||
463 | .procname = "sem", | ||
464 | .data = &init_ipc_ns.sem_ctls, | ||
465 | .maxlen = 4*sizeof (int), | ||
466 | .mode = 0644, | ||
467 | .proc_handler = &proc_ipc_dointvec, | ||
468 | .strategy = sysctl_ipc_data, | ||
469 | }, | ||
470 | #endif | ||
471 | #ifdef CONFIG_MAGIC_SYSRQ | 384 | #ifdef CONFIG_MAGIC_SYSRQ |
472 | { | 385 | { |
473 | .ctl_name = KERN_SYSRQ, | 386 | .ctl_name = KERN_SYSRQ, |
@@ -2269,27 +2182,6 @@ int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp, | |||
2269 | do_proc_dointvec_ms_jiffies_conv, NULL); | 2182 | do_proc_dointvec_ms_jiffies_conv, NULL); |
2270 | } | 2183 | } |
2271 | 2184 | ||
2272 | #ifdef CONFIG_SYSVIPC | ||
2273 | static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp, | ||
2274 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2275 | { | ||
2276 | void *which; | ||
2277 | which = get_ipc(table, write); | ||
2278 | return __do_proc_dointvec(which, table, write, filp, buffer, | ||
2279 | lenp, ppos, NULL, NULL); | ||
2280 | } | ||
2281 | |||
2282 | static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, | ||
2283 | struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2284 | { | ||
2285 | void *which; | ||
2286 | which = get_ipc(table, write); | ||
2287 | return __do_proc_doulongvec_minmax(which, table, write, filp, buffer, | ||
2288 | lenp, ppos, 1l, 1l); | ||
2289 | } | ||
2290 | |||
2291 | #endif | ||
2292 | |||
2293 | static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, | 2185 | static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, |
2294 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2186 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2295 | { | 2187 | { |
@@ -2320,25 +2212,6 @@ int proc_dostring(ctl_table *table, int write, struct file *filp, | |||
2320 | return -ENOSYS; | 2212 | return -ENOSYS; |
2321 | } | 2213 | } |
2322 | 2214 | ||
2323 | #ifdef CONFIG_SYSVIPC | ||
2324 | static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp, | ||
2325 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2326 | { | ||
2327 | return -ENOSYS; | ||
2328 | } | ||
2329 | static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp, | ||
2330 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2331 | { | ||
2332 | return -ENOSYS; | ||
2333 | } | ||
2334 | static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, | ||
2335 | struct file *filp, void __user *buffer, | ||
2336 | size_t *lenp, loff_t *ppos) | ||
2337 | { | ||
2338 | return -ENOSYS; | ||
2339 | } | ||
2340 | #endif | ||
2341 | |||
2342 | int proc_dointvec(ctl_table *table, int write, struct file *filp, | 2215 | int proc_dointvec(ctl_table *table, int write, struct file *filp, |
2343 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2216 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2344 | { | 2217 | { |
@@ -2550,47 +2423,6 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, | |||
2550 | 2423 | ||
2551 | 2424 | ||
2552 | 2425 | ||
2553 | #ifdef CONFIG_SYSVIPC | ||
2554 | /* The generic sysctl ipc data routine. */ | ||
2555 | static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen, | ||
2556 | void __user *oldval, size_t __user *oldlenp, | ||
2557 | void __user *newval, size_t newlen) | ||
2558 | { | ||
2559 | size_t len; | ||
2560 | void *data; | ||
2561 | |||
2562 | /* Get out of I don't have a variable */ | ||
2563 | if (!table->data || !table->maxlen) | ||
2564 | return -ENOTDIR; | ||
2565 | |||
2566 | data = get_ipc(table, 1); | ||
2567 | if (!data) | ||
2568 | return -ENOTDIR; | ||
2569 | |||
2570 | if (oldval && oldlenp) { | ||
2571 | if (get_user(len, oldlenp)) | ||
2572 | return -EFAULT; | ||
2573 | if (len) { | ||
2574 | if (len > table->maxlen) | ||
2575 | len = table->maxlen; | ||
2576 | if (copy_to_user(oldval, data, len)) | ||
2577 | return -EFAULT; | ||
2578 | if (put_user(len, oldlenp)) | ||
2579 | return -EFAULT; | ||
2580 | } | ||
2581 | } | ||
2582 | |||
2583 | if (newval && newlen) { | ||
2584 | if (newlen > table->maxlen) | ||
2585 | newlen = table->maxlen; | ||
2586 | |||
2587 | if (copy_from_user(data, newval, newlen)) | ||
2588 | return -EFAULT; | ||
2589 | } | ||
2590 | return 1; | ||
2591 | } | ||
2592 | #endif | ||
2593 | |||
2594 | #else /* CONFIG_SYSCTL_SYSCALL */ | 2426 | #else /* CONFIG_SYSCTL_SYSCALL */ |
2595 | 2427 | ||
2596 | 2428 | ||
@@ -2655,14 +2487,6 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, | |||
2655 | return -ENOSYS; | 2487 | return -ENOSYS; |
2656 | } | 2488 | } |
2657 | 2489 | ||
2658 | #ifdef CONFIG_SYSVIPC | ||
2659 | static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen, | ||
2660 | void __user *oldval, size_t __user *oldlenp, | ||
2661 | void __user *newval, size_t newlen) | ||
2662 | { | ||
2663 | return -ENOSYS; | ||
2664 | } | ||
2665 | #endif | ||
2666 | #endif /* CONFIG_SYSCTL_SYSCALL */ | 2490 | #endif /* CONFIG_SYSCTL_SYSCALL */ |
2667 | 2491 | ||
2668 | /* | 2492 | /* |