lkml.org 
[lkml]   [2006]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: How to call a function in a module from the kernel code !!! (Linux kernel)

    On Thu, 9 Feb 2006, Kyle Moffett wrote:

    > It would help a lot if you could post a link to your source code.

    Not really. The question is pretty straight forward, so no source is
    really necessary. Are you just asking this because you want to stress the
    next point.

    > Let me point out (in case you don't know this already) that if you do
    > what you describe and distribute the result, you are automatically
    > licensing your ll.c file under the GPLv2. By distributing a
    > derivative of both the Linux kernel and your proprietary module (You
    > are taking Linux kernel sources and modifying them explicitly for
    > your module), the result must be GPL.

    Well, just because something is under the GPL, doesn't mean you need to
    post a link for all to have. You only need to give the source to those
    that you distribute it to. For example, if you give GPL code to someone
    that paid a hell of a lot to get it (the distribution, not paying for the
    code) then those that have paid might not want to give it away either. So
    yes, you can have closed GPL if all that get the binary and code don't
    distribute it to anyone else. Of course once one that has it does give it
    away (since no one can prevent them from doing so) then the code will be
    opened.

    > Also, I think what you are
    > describing is basically impossible. I believe what you want to do is
    > this:
    >
    > /* in shm.c */
    > unsigned long long (*ptr1)(int);
    > EXPORT_SYMBOL(ptr1);
    >
    > However this makes it impossible to reliably remove your module,
    > because a process could race entering the function as the module
    > loader is trying to remove the module.

    Not really impossible. As I have done in my (yes GPL) logdev module
    http://www.kihontech.com/logdev/logdev-2.6.15-rt16.patch
    I have a "hooks" file that has all the functions I need for the loadable
    module. But to call any of the hooks, you must call wrapper functions
    that grabs a spinlock before calling the function. This spinlock is also
    used to reset the function pointer when removing the module. Yes, I know
    that this is inefficient, but when the module is compiled into the kernel,
    those wrapper functions also turn into direct functions without the need
    of the spinlock, or redirected function pointers.

    -- Steve
    -
    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: 2006-02-10 08:58    [W:0.036 / U:36.232 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site