Find the answer to your Linux question:
Results 1 to 3 of 3
Ok I have just started reading how to program kernel modules from a really really old source, my question is why the static __init and static __exit aren't needed any ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Location
    Rajshahi || Dhaka, Bangladesh
    Posts
    11

    Exclamation A Stupid Question


    Ok I have just started reading how to program kernel modules from a really really old source, my question is why the static __init and static __exit aren't needed any more ?? i am using fedora 12 and they are caught as errors. According to that source the syntax of init_module and cleanup_module should be:
    Code:
    static __init int init_module(void){
    	// ... 
    	return 0 ;
    }
    
    static __exit void cleanup_module(void){
    	// ...
    }
    But they just work fine without the static __init and static __exit. Could someone plz explain ??

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,533
    Older kernels used this form so that the kernel knew what functions to call when loading or unloading a kernel module (driver). More current Linux kernels use the macros module_init(init_func_name) and module_exit(exit_func_name) to inform the kernel of that same information. You can download free a copy of "Linux Device Drivers, 3rd Edition" as a single PDF from here: http://www.davehylands.com/Misc/Linu...rd-Edition.pdf
    It is also available in pdf-per-chapter form officially from here: Linux Device Drivers, Third Edition [LWN.net]
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Location
    Rajshahi || Dhaka, Bangladesh
    Posts
    11

    Talking

    Thank u. And thank u for the pdf. U rock.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •