Hard module dependencies
Andy Whitcroft
apw at canonical.com
Thu Oct 8 10:42:17 UTC 2009
On Tue, Oct 06, 2009 at 10:12:57AM -0600, Tim Gardner wrote:
> Andy - How about something like this? I need to test some boundary
> conditions (like what happens if the target is not a module, etc), and
> flesh out the commit log, perhaps add some comments to the function.
> --
> Tim Gardner tim.gardner at canonical.com
> From 31223d1147dc4d96a70688b5987e9cb63b579f62 Mon Sep 17 00:00:00 2001
> From: Tim Gardner <tim.gardner at canonical.com>
> Date: Tue, 6 Oct 2009 08:52:38 -0600
> Subject: [PATCH 1/2] UBUNTU: [Upstream] Added module_depends()
>
> Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
> ---
> include/linux/module.h | 19 +++++++++++++++++++
> 1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 098bdb7..8827da5 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -703,6 +703,25 @@ static inline void module_remove_modinfo_attrs(struct module *mod)
>
> #define __MODULE_STRING(x) __stringify(x)
>
> +static inline void module_depends(const char *mod_name)
> +{
> + struct module *mod;
> +
> + if (mutex_lock_interruptible(&module_mutex) != 0) {
> + printk(KERN_ERR "%s Could not get module_mutex\n",__func__);
> + return;
> + }
> + mod = find_module(mod_name);
> + if (!mod) {
> + mutex_unlock(&module_mutex);
> + printk(KERN_ERR "%s Could not find module %s\n",__func__,mod_name);
> + return;
> + }
> + if (use_module(THIS_MODULE,mod) <= 0) {
> + printk(KERN_ERR "%s Could not load module %s\n",__func__,mod_name);
> + }
> + mutex_unlock(&module_mutex);
> +}
>
> #ifdef CONFIG_GENERIC_BUG
> int module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
Looking pretty sensible, how did this fair in testing?
-apw
More information about the kernel-team
mailing list