linux/module.h does not exist

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

 



I wrote following program in my home directory.



#include <linux/kernel.h>
#include <sys/syscall.h>
#include <linux/module.h>
extern void *sys_table[];
asmlinkage int(*main_sys_exit)(int);
{
        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;
}
~      [/code]

When I compiled it as


gcc -Wall -DMODULE -D__KERNEL__  -DLINUX -c sample2.c[/code]

I got following error


sample2.c:3:26: error: linux/module.h: No such file or directory
sample2.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘int’
sample2.c:6: error: expected identifier or ‘(’ before ‘{’ token
sample2.c: In function ‘init_module’:
sample2.c:13: error: ‘main_sys_exit’ undeclared (first use in this function)
sample2.c:13: error: (Each undeclared identifier is reported only once
sample2.c:13: error: for each function it appears in.)
sample2.c:14: error: ‘alt_exit_function’ undeclared (first use in this function)
sample2.c:15: warning: control reaches end of non-void function
sample2.c: In function ‘cleanup_module’:
sample2.c:18: error: ‘main_sys_exit’ undeclared (first use in this function)

What is the above error and why is it coming?
I did all this in my home directory.

-- 
Tapas

--
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