major doubt..........

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

 



Hi 

I am a newbie to Linux kernel. I am reading
Alessandro Rubini's "Linux Device Drivers".

I have trouble executing a simple sample code 
given in chapter 2 of the book:

/********hello.c***************/
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void)      { printk("<1>Hello,
world\n"); return 0; }
void cleanup_module(void)  { printk("<1>Goodbye cruel 
   world\n"); }

/*********end*******************/

root# gcc -c hello.c
root# insmod ./hello.o

./hello.o: kernel-module version mismatch
        ./hello.o was compiled for kernel version
2.4.9-9
        while this kernel is version 2.4.18-3.

I looked at the man page for insmod and found
that the -f switch can be used to override kernel
versioning.So I did,

root# insmod -f ./hello.o
Warning: kernel-module version mismatch
        ./hello.o was compiled for kernel version
2.4.9-9
        while this kernel is version 2.4.18-3
Warning: loading ./hello.o will taint the kernel: no
license
Warning: loading ./hello.o will taint the kernel:
forced load

root# rmmod -f hello
root# 

I have a few naive questions:

1. Why does gcc compile hello.c for 2.4.9-9
while my kernel's version is 2.4.18-3 ?
2. Why was insmod's -f switch not effective ?
3. How to make this code work? !!

Thanks in advance,
sidharth.R

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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