lkml.org 
[lkml]   [2011]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: Is there something like MODULE_DEPEND?
From
Hi Felipe,

On Sat, Dec 10, 2011 at 6:08 AM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> Hi,
>
> So I've finally found that my problem was that I have to load module
> B, before loading module A. The dependency is in the Kconfig file, but
> module A doesn't use any symbols from module B, so it's not
> automatically loaded.

From this, I think you are looking for the "request_module()".

> Apparently FreeBSD has a macro named MODULE_DEPEND for that, which
> would make sense.
>
> After reading some code, it seems to me that there's no easy way to
> achieve this, as by default there are no symbols that can be found by
> modpost, so something like this is needed:
>
>  const const char *module_b;
>  EXPORT_SYMBOL(module_b);
>
> note: KBUILD_MODNAME can't be used.
>
> And then, use it in module A:
>
>  extern const char *module_b;
>  static const char **test __used = &module_b;
>
> But ultimately, all we want is to add "module_b" to the "depends"
> field in the .modinfo section. It should be relatively easy to achieve
> by having a special section modpost can detect, and then just put it
> into "depends".
>
> Apparently I'm not the first one to have this need[1], but I wonder
> why not more people have it.
> [1] http://article.gmane.org/gmane.linux.kernel/1183905/match=module_depend
>
> --

Eg:

This "bare minimum" module should load "nfs" along with it.
---
#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void)
{
request_module("nfs");
return 0;
}

void cleanup_module(void)
{

}

MODULE_LICENSE("GPL");
---
$ sudo insmod test.ko
$ lsmod|grep nfs
nfs 275462 0
nfs_acl 2257 1 nfs
lockd 65605 1 nfs
fscache 46361 1 nfs
auth_rpcgss 34001 1 nfs
sunrpc 193146 5 nfs,nfs_acl,lockd,auth_rpcgss


> Felipe Contreras

Is this what you are looking for or I missed your point ?

HTH,
Maxin B. John
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-12-10 07:13    [W:0.030 / U:0.684 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site