the world's shortest module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  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?

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 ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux