Re: linux/module.h does not exist

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

 



Ok I corrected the make file there should have been a blank space here
is the new make file for the program

ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
.PHONY: build clean
build:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
        rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c
        rm -rf modules.order Module.symvers
else
$(info Building with KERNELRELEASE =${KERNELRELEASE})
obj-m := sample2.o

endif

and following were the errors when I tried to execute it
make

tapas@tapas-laptop:~/LKP/pandora/temp/sample2$ make
make -C /lib/modules/2.6.28-11-generic/build
M=/home/tapas/LKP/pandora/temp/sample2 modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.28-11-generic'
Building with KERNELRELEASE =2.6.28-11-generic
  CC [M]  /home/tapas/LKP/pandora/temp/sample2/sample2.o
/home/tapas/LKP/pandora/temp/sample2/sample2.c:2:26: error:
sys/syscalls.h: No such file or directory
/home/tapas/LKP/pandora/temp/sample2/sample2.c: In function ‘init_module’:
/home/tapas/LKP/pandora/temp/sample2/sample2.c:14: error: ‘__NR_exit’
undeclared (first use in this function)
/home/tapas/LKP/pandora/temp/sample2/sample2.c:14: error: (Each
undeclared identifier is reported only once
/home/tapas/LKP/pandora/temp/sample2/sample2.c:14: error: for each
function it appears in.)
/home/tapas/LKP/pandora/temp/sample2/sample2.c: In function ‘cleanup_module’:
/home/tapas/LKP/pandora/temp/sample2/sample2.c:19: error: ‘__NR_exit’
undeclared (first use in this function)
make[2]: *** [/home/tapas/LKP/pandora/temp/sample2/sample2.o] Error 1
make[1]: *** [_module_/home/tapas/LKP/pandora/temp/sample2] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.28-11-generic'
make: *** [build] Error 2


the program for which I made above Makefile is

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

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