Re: linux/module.h does not exist

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

 



Yes you were right I had missed one line
following.
asmlinkage int alt_exit_function(int err_code)

I have added this line so the program becomes now

#include <linux/kernel.h>
#include <sys/syscall.h>
#include <linux/module.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;
}



I compiled it

got new errors

 gcc -Wall -DMODULE -D__KERNEL -DLINUX -c sample2.c
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 ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
before ‘int’
sample2.c: In function ‘init_module’:
sample2.c:14: error: ‘main_sys_exit’ undeclared (first use in this function)
sample2.c:14: error: (Each undeclared identifier is reported only once
sample2.c:14: error: for each function it appears in.)
sample2.c:15: error: ‘alt_exit_function’ undeclared (first use in this function)
sample2.c:16: warning: control reaches end of non-void function
sample2.c: In function ‘cleanup_module’:
sample2.c:19: error: ‘main_sys_exit’ undeclared (first use in this function)


On Fri, Aug 20, 2010 at 9:37 PM, Dave Hylands <dhylands@xxxxxxxxx> wrote:
> Hi Tapas,
>
> Replying to all this time...
>
> On Fri, Aug 20, 2010 at 12:52 AM, Tapas Mishra wrote:
>> Hi Dave I could not understand your reply.
>>
>
> Go back to page 48 of the PDF, and look at the example. And then look
> at the code you posted. It's missing a line in the spot I indicated.
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.DaveHylands.com/
>



-- 
Tapas
http://mightydreams.blogspot.com
http://wiki.xensource.com/xenwiki/Xen_on_4_app_servers

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