[RFC PATCH 4/9] Ksplice: Make needed symbol and module functions global

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeffrey Brian Arnold
Date: Friday, September 12, 2008 - 9:49 pm

From: Tim Abbott <tabbott@mit.edu>

Make module_mutex, find_module(), find_symbol(), and use_module()
global.  Ksplice needs access to these functions from module.c in
order to resolve symbols and implement dependency handling.

Signed-off-by: Tim Abbott <tabbott@mit.edu>
---
 include/linux/module.h |   13 +++++++++++++
 kernel/module.c        |   18 +++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index cd982cd..6ae0fc9 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -351,6 +351,8 @@ struct module
 #define MODULE_ARCH_INIT {}
 #endif
 
+extern struct mutex module_mutex;
+
 /* FIXME: It'd be nice to isolate modules during init, too, so they
    aren't used before they (may) fail.  But presently too much code
    (IDE & SCSI) require entry into the module during init.*/
@@ -366,6 +368,16 @@ struct module *module_data_address(unsigned long addr);
 struct module *__module_data_address(unsigned long addr);
 int is_module_address(unsigned long addr);
 
+/* Search for module by name: must hold module_mutex. */
+struct module *find_module(const char *name);
+
+/* Search for an exported symbol by name. */
+const struct kernel_symbol *find_symbol(const char *name,
+					struct module **owner,
+					const unsigned long **crc,
+					bool gplok,
+					bool warn);
+
 /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
    symnum out of range. */
 int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
@@ -431,6 +443,7 @@ static inline void __module_get(struct module *module)
 #define symbol_put_addr(p) do { } while(0)
 
 #endif /* CONFIG_MODULE_UNLOAD */
+int use_module(struct module *a, struct module *b);
 
 /* This is a #define so the string doesn't get put in every .o file */
 #define module_name(mod)			\
diff --git a/kernel/module.c b/kernel/module.c
index 343c8f8..2acb646 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -62,7 +62,7 @@
 
 /* List of modules, protected by module_mutex or preempt_disable
  * (add/delete uses stop_machine). */
-static DEFINE_MUTEX(module_mutex);
+DEFINE_MUTEX(module_mutex);
 static LIST_HEAD(modules);
 
 /* Waiting for a module to finish initializing? */
@@ -301,11 +301,11 @@ static bool find_symbol_in_section(const struct symsearch *syms,
 
 /* Find a symbol and return it, along with, (optional) crc and
  * (optional) module which owns it */
-static const struct kernel_symbol *find_symbol(const char *name,
-					       struct module **owner,
-					       const unsigned long **crc,
-					       bool gplok,
-					       bool warn)
+const struct kernel_symbol *find_symbol(const char *name,
+					struct module **owner,
+					const unsigned long **crc,
+					bool gplok,
+					bool warn)
 {
 	struct find_symbol_arg fsa;
 
@@ -326,7 +326,7 @@ static const struct kernel_symbol *find_symbol(const char *name,
 }
 
 /* Search for module by name: must hold module_mutex. */
-static struct module *find_module(const char *name)
+struct module *find_module(const char *name)
 {
 	struct module *mod;
 
@@ -579,7 +579,7 @@ static int already_uses(struct module *a, struct module *b)
 }
 
 /* Module a uses b */
-static int use_module(struct module *a, struct module *b)
+int use_module(struct module *a, struct module *b)
 {
 	struct module_use *use;
 	int no_warn, err;
@@ -874,7 +874,7 @@ static inline void module_unload_free(struct module *mod)
 {
 }
 
-static inline int use_module(struct module *a, struct module *b)
+int use_module(struct module *a, struct module *b)
 {
 	return strong_try_module_get(b) == 0;
 }
-- 
1.5.4.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH 0/9] Ksplice: Rebootless kernel updates, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 1/9] Ksplice: Make find_symbol return a struct ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 2/9] Ksplice: Add module_data_address (the anal ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 3/9] Ksplice: Add functions for walking kallsym ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 4/9] Ksplice: Make needed symbol and module fun ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 5/9] Ksplice: Architecture-independent core, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 5/9] Ksplice core (architecture independent), Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 6/9] Ksplice: Documentation, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 6/9] Ksplice documentation, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 7/9] Ksplice: x86-32 and x86-64 support, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 8/9] Ksplice: ARM support, Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
[RFC PATCH 9/9] Ksplice: Add support for building Ksplice ..., Jeffrey Brian Arnold, (Fri Sep 12, 9:49 pm)
Re: [RFC PATCH 0/9] Ksplice: Rebootless kernel updates, Alexey Dobriyan, (Fri Sep 12, 10:12 pm)
Re: [RFC PATCH 0/9] Ksplice: Rebootless kernel updates, Jeff Arnold, (Sun Sep 14, 1:24 pm)