aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2008-10-06 05:19:27 -0400
committerAlexey Dobriyan <adobriyan@gmail.com>2008-10-23 10:03:13 -0400
commit3b5d5c6b0ccba733a313f8752ebc3f8015628ba3 (patch)
tree7277d87d64b8be615013457ab0cdb178d41a9efe
parent31d85ab28e71b0c938e0ef48af45747e80d99b53 (diff)
proc: move /proc/modules boilerplate to kernel/module.c
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
-rw-r--r--fs/proc/proc_misc.c17
-rw-r--r--kernel/module.c59
2 files changed, 41 insertions, 35 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 7c22831efd94..f6d25db98922 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -57,20 +57,6 @@
57#include <asm/div64.h> 57#include <asm/div64.h>
58#include "internal.h" 58#include "internal.h"
59 59
60#ifdef CONFIG_MODULES
61extern const struct seq_operations modules_op;
62static int modules_open(struct inode *inode, struct file *file)
63{
64 return seq_open(file, &modules_op);
65}
66static const struct file_operations proc_modules_operations = {
67 .open = modules_open,
68 .read = seq_read,
69 .llseek = seq_lseek,
70 .release = seq_release,
71};
72#endif
73
74#ifdef CONFIG_PROC_PAGE_MONITOR 60#ifdef CONFIG_PROC_PAGE_MONITOR
75#define KPMSIZE sizeof(u64) 61#define KPMSIZE sizeof(u64)
76#define KPMMASK (KPMSIZE - 1) 62#define KPMMASK (KPMSIZE - 1)
@@ -209,9 +195,6 @@ void __init proc_misc_init(void)
209 proc_symlink("mounts", NULL, "self/mounts"); 195 proc_symlink("mounts", NULL, "self/mounts");
210 196
211 /* And now for trickier ones */ 197 /* And now for trickier ones */
212#ifdef CONFIG_MODULES
213 proc_create("modules", 0, NULL, &proc_modules_operations);
214#endif
215#ifdef CONFIG_SCHEDSTATS 198#ifdef CONFIG_SCHEDSTATS
216 proc_create("schedstat", 0, NULL, &proc_schedstat_operations); 199 proc_create("schedstat", 0, NULL, &proc_schedstat_operations);
217#endif 200#endif
diff --git a/kernel/module.c b/kernel/module.c
index 0d8d21ee792c..6fded84d7029 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -20,11 +20,13 @@
20#include <linux/moduleloader.h> 20#include <linux/moduleloader.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/kallsyms.h> 22#include <linux/kallsyms.h>
23#include <linux/fs.h>
23#include <linux/sysfs.h> 24#include <linux/sysfs.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
27#include <linux/elf.h> 28#include <linux/elf.h>
29#include <linux/proc_fs.h>
28#include <linux/seq_file.h> 30#include <linux/seq_file.h>
29#include <linux/syscalls.h> 31#include <linux/syscalls.h>
30#include <linux/fcntl.h> 32#include <linux/fcntl.h>
@@ -2599,23 +2601,6 @@ unsigned long module_kallsyms_lookup_name(const char *name)
2599} 2601}
2600#endif /* CONFIG_KALLSYMS */ 2602#endif /* CONFIG_KALLSYMS */
2601 2603
2602/* Called by the /proc file system to return a list of modules. */
2603static void *m_start(struct seq_file *m, loff_t *pos)
2604{
2605 mutex_lock(&module_mutex);
2606 return seq_list_start(&modules, *pos);
2607}
2608
2609static void *m_next(struct seq_file *m, void *p, loff_t *pos)
2610{
2611 return seq_list_next(p, &modules, pos);
2612}
2613
2614static void m_stop(struct seq_file *m, void *p)
2615{
2616 mutex_unlock(&module_mutex);
2617}
2618
2619static char *module_flags(struct module *mod, char *buf) 2604static char *module_flags(struct module *mod, char *buf)
2620{ 2605{
2621 int bx = 0; 2606 int bx = 0;
@@ -2649,6 +2634,24 @@ static char *module_flags(struct module *mod, char *buf)
2649 return buf; 2634 return buf;
2650} 2635}
2651 2636
2637#ifdef CONFIG_PROC_FS
2638/* Called by the /proc file system to return a list of modules. */
2639static void *m_start(struct seq_file *m, loff_t *pos)
2640{
2641 mutex_lock(&module_mutex);
2642 return seq_list_start(&modules, *pos);
2643}
2644
2645static void *m_next(struct seq_file *m, void *p, loff_t *pos)
2646{
2647 return seq_list_next(p, &modules, pos);
2648}
2649
2650static void m_stop(struct seq_file *m, void *p)
2651{
2652 mutex_unlock(&module_mutex);
2653}
2654
2652static int m_show(struct seq_file *m, void *p) 2655static int m_show(struct seq_file *m, void *p)
2653{ 2656{
2654 struct module *mod = list_entry(p, struct module, list); 2657 struct module *mod = list_entry(p, struct module, list);
@@ -2679,13 +2682,33 @@ static int m_show(struct seq_file *m, void *p)
2679 Where refcount is a number or -, and deps is a comma-separated list 2682 Where refcount is a number or -, and deps is a comma-separated list
2680 of depends or -. 2683 of depends or -.
2681*/ 2684*/
2682const struct seq_operations modules_op = { 2685static const struct seq_operations modules_op = {
2683 .start = m_start, 2686 .start = m_start,
2684 .next = m_next, 2687 .next = m_next,
2685 .stop = m_stop, 2688 .stop = m_stop,
2686 .show = m_show 2689 .show = m_show
2687}; 2690};
2688 2691
2692static int modules_open(struct inode *inode, struct file *file)
2693{
2694 return seq_open(file, &modules_op);
2695}
2696
2697static const struct file_operations proc_modules_operations = {
2698 .open = modules_open,
2699 .read = seq_read,
2700 .llseek = seq_lseek,
2701 .release = seq_release,
2702};
2703
2704static int __init proc_modules_init(void)
2705{
2706 proc_create("modules", 0, NULL, &proc_modules_operations);
2707 return 0;
2708}
2709module_init(proc_modules_init);
2710#endif
2711
2689/* Given an address, look for it in the module exception tables. */ 2712/* Given an address, look for it in the module exception tables. */
2690const struct exception_table_entry *search_module_extables(unsigned long addr) 2713const struct exception_table_entry *search_module_extables(unsigned long addr)
2691{ 2714{