On Wed, 28 Nov 2007, Rene Herman wrote:

> On 28-11-07 11:46, Robert P. J. Day wrote:
>
> >   based on a book i'm reading, apparently i can write a loadable
> > module whose entire source file is nothing more than:
> >
> > =====
> > #include <linux/module.h>
> > #include <linux/jiffies.h>
> >
> > module_param(jiffies, uint, 444) ;
> >
> > MODULE_LICENSE("Dual BSD/GPL");
> > =====
> >
> >   as you can see, its entire purpose is to make the internal value
> > "jiffies" available to me under /sys/module and, sure enough, using
> > the standard kbuild structure, it builds and loads and seems to work.
> >
> >   but i wasn't aware that you could write a valid loadable module
> > without at least a call to module_init().  in fact, from
> > include/linux/init.h:
> >
> > /* Each module must use one module_init(), or one no_module_init */
> >
> >   clearly, i'm not doing that.  so, should i have been surprised that
> > the above is a valid loadable module?  why does it load without a call
> > to module_init() that returns a success value of zero?
>
> Due to:
>
> === kernel/module.c
>
> asmlinkage long sys_init_module(...)
> {
>       [ ... ]
>
>         int ret = 0;
>
>       [ ... ]
>
>         /* Start the module */
>         if (mod->init != NULL)
>                 ret = mod->init();
>         if (ret < 0) {
>               [ ... ]
>       }
>
>         /* Now it's a first class citizen! */
>         mutex_lock(&module_mutex);
>
>       [ ... ]
> }

ah, i knew it was in there somewhere, i just didn't look closely
enough.  i'll throw in a patch to fix that comment.  thanks.

rday

========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to