diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-23 15:04:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-23 15:04:37 -0400 |
commit | 88ed86fee6651033de9b7038dac7869a9f19775a (patch) | |
tree | 38b638d2e7cba110ec271275738f221feb7e0a37 /kernel/module.c | |
parent | 3856d30ded1fe43c6657927ebad402d25cd128f4 (diff) | |
parent | 59c7572e82d69483a66eaa67b46548baeb69ecf4 (diff) |
Merge branch 'proc' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc
* 'proc' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc: (35 commits)
proc: remove fs/proc/proc_misc.c
proc: move /proc/vmcore creation to fs/proc/vmcore.c
proc: move pagecount stuff to fs/proc/page.c
proc: move all /proc/kcore stuff to fs/proc/kcore.c
proc: move /proc/schedstat boilerplate to kernel/sched_stats.h
proc: move /proc/modules boilerplate to kernel/module.c
proc: move /proc/diskstats boilerplate to block/genhd.c
proc: move /proc/zoneinfo boilerplate to mm/vmstat.c
proc: move /proc/vmstat boilerplate to mm/vmstat.c
proc: move /proc/pagetypeinfo boilerplate to mm/vmstat.c
proc: move /proc/buddyinfo boilerplate to mm/vmstat.c
proc: move /proc/vmallocinfo to mm/vmalloc.c
proc: move /proc/slabinfo boilerplate to mm/slub.c, mm/slab.c
proc: move /proc/slab_allocators boilerplate to mm/slab.c
proc: move /proc/interrupts boilerplate code to fs/proc/interrupts.c
proc: move /proc/stat to fs/proc/stat.c
proc: move rest of /proc/partitions code to block/genhd.c
proc: move /proc/cpuinfo code to fs/proc/cpuinfo.c
proc: move /proc/devices code to fs/proc/devices.c
proc: move rest of /proc/locks to fs/locks.c
...
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/kernel/module.c b/kernel/module.c index c0f1826e2d9e..1f4cc00e0c20 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> |
@@ -2556,23 +2558,6 @@ unsigned long module_kallsyms_lookup_name(const char *name) | |||
2556 | } | 2558 | } |
2557 | #endif /* CONFIG_KALLSYMS */ | 2559 | #endif /* CONFIG_KALLSYMS */ |
2558 | 2560 | ||
2559 | /* Called by the /proc file system to return a list of modules. */ | ||
2560 | static void *m_start(struct seq_file *m, loff_t *pos) | ||
2561 | { | ||
2562 | mutex_lock(&module_mutex); | ||
2563 | return seq_list_start(&modules, *pos); | ||
2564 | } | ||
2565 | |||
2566 | static void *m_next(struct seq_file *m, void *p, loff_t *pos) | ||
2567 | { | ||
2568 | return seq_list_next(p, &modules, pos); | ||
2569 | } | ||
2570 | |||
2571 | static void m_stop(struct seq_file *m, void *p) | ||
2572 | { | ||
2573 | mutex_unlock(&module_mutex); | ||
2574 | } | ||
2575 | |||
2576 | static char *module_flags(struct module *mod, char *buf) | 2561 | static char *module_flags(struct module *mod, char *buf) |
2577 | { | 2562 | { |
2578 | int bx = 0; | 2563 | int bx = 0; |
@@ -2606,6 +2591,24 @@ static char *module_flags(struct module *mod, char *buf) | |||
2606 | return buf; | 2591 | return buf; |
2607 | } | 2592 | } |
2608 | 2593 | ||
2594 | #ifdef CONFIG_PROC_FS | ||
2595 | /* Called by the /proc file system to return a list of modules. */ | ||
2596 | static void *m_start(struct seq_file *m, loff_t *pos) | ||
2597 | { | ||
2598 | mutex_lock(&module_mutex); | ||
2599 | return seq_list_start(&modules, *pos); | ||
2600 | } | ||
2601 | |||
2602 | static void *m_next(struct seq_file *m, void *p, loff_t *pos) | ||
2603 | { | ||
2604 | return seq_list_next(p, &modules, pos); | ||
2605 | } | ||
2606 | |||
2607 | static void m_stop(struct seq_file *m, void *p) | ||
2608 | { | ||
2609 | mutex_unlock(&module_mutex); | ||
2610 | } | ||
2611 | |||
2609 | static int m_show(struct seq_file *m, void *p) | 2612 | static int m_show(struct seq_file *m, void *p) |
2610 | { | 2613 | { |
2611 | struct module *mod = list_entry(p, struct module, list); | 2614 | struct module *mod = list_entry(p, struct module, list); |
@@ -2636,13 +2639,33 @@ static int m_show(struct seq_file *m, void *p) | |||
2636 | Where refcount is a number or -, and deps is a comma-separated list | 2639 | Where refcount is a number or -, and deps is a comma-separated list |
2637 | of depends or -. | 2640 | of depends or -. |
2638 | */ | 2641 | */ |
2639 | const struct seq_operations modules_op = { | 2642 | static const struct seq_operations modules_op = { |
2640 | .start = m_start, | 2643 | .start = m_start, |
2641 | .next = m_next, | 2644 | .next = m_next, |
2642 | .stop = m_stop, | 2645 | .stop = m_stop, |
2643 | .show = m_show | 2646 | .show = m_show |
2644 | }; | 2647 | }; |
2645 | 2648 | ||
2649 | static int modules_open(struct inode *inode, struct file *file) | ||
2650 | { | ||
2651 | return seq_open(file, &modules_op); | ||
2652 | } | ||
2653 | |||
2654 | static const struct file_operations proc_modules_operations = { | ||
2655 | .open = modules_open, | ||
2656 | .read = seq_read, | ||
2657 | .llseek = seq_lseek, | ||
2658 | .release = seq_release, | ||
2659 | }; | ||
2660 | |||
2661 | static int __init proc_modules_init(void) | ||
2662 | { | ||
2663 | proc_create("modules", 0, NULL, &proc_modules_operations); | ||
2664 | return 0; | ||
2665 | } | ||
2666 | module_init(proc_modules_init); | ||
2667 | #endif | ||
2668 | |||
2646 | /* Given an address, look for it in the module exception tables. */ | 2669 | /* Given an address, look for it in the module exception tables. */ |
2647 | const struct exception_table_entry *search_module_extables(unsigned long addr) | 2670 | const struct exception_table_entry *search_module_extables(unsigned long addr) |
2648 | { | 2671 | { |