diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-05 13:30:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-05 13:30:21 -0400 |
commit | cab4e4c43f92582a2bfc026137b3d8a175bd0360 (patch) | |
tree | 2f0e8fbc2e7d2d0cd6f1658a5e084a53b1e83a2e /include/linux | |
parent | 5412b5399e095730008a14f2107331b2123733e4 (diff) | |
parent | 49502677e11079c2e3e01867c922a894ce06a8be (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-module-and-param:
module: use strstarts()
strstarts: helper function for !strncmp(str, prefix, strlen(prefix))
arm: allow usage of string functions in linux/string.h
module: don't use stop_machine on module load
module: create a request_module_nowait()
module: include other structures in module version check
module: remove the SHF_ALLOC flag on the __versions section.
module: clarify the force-loading taint message.
module: Export symbols needed for Ksplice
Ksplice: Add functions for walking kallsyms symbols
module: remove module_text_address()
module: __module_address
module: Make find_symbol return a struct kernel_symbol
kernel/module.c: fix an unused goto label
param: fix charp parameters set via sysfs
Fix trivial conflicts in kernel/extable.c manually.
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/kallsyms.h | 15 | ||||
-rw-r--r-- | include/linux/kmod.h | 11 | ||||
-rw-r--r-- | include/linux/module.h | 63 | ||||
-rw-r--r-- | include/linux/moduleparam.h | 10 | ||||
-rw-r--r-- | include/linux/string.h | 9 |
5 files changed, 97 insertions, 11 deletions
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index f3fe34391d8e..792274269f2b 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h | |||
@@ -13,10 +13,17 @@ | |||
13 | #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ | 13 | #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ |
14 | 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) | 14 | 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) |
15 | 15 | ||
16 | struct module; | ||
17 | |||
16 | #ifdef CONFIG_KALLSYMS | 18 | #ifdef CONFIG_KALLSYMS |
17 | /* Lookup the address for a symbol. Returns 0 if not found. */ | 19 | /* Lookup the address for a symbol. Returns 0 if not found. */ |
18 | unsigned long kallsyms_lookup_name(const char *name); | 20 | unsigned long kallsyms_lookup_name(const char *name); |
19 | 21 | ||
22 | /* Call a function on each kallsyms symbol in the core kernel */ | ||
23 | int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, | ||
24 | unsigned long), | ||
25 | void *data); | ||
26 | |||
20 | extern int kallsyms_lookup_size_offset(unsigned long addr, | 27 | extern int kallsyms_lookup_size_offset(unsigned long addr, |
21 | unsigned long *symbolsize, | 28 | unsigned long *symbolsize, |
22 | unsigned long *offset); | 29 | unsigned long *offset); |
@@ -43,6 +50,14 @@ static inline unsigned long kallsyms_lookup_name(const char *name) | |||
43 | return 0; | 50 | return 0; |
44 | } | 51 | } |
45 | 52 | ||
53 | static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, | ||
54 | struct module *, | ||
55 | unsigned long), | ||
56 | void *data) | ||
57 | { | ||
58 | return 0; | ||
59 | } | ||
60 | |||
46 | static inline int kallsyms_lookup_size_offset(unsigned long addr, | 61 | static inline int kallsyms_lookup_size_offset(unsigned long addr, |
47 | unsigned long *symbolsize, | 62 | unsigned long *symbolsize, |
48 | unsigned long *offset) | 63 | unsigned long *offset) |
diff --git a/include/linux/kmod.h b/include/linux/kmod.h index 92213a9194e1..d5fa565086d1 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h | |||
@@ -29,10 +29,15 @@ | |||
29 | #ifdef CONFIG_MODULES | 29 | #ifdef CONFIG_MODULES |
30 | /* modprobe exit status on success, -ve on error. Return value | 30 | /* modprobe exit status on success, -ve on error. Return value |
31 | * usually useless though. */ | 31 | * usually useless though. */ |
32 | extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2))); | 32 | extern int __request_module(bool wait, const char *name, ...) \ |
33 | #define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x))) | 33 | __attribute__((format(printf, 2, 3))); |
34 | #define request_module(mod...) __request_module(true, mod) | ||
35 | #define request_module_nowait(mod...) __request_module(false, mod) | ||
36 | #define try_then_request_module(x, mod...) \ | ||
37 | ((x) ?: (__request_module(false, mod), (x))) | ||
34 | #else | 38 | #else |
35 | static inline int request_module(const char * name, ...) { return -ENOSYS; } | 39 | static inline int request_module(const char *name, ...) { return -ENOSYS; } |
40 | static inline int request_module_nowait(const char *name, ...) { return -ENOSYS; } | ||
36 | #define try_then_request_module(x, mod...) (x) | 41 | #define try_then_request_module(x, mod...) (x) |
37 | #endif | 42 | #endif |
38 | 43 | ||
diff --git a/include/linux/module.h b/include/linux/module.h index 145a75528cc1..d246da0b0f8c 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -248,6 +248,10 @@ struct module | |||
248 | const unsigned long *crcs; | 248 | const unsigned long *crcs; |
249 | unsigned int num_syms; | 249 | unsigned int num_syms; |
250 | 250 | ||
251 | /* Kernel parameters. */ | ||
252 | struct kernel_param *kp; | ||
253 | unsigned int num_kp; | ||
254 | |||
251 | /* GPL-only exported symbols. */ | 255 | /* GPL-only exported symbols. */ |
252 | unsigned int num_gpl_syms; | 256 | unsigned int num_gpl_syms; |
253 | const struct kernel_symbol *gpl_syms; | 257 | const struct kernel_symbol *gpl_syms; |
@@ -350,6 +354,8 @@ struct module | |||
350 | #define MODULE_ARCH_INIT {} | 354 | #define MODULE_ARCH_INIT {} |
351 | #endif | 355 | #endif |
352 | 356 | ||
357 | extern struct mutex module_mutex; | ||
358 | |||
353 | /* FIXME: It'd be nice to isolate modules during init, too, so they | 359 | /* FIXME: It'd be nice to isolate modules during init, too, so they |
354 | aren't used before they (may) fail. But presently too much code | 360 | aren't used before they (may) fail. But presently too much code |
355 | (IDE & SCSI) require entry into the module during init.*/ | 361 | (IDE & SCSI) require entry into the module during init.*/ |
@@ -358,10 +364,10 @@ static inline int module_is_live(struct module *mod) | |||
358 | return mod->state != MODULE_STATE_GOING; | 364 | return mod->state != MODULE_STATE_GOING; |
359 | } | 365 | } |
360 | 366 | ||
361 | /* Is this address in a module? (second is with no locks, for oops) */ | ||
362 | struct module *module_text_address(unsigned long addr); | ||
363 | struct module *__module_text_address(unsigned long addr); | 367 | struct module *__module_text_address(unsigned long addr); |
364 | int is_module_address(unsigned long addr); | 368 | struct module *__module_address(unsigned long addr); |
369 | bool is_module_address(unsigned long addr); | ||
370 | bool is_module_text_address(unsigned long addr); | ||
365 | 371 | ||
366 | static inline int within_module_core(unsigned long addr, struct module *mod) | 372 | static inline int within_module_core(unsigned long addr, struct module *mod) |
367 | { | 373 | { |
@@ -375,6 +381,31 @@ static inline int within_module_init(unsigned long addr, struct module *mod) | |||
375 | addr < (unsigned long)mod->module_init + mod->init_size; | 381 | addr < (unsigned long)mod->module_init + mod->init_size; |
376 | } | 382 | } |
377 | 383 | ||
384 | /* Search for module by name: must hold module_mutex. */ | ||
385 | struct module *find_module(const char *name); | ||
386 | |||
387 | struct symsearch { | ||
388 | const struct kernel_symbol *start, *stop; | ||
389 | const unsigned long *crcs; | ||
390 | enum { | ||
391 | NOT_GPL_ONLY, | ||
392 | GPL_ONLY, | ||
393 | WILL_BE_GPL_ONLY, | ||
394 | } licence; | ||
395 | bool unused; | ||
396 | }; | ||
397 | |||
398 | /* Search for an exported symbol by name. */ | ||
399 | const struct kernel_symbol *find_symbol(const char *name, | ||
400 | struct module **owner, | ||
401 | const unsigned long **crc, | ||
402 | bool gplok, | ||
403 | bool warn); | ||
404 | |||
405 | /* Walk the exported symbol table */ | ||
406 | bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner, | ||
407 | unsigned int symnum, void *data), void *data); | ||
408 | |||
378 | /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if | 409 | /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if |
379 | symnum out of range. */ | 410 | symnum out of range. */ |
380 | int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, | 411 | int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, |
@@ -383,6 +414,10 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, | |||
383 | /* Look for this name: can be of form module:name. */ | 414 | /* Look for this name: can be of form module:name. */ |
384 | unsigned long module_kallsyms_lookup_name(const char *name); | 415 | unsigned long module_kallsyms_lookup_name(const char *name); |
385 | 416 | ||
417 | int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, | ||
418 | struct module *, unsigned long), | ||
419 | void *data); | ||
420 | |||
386 | extern void __module_put_and_exit(struct module *mod, long code) | 421 | extern void __module_put_and_exit(struct module *mod, long code) |
387 | __attribute__((noreturn)); | 422 | __attribute__((noreturn)); |
388 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); | 423 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); |
@@ -444,6 +479,7 @@ static inline void __module_get(struct module *module) | |||
444 | #define symbol_put_addr(p) do { } while(0) | 479 | #define symbol_put_addr(p) do { } while(0) |
445 | 480 | ||
446 | #endif /* CONFIG_MODULE_UNLOAD */ | 481 | #endif /* CONFIG_MODULE_UNLOAD */ |
482 | int use_module(struct module *a, struct module *b); | ||
447 | 483 | ||
448 | /* This is a #define so the string doesn't get put in every .o file */ | 484 | /* This is a #define so the string doesn't get put in every .o file */ |
449 | #define module_name(mod) \ | 485 | #define module_name(mod) \ |
@@ -490,21 +526,24 @@ search_module_extables(unsigned long addr) | |||
490 | return NULL; | 526 | return NULL; |
491 | } | 527 | } |
492 | 528 | ||
493 | /* Is this address in a module? */ | 529 | static inline struct module *__module_address(unsigned long addr) |
494 | static inline struct module *module_text_address(unsigned long addr) | ||
495 | { | 530 | { |
496 | return NULL; | 531 | return NULL; |
497 | } | 532 | } |
498 | 533 | ||
499 | /* Is this address in a module? (don't take a lock, we're oopsing) */ | ||
500 | static inline struct module *__module_text_address(unsigned long addr) | 534 | static inline struct module *__module_text_address(unsigned long addr) |
501 | { | 535 | { |
502 | return NULL; | 536 | return NULL; |
503 | } | 537 | } |
504 | 538 | ||
505 | static inline int is_module_address(unsigned long addr) | 539 | static inline bool is_module_address(unsigned long addr) |
506 | { | 540 | { |
507 | return 0; | 541 | return false; |
542 | } | ||
543 | |||
544 | static inline bool is_module_text_address(unsigned long addr) | ||
545 | { | ||
546 | return false; | ||
508 | } | 547 | } |
509 | 548 | ||
510 | /* Get/put a kernel symbol (calls should be symmetric) */ | 549 | /* Get/put a kernel symbol (calls should be symmetric) */ |
@@ -559,6 +598,14 @@ static inline unsigned long module_kallsyms_lookup_name(const char *name) | |||
559 | return 0; | 598 | return 0; |
560 | } | 599 | } |
561 | 600 | ||
601 | static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, | ||
602 | struct module *, | ||
603 | unsigned long), | ||
604 | void *data) | ||
605 | { | ||
606 | return 0; | ||
607 | } | ||
608 | |||
562 | static inline int register_module_notifier(struct notifier_block * nb) | 609 | static inline int register_module_notifier(struct notifier_block * nb) |
563 | { | 610 | { |
564 | /* no events will happen anyway, so this can always succeed */ | 611 | /* no events will happen anyway, so this can always succeed */ |
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index e4af3399ef48..a4f0b931846c 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
@@ -138,6 +138,16 @@ extern int parse_args(const char *name, | |||
138 | unsigned num, | 138 | unsigned num, |
139 | int (*unknown)(char *param, char *val)); | 139 | int (*unknown)(char *param, char *val)); |
140 | 140 | ||
141 | /* Called by module remove. */ | ||
142 | #ifdef CONFIG_SYSFS | ||
143 | extern void destroy_params(const struct kernel_param *params, unsigned num); | ||
144 | #else | ||
145 | static inline void destroy_params(const struct kernel_param *params, | ||
146 | unsigned num) | ||
147 | { | ||
148 | } | ||
149 | #endif /* !CONFIG_SYSFS */ | ||
150 | |||
141 | /* All the helper functions */ | 151 | /* All the helper functions */ |
142 | /* The macros to do compile-time type checking stolen from Jakub | 152 | /* The macros to do compile-time type checking stolen from Jakub |
143 | Jelinek, who IIRC came up with this idea for the 2.4 module init code. */ | 153 | Jelinek, who IIRC came up with this idea for the 2.4 module init code. */ |
diff --git a/include/linux/string.h b/include/linux/string.h index 3c877d686375..489019ef1694 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
@@ -122,5 +122,14 @@ int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4); | |||
122 | extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, | 122 | extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, |
123 | const void *from, size_t available); | 123 | const void *from, size_t available); |
124 | 124 | ||
125 | /** | ||
126 | * strstarts - does @str start with @prefix? | ||
127 | * @str: string to examine | ||
128 | * @prefix: prefix to look for. | ||
129 | */ | ||
130 | static inline bool strstarts(const char *str, const char *prefix) | ||
131 | { | ||
132 | return strncmp(str, prefix, strlen(prefix)) == 0; | ||
133 | } | ||
125 | #endif | 134 | #endif |
126 | #endif /* _LINUX_STRING_H_ */ | 135 | #endif /* _LINUX_STRING_H_ */ |