Re: linux/module.h does not exist

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

 




On Mon, Aug 23, 2010 at 9:59 PM, Tapas Mishra <mightydreams@xxxxxxxxx> wrote:
No It did not worked I tried what you said.
Here is the new program.
If possible just copy paste the program and try to run.

#include <linux/kernel.h>
#include <asm/syscalls.h>
#include <linux/module.h>
#include <linux/unistd.h>
extern void *sys_table[];
asmlinkage int(*main_sys_exit)(int);
asmlinkage int alt_exit_function(int err_code)
{
       printk("Sys_exit called with err_code=%d\n",err_code);
       return main_sys_exit(err_code);
}

int init_module()
{
       main_sys_exit=sys_table[__NR_exit];
       sys_table[__NR_exit]=alt_exit_function;
}
void cleanup_module()
{
       sys_table[__NR_exit]=main_sys_exit;
}


Following way I tried to do it.

gcc -I /usr/src/linux-headers-`uname -r`/include -I
/usr/src/linux-headers-`uname -r`/linux -Wall -DMODULE -D__KERNEL__
-DLINUX -c sample2.c

and following errors I got

http://pastebin.com/ZGRD8cC3
any more guess?

I'm having the same code as yours, no change in that, below is the makefile I used to compile the module

obj-m += module1.o

all: 
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean: 
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

with this, I'm able to get the module1.ko, though it has the undefined reference to the sys_table.
Inserting the module will fail.

Regards,
~Sharad.



[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