aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
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 /kernel
parent31d85ab28e71b0c938e0ef48af45747e80d99b53 (diff)
proc: move /proc/modules boilerplate to kernel/module.c
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c59
1 files changed, 41 insertions, 18 deletions
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{