Sharad you are right.
It did worked I got a warning in it.
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'
CC [M] /home/tapas/LKP/pandora/temp/sample2/sample21.o
/home/tapas/LKP/pandora/temp/sample2/sample21.c: In function ‘init_module’:
/home/tapas/LKP/pandora/temp/sample2/sample21.c:17: warning: control
reaches end of non-void function
Building modules, stage 2.
MODPOST 1 modules
WARNING: "sys_table"
[/home/tapas/LKP/pandora/temp/sample2/sample21.ko] undefined!
CC /home/tapas/LKP/pandora/temp/sample2/sample21.mod.o
LD [M] /home/tapas/LKP/pandora/temp/sample2/sample21.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.28-11-generic'
but the program in book which is used is
#include <linux/kernel.h>
#include <linux/module.h>
#include <sys/syscall.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;
}
and I made a Makefile for the same as (My program name is sample2.c)
obj-m += sample2.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
and got following error with the Makefile approach for the program
given in book.
ta...@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'
CC [M] /home/tapas/LKP/pandora/temp/sample2/sample2.o
/home/tapas/LKP/pandora/temp/sample2/sample2.c:3:25: error:
sys/syscall.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: *** [all] Error 2
Any idea of what is it complaining about?
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ